fix: edit gpu_selector failed

This commit is contained in:
jialin
2025-09-17 19:53:40 +08:00
parent 4d9dec8511
commit bf400547e1
17 changed files with 296 additions and 544 deletions
+13 -14
View File
@@ -1,31 +1,30 @@
import { PageActionType } from '@/config/types';
import React from 'react';
import { DeployFormKey } from './types';
interface FormContextProps {
isGGUF?: boolean;
byBuiltIn?: boolean;
formKey: DeployFormKey;
source?: string;
pageAction: PageActionType;
sizeOptions?: Global.BaseOption<number>[];
quantizationOptions?: Global.BaseOption<string>[];
gpuOptions?: any[];
onSizeChange?: (val: number) => void;
onQuantizationChange?: (val: string) => void;
onValuesChange?: (changedValues: any, allValues: any) => void;
onBackendChange?: (backend: string) => void;
}
interface FormInnerContextProps {
onBackendChange?: (backend: string) => void;
onValuesChange?: (changedValues: any, allValues: any) => void;
gpuOptions?: any[];
interface CatalogFormContextProps {
sizeOptions: Global.BaseOption<number>[];
quantizationOptions: Global.BaseOption<string>[];
onSizeChange: (val: number) => void;
onQuantizationChange: (val: string) => void;
}
export const FormContext = React.createContext<FormContextProps>(
{} as FormContextProps
);
export const FormInnerContext = React.createContext<FormInnerContextProps>(
{} as FormInnerContextProps
export const CatalogFormContext = React.createContext<CatalogFormContextProps>(
{} as CatalogFormContextProps
);
export const useFormContext = () => {
@@ -36,11 +35,11 @@ export const useFormContext = () => {
return context;
};
export const useFormInnerContext = () => {
const context = React.useContext(FormInnerContext);
export const useCatalogFormContext = () => {
const context = React.useContext(CatalogFormContext);
if (!context) {
throw new Error(
'useFormInnerContext must be used within a FormInnerProvider'
'useCatalogFormContext must be used within a CatalogFormProvider'
);
}
return context;