Skip to content

Commit f9f9963

Browse files
committed
update
1 parent 90e7b5a commit f9f9963

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

app/store/plugin.ts

+21-16
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import yaml from "js-yaml";
77
import { adapter } from "../utils";
88
import { useAccessStore } from "./access";
99

10-
const isApp = getClientConfig()?.buildMode === "export";
10+
const isApp = getClientConfig()?.isApp;
1111

1212
export type Plugin = {
1313
id: string;
@@ -231,7 +231,6 @@ export const usePluginStore = createPersistStore(
231231
name: StoreKey.Plugin,
232232
version: 1,
233233
onRehydrateStorage(state) {
234-
console.log("onRehydrateStorage", state);
235234
// Skip store rehydration on server side
236235
if (typeof window === "undefined") {
237236
return;
@@ -242,23 +241,29 @@ export const usePluginStore = createPersistStore(
242241
.then((res) => {
243242
Promise.all(
244243
res.map((item: any) =>
245-
fetch(item.schema)
246-
.then((res) => res.text())
247-
.then((content) => ({
248-
...item,
249-
content,
250-
})),
244+
// skip get schema
245+
state.get(item.id)
246+
? item
247+
: fetch(item.schema)
248+
.then((res) => res.text())
249+
.then((content) => ({
250+
...item,
251+
content,
252+
}))
253+
.catch((e) => item),
251254
),
252255
).then((builtinPlugins: any) => {
253-
builtinPlugins.forEach((item: any) => {
254-
const plugin = state.create(item);
255-
state.updatePlugin(plugin.id, (plugin) => {
256-
const tool = FunctionToolService.add(plugin, true);
257-
plugin.title = tool.api.definition.info.title;
258-
plugin.version = tool.api.definition.info.version;
259-
plugin.builtin = true;
256+
builtinPlugins
257+
.filter((item: any) => item?.content)
258+
.forEach((item: any) => {
259+
const plugin = state.create(item);
260+
state.updatePlugin(plugin.id, (plugin) => {
261+
const tool = FunctionToolService.add(plugin, true);
262+
plugin.title = tool.api.definition.info.title;
263+
plugin.version = tool.api.definition.info.version;
264+
plugin.builtin = true;
265+
});
260266
});
261-
});
262267
});
263268
});
264269
},

0 commit comments

Comments
 (0)