diff --git a/package-lock.json b/package-lock.json index de4ad9a..5c7ac48 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ }, "devDependencies": { "@types/event-source-polyfill": "^1.0.5", + "@types/node": "^22.10.2", "@types/react": "^18.2.56", "@types/react-dom": "^18.2.19", "@typescript-eslint/eslint-plugin": "^7.0.2", @@ -1505,6 +1506,15 @@ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true }, + "node_modules/@types/node": { + "version": "22.10.2", + "resolved": "https://registry.npmmirror.com/@types/node/-/node-22.10.2.tgz", + "integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==", + "dev": true, + "dependencies": { + "undici-types": "~6.20.0" + } + }, "node_modules/@types/prop-types": { "version": "15.7.11", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", @@ -4377,6 +4387,12 @@ "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "dev": true + }, "node_modules/update-browserslist-db": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", diff --git a/package.json b/package.json index 74988c0..df10110 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ }, "devDependencies": { "@types/event-source-polyfill": "^1.0.5", + "@types/node": "^22.10.2", "@types/react": "^18.2.56", "@types/react-dom": "^18.2.19", "@typescript-eslint/eslint-plugin": "^7.0.2", diff --git a/src/layout/head/Head.tsx b/src/layout/head/Head.tsx index 1039d87..7b506eb 100644 --- a/src/layout/head/Head.tsx +++ b/src/layout/head/Head.tsx @@ -1,11 +1,12 @@ import './head.css' +// import { NodeJS } from 'types/node'; import { useDispatch } from 'react-redux' import BalanceHead from '../../components/balance/BalanceHead.tsx'; import RechargeHead from '../../components/recharge/RechargeHead.tsx'; import { Dropdown, MenuProps, message, Modal, Space, Spin, Input } from "antd"; import { DownOutlined, UserOutlined, QuestionCircleOutlined, BellOutlined, KeyOutlined, LogoutOutlined, GiftOutlined, AccountBookOutlined, ContainerOutlined, MenuFoldOutlined, UsergroupAddOutlined } from "@ant-design/icons"; import { useContext, useEffect, useState } from "react"; -import { put, get, post,getUseUrl } from "../../util/AjaxUtils.ts"; +import { put, get, post, getUseUrl } from "../../util/AjaxUtils.ts"; import { GlobalContext, GlobalDispatchContext, reloadUser } from "../../context/GlobalContext.ts"; import UserEdit from "../../components/user/UserEdit.tsx"; import PasswordChange from "../../components/password/PasswordChange.tsx"; @@ -291,6 +292,9 @@ export default function Head() { // }) // } + + + useEffect(() => { // getLength() reloadUser(messageApi, globalDispatchContext).then((data) => { @@ -299,9 +303,16 @@ export default function Head() { } }); }, [globalContext.user]); + // 刷新用户信息 + const reloadUserInterval = async () => { + await reloadUser(messageApi, globalDispatchContext); + }; useEffect(() => { getUnRead() + setInterval(reloadUserInterval, 5 * 60 * 1000); }, []) + + const items: MenuProps['items'] = [ { key: 'userinfo', diff --git a/tsconfig.json b/tsconfig.json index a7fc6fb..2f6c7e7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,5 +21,6 @@ "noFallthroughCasesInSwitch": true }, "include": ["src"], - "references": [{ "path": "./tsconfig.node.json" }] + "references": [{ "path": "./tsconfig.node.json" }], + }