@duxweb/dvha-core 0.0.4 → 0.0.6

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @duxweb/dvha-core
2
2
 
3
+ ## 0.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: dependencie @tanstack/vue-query
8
+
9
+ ## 0.0.5
10
+
11
+ ### Patch Changes
12
+
13
+ - 增加 loader 加载器类型
14
+
3
15
  ## 0.0.4
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@duxweb/dvha-core",
3
3
  "type": "module",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "author": "DuxWeb",
6
6
  "license": "LGPL-3.0",
7
7
  "repository": {
@@ -11,7 +11,7 @@
11
11
  "main": "src/index.ts",
12
12
  "dependencies": {
13
13
  "@overlastic/vue": "^0.8.1",
14
- "@tanstack/react-query": "^5.76.1",
14
+ "@tanstack/vue-query": "^5.76.2",
15
15
  "@vueuse/core": "^13.2.0",
16
16
  "@vueuse/integrations": "^13.2.0",
17
17
  "axios": "^1.9.0",
@@ -19,9 +19,8 @@
19
19
  "pinia": "^3.0.2",
20
20
  "pinia-plugin-persistedstate": "^4.3.0",
21
21
  "vue": "^3.5.14",
22
- "vue-router": "4"
23
- },
24
- "devDependencies": {
22
+ "vue-router": "4",
25
23
  "clsx": "^2.1.1"
26
- }
24
+ },
25
+ "devDependencies": {}
27
26
  }
package/src/hooks/data.ts CHANGED
@@ -1,13 +1,12 @@
1
- import type { DefaultError, DefinedInitialDataInfiniteOptions, InfiniteData, QueryKey, UndefinedInitialDataOptions, UseMutationOptions } from '@tanstack/react-query'
1
+ import type { DefaultError, DefinedInitialDataInfiniteOptions, DefinedInitialQueryOptions, InfiniteData, QueryKey, UseMutationOptions } from '@tanstack/vue-query'
2
2
  import type { IDataProviderCreateManyOptions, IDataProviderCreateOptions, IDataProviderCustomOptions, IDataProviderDeleteManyOptions, IDataProviderDeleteOptions, IDataProviderGetManyOptions, IDataProviderGetOneOptions, IDataProviderListOptions, IDataProviderResponse, IDataProviderUpdateManyOptions, IDataProviderUpdateOptions } from '../types'
3
- import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
3
+ import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
4
4
  import { computed, watch } from 'vue'
5
5
  import { useError, useGetAuth } from './auth'
6
6
  import { useManage } from './manage'
7
- import { useAuthStore } from 'src/stores'
8
7
 
9
- type IDataQueryOptions = UndefinedInitialDataOptions<IDataProviderResponse | undefined, DefaultError, IDataProviderResponse | undefined, QueryKey>
10
- type IDataQueryOptionsInfinite = DefinedInitialDataInfiniteOptions<IDataProviderResponse | undefined, DefaultError, InfiniteData<IDataProviderResponse | undefined>, QueryKey, number>
8
+ type IDataQueryOptions = DefinedInitialQueryOptions<IDataProviderResponse | undefined, DefaultError, IDataProviderResponse | undefined, any>
9
+ type IDataQueryOptionsInfinite = DefinedInitialDataInfiniteOptions<IDataProviderResponse | undefined, DefaultError, InfiniteData<IDataProviderResponse | undefined>, any, number>
11
10
 
12
11
  interface IListParams extends IDataProviderListOptions {
13
12
  options?: IDataQueryOptions
@@ -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
- router.addRoute(`${manageName}.auth`, {
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
 
@@ -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
  }