diff --git a/src/main.js b/src/main.js index 51d01fe6f4fe0d31af36276f5507e3dbaf982a56..3356de67b91b6b5dee8d90952e936c25f06c07ef 100644 --- a/src/main.js +++ b/src/main.js @@ -1,115 +1,109 @@ -import { createApp } from 'vue' +import { createApp } from "vue"; -import ElementPlus from 'element-plus' -import 'element-plus/dist/index.css' -import locale from 'element-plus/lib/locale/lang/zh-cn' +import ElementPlus from "element-plus"; +import "element-plus/dist/index.css"; +import locale from "element-plus/lib/locale/lang/zh-cn"; -import * as ElementPlusIconsVue from '@element-plus/icons-vue' +import * as ElementPlusIconsVue from "@element-plus/icons-vue"; import bgui from "@/bg-ui"; import "@/bg-ui/index.scss"; -import msgSdk from './msg-sdk/index.js'; +import msgSdk from "./msg-sdk/index.js"; -import App from './App.vue' +import App from "./App.vue"; -import router from './router' -import {generateRoutes} from './router/index.js' +import router from "./router"; +import { generateRoutes } from "./router/index.js"; +import "../src/assets/css/font.css"; +import "../src/assets/css/index.css"; +import "../src/assets/item.css"; -import '../src/assets/css/font.css' -import '../src/assets/css/index.css' -import '../src/assets/item.css' +import store from "@/store"; -import store from '@/store'; +import i18n from "./i18n/i18n.js"; -import i18n from './i18n/i18n.js' +import axios from "./request/http.js"; -import axios from './request/http.js' - -const createVue = createApp(App) +const createVue = createApp(App); createVue.use(ElementPlus, { locale }); function getMsgAppid() { - axios.get(`/apaas/system/v5/message/account`).then(res => { + axios.get(`/apaas/system/v5/message/account`).then((res) => { if (res.data.code == 200) { createVue.use(msgSdk, { - requestUrl: 'https://msg.wodcloud.com', // 请求地址 + requestUrl: "https://msg.wodcloud.com", // 请求地址 appID: decodeURIComponent(escape(window.atob(res.data.data.app_id))), // 应用id secretKey: decodeURIComponent(escape(window.atob(res.data.data.secret_key))), // 应用密钥 - userId: '', - userType: '', - roleId: '', - organization: '', - }) + userId: "", + userType: "", + roleId: "", + organization: "", + }); } - }) + }); } // getMsgAppid() for (const [key, component] of Object.entries(ElementPlusIconsVue)) { - createVue.component(key, component) + createVue.component(key, component); } -createVue.config.globalProperties.$axios = axios +createVue.config.globalProperties.$axios = axios; -import menu from './router/function.js' +import menu from "./router/function.js"; //获取用户信息 function getUser() { - return axios.get(`/apaas/system/v5/user/getUserInfo`) + return axios.get(`/apaas/system/v5/user/getUserInfo`); } //获取用户菜单信息 function getMenu(search) { - return axios.get(`/apaas/system/v5/menu/user/tree?search=${search}`) + return axios.get(`/apaas/system/v5/menu/user/tree?search=${search}`); } //处理菜单成为对象 -function getMenuObj(menu,parentRowPath,menuObj){ - menu.forEach((e,idx) => { - e.rowPath = parentRowPath + '.' + idx - menuObj[e.path] = e - if(e.children&&e.children.length){ - getMenuObj(e.children,e.rowPath,menuObj) +function getMenuObj(menu, parentRowPath, menuObj) { + menu.forEach((e, idx) => { + e.rowPath = parentRowPath + "." + idx; + menuObj[e.path] = e; + if (e.children && e.children.length) { + getMenuObj(e.children, e.rowPath, menuObj); } }); } - -Promise.all([getUser(),getMenu('dadb2d3f-e263-48d1-9389-42acb9ea49f8')]).then(res => { - console.log(res); - if (res[0].data.code == 200&&res[1].data.code == 200) { +Promise.all([getUser(), getMenu("dadb2d3f-e263-48d1-9389-42acb9ea49f8")]) + .then((res) => { + if (res[0].data.code == 200 && res[1].data.code == 200) { //已登录则记录菜单和用户信息 - let data = res[1].data.data&&res[1].data.data[0].children||[] - store.commit('setUserInfo', res[0].data.data) - + let data = (res[1].data.data && res[1].data.data[0].children) || []; + store.commit("setUserInfo", res[0].data.data); + // if (res[0].data.data.userType == 1) {//超管 - store.commit('setMenu', data) - menu.menuToRouter(data) - console.log(menu); - store.commit('setRoute',data) - - //存储菜单对象信息 - let menuObj = {} - getMenuObj(data,'',menuObj) - store.commit('setMenuObj',menuObj) - console.log(menuObj); - + store.commit("setMenu", data); + console.log("data", data); + menu.menuToRouter(data); + store.commit("setRoute", data); + + //存储菜单对象信息 + let menuObj = {}; + getMenuObj(data, "", menuObj); + store.commit("setMenuObj", menuObj); + // } } - generateRoutes() - - createVue.use(ElementPlus).use(store).use(router).use(i18n).use(bgui) - createVue.mount('#app') - }).catch(() => { - createVue.use(ElementPlus).use(store).use(router).use(i18n).use(bgui) - createVue.mount('#app') + generateRoutes(); + + createVue.use(ElementPlus).use(store).use(router).use(i18n).use(bgui); + createVue.mount("#app"); }) + .catch(() => { + createVue.use(ElementPlus).use(store).use(router).use(i18n).use(bgui); + createVue.mount("#app"); + }); //后期加入权限处理,参考msg/ui - - - - diff --git a/src/page/main/config/accessRule/index.vue b/src/page/main/config/accessRule/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..921a85a8d6813d499a518334df2307f55eb3f6bb --- /dev/null +++ b/src/page/main/config/accessRule/index.vue @@ -0,0 +1,490 @@ + + + + + diff --git a/src/page/main/config/loginPage/index.vue b/src/page/main/config/loginPage/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..425ce1576bab48a4d86df9f0fa4b7d0ed86e0198 --- /dev/null +++ b/src/page/main/config/loginPage/index.vue @@ -0,0 +1,135 @@ + + + + + + diff --git a/src/page/main/config/preference/index.vue b/src/page/main/config/preference/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..73831a14ec5a31f91407a5f69ad457f47014c39b --- /dev/null +++ b/src/page/main/config/preference/index.vue @@ -0,0 +1,287 @@ + + + + + diff --git a/src/page/main/develop/systemApproval/approval/index.vue b/src/page/main/develop/systemApproval/approval/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..b97c990c6af7bad3a961f30694111dc3bc358060 --- /dev/null +++ b/src/page/main/develop/systemApproval/approval/index.vue @@ -0,0 +1,211 @@ + + + + + diff --git a/src/page/main/develop/systemApproval/detail/index.vue b/src/page/main/develop/systemApproval/detail/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..f8476cd11d5acaa7bf9b9762307d915ff6ed14f2 --- /dev/null +++ b/src/page/main/develop/systemApproval/detail/index.vue @@ -0,0 +1,116 @@ + + + + + diff --git a/src/page/main/develop/systemApproval/index.vue b/src/page/main/develop/systemApproval/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..73b258c10e6a8ce4c1fd9282c3d9dd329cdb70e3 --- /dev/null +++ b/src/page/main/develop/systemApproval/index.vue @@ -0,0 +1,391 @@ + + + + + diff --git a/src/page/main/log/system/index.vue b/src/page/main/log/system/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..18edfbc65a6946554bafce8c71e3dcae68cdc328 --- /dev/null +++ b/src/page/main/log/system/index.vue @@ -0,0 +1,469 @@ + + + + + diff --git a/src/page/main/log/userAccount/index.vue b/src/page/main/log/userAccount/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..f99ed732590967d3fe1c7ab340b111a2441cbae8 --- /dev/null +++ b/src/page/main/log/userAccount/index.vue @@ -0,0 +1,527 @@ + + + + + diff --git a/src/page/main/log/userBehavior/index.vue b/src/page/main/log/userBehavior/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..f99ed732590967d3fe1c7ab340b111a2441cbae8 --- /dev/null +++ b/src/page/main/log/userBehavior/index.vue @@ -0,0 +1,527 @@ + + + + + diff --git a/src/router/function.js b/src/router/function.js index 4328978e96120857dda52e1c98d0ca95f32f8a19..84308b3a2fb3cd05c6724557d1ad7769945dfb9b 100644 --- a/src/router/function.js +++ b/src/router/function.js @@ -100,7 +100,7 @@ var adminMenu = [ dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25", menuType: 2, }, - ] + ], }, ], dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25", @@ -169,7 +169,7 @@ var adminMenu = [ dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d", menuType: 1, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4 path: "/system/organization", - children:[ + children: [ { menuName: "新增平台用户", dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d", @@ -198,27 +198,27 @@ var adminMenu = [ show: false, path: "/system/organization/org-detail", }, - ] + ], }, { menuName: "角色管理", dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d", menuType: 1, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4 path: "/system/role", - children:[ + children: [ { - menuName:'新增角色', - menuType:2, + menuName: "新增角色", + menuType: 2, dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d", path: "/system/role/add", }, { - menuName:'编辑角色', - menuType:2, + menuName: "编辑角色", + menuType: 2, dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d", path: "/system/role/edit", }, - ] + ], }, ], }, @@ -241,13 +241,13 @@ var adminMenu = [ }, ]; -function getName(str){ - if(str=='/'){ - return 'index' +function getName(str) { + if (str == "/") { + return "index"; } - let temp = str.slice(1) - temp = temp.replaceAll('/','-') - return temp + let temp = str.slice(1); + temp = temp.replaceAll("/", "-"); + return temp; } function getViews(path) { @@ -271,14 +271,13 @@ function getViews(path) { break; } // 然后动态路由的时候这样来取 - console.log(modules["../page/main" + path + "/index.vue"]); return modules["../page/main" + path + "/index.vue"]; } //处理路由方法 var menuToRouter = (menu) => { menu.forEach((e) => { - e.name = getName(e.path) + e.name = getName(e.path); if (e.children && e.menuType == 0) { // 其他层级作为文件夹,只提供父级 e.component = () => import("../page/parent/parent.vue"); @@ -286,28 +285,25 @@ var menuToRouter = (menu) => { } else if (e.children && e.menuType !== 0) { //叶子层级需要加载到对应文件 //对首页做兼容 - if(e.source){ - console.log(`@/page/main${e.source}/index.vue`); + if (e.source) { e.component = getViews(e.source); - }else{ - console.log(`@/page/main${e.path}/index.vue`); + } else { e.component = getViews(e.path); } menuToRouter(e.children); } else { - console.log(`@/page/main${e.path}/index.vue`); //叶子层级需要加载到对应文件 //对首页做兼容 if (e.path == "/") { - if(e.source){ + if (e.source) { e.component = () => import(`../page/main/${e.source}/index.vue`); - }else{ + } else { e.component = () => import("../page/main/index/index.vue"); } } else { - if(e.source){ + if (e.source) { e.component = getViews(e.source); - }else{ + } else { e.component = getViews(e.path); } } diff --git a/src/router/index.js b/src/router/index.js index a78d42a71a3679958226661aa2006582999b66ca..378f7a27e5d99544644d0ac93a8191299287c257 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,130 +1,119 @@ //路由前端原则可以不写,但是需要在recorder中记录,防止以后忘记 //不用新增父路由的文件,父路由全部由parent/parent.vue来支撑 -import {createRouter, createWebHashHistory} from "vue-router"; -import store from '../store' - +import { createRouter, createWebHashHistory } from "vue-router"; +import store from "../store"; //写入初始必须有的路由 //或者隐藏式路由,不会表现在菜单上,但是需要存在的路由 const routes = [ { - path: '/login', - name: 'login', - show:true, - component: () => import('../page/login/index.vue') + path: "/login", + name: "login", + show: true, + component: () => import("../page/login/index.vue"), }, { - path: '/', - name: 'index', - component: () => import('../page/welcom.vue'), + path: "/", + name: "index", + component: () => import("../page/welcom.vue"), }, { - path: '/404', - show:true, - component: () => import('../page/404.vue') + path: "/404", + show: true, + component: () => import("../page/404.vue"), }, -] +]; //重新创建router -function newRouterFunc(){ +function newRouterFunc() { return createRouter({ history: createWebHashHistory(), - routes + routes, }); } -const router = newRouterFunc() +const router = newRouterFunc(); function inWhiteList(toPath) { //配置白名单 - const whiteList = ['/login'] + const whiteList = ["/login"]; const path = whiteList.find((value) => { // 使用正则匹配 - const reg = new RegExp('^' + value) - return reg.test(toPath) - }) - return !!path + const reg = new RegExp("^" + value); + return reg.test(toPath); + }); + return !!path; } router.beforeEach((to, from, next) => { - - const userInfo = store.state.userInfo + const userInfo = store.state.userInfo; console.log(store.state.route); //已登录不可跳转登陆页 - if(userInfo&&(to.path=='/login'||to.path=='/')){ - next({path:'/develop/account'}) + if (userInfo && (to.path == "/login" || to.path == "/")) { + next({ path: "/develop/account" }); } - // 检查to.path是否存在于免登陆白名单 if (inWhiteList(to.path)) { - next() + next(); } else { // 判断是否已经登录,未登录则重定向到首页或其他页面(通过query传参记录原来的路径) // 根据配置判断是否跳转第三方登录,跳转第三方登录则不跳login // axios封装中也需要对是否登录过期进行判断,如果登录过期,则跳转登录页,具体跳转地址根据配置来· if (!userInfo) { next({ - path: '/login', - }) + path: "/login", + }); } else { - } } //判读是否匹配,否则跳转404 if (to.matched.length !== 0) { - next() + next(); } else { - return next({ path: '/404' }) + return next({ path: "/404" }); } -}) - +}); // 在路由完成初始导航时调用,如果有异步操作放置到这里 // 请求相应的角色和菜单 // router.onReady(() => { // generateRoutes() // }) -function addRoute(router,routers){ - routers.forEach(e => { - if(e.path[0]=='/'){ - router.addRoute(e) - if(e.children&&e.children.length){ - addRoute(router,e.children) +function addRoute(router, routers) { + routers.forEach((e) => { + if (e.path[0] == "/") { + router.addRoute(e); + if (e.children && e.children.length) { + addRoute(router, e.children); } } }); } export function generateRoutes() { - const _asyncRoutes = store.state.route + const _asyncRoutes = store.state.route; if (_asyncRoutes) { //动态添加路由 - addRoute(router,_asyncRoutes) + addRoute(router, _asyncRoutes); } - router.addRoute( - { - path: '/:pathMatch(.*)', - redirect: '/404' - } - ) + router.addRoute({ + path: "/:pathMatch(.*)", + redirect: "/404", + }); console.log(router.getRoutes()); - } //新创建一个router替代之前的router,并把matcher方法替换成新的router的matcher export function resetRouter() { - const newRouter = newRouterFunc() - router.matcher = newRouter.matcher + const newRouter = newRouterFunc(); + router.matcher = newRouter.matcher; } - - - -export default router +export default router;