| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import { createApp } from 'vue'
- import App from './App.vue'
- let initApp = createApp(App);
- import router from './router'
- initApp.use(router);
- import store from './store'
- initApp.use(store);
- import ElementPlus from 'element-plus'
- import 'element-plus/dist/index.css'
- initApp.use(ElementPlus)
- // 如果您正在使用CDN引入,请删除下面一行。
- import * as ElementPlusIconsVue from '@element-plus/icons-vue'
- for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
- initApp.component(key, component)
- }
- // 添加自定义方法,得到用户类型【1:游客;2:普通用户;3:管理员】
- const getUserType = () => {
- // console.log("=====userInfo==="+JSON.stringify(store.state.userInfo));
- if (store.state.userInfo && store.state.userInfo.id != null) {
- // 得到用户id
- let userId = store.state.userInfo.id;
- // 得到角色ids
- let roleIds = store.state.userInfo.roleId;
- // 得到默认管理员角色id(roleId,在Oauth中配置)
- let adminRoleId = webConfig.defaultAccount.adminRoleId;
- if (!store.state.userInfo || !userId || !roleIds) {
- // 游客
- return 1;
- } else if (roleIds.split(",").includes(adminRoleId)) {
- // 管理员
- return 3;
- } else {
- // 普通用户
- return 2;
- }
- } else {
- // 游客
- return 1;
- }
- };
- initApp.config.globalProperties.$getUserType = getUserType;
- // 剪切板
- import useClipboard from 'vue-clipboard3'
- initApp.config.globalProperties.$copyText = function (text) {
- try {
- useClipboard().toClipboard(text);
- // this.$message({ message: '已复制到剪切板:' + text, type: 'success' })
- this.$message({ message: '复制成功', type: 'success' })
- } catch (e) { }
- }
- initApp.mount('#app');
|