@shwfed/nuxt 0.1.64 → 0.1.65

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 CHANGED
@@ -2,18 +2,12 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  interface ModuleOptions {
4
4
  apis: Readonly<{
5
- /**
6
- * 当前应用的 App ID
7
- *
8
- * @type string
9
- */
10
- clientId: string;
11
5
  /**
12
6
  * 配置该项目获取 token 的表达式
13
7
  *
14
8
  * @type DSL string
15
9
  */
16
- token: string;
10
+ token?: string;
17
11
  /**
18
12
  * 配置该项目的 API 请求头
19
13
  *
@@ -39,18 +33,6 @@ interface ModuleOptions {
39
33
  * @type DSL
40
34
  */
41
35
  expired?: string;
42
- /**
43
- * 配置该项目的登录页 URI
44
- *
45
- * @type string
46
- */
47
- authorizeUri?: string;
48
- /**
49
- * 配置该项目的 URI 重定向地址
50
- *
51
- * @type string
52
- */
53
- redirectUri?: string;
54
36
  /**
55
37
  * 配置该项目的退出登录 URI
56
38
  *
@@ -66,8 +48,63 @@ interface ModuleOptions {
66
48
  *
67
49
  * @type Markdown
68
50
  */
69
- name: string;
51
+ name?: string;
70
52
  }>;
53
+ sidebar: {
54
+ /**
55
+ * 侧边栏的菜单
56
+ *
57
+ * DSL 应当返回一个数组,每个元素是一个对象,对象的结构如下:
58
+ *
59
+ * ```ts
60
+ * type Item = {
61
+ * id: string
62
+ * title: string
63
+ * path: string
64
+ * disabled?: string
65
+ * hidden?: string
66
+ * icon?: string
67
+ * keywords?: string[]
68
+ * children?: Item[]
69
+ * }
70
+ * ```
71
+ *
72
+ * @type DSL
73
+ */
74
+ menus?: string;
75
+ };
76
+ /**
77
+ * 个人菜单下拉中的命令配置
78
+ *
79
+ * DSL 应当返回一个数组,每个元素是一个分组或命令项:
80
+ *
81
+ * ```ts
82
+ * type CommandItem = {
83
+ * id: string | number
84
+ * title: string
85
+ * icon?: string
86
+ * hidden?: string
87
+ * disabled?: string
88
+ * effect?: string
89
+ * keywords?: string[]
90
+ * }
91
+ *
92
+ * type CommandGroup = {
93
+ * id: string | number
94
+ * title: string
95
+ * icon?: string
96
+ * children: CommandItem[]
97
+ * }
98
+ * ```
99
+ *
100
+ * 其中 `effect` 为 DSL 表达式,返回动作对象:
101
+ * - `{ type: 'route', to: string }`
102
+ * - `{ type: 'external', href: string }`
103
+ * - `{ type: 'logout' }`
104
+ *
105
+ * @type DSL
106
+ */
107
+ commands?: string | null;
71
108
  /**
72
109
  * 默认展示的应用标题
73
110
  *
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
3
  "configKey": "shwfed",
4
- "version": "0.1.64",
4
+ "version": "0.1.65",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -10,7 +10,11 @@ const module$1 = defineNuxtModule({
10
10
  defaults: {},
11
11
  setup(options, nuxt) {
12
12
  const resolver = createResolver(import.meta.url);
13
- nuxt.options.runtimeConfig.public.shwfed = defu(options, {
13
+ const normalizedOptions = {
14
+ ...options,
15
+ commands: typeof options.commands === "string" ? options.commands : void 0
16
+ };
17
+ const resolvedConfig = defu(normalizedOptions, {
14
18
  git: {
15
19
  commit: process.env.GIT_COMMIT,
16
20
  branch: process.env.GIT_LOCAL_BRANCH
@@ -20,6 +24,11 @@ const module$1 = defineNuxtModule({
20
24
  build: process.env.BUILD_NUMBER ? Number.parseInt(process.env.BUILD_NUMBER) : void 0
21
25
  }
22
26
  });
27
+ const commands = resolvedConfig.commands;
28
+ nuxt.options.runtimeConfig.public.shwfed = {
29
+ ...resolvedConfig,
30
+ commands: commands === null ? null : typeof commands === "string" ? commands : void 0
31
+ };
23
32
  nuxt.options.css ||= [];
24
33
  nuxt.options.css.push("vue-sonner/style.css");
25
34
  addVitePlugin(VueI18nPlugin({
@@ -1,81 +1,6 @@
1
1
  import type { Scope } from 'effect';
2
2
  import { Effect } from 'effect';
3
- type Item = Readonly<{
4
- id: string;
5
- /**
6
- * 命令的标题
7
- *
8
- * 调用者处理 i18n
9
- *
10
- * @type string
11
- */
12
- title: string;
13
- /**
14
- * 命令的图标
15
- *
16
- * @type string
17
- */
18
- icon?: string;
19
- /**
20
- * 命令是否禁用
21
- *
22
- * @type DSL
23
- */
24
- disabled?: boolean | string;
25
- /**
26
- * 命令是否隐藏
27
- *
28
- * @type DSL | boolean
29
- */
30
- hidden?: boolean | string;
31
- /**
32
- * 命令的关键词
33
- *
34
- * @type string[]
35
- */
36
- keywords?: ReadonlyArray<string>;
37
- }>;
38
- type CommandPosition = 'profile' | 'command-palette';
39
- interface Command extends Item {
40
- positions: ReadonlyArray<CommandPosition>;
41
- effect: Effect.Effect<void, never, Scope.Scope>;
42
- }
43
- interface Navigation extends Item {
44
- /**
45
- * 导航项的跳转目标
46
- *
47
- * @type string
48
- */
49
- target: string;
50
- /**
51
- * 导航项是否为外部链接
52
- *
53
- * @type DSL
54
- */
55
- external: string;
56
- }
57
3
  type __VLS_Props = {
58
- /**
59
- * 所有导航项
60
- */
61
- navigation?: ReadonlyArray<Navigation | Readonly<{
62
- id: string;
63
- title: string;
64
- icon?: string;
65
- children: ReadonlyArray<Navigation>;
66
- }>>;
67
- /**
68
- * 应用内命令列表,用于命令面板(Cmd+K)和/或顶栏个人资料下拉菜单。
69
- * 每项为「单个命令」或「分组」:单个命令含 positions、effect;分组含 id、title、可选 icon、children(Command 数组)。
70
- * positions 控制展示位置:'command-palette' 出现在命令面板,'profile' 出现在个人资料菜单;可同时包含两者。
71
- * 用户选择某命令时执行其 effect(带 Scope)。可选 disabled、hidden(CEL 表达式)、keywords 与导航等用法一致。
72
- */
73
- commands?: ReadonlyArray<Command | Readonly<{
74
- id: string;
75
- title: string;
76
- icon?: string;
77
- children: ReadonlyArray<Command>;
78
- }>>;
79
4
  /**
80
5
  * 应用的全局 DSL(CEL)执行上下文。传入一个 Effect,在应用启动时运行一次;
81
6
  * 其解析结果(一个 record)会被永久设为全局上下文,供后续所有 CEL 求值(如 `$dsl.evaluate`)使用。
@@ -114,11 +39,11 @@ type __VLS_Props = {
114
39
  */
115
40
  dsl?: Effect.Effect<Record<string, unknown>, never, Scope.Scope>;
116
41
  };
117
- declare var __VLS_103: {}, __VLS_377: {};
42
+ declare var __VLS_122: {}, __VLS_346: {};
118
43
  type __VLS_Slots = {} & {
119
- menu?: (props: typeof __VLS_103) => any;
44
+ menu?: (props: typeof __VLS_122) => any;
120
45
  } & {
121
- default?: (props: typeof __VLS_377) => any;
46
+ default?: (props: typeof __VLS_346) => any;
122
47
  };
123
48
  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>;
124
49
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;