main.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import Vue from 'vue'
  2. import store from 'vuejs/store'
  3. import VUserBlock from 'vuejs/components/User/UserBlock'
  4. import VTestContent from 'vuejs/components/Content/Test'
  5. import { mapState } from 'vuex'
  6. // require('theme/assets/styles/main.scss');
  7. import 'theme/assets/styles/main.scss'
  8. (function(Drupal, drupalSettings) {
  9. var MaterioTheme = function(){
  10. var v_user_block, v_test_content;
  11. // var _is_front = drupalSettings.path.isFront;
  12. console.log('drupalSettings', drupalSettings);
  13. // ___ _ _
  14. // |_ _|_ _ (_) |_
  15. // | || ' \| | _|
  16. // |___|_||_|_|\__|
  17. function init(){
  18. console.log("MaterioTheme init()")
  19. initVues()
  20. }
  21. function initVues(){
  22. initUserVBlock()
  23. // initTestVContent()
  24. }
  25. function initUserVBlock(){
  26. let mount_point = drupalSettings.user.uid !== 0 ? '#block-userblock' : '#block-userlogin';
  27. let props = {
  28. title: ""
  29. };
  30. switch (mount_point) {
  31. case '#block-userlogin':
  32. let $block = document.querySelector(mount_point);
  33. props = {
  34. title: $block.querySelector('h2').textContent,
  35. form: {
  36. ph_email: $block.querySelector('input#edit-name').getAttribute('placeholder'),
  37. ph_pass: $block.querySelector('input#edit-pass').getAttribute('placeholder'),
  38. btn_value: $block.querySelector('input#edit-submit').getAttribute('value'),
  39. register: {
  40. title: $block.querySelector('a.create-account-link').textContent,
  41. href: $block.querySelector('a.create-account-link').getAttribute('href')
  42. },
  43. reset: {
  44. title: $block.querySelector('a.request-password-link').textContent,
  45. href: $block.querySelector('a.request-password-link').getAttribute('href')
  46. }
  47. }
  48. }
  49. break;
  50. case '#block-userblock':
  51. default:
  52. break;
  53. }
  54. // console.log(props);
  55. v_user_block = new Vue({
  56. store,
  57. computed: {
  58. ...mapState({
  59. isloggedin: state => state.User.isloggedin
  60. })
  61. },
  62. created () {
  63. if(drupalSettings.user.uid !== 0){
  64. this.$store.commit('User/setUid', drupalSettings.user.uid)
  65. this.$store.dispatch('User/getUser')
  66. }
  67. },
  68. render: h => h(VUserBlock, {props:props})
  69. }).$mount(mount_point)
  70. console.log('initUserVBlock', v_user_block);
  71. }
  72. function initTestVContent(){
  73. v_test_content = new Vue({
  74. store,
  75. render: h => h(VTestContent)
  76. }).$mount('#block-pagetitle')
  77. // console.log('initTestVContent', v_test_content);
  78. }
  79. init()
  80. } // end MaterioTheme()
  81. var materiotheme = new MaterioTheme();
  82. })(Drupal, drupalSettings);