main.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 props = {
  27. title: ""
  28. };
  29. let mount_point = drupalSettings.user.uid !== 0 ? '#block-userblock' : '#block-userlogin';
  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. break;
  52. default:
  53. }
  54. console.log(props);
  55. v_user_block = new Vue({
  56. // data: data,
  57. store,
  58. computed: {
  59. ...mapState({
  60. isloggedin: state => state.User.isloggedin
  61. })
  62. },
  63. created () {
  64. if(drupalSettings.user.uid !== 0){
  65. this.$store.commit('User/setUid', drupalSettings.user.uid)
  66. this.$store.dispatch('User/getUser')
  67. }
  68. },
  69. render: h => h(VUserBlock, {props:props})
  70. }).$mount(mount_point)
  71. console.log('initUserVBlock', v_user_block);
  72. }
  73. function initTestVContent(){
  74. v_test_content = new Vue({
  75. store,
  76. render: h => h(VTestContent)
  77. }).$mount('#block-pagetitle')
  78. // console.log('initTestVContent', v_test_content);
  79. }
  80. init()
  81. } // end MaterioTheme()
  82. var materiotheme = new MaterioTheme();
  83. })(Drupal, drupalSettings);