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

This commit is contained in:
zhanjunhao
2026-11-06 20:19:43 +08:00
parent d4495eb703
commit 84803192ba
147 changed files with 9816 additions and 8768 deletions
+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,
};
}