MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / getOptions

Function getOptions

web/src/components/settings/RatioSetting.js:31–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29 const [loading, setLoading] = useState(false);
30
31 const getOptions = async () => {
32 const res = await API.get('/api/option/');
33 const { success, message, data } = res.data;
34 if (success) {
35 let newInputs = {};
36 data.forEach((item) => {
37 if (
38 item.key === 'ModelRatio' ||
39 item.key === 'GroupRatio' ||
40 item.key === 'GroupGroupRatio' ||
41 item.key === 'AutoGroups' ||
42 item.key === 'UserUsableGroups' ||
43 item.key === 'CompletionRatio' ||
44 item.key === 'ModelPrice' ||
45 item.key === 'CacheRatio'
46 ) {
47 try {
48 item.value = JSON.stringify(JSON.parse(item.value), null, 2);
49 } catch (e) {
50 // 如果后端返回的不是合法 JSON,直接展示
51 }
52 }
53 if (['DefaultUseAutoGroup', 'ExposeRatioEnabled'].includes(item.key)) {
54 newInputs[item.key] = toBoolean(item.value);
55 } else {
56 newInputs[item.key] = item.value;
57 }
58 });
59 setInputs(newInputs);
60 } else {
61 showError(message);
62 }
63 };
64
65 const onRefresh = async () => {
66 try {

Callers 1

onRefreshFunction · 0.70

Calls 2

toBooleanFunction · 0.90
showErrorFunction · 0.90

Tested by

no test coverage detected