feat: 参考原型图 ui优化提交 企业端-企业中心 相关的页面

This commit is contained in:
zhanjunhao
2026-11-06 20:19:43 +08:00
parent 43048626a6
commit a075732cb4
147 changed files with 9816 additions and 8768 deletions
@@ -122,7 +122,7 @@ export const useAdminTokensData = () => {
);
// 注意:不能像 users hook 那样用 `list[i].key = list[i].id`,
// 因为 Token 的 key 字段本身有意义(脱敏后的秘钥),覆盖会破坏列表展示
// 因为 Token 的 key 字段本身有意义(脱敏后的密钥),覆盖会破坏列表展示
// 改为在 Table 上用 rowKey='id'
const setListFormat = (list) => {
setTokens(list);
@@ -219,7 +219,7 @@ export const useAdminTokensData = () => {
// 批量管理
const batchManageTokens = async (ids, action) => {
if (!ids || ids.length === 0) {
showError(t('请先选择秘钥'));
showError(t('请先选择密钥'));
return;
}
try {
+1 -1
View File
@@ -30,7 +30,7 @@ export function useTokenKeys(id) {
const loadAllData = async () => {
const fetchedKeys = await fetchTokenKeys();
if (fetchedKeys.length === 0) {
showError('当前没有可用的启用令牌,请确认是否有令牌处于启用状态!');
showError('当前没有可用的启用密钥,请确认是否有密钥处于启用状态!');
setTimeout(() => {
window.location.href = '/console/token';
}, 1500); // 延迟 1.5 秒后跳转
+1 -1
View File
@@ -107,7 +107,7 @@ export const useNavigation = (
const allLinks = [
{
text: t('秘钥管理'),
text: t('密钥管理'),
itemKey: 'keyManagement',
to: '/user-center/key-management',
requireAuth: getHeaderModuleRequireAuth(modules, 'keyManagement'),
+71
View File
@@ -0,0 +1,71 @@
/*
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, useEffect, useRef, useState } from 'react';
import { API } from '../../helpers';
import { parsePayPalQuote } from '../../helpers/paypalPayment';
// Bind quotes to the exact selection and coalesce preview/confirmation requests.
export default function usePayPalQuote(endpoint, body, enabled, orgId) {
const key = JSON.stringify([endpoint, body, orgId]);
const currentKey = useRef(key);
currentKey.current = key;
const pending = useRef(null);
const [result, setResult] = useState(null);
const [loadingKey, setLoadingKey] = useState(null);
const setQuote = (quote) => setResult({ key, quote });
const refresh = useCallback(() => {
if (pending.current?.key === key) return pending.current.promise;
const [url, payload, organization] = JSON.parse(key);
setLoadingKey(key);
setResult(null);
const promise = API.post(
url,
payload,
organization === undefined || organization === null
? undefined
: { headers: { 'X-Org-Id': String(organization) } },
)
.then((response) => {
if (!response.data.success) throw new Error(response.data.message);
const quote = parsePayPalQuote(response);
if (currentKey.current !== key) return null;
setResult({ key, quote });
return quote;
})
.finally(() => {
if (pending.current?.promise === promise) pending.current = null;
setLoadingKey((previous) => (previous === key ? null : previous));
});
pending.current = { key, promise };
return promise;
}, [key]);
useEffect(() => {
if (enabled) refresh().catch(() => {});
}, [enabled, refresh]);
return {
quote: result?.key === key ? result.quote : null,
setQuote,
loading: enabled && loadingKey === key,
refresh,
};
}
+4 -4
View File
@@ -258,7 +258,7 @@ export const useTokensData = (openFluentNotification) => {
// Batch delete tokens
const batchDeleteTokens = async () => {
if (selectedKeys.length === 0) {
showError(t('请先选择要删除的令牌!'));
showError(t('请先选择要删除的密钥!'));
return;
}
setLoading(true);
@@ -267,7 +267,7 @@ export const useTokensData = (openFluentNotification) => {
const res = await API.post('/api/token/batch', { ids });
if (res?.data?.success) {
const count = res.data.data || 0;
showSuccess(t('已删除 {{count}} 个令牌!', { count }));
showSuccess(t('已删除 {{count}} 个密钥!', { count }));
await refresh();
setTimeout(() => {
if (tokens.length === 0 && activePage > 1) {
@@ -287,12 +287,12 @@ export const useTokensData = (openFluentNotification) => {
// Batch copy tokens
const batchCopyTokens = (copyType) => {
if (selectedKeys.length === 0) {
showError(t('请至少选择一个令牌!'));
showError(t('请至少选择一个密钥!'));
return;
}
Modal.info({
title: t('复制令牌'),
title: t('复制密钥'),
icon: null,
content: t('请选择你的复制方式'),
footer: (