@bbki.ng/site 1.8.7 → 1.8.9

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,9 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 1.8.9
4
+
5
+ ## 1.8.8
6
+
3
7
  ## 1.8.7
4
8
 
5
9
  ## 1.8.6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "1.8.7",
3
+ "version": "1.8.9",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -52,7 +52,7 @@ export const ImgCtxMenu = (props: {
52
52
  await delImg(props.id);
53
53
  await props.onRemoved?.();
54
54
  toast.success("删除成功", {
55
- position: "top-center",
55
+ position: "bottom-right",
56
56
  });
57
57
  setIsLoading(false);
58
58
  });
@@ -24,7 +24,7 @@ export const LoginMenuItem = () => {
24
24
  onClick={() => {
25
25
  supabase.auth.signOut().then(() => {
26
26
  toast.success("已退出登录", {
27
- position: "top-center",
27
+ position: "bottom-right",
28
28
  });
29
29
  });
30
30
  }}
@@ -33,7 +33,7 @@ export const ArticleCtxMenu = (props: { children: ReactElement }) => {
33
33
  del(title)
34
34
  .then(() => {
35
35
  toast.success("删除成功", {
36
- position: "top-center",
36
+ position: "bottom-right",
37
37
  });
38
38
  dot.setVisibility(false);
39
39
  nav("/blog");
@@ -5,6 +5,7 @@ import { PluginInput } from "@/plugin/Plugin";
5
5
  import { toast } from "sonner";
6
6
  import { GlobalRoutesContext } from "@/context/global_routes_provider";
7
7
  import { PluginManager } from "@/plugin/PluginManager";
8
+ import { apiFetcher } from "@/utils";
8
9
 
9
10
  type inputResolve = (value: string | PromiseLike<string>) => void;
10
11
 
@@ -60,6 +61,9 @@ export const useDependencies = (): depHooksRes => {
60
61
  }
61
62
  pluginUIRef.current.setHtml(html);
62
63
  },
64
+ fetchPlugins: async () => {
65
+ return apiFetcher("plugin");
66
+ },
63
67
  showForm: async (input) => {
64
68
  setOpen(true);
65
69
  setInput(input);
@@ -26,7 +26,7 @@ export const ReloadPrompt = () => {
26
26
  toast("", {
27
27
  description: "发现新版本,是否更新?",
28
28
  duration: 10000,
29
- position: "top-center",
29
+ position: "bottom-right",
30
30
  actionButtonStyle: {
31
31
  backgroundColor: "#fff",
32
32
  color: "rgb(37,99,235)",
@@ -38,7 +38,7 @@ export const ReloadPrompt = () => {
38
38
  // @ts-ignore
39
39
  toast("", {
40
40
  description: `已更新`,
41
- position: "top-center",
41
+ position: "bottom-right",
42
42
  });
43
43
  setNeedRefresh(false);
44
44
  });
@@ -9,7 +9,7 @@ const plugin = await createPlugin("http://localhost:5173/demo.wasm", {
9
9
  toast: (cp: CurrentPlugin, offs: bigint) => {
10
10
  const content = cp.read(offs).text();
11
11
  toast.success(content, {
12
- position: "top-center",
12
+ position: "bottom-right",
13
13
  });
14
14
  },
15
15
  },
@@ -1,11 +1,14 @@
1
1
  import { PluginInput } from "@/plugin/Plugin";
2
+ import { PluginConfig } from "@/plugin/Plugin";
2
3
 
3
4
  export interface Dependencies {
4
5
  toast: (content: string) => void;
5
6
  loading: (show: boolean) => void;
6
7
  showForm: (input: PluginInput) => Promise<string>;
7
8
  showUI: (html: string) => void;
9
+
8
10
  addRoute: (name: string, to: string) => void;
9
11
  removeRoute: (name: string) => void;
10
12
  callPlugin: (id: number, method: string) => Promise<any>;
13
+ fetchPlugins: () => Promise<PluginConfig[]>;
11
14
  }
@@ -70,10 +70,12 @@ export class PluginManager {
70
70
 
71
71
  PluginManager.instance = new PluginManager(dependencies);
72
72
  dependencies.loading(true);
73
- await PluginManager.instance.fetchPluginConfig();
73
+ const remotePlugins = await dependencies.fetchPlugins();
74
+ remotePlugins.forEach((p: PluginConfig) => PluginManager.instance.pluginConfigMap.set(p.id, p));
75
+
74
76
  await PluginManager.instance.restoreInstalledPlugins();
75
77
  dependencies.loading(false);
76
- // dependencies.toast("Plugin manager initialized");
78
+ // dependencies.toast("Plugins initialized");
77
79
  PluginManager.dispatchEvent<null>(PluginEvent.INIT, null);
78
80
 
79
81
  // @ts-ignore
@@ -165,32 +167,4 @@ export class PluginManager {
165
167
  private pluginConfigMap: Map<number, PluginConfig> = new Map();
166
168
 
167
169
  private plugins: Map<number, Plugin> = new Map();
168
-
169
- async fetchPluginConfig(): Promise<Map<number, PluginConfig>> {
170
- if (this.pluginConfigMap.size > 0) {
171
- return this.pluginConfigMap;
172
- }
173
-
174
- this.pluginConfigMap.set(1, {
175
- name: "now",
176
- id: 1,
177
- version: "1.0.0",
178
- description: "A now page plugin",
179
- url: "https://zjh-im-res.oss-cn-shenzhen.aliyuncs.com/plugins/now.wasm",
180
- status: 0,
181
- route: "近况",
182
- });
183
-
184
- // this.pluginConfigMap.set(2, {
185
- // name: "core",
186
- // id: 2,
187
- // version: "1.0.0",
188
- // description: "core",
189
- // url: "https://zjh-im-res.oss-cn-shenzhen.aliyuncs.com/plugins/reactable.core.wasm",
190
- // status: 0,
191
- // builtIn: true,
192
- // })
193
-
194
- return this.pluginConfigMap;
195
- }
196
170
  }
@@ -163,7 +163,7 @@ export const confirm = (message: string, exec: () => void) => {
163
163
  backgroundColor: "#fff",
164
164
  color: "rgb(37,99,235)",
165
165
  },
166
- position: "top-center",
166
+ position: "bottom-right",
167
167
  action: {
168
168
  label: "是",
169
169
  onClick: () => {