mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-02 16:16:39 +08:00
Merge branch 'main' into dev
This commit is contained in:
commit
304a96a4ff
@ -141,6 +141,21 @@ function EchartsComponent({ currentDate, setCurrentDate }: ComponentProps) {
|
||||
};
|
||||
}, [currentDate, searchDate]); // 空数组作为第二个参数,表示仅在组件挂载和卸载时执行
|
||||
|
||||
// useEffect(() => {
|
||||
// const handleResize = () => {
|
||||
// console.log("窗口大小变化");
|
||||
// let chartDom = document.getElementById("usage-by-model-chart");
|
||||
// if (!chartDom) return;
|
||||
// const myChart = echarts.getInstanceByDom(chartDom);
|
||||
// myChart?.resize();
|
||||
// };
|
||||
// window.addEventListener("resize", handleResize);
|
||||
// return () => {
|
||||
// window.removeEventListener("resize", handleResize);
|
||||
// };
|
||||
// }, []);
|
||||
|
||||
// #admin-page-content
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
console.log("窗口大小变化");
|
||||
@ -149,9 +164,24 @@ function EchartsComponent({ currentDate, setCurrentDate }: ComponentProps) {
|
||||
const myChart = echarts.getInstanceByDom(chartDom);
|
||||
myChart?.resize();
|
||||
};
|
||||
window.addEventListener("resize", handleResize);
|
||||
const targetNode = document.getElementById("admin-page-content");
|
||||
// 创建一个观察器实例并传入回调函数,该函数在观察到变化时执行
|
||||
const resizeObserver = new ResizeObserver((entries) => {
|
||||
for (let entry of entries) {
|
||||
const { width, height } = entry.contentRect;
|
||||
// console.log(`Element's size: ${width}px x ${height}px`);
|
||||
handleResize();
|
||||
}
|
||||
});
|
||||
|
||||
// const config = { attributes: true, childList: true, subtree: true };
|
||||
targetNode && resizeObserver.observe(targetNode);
|
||||
|
||||
// window.addEventListener("resize", handleResize);
|
||||
return () => {
|
||||
window.removeEventListener("resize", handleResize);
|
||||
resizeObserver.disconnect();
|
||||
|
||||
// window.removeEventListener("resize", handleResize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
@ -69,6 +69,7 @@ function MainLayout({ children }: { children: ReactNode }) {
|
||||
/>
|
||||
</Header>
|
||||
<Content
|
||||
id="admin-page-content"
|
||||
style={{
|
||||
// margin: "24px 16px",
|
||||
padding: 24,
|
||||
|
@ -97,9 +97,9 @@ export const authOptions: NextAuthOptions = {
|
||||
let existingUser = await existUser(user); // await insertUser(user)
|
||||
if (!existingUser) {
|
||||
// 如果不存在,则报错
|
||||
throw new Error("用户名或密码不正确")
|
||||
// throw new Error("用户名或密码不正确")
|
||||
// 如果不存在,则创建
|
||||
// existingUser = await insertUser(user);
|
||||
existingUser = await insertUser(user);
|
||||
}
|
||||
// 有密码就校验密码,没有就直接返回用户
|
||||
(password || existingUser.password) && validatePassword(password, existingUser.password);
|
||||
|
Loading…
Reference in New Issue
Block a user