diff --git a/app/store/config.ts b/app/store/config.ts index a4fa191a2..e81ecd3b8 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -138,7 +138,7 @@ export const useAppConfig = createPersistStore( }), { name: StoreKey.Config, - version: 3.95, + version: 3.96, migrate(persistedState, version) { const state = persistedState as ChatConfig; @@ -174,7 +174,7 @@ export const useAppConfig = createPersistStore( // return { ...DEFAULT_CONFIG }; // } - if (version < 3.95) { + if (version < 3.96) { state.modelConfig = DEFAULT_CONFIG.modelConfig; // state.modelConfig.template = // state.modelConfig.template !== DEFAULT_INPUT_TEMPLATE diff --git a/app/utils/hooks.ts b/app/utils/hooks.ts index cabc55918..1876e7930 100644 --- a/app/utils/hooks.ts +++ b/app/utils/hooks.ts @@ -7,7 +7,7 @@ export function useAllModels() { const accessStore = useAccessStore(); const configStore = useAppConfig(); const { data: session, status } = useSession(); - console.log("-sssssssssss", session, status); + const models = useMemo(() => { return collectModelsWithDefaultModel( configStore.models, @@ -22,5 +22,10 @@ export function useAllModels() { configStore.dontUseModel, ]); + // @ts-expect-error + if (status === "authenticated" && !session?.user?.isAdmin) { + // 过滤非管理员用户可使用的模型 + return models.filter((m) => !m.name.endsWith("-all")); + } return models; } diff --git a/lib/auth.ts b/lib/auth.ts index 10a0cb1fc..abdd038e5 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -171,6 +171,8 @@ export const authOptions: NextAuthOptions = { username: token?.user?.username || token?.user?.gh_username, // @ts-expect-error hasPassword: !!token?.user?.password, + // @ts-expect-error + isAdmin: token?.user?.isAdmin, }; // console.log('555555555,', session, token) return session;