This commit is contained in:
lloydzhou 2024-09-24 12:59:21 +08:00
parent 90e7b5aecf
commit f9f99639db
1 changed files with 21 additions and 16 deletions

View File

@ -7,7 +7,7 @@ import yaml from "js-yaml";
import { adapter } from "../utils";
import { useAccessStore } from "./access";
const isApp = getClientConfig()?.buildMode === "export";
const isApp = getClientConfig()?.isApp;
export type Plugin = {
id: string;
@ -231,7 +231,6 @@ export const usePluginStore = createPersistStore(
name: StoreKey.Plugin,
version: 1,
onRehydrateStorage(state) {
console.log("onRehydrateStorage", state);
// Skip store rehydration on server side
if (typeof window === "undefined") {
return;
@ -242,15 +241,21 @@ export const usePluginStore = createPersistStore(
.then((res) => {
Promise.all(
res.map((item: any) =>
fetch(item.schema)
// skip get schema
state.get(item.id)
? item
: fetch(item.schema)
.then((res) => res.text())
.then((content) => ({
...item,
content,
})),
}))
.catch((e) => item),
),
).then((builtinPlugins: any) => {
builtinPlugins.forEach((item: any) => {
builtinPlugins
.filter((item: any) => item?.content)
.forEach((item: any) => {
const plugin = state.create(item);
state.updatePlugin(plugin.id, (plugin) => {
const tool = FunctionToolService.add(plugin, true);