main.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. v_user_block = new Vue({
  28. store,
  29. computed: {
  30. ...mapState({
  31. isloggedin: state => state.User.isloggedin
  32. })
  33. },
  34. created () {
  35. if(drupalSettings.user.uid !== 0){
  36. this.$store.commit('User/setUid', drupalSettings.user.uid)
  37. this.$store.dispatch('User/getUser')
  38. }
  39. },
  40. render: h => h(VUserBlock)
  41. }).$mount(mount_point)
  42. }
  43. function initTestVContent(){
  44. v_test_content = new Vue({
  45. store,
  46. render: h => h(VTestContent)
  47. }).$mount('#block-pagetitle')
  48. console.log('initTestVContent', v_test_content);
  49. }
  50. init()
  51. } // end MaterioTheme()
  52. var materiotheme = new MaterioTheme();
  53. })(Drupal, drupalSettings);