zsysview 0.0.16 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/app.ts CHANGED
@@ -10,7 +10,7 @@ import zhCn from 'element-plus/es/locale/lang/zh-cn'
10
10
 
11
11
 
12
12
  //路由
13
- import {initRouter} from './router.ts' //导入路由模块
13
+ import router from './router.ts' //导入路由模块
14
14
 
15
15
 
16
16
  const zsysapp=createApp(app)
@@ -20,7 +20,7 @@ pinia.use(piniaPluginPersistedstate)
20
20
 
21
21
  // addFrameRouter({path:'/desktop',component:()=>import('../../test_view/test_desktop.vue')})
22
22
 
23
- zsysapp.use(initRouter()) //将 Vue Router 插件注册到 Vue 应用中
23
+ zsysapp.use(router) //将 Vue Router 插件注册到 Vue 应用中
24
24
  zsysapp.use(ElementPlus,{locale: zhCn}) //将 ElementPlus 插件注册到 Vue 应用中
25
25
  zsysapp.use(pinia)
26
26
  //从后台获取全局信息
package/core/router.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { createRouter, createWebHistory, type Router,type RouteRecordRaw } from "vue-router"
1
+ import { createRouter, createWebHistory, type Router, type RouteRecordRaw } from "vue-router"
2
2
  import { useTokenStore } from "./user_token"
3
3
 
4
4
  const routes = [
@@ -83,52 +83,56 @@ const router = createRouter({
83
83
  })
84
84
 
85
85
  function addFrameRouter(r: RouteRecordRaw) {
86
- try {
87
- // 查找path为"/main"的路由
88
- const mainRoute = routes.find(route => route.path === "/main");
89
-
90
- if (!mainRoute) {
91
- console.error('未找到path为"/main"的路由');
92
- return
93
- }
94
-
95
- // 确保mainRoute有children数组
96
- if (!mainRoute.children) {
97
- mainRoute.children = [];
98
- }
99
-
100
- // 检查是否已存在相同path的路由
101
- const existingRouteIndex = mainRoute.children.findIndex(
102
- child => child.path === r.path
103
- );
104
-
105
- if (existingRouteIndex !== -1) {
106
- // 如果已存在,替换该路由
107
- mainRoute.children[existingRouteIndex] = r;
108
- console.log(`已更新路由: ${r.path}`);
109
- } else {
110
- // 如果不存在,添加新路由
111
- mainRoute.children.push(r);
112
- console.log(`已添加新路由: ${r.path}`);
113
- }
114
-
115
- // 重新创建router实例以确保路由更新生效
116
- // 注意:在实际项目中可能需要更复杂的路由更新逻辑
117
- // router.addRoute('main', r as RouteRecordRaw);
118
-
119
- return 1;
120
- } catch (error) {
121
- console.error('添加路由失败:', error);
122
- return 0;
123
- }
86
+ router.addRoute('main', r)
124
87
  }
125
88
 
126
- function initRouter(): Router {
127
- return createRouter({
128
- history: createWebHistory(),
129
- routes
130
- })
131
- }
89
+ // function addFrameRouter(r: RouteRecordRaw) {
90
+ // try {
91
+ // // 查找path为"/main"的路由
92
+ // const mainRoute = routes.find(route => route.path === "/main");
93
+
94
+ // if (!mainRoute) {
95
+ // console.error('未找到path为"/main"的路由');
96
+ // return
97
+ // }
98
+
99
+ // // 确保mainRoute有children数组
100
+ // if (!mainRoute.children) {
101
+ // mainRoute.children = [];
102
+ // }
103
+
104
+ // // 检查是否已存在相同path的路由
105
+ // const existingRouteIndex = mainRoute.children.findIndex(
106
+ // child => child.path === r.path
107
+ // );
108
+
109
+ // if (existingRouteIndex !== -1) {
110
+ // // 如果已存在,替换该路由
111
+ // mainRoute.children[existingRouteIndex] = r;
112
+ // console.log(`已更新路由: ${r.path}`);
113
+ // } else {
114
+ // // 如果不存在,添加新路由
115
+ // mainRoute.children.push(r);
116
+ // console.log(`已添加新路由: ${r.path}`);
117
+ // }
118
+
119
+ // // 重新创建router实例以确保路由更新生效
120
+ // // 注意:在实际项目中可能需要更复杂的路由更新逻辑
121
+ // // router.addRoute('main', r as RouteRecordRaw);
122
+
123
+ // return 1;
124
+ // } catch (error) {
125
+ // console.error('添加路由失败:', error);
126
+ // return 0;
127
+ // }
128
+ // }
129
+
130
+ // function initRouter(): Router {
131
+ // return createRouter({
132
+ // history: createWebHistory(),
133
+ // routes
134
+ // })
135
+ // }
132
136
 
133
137
  router.beforeEach((to, _, next) => {
134
138
  console.log('to', to.fullPath);
@@ -145,5 +149,5 @@ router.beforeEach((to, _, next) => {
145
149
  }
146
150
  })
147
151
 
148
- // export default router
149
- export { initRouter, addFrameRouter }
152
+ export default router
153
+ export { addFrameRouter }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zsysview",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "zsystem view",
5
5
  "author": {
6
6
  "name": "liuhaomiao"