@shwfed/nuxt 0.1.26 → 0.1.27

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.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
3
  "configKey": "shwfed",
4
- "version": "0.1.26",
4
+ "version": "0.1.27",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,23 +1,29 @@
1
- export type NavigationCommand = Readonly<{
2
- type: 'navigation';
3
- id: string;
4
- title: string;
5
- icon?: string;
6
- path: string;
7
- }>;
8
- export type APICommand = Readonly<{
9
- type: 'api';
10
- id: string;
11
- title: string;
12
- icon?: string;
13
- }>;
14
- export type Command = NavigationCommand | APICommand;
1
+ import type { Scope } from 'effect';
2
+ import { Effect } from 'effect';
15
3
  declare const _default: typeof __VLS_export;
16
4
  export default _default;
17
5
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
18
- commands?: ReadonlyArray<Command>;
6
+ commands?: ReadonlyArray<Readonly<{
7
+ id: string;
8
+ title: string;
9
+ children: ReadonlyArray<Readonly<{
10
+ id: string;
11
+ title: string;
12
+ icon?: string;
13
+ effect: Effect.Effect<void, never, Scope.Scope>;
14
+ }>>;
15
+ }>>;
19
16
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
20
- commands?: ReadonlyArray<Command>;
17
+ commands?: ReadonlyArray<Readonly<{
18
+ id: string;
19
+ title: string;
20
+ children: ReadonlyArray<Readonly<{
21
+ id: string;
22
+ title: string;
23
+ icon?: string;
24
+ effect: Effect.Effect<void, never, Scope.Scope>;
25
+ }>>;
26
+ }>>;
21
27
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
22
28
  default?: (props: {}) => any;
23
29
  }>;
@@ -1,16 +1,17 @@
1
1
  <script>
2
- import { useHead, useRouter } from "#app";
2
+ import { useHead } from "#app";
3
3
  import { ref } from "vue";
4
4
  import { CommandDialog, CommandInput, CommandList, CommandGroup, CommandEmpty, CommandItem, CommandSeparator } from "./ui/command";
5
5
  import { TooltipProvider } from "./ui/tooltip";
6
6
  import { Toaster } from "vue-sonner";
7
- import { useLocalStorage, useMagicKeys, whenever } from "@vueuse/core";
7
+ import { useMagicKeys, whenever } from "@vueuse/core";
8
8
  import { useI18n } from "vue-i18n";
9
9
  import { Icon } from "@iconify/vue";
10
+ import { Effect } from "effect";
10
11
  </script>
11
12
 
12
13
  <script setup>
