mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-02 14:53:55 +08:00
@@ -23,10 +23,12 @@ export const CommonContext = createContext<{
|
||||
coderModel: DomainModel[];
|
||||
llmModel: DomainModel[];
|
||||
isConfigModel: boolean;
|
||||
modelLoading: boolean;
|
||||
refreshModel: () => void;
|
||||
}>({
|
||||
coderModel: [],
|
||||
llmModel: [],
|
||||
isConfigModel: false,
|
||||
modelLoading: false,
|
||||
refreshModel: () => {},
|
||||
});
|
||||
|
||||
@@ -55,6 +55,7 @@ dayjs.extend(relativeTime);
|
||||
const App = () => {
|
||||
const [user, setUser] = useState<DomainUser | DomainAdminUser | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [modelLoading, setModelLoading] = useState(true);
|
||||
const [coderModel, setCoderModel] = useState<DomainModel[]>([]);
|
||||
const [llmModel, setLlmModel] = useState<DomainModel[]>([]);
|
||||
const [isConfigModel, setIsConfigModel] = useState(false);
|
||||
@@ -65,6 +66,7 @@ const App = () => {
|
||||
};
|
||||
|
||||
const getModelList = () => {
|
||||
setModelLoading(true);
|
||||
return Promise.all([
|
||||
getMyModelList({
|
||||
model_type: 'coder',
|
||||
@@ -78,7 +80,10 @@ const App = () => {
|
||||
setLlmModel(res[1] || []);
|
||||
return res;
|
||||
})
|
||||
.then(handleModelConfig);
|
||||
.then(handleModelConfig)
|
||||
.finally(() => {
|
||||
setModelLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
const handleModelConfig = (res: [DomainModel[], DomainModel[]]) => {
|
||||
@@ -160,6 +165,7 @@ const App = () => {
|
||||
value={{
|
||||
coderModel,
|
||||
llmModel,
|
||||
modelLoading,
|
||||
isConfigModel,
|
||||
refreshModel: getModelList,
|
||||
}}
|
||||
|
||||
@@ -7,11 +7,11 @@ import { useCommonContext } from '@/hooks/context';
|
||||
import { Modal } from '@c-x/ui';
|
||||
|
||||
const Model = () => {
|
||||
const { coderModel, llmModel, refreshModel, isConfigModel } =
|
||||
const { coderModel, llmModel, refreshModel, isConfigModel, modelLoading } =
|
||||
useCommonContext();
|
||||
const isFirst = useRef(true);
|
||||
useEffect(() => {
|
||||
if (isFirst.current && !isConfigModel) {
|
||||
if (isFirst.current && !isConfigModel && !modelLoading) {
|
||||
isFirst.current = false;
|
||||
let text = '';
|
||||
if (
|
||||
@@ -34,7 +34,7 @@ const Model = () => {
|
||||
okText: '去配置',
|
||||
});
|
||||
}
|
||||
}, [isConfigModel, coderModel, llmModel]);
|
||||
}, [isConfigModel, coderModel, llmModel, modelLoading]);
|
||||
|
||||
return (
|
||||
<Stack gap={2}>
|
||||
|
||||
Reference in New Issue
Block a user