@duxweb/dvha-core 0.0.3 → 0.0.5
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/CHANGELOG.md +12 -0
- package/package.json +2 -2
- package/src/provider/app.tsx +25 -4
- package/src/types/config.ts +3 -1
- package/src/types/menu.ts +3 -3
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duxweb/dvha-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"author": "DuxWeb",
|
|
6
6
|
"license": "LGPL-3.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/duxweb/
|
|
9
|
+
"url": "https://github.com/duxweb/dvha.git"
|
|
10
10
|
},
|
|
11
11
|
"main": "src/index.ts",
|
|
12
12
|
"dependencies": {
|
package/src/provider/app.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, inject, Ref } from 'vue'
|
|
2
|
-
import { useRouter } from 'vue-router'
|
|
2
|
+
import { RouteRecordRaw, useRouter } from 'vue-router'
|
|
3
3
|
import { useConfig, useManage } from '../hooks'
|
|
4
4
|
import { useAuthStore, useRouteStore } from '../stores'
|
|
5
5
|
import { storeToRefs } from 'pinia'
|
|
@@ -127,12 +127,33 @@ export const DuxAppProvider = defineComponent({
|
|
|
127
127
|
return
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
const route: Partial<RouteRecordRaw> = {
|
|
131
131
|
name: item.name,
|
|
132
132
|
path: item.path,
|
|
133
|
-
component: typeof item.component === 'function' ? item.component : () => import('../components/loader/iframe'),
|
|
134
133
|
meta: item.meta,
|
|
135
|
-
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
switch (item.loader) {
|
|
138
|
+
case 'iframe':
|
|
139
|
+
route.component = manage.config?.components?.iframe
|
|
140
|
+
break
|
|
141
|
+
case 'link':
|
|
142
|
+
route.beforeEnter = () => {
|
|
143
|
+
const url = item.meta?.url || item.path
|
|
144
|
+
if (url) {
|
|
145
|
+
window.open(url, '_blank')
|
|
146
|
+
}
|
|
147
|
+
return false
|
|
148
|
+
}
|
|
149
|
+
route.component = () => Promise.resolve({ template: '<div></div>' })
|
|
150
|
+
break
|
|
151
|
+
default:
|
|
152
|
+
route.component = typeof item.component === 'string' ? () => import(item.component as string) : item.component
|
|
153
|
+
break
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
router.addRoute(`${manageName}.auth`, route as RouteRecordRaw)
|
|
136
157
|
})
|
|
137
158
|
|
|
138
159
|
|
package/src/types/config.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface IConfig {
|
|
|
23
23
|
// 默认管理端
|
|
24
24
|
defaultManage?: string
|
|
25
25
|
// 管理端提供者
|
|
26
|
-
manages
|
|
26
|
+
manages: IManage[]
|
|
27
27
|
// 全局认证提供者
|
|
28
28
|
authProvider?: IAuthProvider
|
|
29
29
|
// 全局数据提供者
|
|
@@ -46,4 +46,6 @@ export interface IConfigComponent {
|
|
|
46
46
|
notFound?: RouteComponent // 未找到布局
|
|
47
47
|
notAuthorized?: RouteComponent // 未授权布局
|
|
48
48
|
error?: RouteComponent // 错误布局
|
|
49
|
+
|
|
50
|
+
iframe?: RouteComponent // iframe 组件
|
|
49
51
|
}
|
package/src/types/menu.ts
CHANGED
|
@@ -15,10 +15,10 @@ export interface IMenu {
|
|
|
15
15
|
parent?: string
|
|
16
16
|
// 是否隐藏
|
|
17
17
|
hidden?: boolean
|
|
18
|
-
// 菜单加载器
|
|
18
|
+
// 菜单加载器 ('iframe' | 'link' | 'component')
|
|
19
19
|
loader?: string
|
|
20
20
|
// 菜单组件
|
|
21
|
-
component?: RouteComponent
|
|
22
|
-
// 菜单元数据
|
|
21
|
+
component?: RouteComponent | string
|
|
22
|
+
// 菜单元数据 (当 loader 为 'link' 时,可在 meta.url 中设置外部链接地址)
|
|
23
23
|
meta?: Record<string, any>
|
|
24
24
|
}
|