13
- const props = defineProps({
14
+ defineProps({
14
15
  commands: { type: Array, required: false }
15
16
  });
16
17
  const { t } = useI18n();
@@ -26,29 +27,6 @@ const { meta_k } = useMagicKeys();
26
27
  whenever(() => meta_k?.value, () => {
27
28
  isCommandOpen.value = !isCommandOpen.value;
28
29
  });
29
- const router = useRouter();
30
- const recent = useLocalStorage("recent-commands", []);
31
- function addRecent(id) {
32
- if (recent.value.includes(id)) {
33
- recent.value.splice(recent.value.indexOf(id), 1);
34
- }
35
- recent.value.unshift(id);
36
- recent.value.splice(10);
37
- }
38
- async function handleCommandSelect(event) {
39
- const value = event.detail.value;
40
- const command = props.commands?.find((command2) => command2.title === value);
41
- if (!command) return;
42
- switch (command.type) {
43
- case "navigation":
44
- isCommandOpen.value = false;
45
- addRecent(command.id);
46
- await router.push(command.path);
47
- break;
48
- case "api":
49
- break;
50
- }
51
- }
52
30
  </script>
53
31
 
54
32
  <template>
@@ -74,38 +52,27 @@ async function handleCommandSelect(event) {
74
52
  </CommandEmpty>
75
53
 
76
54
  <CommandGroup
77
- v-if="recent.length > 0"
78
- :heading="t('recent')"
55
+ v-for="(group, i) in commands"
56
+ :key="group.id"
57
+ :heading="group.title"
79
58
  >
80
59
  <CommandItem
81
- v-for="command in commands"
82
- :key="command.title"
83
- :value="command.title"
84
- @select="handleCommandSelect"
85
- >
86
- <Icon
87
- v-if="command.icon"
88
- :icon="command.icon"
89
- />
90
- <span>{{ command.title }}</span>
91
- </CommandItem>
92
- </CommandGroup>
93
-
94
- <CommandSeparator v-if="recent.length > 0" />
95
-
96
- <CommandGroup :heading="t('navigation')">
97
- <CommandItem
98
- v-for="command in commands"
99
- :key="command.title"
100
- :value="command.title"
101
- @select="handleCommandSelect"
60
+ v-for="child in group.children"
61
+ :key="child.id"
62
+ :value="child.id"
63
+ @select="
64
+ child.effect.pipe(Effect.scoped).pipe(Effect.tap(() => {
65
+ isCommandOpen = false;
66
+ })).pipe(Effect.runPromise)
67
+ "
102
68
  >
103
69
  <Icon
104
- v-if="command.icon"
105
- :icon="command.icon"
70
+ v-if="child.icon"
71
+ :icon="child.icon"
106
72
  />
107
- <span>{{ command.title }}</span>
73
+ <span>{{ child.title }}</span>
108
74
  </CommandItem>
75
+ <CommandSeparator v-if="i !== Object.keys(commands ?? {}).length - 1" />
109
76
  </CommandGroup>
110
77
  </CommandList>
111
78
  </CommandDialog>
@@ -117,19 +84,13 @@ async function handleCommandSelect(event) {
117
84
  <i18n lang="json">
118
85
  {
119
86
  "zh": {
120
- "command-palette-empty": "无搜索结果",
121
- "navigation": "导航",
122
- "recent": "最近访问"
87
+ "command-palette-empty": "无搜索结果"
123
88
  },
124
89
  "ja": {
125
- "command-palette-empty": "結果はありません",
126
- "navigation": "ナビゲーション",
127
- "recent": "最近使用"
90
+ "command-palette-empty": "結果はありません"
128
91
  },
129
92
  "en": {
130
- "command-palette-empty": "No results",
131
- "navigation": "Navigation",
132
- "recent": "Recent"
93
+ "command-palette-empty": "No results"
133
94
  }
134
95
  }
135
96
  </i18n>
@@ -1,23 +1,29 @@
1
- export type NavigationCommand = Readonly<{
2
- type: 'navigation';
3
- id: string;
4
- title: string;
5
- icon?: string;
6
- path: string;
7
- }>;
8
- export type APICommand = Readonly<{
9
- type: 'api';
10
- id: string;
11
- title: string;
12
- icon?: string;
13
- }>;
14
- export type Command = NavigationCommand | APICommand;
1
+ import type { Scope } from 'effect';
2
+ import { Effect } from 'effect';
15
3
  declare const _default: typeof __VLS_export;
16
4
  export default _default;
17
5
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
18
- commands?: ReadonlyArray<Command>;
6
+ commands?: ReadonlyArray<Readonly<{
7
+ id: string;
8
+ title: string;
9
+ children: ReadonlyArray<Readonly<{
10
+ id: string;
11
+ title: string;
12
+ icon?: string;
13
+ effect: Effect.Effect<void, never, Scope.Scope>;
14
+ }>>;
15
+ }>>;
19
16
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
20
- commands?: ReadonlyArray<Command>;
17
+ commands?: ReadonlyArray<Readonly<{
18
+ id: string;
19
+ title: string;
20
+ children: ReadonlyArray<Readonly<{
21
+ id: string;
22
+ title: string;
23
+ icon?: string;
24
+ effect: Effect.Effect<void, never, Scope.Scope>;
25
+ }>>;
26
+ }>>;
21
27
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
22
28
  default?: (props: {}) => any;
23
29
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -51,6 +51,7 @@
51
51
  "date-fns": "^4.1.0",
52
52
  "defu": "^6.1.4",
53
53
  "dot-prop": "^10.1.0",
54
+ "effect": "^3.19.15",
54
55
  "markdown-it": "^14.1.0",
55
56
  "reka-ui": "^2.7.0",
56
57
  "tailwind-merge": "^3.4.0",