@shwfed/nuxt 0.1.75 → 0.1.76
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/dist/module.d.mts +13 -134
- package/dist/module.json +2 -2
- package/dist/module.mjs +17 -14
- package/dist/runtime/components/app.d.vue.ts +33 -3
- package/dist/runtime/components/app.vue +77 -311
- package/dist/runtime/components/app.vue.d.ts +33 -3
- package/dist/runtime/composables/useFavorite.d.ts +1 -1
- package/dist/runtime/composables/useNavigationTabs.d.ts +19 -5
- package/dist/runtime/composables/useNavigationTabs.js +71 -46
- package/dist/runtime/middleware/token.d.ts +2 -0
- package/dist/runtime/middleware/token.js +9 -0
- package/dist/runtime/plugins/api/index.d.ts +0 -2
- package/dist/runtime/plugins/api/index.js +6 -56
- package/dist/runtime/plugins/cel/env.js +1 -1
- package/dist/runtime/plugins/cel/index.js +3 -2
- package/dist/runtime/plugins/toast/index.d.ts +2 -2
- package/dist/types.d.mts +7 -1
- package/package.json +1 -1
- package/dist/runtime/utils/command-palette.d.ts +0 -71
- package/dist/runtime/utils/command-palette.js +0 -72
- package/dist/runtime/utils/command.d.ts +0 -31
- package/dist/runtime/utils/command.js +0 -40
- package/dist/runtime/utils/navigation-title.d.ts +0 -10
- package/dist/runtime/utils/navigation-title.js +0 -28
- package/dist/runtime/utils/route.d.ts +0 -2
- package/dist/runtime/utils/route.js +0 -14
- package/dist/runtime/utils/sidebar-fallback.d.ts +0 -16
- package/dist/runtime/utils/sidebar-fallback.js +0 -32
package/dist/module.d.mts
CHANGED
|
@@ -1,136 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
|
-
interface ModuleOptions {
|
|
4
|
-
apis: Readonly<{
|
|
5
|
-
/**
|
|
6
|
-
* 配置该项目获取 token 的表达式
|
|
7
|
-
*
|
|
8
|
-
* @type DSL string
|
|
9
|
-
*/
|
|
10
|
-
token?: string;
|
|
11
|
-
/**
|
|
12
|
-
* 配置该项目的 API 请求头
|
|
13
|
-
*
|
|
14
|
-
* DSL 应当返回一个 `map<string, string>`,其优先级低于直接设置的请求头。
|
|
15
|
-
*
|
|
16
|
-
* 这个表达式可以访问到 `token` 变量,其通过 `token` 配置的表达式计算得到。
|
|
17
|
-
*
|
|
18
|
-
* 仅当 `token` 与 `headers` 都配置为字符串时才会执行该表达式;
|
|
19
|
-
* 若 `token` 表达式结果不是字符串或表达式执行失败,则不会注入任何请求头。
|
|
20
|
-
*
|
|
21
|
-
* @type DSL
|
|
22
|
-
*/
|
|
23
|
-
headers?: string;
|
|
24
|
-
/**
|
|
25
|
-
* 配置该项目的 API 请求基础 URL
|
|
26
|
-
*
|
|
27
|
-
* @type string
|
|
28
|
-
*/
|
|
29
|
-
apiHost?: string;
|
|
30
|
-
/**
|
|
31
|
-
* 检查 API 响应,判断是否需要重定向到登陆页
|
|
32
|
-
*
|
|
33
|
-
* DSL 应当返回一个布尔值,表示是否需要重定向到登陆页。该表达式可以访问到**每一个 API 响应**的响应数据,
|
|
34
|
-
* 可以通过 `response` 变量访问。
|
|
35
|
-
*
|
|
36
|
-
* 仅当 `expired` 与 `logoutUri` 都配置为字符串时才会执行该表达式。
|
|
37
|
-
*
|
|
38
|
-
* @type DSL
|
|
39
|
-
*/
|
|
40
|
-
expired?: string;
|
|
41
|
-
/**
|
|
42
|
-
* 配置该项目的退出登录 URI
|
|
43
|
-
*
|
|
44
|
-
* @type string
|
|
45
|
-
*/
|
|
46
|
-
logoutUri?: string;
|
|
47
|
-
}>;
|
|
48
|
-
profile: Readonly<{
|
|
49
|
-
/**
|
|
50
|
-
* 导航栏右侧显示的内容,可以使用 Markdown (DSL)
|
|
51
|
-
*
|
|
52
|
-
* 通常显示用户名
|
|
53
|
-
*
|
|
54
|
-
* @type Markdown
|
|
55
|
-
*/
|
|
56
|
-
name?: string;
|
|
57
|
-
}>;
|
|
58
|
-
sidebar: {
|
|
59
|
-
/**
|
|
60
|
-
* 侧边栏的菜单
|
|
61
|
-
*
|
|
62
|
-
* DSL 应当返回一个数组,每个元素是一个分组或路由项:
|
|
63
|
-
*
|
|
64
|
-
* ```ts
|
|
65
|
-
* type RouteItem = {
|
|
66
|
-
* id: string | number
|
|
67
|
-
* title: string
|
|
68
|
-
* route: string
|
|
69
|
-
* icon?: string
|
|
70
|
-
* keywords?: string[]
|
|
71
|
-
* }
|
|
72
|
-
*
|
|
73
|
-
* type GroupItem = {
|
|
74
|
-
* id: string | number
|
|
75
|
-
* title: string
|
|
76
|
-
* icon?: string
|
|
77
|
-
* children: RouteItem[]
|
|
78
|
-
* }
|
|
79
|
-
* ```
|
|
80
|
-
*
|
|
81
|
-
* `RouteItem` 不支持 `hidden` / `disabled`,且 `children` 仅支持一层(`GroupItem -> RouteItem[]`)。
|
|
82
|
-
*
|
|
83
|
-
* @type DSL
|
|
84
|
-
*/
|
|
85
|
-
menus?: string;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* 个人菜单下拉中的命令配置
|
|
89
|
-
*
|
|
90
|
-
* DSL 应当返回一个数组,每个元素是一个分组或命令项:
|
|
91
|
-
*
|
|
92
|
-
* ```ts
|
|
93
|
-
* type CommandItem = {
|
|
94
|
-
* id: string | number
|
|
95
|
-
* title: string
|
|
96
|
-
* icon?: string
|
|
97
|
-
* hidden?: string
|
|
98
|
-
* disabled?: string
|
|
99
|
-
* effect?: string
|
|
100
|
-
* keywords?: string[]
|
|
101
|
-
* }
|
|
102
|
-
*
|
|
103
|
-
* type CommandGroup = {
|
|
104
|
-
* id: string | number
|
|
105
|
-
* title: string
|
|
106
|
-
* icon?: string
|
|
107
|
-
* children: CommandItem[]
|
|
108
|
-
* }
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* 其中 `effect` 为 DSL 表达式,返回动作对象:
|
|
112
|
-
* - `{ type: 'route', to: string }`
|
|
113
|
-
* - `{ type: 'external', href: string }`
|
|
114
|
-
* - `{ type: 'logout' }`
|
|
115
|
-
* - `{ type: 'request', url: string, method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', body?: unknown, query?: Record<string, unknown>, headers?: Record<string, string> }`
|
|
116
|
-
*
|
|
117
|
-
* 示例:
|
|
118
|
-
* - 维护任务:`{ type: 'request', url: '/maintenance/run', method: 'POST' }`
|
|
119
|
-
* - 清理缓存:`{ type: 'request', url: '/cache/clear', method: 'POST', body: { scope: 'all' } }`
|
|
120
|
-
* - 重建索引:`{ type: 'request', url: '/search/reindex', method: 'POST', query: { async: true }, headers: { 'X-Command-Source': 'palette' } }`
|
|
121
|
-
*
|
|
122
|
-
* 当前模块实现会将 `commands: null` 规范化为 `undefined`,等价于不配置。
|
|
123
|
-
*
|
|
124
|
-
* @type DSL
|
|
125
|
-
*/
|
|
126
|
-
commands?: string | null;
|
|
127
|
-
/**
|
|
128
|
-
* 默认展示的应用标题
|
|
129
|
-
*
|
|
130
|
-
* 如果当前路由没有匹配到导航项,则显示该标题
|
|
131
|
-
*/
|
|
132
|
-
title: string;
|
|
133
|
-
}
|
|
134
3
|
interface Env {
|
|
135
4
|
git: Readonly<{
|
|
136
5
|
commit?: string;
|
|
@@ -140,19 +9,29 @@ interface Env {
|
|
|
140
9
|
job?: string;
|
|
141
10
|
build?: number;
|
|
142
11
|
}>;
|
|
12
|
+
api: Readonly<{
|
|
13
|
+
host?: string;
|
|
14
|
+
logout?: string;
|
|
15
|
+
}>;
|
|
16
|
+
headers: Readonly<{
|
|
17
|
+
token?: string;
|
|
18
|
+
}>;
|
|
143
19
|
}
|
|
144
20
|
declare module 'nuxt/schema' {
|
|
145
21
|
interface PublicRuntimeConfig {
|
|
146
|
-
shwfed:
|
|
22
|
+
shwfed: Env;
|
|
147
23
|
}
|
|
148
24
|
}
|
|
149
25
|
declare global {
|
|
150
26
|
interface ImportMetaEnv {
|
|
151
27
|
readonly GIT_COMMIT?: string;
|
|
152
28
|
readonly GIT_LOCAL_BRANCH?: string;
|
|
29
|
+
readonly NUXT_PUBLIC_API_URI?: string;
|
|
30
|
+
readonly NUXT_PUBLIC_SSO_LOGOUT_URI?: string;
|
|
31
|
+
readonly NUXT_PUBLIC_TOKEN_HEADER_NAME?: string;
|
|
153
32
|
}
|
|
154
33
|
}
|
|
155
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
34
|
+
declare const _default: _nuxt_schema.NuxtModule<_nuxt_schema.ModuleOptions, _nuxt_schema.ModuleOptions, false>;
|
|
156
35
|
|
|
157
36
|
export { _default as default };
|
|
158
|
-
export type { Env
|
|
37
|
+
export type { Env };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addVitePlugin, addPlugin, addImportsDir, addComponentsDir } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, createResolver, addVitePlugin, addPlugin, addImportsDir, addComponentsDir, addRouteMiddleware } from '@nuxt/kit';
|
|
2
2
|
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
|
|
3
3
|
import defu from 'defu';
|
|
4
4
|
|
|
5
5
|
const module$1 = defineNuxtModule({
|
|
6
6
|
meta: {
|
|
7
|
-
name: "@shwfed/nuxt"
|
|
8
|
-
configKey: "shwfed"
|
|
7
|
+
name: "@shwfed/nuxt"
|
|
9
8
|
},
|
|
10
|
-
defaults: {},
|
|
11
9
|
setup(options, nuxt) {
|
|
12
10
|
const resolver = createResolver(import.meta.url);
|
|
13
|
-
const
|
|
14
|
-
...options,
|
|
15
|
-
commands: typeof options.commands === "string" ? options.commands : void 0
|
|
16
|
-
};
|
|
17
|
-
const resolvedConfig = defu(normalizedOptions, {
|
|
11
|
+
const resolvedConfig = defu(options, {
|
|
18
12
|
git: {
|
|
19
13
|
commit: process.env.GIT_COMMIT,
|
|
20
14
|
branch: process.env.GIT_LOCAL_BRANCH
|
|
@@ -22,15 +16,19 @@ const module$1 = defineNuxtModule({
|
|
|
22
16
|
ci: {
|
|
23
17
|
job: process.env.JOB_NAME,
|
|
24
18
|
build: process.env.BUILD_NUMBER ? Number.parseInt(process.env.BUILD_NUMBER) : void 0
|
|
19
|
+
},
|
|
20
|
+
api: {
|
|
21
|
+
host: process.env.NUXT_PUBLIC_API_URI,
|
|
22
|
+
logout: process.env.NUXT_PUBLIC_SSO_LOGOUT_URI
|
|
23
|
+
},
|
|
24
|
+
headers: {
|
|
25
|
+
token: process.env.NUXT_PUBLIC_TOKEN_HEADER_NAME
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
|
-
|
|
28
|
-
nuxt.options.runtimeConfig.public.shwfed = {
|
|
29
|
-
...resolvedConfig,
|
|
30
|
-
commands: commands === null ? null : typeof commands === "string" ? commands : void 0
|
|
31
|
-
};
|
|
28
|
+
nuxt.options.runtimeConfig.public.shwfed = resolvedConfig;
|
|
32
29
|
nuxt.options.css ||= [];
|
|
33
30
|
nuxt.options.css.push("vue-sonner/style.css");
|
|
31
|
+
nuxt.options.ssr = false;
|
|
34
32
|
addVitePlugin(VueI18nPlugin({
|
|
35
33
|
ssr: true
|
|
36
34
|
}));
|
|
@@ -49,6 +47,11 @@ const module$1 = defineNuxtModule({
|
|
|
49
47
|
prefix: "shwfed",
|
|
50
48
|
extensions: ["vue"]
|
|
51
49
|
});
|
|
50
|
+
addRouteMiddleware({
|
|
51
|
+
path: resolver.resolve("runtime/middleware/token"),
|
|
52
|
+
name: "token",
|
|
53
|
+
global: true
|
|
54
|
+
});
|
|
52
55
|
}
|
|
53
56
|
});
|
|
54
57
|
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import type { Scope } from 'effect';
|
|
2
2
|
import { Effect } from 'effect';
|
|
3
|
+
import { type Sidebar as SidebarType } from '../composables/useNavigationTabs.js';
|
|
4
|
+
type ProfileCommandInputItem = Readonly<{
|
|
5
|
+
id: string | number;
|
|
6
|
+
title: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
hidden?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
effect?: Effect.Effect<void>;
|
|
11
|
+
keywords?: Array<string>;
|
|
12
|
+
}>;
|
|
13
|
+
type ProfileCommandInputGroup = Readonly<{
|
|
14
|
+
id: string | number;
|
|
15
|
+
title: string;
|
|
16
|
+
icon?: string;
|
|
17
|
+
children: Array<ProfileCommandInputItem>;
|
|
18
|
+
}>;
|
|
3
19
|
type __VLS_Props = {
|
|
4
20
|
/**
|
|
5
21
|
* 应用的全局 DSL(CEL)执行上下文。传入一个 Effect,在应用启动时运行一次;
|
|
@@ -38,12 +54,26 @@ type __VLS_Props = {
|
|
|
38
54
|
* // CEL 中可访问 user.name、permissions.canEdit 等;失败时在 effect 内兜底,不抛错
|
|
39
55
|
*/
|
|
40
56
|
dsl?: Effect.Effect<Record<string, unknown>, never, Scope.Scope>;
|
|
57
|
+
/**
|
|
58
|
+
* Sidebar config.
|
|
59
|
+
*
|
|
60
|
+
* `menus` is structured navigation data.
|
|
61
|
+
*/
|
|
62
|
+
sidebar?: SidebarType;
|
|
63
|
+
/**
|
|
64
|
+
* Profile command config.
|
|
65
|
+
*
|
|
66
|
+
* Structured command entries for profile menu and command palette.
|
|
67
|
+
*/
|
|
68
|
+
commands?: Array<ProfileCommandInputItem | ProfileCommandInputGroup>;
|
|
41
69
|
};
|
|
42
|
-
declare var
|
|
70
|
+
declare var __VLS_108: {}, __VLS_124: {}, __VLS_334: {};
|
|
43
71
|
type __VLS_Slots = {} & {
|
|
44
|
-
menu?: (props: typeof
|
|
72
|
+
menu?: (props: typeof __VLS_108) => any;
|
|
73
|
+
} & {
|
|
74
|
+
profile?: (props: typeof __VLS_124) => any;
|
|
45
75
|
} & {
|
|
46
|
-
default?: (props: typeof
|
|
76
|
+
default?: (props: typeof __VLS_334) => any;
|
|
47
77
|
};
|
|
48
78
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
49
79
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|