chore(frontend): 对齐 mcp api 与 mobile hook 格式
This commit is contained in:
parent
7071ead062
commit
c532f830d9
|
|
@ -8,12 +8,14 @@ export async function loadMCPConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateMCPConfig(config: MCPConfig) {
|
export async function updateMCPConfig(config: MCPConfig) {
|
||||||
const response = await fetch(`${getBackendBaseURL()}/api/mcp/config`, {
|
const response = await fetch(`${getBackendBaseURL()}/api/mcp/config`,
|
||||||
method: "PUT",
|
{
|
||||||
headers: {
|
method: "PUT",
|
||||||
"Content-Type": "application/json",
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(config),
|
||||||
},
|
},
|
||||||
body: JSON.stringify(config),
|
);
|
||||||
});
|
|
||||||
return response.json();
|
return response.json();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,19 @@
|
||||||
import * as React from "react";
|
import * as React from "react"
|
||||||
|
|
||||||
const MOBILE_BREAKPOINT = 768;
|
const MOBILE_BREAKPOINT = 768
|
||||||
|
|
||||||
export function useIsMobile() {
|
export function useIsMobile() {
|
||||||
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
|
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
|
||||||
undefined,
|
|
||||||
);
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
|
||||||
const onChange = () => {
|
const onChange = () => {
|
||||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
||||||
};
|
}
|
||||||
mql.addEventListener("change", onChange);
|
mql.addEventListener("change", onChange)
|
||||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
||||||
return () => mql.removeEventListener("change", onChange);
|
return () => mql.removeEventListener("change", onChange)
|
||||||
}, []);
|
}, [])
|
||||||
|
|
||||||
return !!isMobile;
|
return !!isMobile
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue