fix(后台管理): 退款时间问题修复,登录菜单显示问题修复

This commit is contained in:
2025-07-10 11:11:34 +08:00
parent 3c4cb729dc
commit 8fffa91200
4 changed files with 51 additions and 23 deletions
@@ -9,43 +9,43 @@
export default { export default {
dev: { dev: {
'/api-uaa/': { '/api-uaa/': {
// target: 'http://119.45.169.13:9900', target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900', // target: 'http://127.0.0.1:9900',
changeOrigin: true, changeOrigin: true,
}, },
'/api-user/': { '/api-user/': {
// target: 'http://119.45.169.13:9900', target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900', // target: 'http://127.0.0.1:9900',
changeOrigin: true, changeOrigin: true,
}, },
'/api-log/': { '/api-log/': {
// target: 'http://119.45.169.13:9900', target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900', // target: 'http://127.0.0.1:9900',
changeOrigin: true, changeOrigin: true,
}, },
'/api-search/': { '/api-search/': {
// target: 'http://119.45.169.13:9900', target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900', // target: 'http://127.0.0.1:9900',
changeOrigin: true, changeOrigin: true,
}, },
'/api-generator/': { '/api-generator/': {
// target: 'http://119.45.169.13:9900', target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900', // target: 'http://127.0.0.1:9900',
changeOrigin: true, changeOrigin: true,
}, },
'/api-file/': { '/api-file/': {
// target: 'http://119.45.169.13:9900', target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900', // target: 'http://127.0.0.1:9900',
changeOrigin: true, changeOrigin: true,
}, },
'/api-order/': { '/api-order/': {
// target: 'http://119.45.169.13:9900', target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900', // target: 'http://127.0.0.1:9900',
changeOrigin: true, changeOrigin: true,
}, },
'/api-device/': { '/api-device/': {
// target: 'http://119.45.169.13:9900', target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900', // target: 'http://127.0.0.1:9900',
changeOrigin: true, changeOrigin: true,
}, },
}, },
@@ -93,6 +93,8 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
// 每当 initialState?.currentUser?.userid 发生修改时重新执行 request // 每当 initialState?.currentUser?.userid 发生修改时重新执行 request
params: { params: {
userId: initialState?.currentUser?.userId, userId: initialState?.currentUser?.userId,
// 添加一个时间戳来强制重新加载菜单
timestamp: initialState?.currentUser ? Date.now() : 0,
}, },
request: async () => { request: async () => {
try { try {
@@ -24,6 +24,30 @@ const formatAmount = (amount?: string | number | null) => {
return `¥ ${(Number(amount) / 100).toFixed(2)}`; return `¥ ${(Number(amount) / 100).toFixed(2)}`;
}; };
// 时间格式化:处理时区问题
const formatDateTime = (dateTime?: string | null) => {
if (!dateTime) return '-';
try {
// 如果时间已经是ISO格式,直接解析
const date = new Date(dateTime);
if (isNaN(date.getTime())) {
return dateTime; // 如果解析失败,返回原始值
}
// 格式化为本地时间
return date.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false,
});
} catch (error) {
return dateTime; // 如果出错,返回原始值
}
};
const UpdateForm: React.FC<UpdateFormProps> = (props) => { const UpdateForm: React.FC<UpdateFormProps> = (props) => {
const { values } = props; const { values } = props;
@@ -54,13 +78,13 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
<span className={styles.amount}>{formatAmount(values?.refundAmount)}</span> <span className={styles.amount}>{formatAmount(values?.refundAmount)}</span>
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="订单状态"> <Descriptions.Item label="订单状态">
<Tag color={ORDER_STATUS[values?.status]?.color}> <Tag color={(ORDER_STATUS as any)[Number(values?.status)]?.color}>
{ORDER_STATUS[values?.status]?.text || '未知状态'} {(ORDER_STATUS as any)[Number(values?.status)]?.text || '未知状态'}
</Tag> </Tag>
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="退款状态"> <Descriptions.Item label="退款状态">
<Tag color={REFUND_STATUS[values?.state]?.color}> <Tag color={(REFUND_STATUS as any)[Number(values?.state)]?.color}>
{REFUND_STATUS[values?.state]?.text || '未知状态'} {(REFUND_STATUS as any)[Number(values?.state)]?.text || '未知状态'}
</Tag> </Tag>
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="退款原因" span={2}> <Descriptions.Item label="退款原因" span={2}>
@@ -87,7 +111,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
)} )}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="申请时间" span={2}> <Descriptions.Item label="申请时间" span={2}>
{values?.createTime} {formatDateTime(values?.createTime)}
</Descriptions.Item> </Descriptions.Item>
</Descriptions> </Descriptions>
</div> </div>
@@ -68,12 +68,14 @@ const Login: React.FC = () => {
sessionStorage.setItem('access_token', msg.data.access_token); sessionStorage.setItem('access_token', msg.data.access_token);
if (mountedRef.current) { if (mountedRef.current) {
message.success('登录成功!'); message.success('登录成功!');
// 先获取用户信息
await fetchUserInfo(); await fetchUserInfo();
// 强制重新获取用户信息以触发菜单重新加载
await initialState?.fetchUserInfo?.(); await initialState?.fetchUserInfo?.();
// 直接刷新页面,确保菜单栏正常显示
const { query } = history.location; const { query } = history.location;
const { redirect } = query as { redirect: string }; const { redirect } = query as { redirect: string };
history.push(redirect || '/'); window.location.href = redirect || '/';
return; return;
} }
} }