main.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import Vue from 'vue'
  2. import App from './App.vue'
  3. import router from './router'
  4. import ElementUI from 'element-ui';
  5. import 'element-ui/lib/theme-chalk/index.css';
  6. import lang from './tools/lang';
  7. import ajax from './tools/ajax';
  8. Vue.use(ElementUI);
  9. Vue.config.productionTip = false;
  10. // 多语言支持
  11. Vue.prototype.$lang = moduleName => {
  12. let type = localStorage.getItem('lang') || 'zht';
  13. return lang[type][moduleName];
  14. }
  15. // 复制分享链接
  16. Vue.prototype.$copy = (id, title) => {
  17. let user = JSON.parse(localStorage.getItem('designer_user')).user_name;
  18. let input = document.createElement('textarea');
  19. input.value = `${user}为您分享了一个项目,快来看看吧!\n项目地址:http://designer.xuxiangbo.com/${id}\n项目名称: ${title}`;
  20. document.body.append(input);
  21. input.select();
  22. document.execCommand('copy');
  23. input.remove();
  24. ElementUI.Message({
  25. type: 'success',
  26. message: '已复制项目链接!'
  27. })
  28. }
  29. // ajax
  30. Vue.prototype.$ajax = ajax;
  31. new Vue({
  32. router,
  33. render: function (h) { return h(App) }
  34. }).$mount('#app')