@@ -7,7 +7,7 @@ import yaml from "js-yaml";
7
7
import { adapter } from "../utils" ;
8
8
import { useAccessStore } from "./access" ;
9
9
10
- const isApp = getClientConfig ( ) ?. buildMode === "export" ;
10
+ const isApp = getClientConfig ( ) ?. isApp ;
11
11
12
12
export type Plugin = {
13
13
id : string ;
@@ -231,7 +231,6 @@ export const usePluginStore = createPersistStore(
231
231
name : StoreKey . Plugin ,
232
232
version : 1 ,
233
233
onRehydrateStorage ( state ) {
234
- console . log ( "onRehydrateStorage" , state ) ;
235
234
// Skip store rehydration on server side
236
235
if ( typeof window === "undefined" ) {
237
236
return ;
@@ -242,23 +241,29 @@ export const usePluginStore = createPersistStore(
242
241
. then ( ( res ) => {
243
242
Promise . all (
244
243
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 ) ,
251
254
) ,
252
255
) . 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
+ } ) ;
260
266
} ) ;
261
- } ) ;
262
267
} ) ;
263
268
} ) ;
264
269
} ,
0 commit comments