feat: add new SVG assets for file icons, LLM providers, and UI elements
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
import { useUserData } from "./useUserData";
|
||||
import { useEffect } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import logger from "@/utils/logger";
|
||||
import type { IUserInfo } from "@/interfaces/database/user-setting";
|
||||
import userService from "@/services/user_service";
|
||||
import { rsaPsw } from "../utils/encryption";
|
||||
import type { IFactory, IMyLlmModel } from "@/interfaces/database/llm";
|
||||
import type { LLMFactory } from "@/constants/llm";
|
||||
|
||||
/**
|
||||
* 个人中心设置
|
||||
*/
|
||||
export function useProfileSetting() {
|
||||
const {fetchUserInfo, userInfo} = useUserData();
|
||||
|
||||
@@ -39,4 +44,45 @@ export function useProfileSetting() {
|
||||
updateUserInfo,
|
||||
changeUserPassword,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* LLM 模型设置
|
||||
*/
|
||||
export function useLlmModelSetting() {
|
||||
const [llmFactory, setLlmFactory] = useState<IFactory[]>([]);
|
||||
const [myLlm, setMyLlm] = useState<Record<LLMFactory, IMyLlmModel>>();
|
||||
|
||||
useEffect(() => {
|
||||
const fetchLlmFactory = async () => {
|
||||
try {
|
||||
const res = await userService.llm_factories_list();
|
||||
const arr = res.data.data || [];
|
||||
setLlmFactory(arr);
|
||||
} catch (error) {
|
||||
logger.error('获取模型工厂失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const fetchMyLlm = async () => {
|
||||
try {
|
||||
const res = await userService.my_llm();
|
||||
const llm_dic = res.data.data || {};
|
||||
setMyLlm(llm_dic);
|
||||
} catch (error) {
|
||||
logger.error('获取我的模型失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
fetchLlmFactory();
|
||||
fetchMyLlm();
|
||||
}, []); // 空依赖数组,只在组件挂载时执行一次
|
||||
|
||||
return {
|
||||
llmFactory,
|
||||
myLlm,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user