feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import { useCallback, useContext, useSyncExternalStore } from 'react';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
|
||||
const STORAGE_KEY = 'marquee_dismissed_content';
|
||||
const listeners = new Set();
|
||||
|
||||
const readDismissed = () => {
|
||||
try {
|
||||
return sessionStorage.getItem(STORAGE_KEY) || '';
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
const subscribe = (listener) => {
|
||||
listeners.add(listener);
|
||||
return () => listeners.delete(listener);
|
||||
};
|
||||
|
||||
// 公告栏内容与关闭状态:关闭仅对当前会话、当前公告内容生效,公告内容变更后自动重新显示。
|
||||
export const useMarquee = () => {
|
||||
const [statusState] = useContext(StatusContext);
|
||||
const content = statusState?.status?.marquee_content?.trim() || '';
|
||||
const dismissed = useSyncExternalStore(subscribe, readDismissed);
|
||||
|
||||
const dismiss = useCallback(() => {
|
||||
try {
|
||||
sessionStorage.setItem(STORAGE_KEY, content);
|
||||
} catch (e) {
|
||||
// 存储不可用时仅本次内存态无法记忆,忽略
|
||||
}
|
||||
listeners.forEach((listener) => listener());
|
||||
}, [content]);
|
||||
|
||||
return { visible: !!content && dismissed !== content, dismiss };
|
||||
};
|
||||
@@ -109,7 +109,7 @@ export const useNavigation = (
|
||||
{
|
||||
text: t('秘钥管理'),
|
||||
itemKey: 'keyManagement',
|
||||
to: '/key-management',
|
||||
to: '/user-center/key-management',
|
||||
requireAuth: getHeaderModuleRequireAuth(modules, 'keyManagement'),
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user