Compare commits
2 Commits
f896495048
...
ed693a450a
| Author | SHA1 | Date | |
|---|---|---|---|
| ed693a450a | |||
| 49515f4ef3 |
@@ -218,6 +218,7 @@ npm run preview
|
||||
| 现象 | 优先检查 |
|
||||
| --- | --- |
|
||||
| 页面能打开但提示状态或接口加载失败 | 后端是否可用;Network 中 `/api/status` 的目标地址与响应;代理配置 |
|
||||
| 共享测试站出现 Vite 红色遮罩 | 检查站点网关的前端上游。共享测试站应由网关提供构建后的静态文件,Vite 开发服务仅用于联调。开发服务对 `.npmrc` 请求直接返回 404。 |
|
||||
| 登录后又回到登录页 | `/api/user/self` 响应、Cookie 是否发送、跨域凭证策略、账号状态 |
|
||||
| 企业数据为空或串到其他企业 | 当前组织选择、`current_org_id` 与请求头 `X-Org-Id` |
|
||||
| 修改环境变量后无变化 | 是否重启开发服务或重新构建发布;HTML 与静态资源缓存 |
|
||||
|
||||
@@ -10,6 +10,54 @@
|
||||
|
||||
## 2026-11-25
|
||||
|
||||
### 优化 · 消费记录固定首尾列
|
||||
|
||||
- **范围**:用户中心 `/user-center/usage-record` 的消费记录调用明细。
|
||||
- **变更**:时间列固定在左侧,操作列显示时固定在右侧。
|
||||
- **影响**:横向滚动中间字段时,仍可读取时间并打开账单详情。
|
||||
- **回滚**:还原消费记录时间列和操作列的固定配置。
|
||||
- **关联**:`src/components/table/usage-logs/`、`docs/ui/USER_CENTER_SPEC.md`。
|
||||
|
||||
### 优化 · 兑换码编辑侧栏窗
|
||||
|
||||
- **范围**:控制台 `/console/redemption` 编辑入口。
|
||||
- **变更**:编辑兑换码信息与添加兑换码共用右侧侧栏窗。
|
||||
- **影响**:两种表单使用相同的宽度、关闭方式和页脚,编辑继续回填当前记录。
|
||||
- **回滚**:还原兑换码编辑表单的独立弹窗。
|
||||
- **关联**:`src/components/table/redemptions/modals/EditRedemptionModal.jsx`、`docs/ui/CONSOLE_SPEC.md`。
|
||||
|
||||
### 优化 · 兑换码列表行内操作
|
||||
|
||||
- **范围**:控制台 `/console/redemption` 表格操作列。
|
||||
- **变更**:「查看详情」入口简化为「查看」,启用、禁用和删除从更多菜单移至行内,按钮单行排列并随操作列固定在右侧。
|
||||
- **影响**:桌面与窄屏均可直接使用行操作,启停权限和删除确认沿用原规则。
|
||||
- **回滚**:还原兑换码操作列按钮、宽度和换行样式。
|
||||
- **关联**:`src/components/table/redemptions/`、`docs/ui/CONSOLE_SPEC.md`。
|
||||
|
||||
### 优化 · 兑换码列表与表单
|
||||
|
||||
- **范围**:控制台 `/console/redemption` 与 `/console/channel` 的表头。
|
||||
- **变更**:沿用渠道列表的表格与行内操作样式,提升两页表头文字对比度,固定兑换码操作列,新增同页详情弹窗,统一添加侧栏窗与编辑弹窗的表单及页脚。
|
||||
- **影响**:可在详情弹窗查看与复制原码,批量复制随选中态启用,清除失效操作保留二次确认。
|
||||
- **回滚**:还原兑换码列表、表单、详情弹窗和对应样式与文案。
|
||||
- **关联**:`src/components/table/redemptions/`、`docs/ui/CONSOLE_SPEC.md`。
|
||||
|
||||
### 修复 · 企业成员排行的主题色与跨页名次
|
||||
|
||||
- **范围**:企业中心 `/org/logs` 的成员排行。
|
||||
- **变更**:前三名使用主题派生的三档底色,其他名次使用中性色;在分页前生成全表名次。
|
||||
- **影响**:切换系统主色或明暗模式时,排名徽章同步更新;翻页时继续显示全表名次。
|
||||
- **回滚**:还原排名列的名次生成和徽章配色。
|
||||
- **关联**:`src/pages/Organization/OrgLogs.jsx`、`src/styles/org-center.css`、`docs/ui/ORG_CENTER_SPEC.md`。
|
||||
|
||||
### 修复 · Vite 读取 npm 配置文件触发错误遮罩
|
||||
|
||||
- **范围**:Vite 开发服务的文件请求处理。
|
||||
- **变更**:在资源转换前拦截 `.npmrc` 请求并返回 404,同时将 `.npmrc` 加入文件访问拒绝列表。
|
||||
- **影响**:npm 配置文件请求不会启动资源转换或触发全站热更新错误遮罩。应用使用的文本资源导入继续由 Vite 转换。
|
||||
- **回滚**:还原 Vite 的 npm 配置文件拦截和对应访问规则。
|
||||
- **关联**:`vite.config.js`、`README.md`。
|
||||
|
||||
### 修复 · 控制台数据看板持续加载
|
||||
|
||||
- **范围**:控制台 `/console/analytics` 运营看板、创作作品详情抽屉及公共 API 的只读请求。
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 控制台 UI 规范(/console/\*)
|
||||
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.4
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-25 · 版本:v2.7
|
||||
|
||||
管理控制台 `/console/*` 的规范:统一页头、控制台原语与差异样式。
|
||||
|
||||
@@ -58,6 +58,8 @@
|
||||
- 提示栏:控制台内的 `Banner` / `Alert` 统一走 `ConsoleAlert`,内边距 12px 16px、正文 14 / 22px、图标 16px,颜色取对应语义 token。
|
||||
- 系统设置(`page.key === 'setting'`):表单统一纵向布局、8px 标签间距、24px 栅格、控件等宽,校验信息预留高度;弹窗页脚按钮高 34px、间距 8px、右对齐。规则限定在 `.settings-page` / `.settings-form-dialog`。
|
||||
- 控制台上下文中 `CompactModeToggle` 不渲染,表格密度状态保留;其他模块仍可使用紧凑模式。
|
||||
- 兑换码列表沿用渠道列表的行内链接按钮、右侧固定操作列和底部分页。「查看、复制、编辑、禁用/启用、删除」在同一行直接显示,保留既有权限和状态限制,删除仍需确认。窄屏横向滚动时操作列不换行。批量复制在选中兑换码后可用,清除失效兑换码由独立的危险操作确认承载。
|
||||
- 添加兑换码与编辑兑换码信息共用右侧侧栏窗、表单样式及页脚。查看详情使用弹窗,优先展示兑换码和状态,再列出额度、时间与兑换人信息。
|
||||
- 平台 Skill 中心的分类标签区域与搜索工具栏同宽、左对齐,不保留独立的最大宽度和自动居中;窄屏按原间距自然换行。
|
||||
- 平台 Skill 详情的审核工作台仅由抽屉正文纵向滚动,技能原文不设置独立滚动区;审核操作进入抽屉固定页脚,按钮右对齐、间距 8px,仅在审核页签展示。
|
||||
- 官网文章抽屉允许点击遮罩关闭,X、取消、遮罩共用同一未保存内容确认流程。
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
- 时间范围为本页签自有的可编辑字段(默认最近 7 天,含快捷预设),与“明细日志”筛选互不影响;起止颠倒沿用原提示。
|
||||
- 末列“操作”不固定:视频任务显示“点击预览视频”,失败任务保留失败原因查看,其余显示“-”。
|
||||
- 预览视频沿用 `ContentModal`:标题栏“视频预览”与关闭按钮、16:9 播放区、加载态、播放失败或无地址时 `Empty` 空态、页脚复制链接 / 新标签页打开 / 关闭;关闭时暂停视频,重开同一视频不残留加载指示。
|
||||
- 成员排行行键使用 `user_id-名次序号`,避免后端同一成员多行时出现重复 key。
|
||||
- 成员排行按接口返回顺序在分页前生成连续名次。行键使用 `user_id-名次序号`,避免后端同一成员多行时出现重复 key。前三名使用当前主题的强调色及三档底色,其余名次使用中性色。
|
||||
- 明细日志查询不写 URL;绘图与视频筛选沿用原有 URL 同步。
|
||||
- 保留差异:明细日志无列设置、分组列、操作列;任务表无渠道 / 用户 ID 筛选、平台列、排序与任务 ID 复制。
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 用户中心 UI 规范(/user-center/\*)
|
||||
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.4
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-25 · 版本:v2.5
|
||||
|
||||
个人登录后用户中心页面的规范,只记录与公共规范不同的部分;密钥管理、服务监控见各自规范。
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
- 页签:纯文字页签(公共列表页签样式),与下方 20px,URL `?tab=` 同步并懒挂载。
|
||||
- 筛选卡:5 列栅格,时间范围跨 2 列;背景使用 `--surface-card` 纯色(浅色为白色、深色为主题卡片色);操作“重置 / 搜索”右下。
|
||||
- 列表卡:标题 15px / 600,导出、列设置位于卡头右侧;表头字重 400(公共标准为 500,待收敛)。
|
||||
- 消费记录调用明细为固定列宽宽表,时间分两行(日期 11px、时间 15px / 600),操作列文字“查看”,固定在右侧;横向滚动条保留 Ant Design 官方固定列表格行为,固定列兼容规则遵循公共规范第 5.2 节。
|
||||
- 消费记录调用明细为固定列宽宽表,横向滚动时“时间”列固定在左侧,“操作”列显示时固定在右侧,中间列可滚动。时间分两行(日期 11px、时间 15px / 600),固定列兼容规则遵循公共规范第 5.2 节。
|
||||
- 消费记录“用时 / 首字”列宽 190px,总用时、首字耗时与流式状态分别用 antd 默认带描边 `Tag` 展示,保留主题算法生成的浅底 / 文字 / 边框。总用时对 `use_time` 取整数秒,`<101s` 用 `green`、`101–299s` 用 `gold`、`≥300s` 用 `magenta`;首字耗时取 `other.frt / 1000`,先保留一位小数再判色,`<3s` 用 `cyan`、`3–<10s` 用 `orange`、`≥10s` 用 `red`。流式显示三枚标签(状态为蓝色“流”),非流式仅显示总用时与中性“非流”;零值正常展示,缺失、非数值或负耗时显示中性破折号。
|
||||
- 绘图与视频:三张统计卡(高 70px、间距 15px)+ 任务记录表。
|
||||
- Webhook 示例为 `<pre class='ui-notify-code'>` +“复制”链接,复制提示沿用原文案。
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
|
||||
.console-page:is(
|
||||
[data-console-page='channel'],
|
||||
[data-console-page='redemption'],
|
||||
[data-console-page='models'],
|
||||
[data-console-page='user'],
|
||||
[data-console-page='organizations'],
|
||||
@@ -73,6 +74,17 @@
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.console-page:is(
|
||||
[data-console-page='channel'],
|
||||
[data-console-page='redemption']
|
||||
)
|
||||
.console-table.ant-table-wrapper
|
||||
.ant-table-thead
|
||||
> tr
|
||||
> th {
|
||||
color: var(--console-text);
|
||||
}
|
||||
|
||||
.console-model-drawer .ant-drawer-title > .ant-space {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,28 @@
|
||||
import React from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import { Button } from 'antd';
|
||||
import { Copy, Plus, Trash2 } from '@/components/common/icons/ActionIcons';
|
||||
import { Button } from '@/components/ui';
|
||||
import { isAdmin } from '../../../helpers';
|
||||
|
||||
const RedemptionsActions = ({
|
||||
selectedKeys,
|
||||
busy,
|
||||
setEditingRedemption,
|
||||
setShowEdit,
|
||||
batchCopyRedemptions,
|
||||
batchDeleteRedemptions,
|
||||
t,
|
||||
}) => {
|
||||
// Add new redemption code
|
||||
const [copying, setCopying] = useState(false);
|
||||
|
||||
const handleCopy = async () => {
|
||||
setCopying(true);
|
||||
try {
|
||||
await batchCopyRedemptions();
|
||||
} finally {
|
||||
setCopying(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddRedemption = () => {
|
||||
setEditingRedemption({
|
||||
id: undefined,
|
||||
@@ -21,14 +32,21 @@ const RedemptionsActions = ({
|
||||
|
||||
return (
|
||||
<div className='console-list-tool-actions'>
|
||||
<Button icon={<Copy size={16} />} onClick={batchCopyRedemptions}>
|
||||
<Button
|
||||
icon={<Copy size={16} aria-hidden />}
|
||||
disabled={busy || selectedKeys.length === 0}
|
||||
loading={copying}
|
||||
onClick={handleCopy}
|
||||
>
|
||||
{t('复制所选兑换码到剪贴板')}
|
||||
</Button>
|
||||
|
||||
{isAdmin() && (
|
||||
<Button
|
||||
type='danger'
|
||||
icon={<Trash2 size={16} />}
|
||||
danger
|
||||
className='redemption-invalid-action'
|
||||
disabled={busy}
|
||||
icon={<Trash2 size={16} aria-hidden />}
|
||||
onClick={batchDeleteRedemptions}
|
||||
>
|
||||
{t('清除失效兑换码')}
|
||||
@@ -37,7 +55,8 @@ const RedemptionsActions = ({
|
||||
{isAdmin() && (
|
||||
<Button
|
||||
type='primary'
|
||||
icon={<Plus size={16} />}
|
||||
className='console-create-action'
|
||||
icon={<Plus size={16} aria-hidden />}
|
||||
onClick={handleAddRedemption}
|
||||
>
|
||||
{t('添加兑换码')}
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Tag, Button, Space, Popover, Dropdown } from '@/components/ui';
|
||||
import { IconMore } from '@/components/ui/icons';
|
||||
import {
|
||||
renderQuota,
|
||||
timestamp2string,
|
||||
isAdmin,
|
||||
hoverOrClickTrigger,
|
||||
} from '../../../helpers';
|
||||
import { Button, Tag, Tooltip } from 'antd';
|
||||
import { renderQuota, timestamp2string, isAdmin } from '../../../helpers';
|
||||
import {
|
||||
REDEMPTION_STATUS,
|
||||
REDEMPTION_STATUS_MAP,
|
||||
@@ -27,36 +21,23 @@ export const isExpired = (record) => {
|
||||
/**
|
||||
* Render timestamp
|
||||
*/
|
||||
const renderTimestamp = (timestamp) => {
|
||||
return <>{timestamp2string(timestamp)}</>;
|
||||
};
|
||||
export const formatRedemptionExpiry = (timestamp, t) =>
|
||||
timestamp === 0 ? t('永不过期') : timestamp2string(timestamp);
|
||||
|
||||
/**
|
||||
* Render redemption code status
|
||||
*/
|
||||
const renderStatus = (status, record, t) => {
|
||||
export const renderRedemptionStatus = (status, record, t) => {
|
||||
if (isExpired(record)) {
|
||||
return (
|
||||
<Tag color='orange' shape='circle'>
|
||||
{t('已过期')}
|
||||
</Tag>
|
||||
);
|
||||
return <Tag color='warning'>{t('已过期')}</Tag>;
|
||||
}
|
||||
|
||||
const statusConfig = REDEMPTION_STATUS_MAP[status];
|
||||
if (statusConfig) {
|
||||
return (
|
||||
<Tag color={statusConfig.color} shape='circle'>
|
||||
{t(statusConfig.text)}
|
||||
</Tag>
|
||||
);
|
||||
return <Tag color={statusConfig.color}>{t(statusConfig.text)}</Tag>;
|
||||
}
|
||||
|
||||
return (
|
||||
<Tag color='black' shape='circle'>
|
||||
{t('未知状态')}
|
||||
</Tag>
|
||||
);
|
||||
return <Tag>{t('未知状态')}</Tag>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -68,115 +49,75 @@ export const getRedemptionsColumns = ({
|
||||
copyText,
|
||||
setEditingRedemption,
|
||||
setShowEdit,
|
||||
refresh,
|
||||
redemptions,
|
||||
activePage,
|
||||
showDetails,
|
||||
showDeleteRedemptionModal,
|
||||
}) => {
|
||||
return [
|
||||
{
|
||||
title: t('ID'),
|
||||
dataIndex: 'id',
|
||||
width: 72,
|
||||
},
|
||||
{
|
||||
title: t('名称'),
|
||||
dataIndex: 'name',
|
||||
width: 224,
|
||||
ellipsis: { showTitle: false },
|
||||
render: (name) => (
|
||||
<Tooltip title={name}>
|
||||
<span>{name}</span>
|
||||
</Tooltip>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
render: (text, record) => {
|
||||
return <div>{renderStatus(text, record, t)}</div>;
|
||||
},
|
||||
width: 120,
|
||||
render: (status, record) => renderRedemptionStatus(status, record, t),
|
||||
},
|
||||
{
|
||||
title: t('额度'),
|
||||
dataIndex: 'quota',
|
||||
render: (text) => {
|
||||
return (
|
||||
<div>
|
||||
<Tag color='grey' shape='circle'>
|
||||
{renderQuota(parseInt(text))}
|
||||
</Tag>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
width: 128,
|
||||
align: 'right',
|
||||
render: (quota) => renderQuota(parseInt(quota)),
|
||||
},
|
||||
{
|
||||
title: t('创建时间'),
|
||||
dataIndex: 'created_time',
|
||||
render: (text) => {
|
||||
return <div>{renderTimestamp(text)}</div>;
|
||||
},
|
||||
width: 180,
|
||||
render: (timestamp) => timestamp2string(timestamp),
|
||||
},
|
||||
{
|
||||
title: t('过期时间'),
|
||||
dataIndex: 'expired_time',
|
||||
render: (text) => {
|
||||
return <div>{text === 0 ? t('永不过期') : renderTimestamp(text)}</div>;
|
||||
},
|
||||
width: 180,
|
||||
render: (timestamp) => formatRedemptionExpiry(timestamp, t),
|
||||
},
|
||||
{
|
||||
title: t('兑换人ID'),
|
||||
dataIndex: 'used_user_id',
|
||||
render: (text) => {
|
||||
return <div>{text === 0 ? t('无') : text}</div>;
|
||||
},
|
||||
width: 128,
|
||||
render: (id) => (id === 0 ? t('无') : id),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
dataIndex: 'operate',
|
||||
fixed: 'right',
|
||||
width: 205,
|
||||
render: (text, record) => {
|
||||
// Create dropdown menu items for more operations
|
||||
const moreMenuItems = [
|
||||
{
|
||||
node: 'item',
|
||||
name: t('删除'),
|
||||
type: 'danger',
|
||||
onClick: () => {
|
||||
showDeleteRedemptionModal(record);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
if (record.status === REDEMPTION_STATUS.UNUSED && !isExpired(record)) {
|
||||
moreMenuItems.push({
|
||||
node: 'item',
|
||||
name: t('禁用'),
|
||||
type: 'warning',
|
||||
onClick: () => {
|
||||
manageRedemption(record.id, REDEMPTION_ACTIONS.DISABLE, record);
|
||||
},
|
||||
});
|
||||
} else if (!isExpired(record)) {
|
||||
moreMenuItems.push({
|
||||
node: 'item',
|
||||
name: t('启用'),
|
||||
type: 'secondary',
|
||||
onClick: () => {
|
||||
manageRedemption(record.id, REDEMPTION_ACTIONS.ENABLE, record);
|
||||
},
|
||||
disabled: record.status === REDEMPTION_STATUS.USED,
|
||||
});
|
||||
}
|
||||
const isUnused = record.status === REDEMPTION_STATUS.UNUSED;
|
||||
|
||||
return (
|
||||
<Space>
|
||||
<Popover
|
||||
// 触屏必须 click:这是查看兑换码明文的唯一入口
|
||||
trigger={hoverOrClickTrigger()}
|
||||
content={record.key}
|
||||
style={{ padding: 20 }}
|
||||
position='top'
|
||||
<div className='console-module-row-actions redemption-row-actions'>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => showDetails(record)}
|
||||
>
|
||||
<Button type='tertiary' size='small'>
|
||||
{t('查看')}
|
||||
</Button>
|
||||
</Popover>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={async () => {
|
||||
await copyText(record.key);
|
||||
@@ -187,26 +128,45 @@ export const getRedemptionsColumns = ({
|
||||
{isAdmin() && (
|
||||
<>
|
||||
<Button
|
||||
type='tertiary'
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingRedemption(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
disabled={record.status !== REDEMPTION_STATUS.UNUSED}
|
||||
disabled={!isUnused}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
<Dropdown
|
||||
trigger='click'
|
||||
position='bottomRight'
|
||||
menu={moreMenuItems}
|
||||
{!isExpired(record) && (
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
disabled={record.status === REDEMPTION_STATUS.USED}
|
||||
onClick={() =>
|
||||
manageRedemption(
|
||||
record.id,
|
||||
isUnused
|
||||
? REDEMPTION_ACTIONS.DISABLE
|
||||
: REDEMPTION_ACTIONS.ENABLE,
|
||||
record,
|
||||
)
|
||||
}
|
||||
>
|
||||
<Button type='tertiary' size='small' icon={<IconMore />} />
|
||||
</Dropdown>
|
||||
{isUnused ? t('禁用') : t('启用')}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
danger
|
||||
onClick={() => showDeleteRedemptionModal(record)}
|
||||
>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import TableEmpty from '../../common/table/TableEmpty';
|
||||
import CardTable from '../../common/ui/CardTable';
|
||||
import { getRedemptionsColumns } from './RedemptionsColumnDefs';
|
||||
import DeleteRedemptionModal from './modals/DeleteRedemptionModal';
|
||||
import RedemptionDetailsModal from './modals/RedemptionDetailsModal';
|
||||
|
||||
const SELECTION_COLUMN_WIDTH = 34;
|
||||
|
||||
const RedemptionsTable = (redemptionsData) => {
|
||||
const {
|
||||
redemptions,
|
||||
loading,
|
||||
searching,
|
||||
activePage,
|
||||
pageSize,
|
||||
tokenCount,
|
||||
compactMode,
|
||||
handlePageChange,
|
||||
rowSelection,
|
||||
handleRow,
|
||||
manageRedemption,
|
||||
copyText,
|
||||
setEditingRedemption,
|
||||
@@ -26,6 +25,7 @@ const RedemptionsTable = (redemptionsData) => {
|
||||
// Modal states
|
||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||
const [deletingRecord, setDeletingRecord] = useState(null);
|
||||
const [detailRecord, setDetailRecord] = useState(null);
|
||||
|
||||
// Handle show delete modal
|
||||
const showDeleteRedemptionModal = (record) => {
|
||||
@@ -40,49 +40,36 @@ const RedemptionsTable = (redemptionsData) => {
|
||||
copyText,
|
||||
setEditingRedemption,
|
||||
setShowEdit,
|
||||
refresh,
|
||||
redemptions,
|
||||
activePage,
|
||||
showDetails: setDetailRecord,
|
||||
showDeleteRedemptionModal,
|
||||
});
|
||||
|
||||
// Handle compact mode by removing fixed positioning
|
||||
const tableColumns = useMemo(() => {
|
||||
return compactMode
|
||||
? columns.map((col) => {
|
||||
if (col.dataIndex === 'operate') {
|
||||
const { fixed, ...rest } = col;
|
||||
return rest;
|
||||
}
|
||||
return col;
|
||||
})
|
||||
: columns;
|
||||
}, [compactMode, columns]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<CardTable
|
||||
columns={tableColumns}
|
||||
columns={columns}
|
||||
minScrollableWidth={SELECTION_COLUMN_WIDTH * 2}
|
||||
dataSource={redemptions}
|
||||
scroll={compactMode ? undefined : { x: 'max-content' }}
|
||||
pagination={{
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
total: tokenCount,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: [10, 20, 50, 100],
|
||||
onPageSizeChange: redemptionsData.handlePageSizeChange,
|
||||
onPageChange: handlePageChange,
|
||||
}}
|
||||
scroll={{ x: 'max-content' }}
|
||||
hidePagination={true}
|
||||
loading={loading}
|
||||
rowSelection={rowSelection}
|
||||
onRow={handleRow}
|
||||
loading={loading || searching}
|
||||
rowSelection={{
|
||||
...rowSelection,
|
||||
fixed: true,
|
||||
columnWidth: SELECTION_COLUMN_WIDTH,
|
||||
}}
|
||||
empty={<TableEmpty />}
|
||||
className='console-list-table overflow-hidden'
|
||||
className='rounded-xl overflow-hidden'
|
||||
size='middle'
|
||||
/>
|
||||
|
||||
<RedemptionDetailsModal
|
||||
record={detailRecord}
|
||||
onClose={() => setDetailRecord(null)}
|
||||
copyText={copyText}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<DeleteRedemptionModal
|
||||
visible={showDeleteModal}
|
||||
onCancel={() => setShowDeleteModal(false)}
|
||||
|
||||
@@ -8,6 +8,8 @@ import EditRedemptionModal from './modals/EditRedemptionModal';
|
||||
import { useRedemptionsData } from '../../../hooks/redemptions/useRedemptionsData';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
import { createCardProPagination } from '../../../helpers/utils';
|
||||
import '../../console/module-alignment.css';
|
||||
import './redemptions.css';
|
||||
|
||||
const RedemptionsPage = () => {
|
||||
const redemptionsData = useRedemptionsData();
|
||||
@@ -47,11 +49,12 @@ const RedemptionsPage = () => {
|
||||
<EditRedemptionModal
|
||||
refresh={refresh}
|
||||
editingRedemption={editingRedemption}
|
||||
visiable={showEdit}
|
||||
visible={showEdit}
|
||||
handleClose={closeEdit}
|
||||
/>
|
||||
|
||||
<CardPro
|
||||
tableTitle={t('兑换码列表')}
|
||||
searchArea={
|
||||
<RedemptionsFilters
|
||||
formInitValues={formInitValues}
|
||||
@@ -65,25 +68,27 @@ const RedemptionsPage = () => {
|
||||
/>
|
||||
}
|
||||
type='type1'
|
||||
actionsArea={
|
||||
<div className='console-list-tools'>
|
||||
descriptionArea={
|
||||
<RedemptionsDescription
|
||||
compactMode={compactMode}
|
||||
setCompactMode={setCompactMode}
|
||||
t={t}
|
||||
/>
|
||||
}
|
||||
tableActions={
|
||||
<RedemptionsActions
|
||||
selectedKeys={selectedKeys}
|
||||
busy={loading || searching}
|
||||
setEditingRedemption={setEditingRedemption}
|
||||
setShowEdit={setShowEdit}
|
||||
batchCopyRedemptions={batchCopyRedemptions}
|
||||
batchDeleteRedemptions={batchDeleteRedemptions}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
preservePage: true,
|
||||
showRange: false,
|
||||
currentPage: redemptionsData.activePage,
|
||||
pageSize: redemptionsData.pageSize,
|
||||
total: redemptionsData.tokenCount,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
|
||||
import React, { useEffect, useState, useRef } from 'react';
|
||||
import React, { useEffect, useId, useRef, useState } from 'react';
|
||||
import { Button, Card, Col, Row, Spin } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
API,
|
||||
@@ -7,126 +7,105 @@ import {
|
||||
showError,
|
||||
showSuccess,
|
||||
renderQuota,
|
||||
} from '../../../../helpers';
|
||||
} from '@/helpers';
|
||||
import { FormQuotaInput } from '../../../common/ui/QuotaInput';
|
||||
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
SideSheet,
|
||||
Space,
|
||||
Spin,
|
||||
Typography,
|
||||
Card,
|
||||
Tag,
|
||||
Form,
|
||||
Avatar,
|
||||
Row,
|
||||
Col,
|
||||
} from '@/components/ui';
|
||||
import {
|
||||
IconCreditCard,
|
||||
IconSave,
|
||||
IconClose,
|
||||
IconGift,
|
||||
} from '@/components/ui/icons';
|
||||
import { Form, Modal, SideSheet } from '@/components/ui';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
|
||||
const EditRedemptionModal = (props) => {
|
||||
const { t } = useTranslation();
|
||||
const isEdit = props.editingRedemption.id !== undefined;
|
||||
const [loading, setLoading] = useState(isEdit);
|
||||
const isMobile = useIsMobile();
|
||||
const formApiRef = useRef(null);
|
||||
|
||||
const getInitValues = () => ({
|
||||
const initialValues = {
|
||||
name: '',
|
||||
quota: 100000,
|
||||
count: 1,
|
||||
expired_time: null,
|
||||
is_gift: false,
|
||||
});
|
||||
|
||||
const handleCancel = () => {
|
||||
props.handleClose();
|
||||
};
|
||||
|
||||
const loadRedemption = async () => {
|
||||
setLoading(true);
|
||||
let res = await API.get(`/api/redemption/${props.editingRedemption.id}`);
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
if (data.expired_time === 0) {
|
||||
data.expired_time = null;
|
||||
} else {
|
||||
data.expired_time = new Date(data.expired_time * 1000);
|
||||
}
|
||||
formApiRef.current?.setValues({ ...getInitValues(), ...data });
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
const EditRedemptionModal = ({
|
||||
editingRedemption,
|
||||
visible,
|
||||
refresh,
|
||||
handleClose,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { id } = editingRedemption;
|
||||
const isEdit = id !== undefined;
|
||||
const isMobile = useIsMobile();
|
||||
const formApi = useRef(null);
|
||||
const formId = useId();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [loadedId, setLoadedId] = useState(null);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const pending = useRef(false);
|
||||
const formDisabled = loading || submitting || (isEdit && loadedId !== id);
|
||||
|
||||
const onScopeChange = useEffectEvent(() => {
|
||||
if (formApiRef.current) {
|
||||
if (isEdit) {
|
||||
loadRedemption();
|
||||
} else {
|
||||
formApiRef.current.setValues(getInitValues());
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
if (!visible) return;
|
||||
|
||||
formApi.current?.reset();
|
||||
setLoadedId(null);
|
||||
setLoading(isEdit);
|
||||
if (!isEdit) return;
|
||||
|
||||
let active = true;
|
||||
async function loadRedemption() {
|
||||
try {
|
||||
const { data: result } = await API.get(`/api/redemption/${id}`);
|
||||
if (!active) return;
|
||||
if (result.success) {
|
||||
const { expired_time, ...data } = result.data;
|
||||
formApi.current?.setValues({
|
||||
...initialValues,
|
||||
...data,
|
||||
expired_time:
|
||||
expired_time === 0 ? null : new Date(expired_time * 1000),
|
||||
});
|
||||
useEffect(() => onScopeChange(), [onScopeChange, props.editingRedemption.id]);
|
||||
setLoadedId(id);
|
||||
} else {
|
||||
showError(result.message);
|
||||
}
|
||||
} catch (error) {
|
||||
if (active && !error.isAxiosError) showError(error.message);
|
||||
} finally {
|
||||
if (active) setLoading(false);
|
||||
}
|
||||
}
|
||||
void loadRedemption();
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [id, isEdit, visible]);
|
||||
|
||||
const submit = async (values) => {
|
||||
let name = values.name;
|
||||
if (!isEdit && (!name || name === '')) {
|
||||
name = renderQuota(values.quota);
|
||||
}
|
||||
setLoading(true);
|
||||
let localInputs = { ...values };
|
||||
localInputs.count = parseInt(localInputs.count) || 0;
|
||||
localInputs.quota = parseInt(localInputs.quota) || 0;
|
||||
localInputs.name = name;
|
||||
if (!localInputs.expired_time) {
|
||||
localInputs.expired_time = 0;
|
||||
} else {
|
||||
localInputs.expired_time = Math.floor(
|
||||
localInputs.expired_time.getTime() / 1000,
|
||||
);
|
||||
}
|
||||
let res;
|
||||
if (isEdit) {
|
||||
res = await API.put(`/api/redemption/`, {
|
||||
...localInputs,
|
||||
id: parseInt(props.editingRedemption.id),
|
||||
});
|
||||
} else {
|
||||
res = await API.post(`/api/redemption/`, {
|
||||
...localInputs,
|
||||
});
|
||||
}
|
||||
if (formDisabled || pending.current) return;
|
||||
pending.current = true;
|
||||
setSubmitting(true);
|
||||
try {
|
||||
const payload = {
|
||||
...values,
|
||||
name: !isEdit && !values.name ? renderQuota(values.quota) : values.name,
|
||||
count: parseInt(values.count) || 0,
|
||||
quota: parseInt(values.quota) || 0,
|
||||
expired_time: values.expired_time
|
||||
? Math.floor(values.expired_time.getTime() / 1000)
|
||||
: 0,
|
||||
};
|
||||
const res = isEdit
|
||||
? await API.put('/api/redemption/', { ...payload, id: parseInt(id) })
|
||||
: await API.post('/api/redemption/', payload);
|
||||
const { success, message, data } = res.data;
|
||||
|
||||
if (success) {
|
||||
if (isEdit) {
|
||||
showSuccess(t('兑换码更新成功!'));
|
||||
props.refresh();
|
||||
props.handleClose();
|
||||
} else {
|
||||
showSuccess(t('兑换码创建成功!'));
|
||||
props.refresh();
|
||||
formApiRef.current?.setValues(getInitValues());
|
||||
props.handleClose();
|
||||
}
|
||||
showSuccess(isEdit ? t('兑换码更新成功!') : t('兑换码创建成功!'));
|
||||
refresh();
|
||||
handleClose();
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
|
||||
if (!isEdit && data) {
|
||||
let text = '';
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
text += data[i] + '\n';
|
||||
for (let index = 0; index < data.length; index++) {
|
||||
text += data[index] + '\n';
|
||||
}
|
||||
Modal.confirm({
|
||||
title: t('兑换码创建成功'),
|
||||
@@ -136,176 +115,100 @@ const EditRedemptionModal = (props) => {
|
||||
<p>{t('兑换码将以文本文件的形式下载,文件名为兑换码的名称。')}</p>
|
||||
</div>
|
||||
),
|
||||
onOk: () => {
|
||||
downloadTextAsFile(text, `${localInputs.name}.txt`);
|
||||
},
|
||||
onOk: () => downloadTextAsFile(text, `${payload.name}.txt`),
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
if (!error.isAxiosError) showError(error.message);
|
||||
} finally {
|
||||
pending.current = false;
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<SideSheet
|
||||
placement={isEdit ? 'right' : 'left'}
|
||||
title={
|
||||
<Space>
|
||||
{isEdit ? (
|
||||
<Tag color='blue' shape='circle'>
|
||||
{t('更新')}
|
||||
</Tag>
|
||||
) : (
|
||||
<Tag color='green' shape='circle'>
|
||||
{t('新建')}
|
||||
</Tag>
|
||||
)}
|
||||
<Title heading={4} className='m-0'>
|
||||
{isEdit ? t('更新兑换码信息') : t('创建新的兑换码')}
|
||||
</Title>
|
||||
</Space>
|
||||
}
|
||||
bodyStyle={{ padding: '0' }}
|
||||
visible={props.visiable}
|
||||
width={isMobile ? '100%' : 600}
|
||||
footer={
|
||||
<div className='flex justify-end'>
|
||||
<Space>
|
||||
const handleCancel = () => {
|
||||
if (!pending.current) handleClose();
|
||||
};
|
||||
const footer = (
|
||||
<div className='console-dialog-actions redemption-form-actions'>
|
||||
<Button disabled={submitting} onClick={handleCancel}>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
onClick={() => formApiRef.current?.submitForm()}
|
||||
icon={<IconSave />}
|
||||
loading={loading}
|
||||
type='primary'
|
||||
htmlType='submit'
|
||||
form={formId}
|
||||
disabled={formDisabled}
|
||||
loading={submitting}
|
||||
>
|
||||
{t('提交')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
type='primary'
|
||||
onClick={handleCancel}
|
||||
icon={<IconClose />}
|
||||
>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
}
|
||||
closeIcon={null}
|
||||
onCancel={() => handleCancel()}
|
||||
>
|
||||
);
|
||||
const form = (
|
||||
<Spin spinning={loading}>
|
||||
<Form
|
||||
initValues={getInitValues()}
|
||||
getFormApi={(api) => (formApiRef.current = api)}
|
||||
id={formId}
|
||||
name={formId}
|
||||
ref={formApi}
|
||||
className='redemption-form'
|
||||
initValues={initialValues}
|
||||
disabled={formDisabled}
|
||||
onSubmit={submit}
|
||||
onSubmitFail={() => formApi.current?.scrollToError()}
|
||||
>
|
||||
{({ values }) => (
|
||||
<div className='p-2'>
|
||||
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
||||
{/* Header: Basic Info */}
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='blue'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<IconGift size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
<Text className='text-lg font-medium'>
|
||||
{t('基本信息')}
|
||||
</Text>
|
||||
<div className='text-xs text-gray-600'>
|
||||
{t('设置兑换码的基本信息')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Row gutter={12}>
|
||||
<Col span={24}>
|
||||
<Card size='small' title={t('基本信息')}>
|
||||
<Form.Input
|
||||
field='name'
|
||||
label={t('名称')}
|
||||
placeholder={t('请输入名称')}
|
||||
style={{ width: '100%' }}
|
||||
rules={
|
||||
!isEdit
|
||||
? []
|
||||
: [{ required: true, message: t('请输入名称') }]
|
||||
}
|
||||
rules={isEdit ? [{ required: true, message: t('请输入名称') }] : []}
|
||||
className={isEdit ? 'redemption-validated-field' : undefined}
|
||||
showClear
|
||||
/>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.DatePicker
|
||||
field='expired_time'
|
||||
label={t('过期时间')}
|
||||
type='dateTime'
|
||||
placeholder={t('选择过期时间(可选,留空为永久)')}
|
||||
style={{ width: '100%' }}
|
||||
showClear
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
<Card className='!rounded-2xl shadow-sm border-0'>
|
||||
{/* Header: Quota Settings */}
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='green'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<IconCreditCard size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
<Text className='text-lg font-medium'>
|
||||
{t('额度设置')}
|
||||
</Text>
|
||||
<div className='text-xs text-gray-600'>
|
||||
{t('设置兑换码的额度和数量')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Row gutter={12}>
|
||||
<Col span={12}>
|
||||
<Card size='small' title={t('额度设置')}>
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} sm={isEdit ? 24 : 12}>
|
||||
<FormQuotaInput
|
||||
field='quota'
|
||||
label={t('额度')}
|
||||
style={{ width: '100%' }}
|
||||
className='redemption-validated-field'
|
||||
rules={[
|
||||
{ required: true, message: t('请输入额度') },
|
||||
{
|
||||
validator: (rule, v) => {
|
||||
const num = parseInt(v, 10);
|
||||
return num > 0
|
||||
validator: (rule, value) =>
|
||||
parseInt(value, 10) > 0
|
||||
? Promise.resolve()
|
||||
: Promise.reject(t('额度必须大于0'));
|
||||
},
|
||||
: Promise.reject(t('额度必须大于0')),
|
||||
},
|
||||
]}
|
||||
showClear
|
||||
/>
|
||||
</Col>
|
||||
{!isEdit && (
|
||||
<Col span={12}>
|
||||
<Col xs={24} sm={12}>
|
||||
<Form.InputNumber
|
||||
field='count'
|
||||
label={t('生成数量')}
|
||||
className='redemption-validated-field'
|
||||
min={1}
|
||||
rules={[
|
||||
{ required: true, message: t('请输入生成数量') },
|
||||
{
|
||||
validator: (rule, v) => {
|
||||
const num = parseInt(v, 10);
|
||||
return num > 0
|
||||
validator: (rule, value) =>
|
||||
parseInt(value, 10) > 0
|
||||
? Promise.resolve()
|
||||
: Promise.reject(t('生成数量必须大于0'));
|
||||
},
|
||||
: Promise.reject(t('生成数量必须大于0')),
|
||||
},
|
||||
]}
|
||||
style={{ width: '100%' }}
|
||||
showClear
|
||||
/>
|
||||
</Col>
|
||||
@@ -319,12 +222,23 @@ const EditRedemptionModal = (props) => {
|
||||
)}
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
</Form>
|
||||
</Spin>
|
||||
);
|
||||
|
||||
return (
|
||||
<SideSheet
|
||||
placement='right'
|
||||
forceRender
|
||||
visible={visible}
|
||||
width={isMobile ? '100%' : 560}
|
||||
title={isEdit ? t('编辑兑换码信息') : t('添加兑换码')}
|
||||
footer={footer}
|
||||
onCancel={handleCancel}
|
||||
closable={!submitting}
|
||||
>
|
||||
{form}
|
||||
</SideSheet>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import React from 'react';
|
||||
import { Button } from 'antd';
|
||||
import { Copy } from '@/components/common/icons/ActionIcons';
|
||||
import { Modal } from '@/components/ui';
|
||||
import { renderQuota, timestamp2string } from '@/helpers';
|
||||
import {
|
||||
formatRedemptionExpiry,
|
||||
renderRedemptionStatus,
|
||||
} from '../RedemptionsColumnDefs';
|
||||
|
||||
export default function RedemptionDetailsModal({
|
||||
record,
|
||||
onClose,
|
||||
copyText,
|
||||
t,
|
||||
}) {
|
||||
const fields = record
|
||||
? [
|
||||
[t('ID'), record.id],
|
||||
[t('额度'), renderQuota(parseInt(record.quota))],
|
||||
[t('创建时间'), timestamp2string(record.created_time)],
|
||||
[t('过期时间'), formatRedemptionExpiry(record.expired_time, t)],
|
||||
[t('兑换人ID'), record.used_user_id || t('无')],
|
||||
]
|
||||
: [];
|
||||
|
||||
return (
|
||||
<Modal
|
||||
centered
|
||||
visible={Boolean(record)}
|
||||
title={t('查看详情')}
|
||||
onCancel={onClose}
|
||||
footer={<Button onClick={onClose}>{t('关闭')}</Button>}
|
||||
destroyOnHidden
|
||||
>
|
||||
{record && (
|
||||
<div className='redemption-details'>
|
||||
<div className='redemption-details-heading'>
|
||||
<h3>{record.name}</h3>
|
||||
{renderRedemptionStatus(record.status, record, t)}
|
||||
</div>
|
||||
<div className='redemption-code'>
|
||||
<div className='redemption-code-header'>
|
||||
<span>{t('兑换码')}</span>
|
||||
<Button
|
||||
icon={<Copy size={16} aria-hidden />}
|
||||
size='small'
|
||||
onClick={() => copyText(record.key)}
|
||||
>
|
||||
{t('复制')}
|
||||
</Button>
|
||||
</div>
|
||||
<code>{record.key}</code>
|
||||
</div>
|
||||
<dl className='redemption-details-fields'>
|
||||
{fields.map(([label, value]) => (
|
||||
<div key={label}>
|
||||
<dt>{label}</dt>
|
||||
<dd>{value}</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
.console-page[data-console-page='redemption']
|
||||
.console-table
|
||||
.ant-table-tbody
|
||||
> .ant-table-row
|
||||
> .ant-table-cell {
|
||||
height: 51px;
|
||||
}
|
||||
|
||||
.redemption-form {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.redemption-form .ant-card-small > .ant-card-head,
|
||||
.redemption-form .ant-card-small > .ant-card-body {
|
||||
padding-inline: 16px;
|
||||
}
|
||||
|
||||
.redemption-form .ant-card-small > .ant-card-body {
|
||||
padding-block: 16px;
|
||||
}
|
||||
|
||||
.redemption-form.console-form .ant-form-item {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.redemption-form.console-form .ant-card-body > .ant-form-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.redemption-form.console-form .ant-form-item-label > label {
|
||||
color: var(--console-text, var(--ui-color-text-0));
|
||||
}
|
||||
|
||||
.redemption-form,
|
||||
.redemption-invalid-action {
|
||||
--redemption-error-text: color-mix(
|
||||
in srgb,
|
||||
var(--ui-color-danger) 65%,
|
||||
var(--console-text, var(--ui-color-text-0))
|
||||
);
|
||||
}
|
||||
|
||||
.redemption-form .ant-form-item .ant-form-item-explain-error,
|
||||
.redemption-form .ant-form-item-label > .ant-form-item-required::before,
|
||||
.console-page .redemption-invalid-action.ant-btn-dangerous:not(:disabled) {
|
||||
color: var(--redemption-error-text);
|
||||
}
|
||||
|
||||
.redemption-form :is(.ant-input-number, .ant-picker) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.redemption-validated-field .ant-form-item-control {
|
||||
min-block-size: 56px;
|
||||
}
|
||||
|
||||
.redemption-form-actions .ant-btn {
|
||||
min-inline-size: 72px;
|
||||
min-block-size: 34px;
|
||||
}
|
||||
|
||||
.redemption-details {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
padding-block: 8px;
|
||||
color: var(--console-text, var(--ui-color-text-0));
|
||||
}
|
||||
|
||||
.redemption-details-heading,
|
||||
.redemption-code-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 8px 16px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.redemption-details-heading h3 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: var(--console-heading, var(--ui-color-text-0));
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.redemption-details-heading .ant-tag {
|
||||
margin-inline-end: 0;
|
||||
}
|
||||
|
||||
.redemption-code {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid var(--console-border, var(--ui-color-border));
|
||||
border-radius: 8px;
|
||||
background: var(--console-fill, var(--ui-color-fill-0));
|
||||
}
|
||||
|
||||
.redemption-code code {
|
||||
overflow-wrap: anywhere;
|
||||
user-select: all;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.redemption-details-fields {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px 20px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.redemption-details dt,
|
||||
.redemption-code-header > span {
|
||||
color: var(--console-text, var(--ui-color-text-0));
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.redemption-details dd {
|
||||
margin: 4px 0 0;
|
||||
overflow-wrap: anywhere;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
@media (max-width: 575px) {
|
||||
.redemption-details-fields {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
.center-action-table .center-action-cell .redemption-row-actions {
|
||||
flex-wrap: nowrap;
|
||||
vertical-align: middle;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.redemption-row-actions .ant-btn {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
@media (max-width: 575px) {
|
||||
.center-action-table .center-action-cell .redemption-row-actions {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.redemption-row-actions.console-module-row-actions .ant-btn-link {
|
||||
padding-inline: 2px;
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,11 @@ const applyUsageRecordPresentation = (
|
||||
};
|
||||
switch (column.key) {
|
||||
case COLUMN_KEYS.TIME:
|
||||
return { ...column, render: (text) => renderRecordTime(text) };
|
||||
return {
|
||||
...column,
|
||||
fixed: 'left',
|
||||
render: (text) => renderRecordTime(text),
|
||||
};
|
||||
case COLUMN_KEYS.USERNAME:
|
||||
return {
|
||||
...column,
|
||||
|
||||
@@ -390,7 +390,8 @@ const LogsTable = (logsData) => {
|
||||
);
|
||||
|
||||
const tableColumns = useMemo(() => {
|
||||
const baseColumns = compactMode
|
||||
const baseColumns =
|
||||
compactMode && !usageRecordMode
|
||||
? visibleColumnsList.map(({ fixed, ...rest }) => rest)
|
||||
: visibleColumnsList;
|
||||
if (!hasExpandableRows()) return baseColumns;
|
||||
@@ -399,7 +400,7 @@ const LogsTable = (logsData) => {
|
||||
{
|
||||
title: usageRecordMode ? t('操作') : t('计费详情'),
|
||||
key: 'billingDetailAction',
|
||||
fixed: compactMode || usageRecordMode ? undefined : 'right',
|
||||
fixed: usageRecordMode || !compactMode ? 'right' : undefined,
|
||||
width: 120,
|
||||
render: (_, record) => {
|
||||
const canView =
|
||||
@@ -452,7 +453,9 @@ const LogsTable = (logsData) => {
|
||||
dataSource={logs}
|
||||
rowKey='key'
|
||||
loading={loading}
|
||||
scroll={compactMode ? undefined : { x: 'max-content' }}
|
||||
scroll={
|
||||
usageRecordMode || !compactMode ? { x: 'max-content' } : undefined
|
||||
}
|
||||
className={
|
||||
usageRecordMode
|
||||
? 'usage-logs-table usage-record-table'
|
||||
|
||||
@@ -7,15 +7,15 @@ export const REDEMPTION_STATUS = {
|
||||
// Redemption code status display mapping
|
||||
export const REDEMPTION_STATUS_MAP = {
|
||||
[REDEMPTION_STATUS.UNUSED]: {
|
||||
color: 'green',
|
||||
color: 'success',
|
||||
text: '未使用',
|
||||
},
|
||||
[REDEMPTION_STATUS.DISABLED]: {
|
||||
color: 'red',
|
||||
color: 'error',
|
||||
text: '已禁用',
|
||||
},
|
||||
[REDEMPTION_STATUS.USED]: {
|
||||
color: 'grey',
|
||||
color: 'default',
|
||||
text: '已使用',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
REDEMPTION_STATUS,
|
||||
} from '../../constants/redemption.constants';
|
||||
import { Modal } from '@/components/ui';
|
||||
import { confirmTableAction } from '@/components/common/table/confirmTableAction';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useTableCompactMode } from '../common/useTableCompactMode';
|
||||
|
||||
@@ -185,28 +186,6 @@ export const useRedemptionsData = () => {
|
||||
},
|
||||
};
|
||||
|
||||
// Row style handling - using isExpired function
|
||||
const handleRow = (record, index) => {
|
||||
// Local isExpired function
|
||||
const isExpired = (rec) => {
|
||||
return (
|
||||
rec.status === REDEMPTION_STATUS.UNUSED &&
|
||||
rec.expired_time !== 0 &&
|
||||
rec.expired_time < Math.floor(Date.now() / 1000)
|
||||
);
|
||||
};
|
||||
|
||||
if (record.status !== REDEMPTION_STATUS.UNUSED || isExpired(record)) {
|
||||
return {
|
||||
style: {
|
||||
background: 'var(--ui-color-disabled-border)',
|
||||
},
|
||||
};
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
// Copy text
|
||||
const copyText = async (text) => {
|
||||
if (await copy(text)) {
|
||||
@@ -235,21 +214,28 @@ export const useRedemptionsData = () => {
|
||||
};
|
||||
|
||||
// Batch delete redemption codes (clear invalid)
|
||||
const batchDeleteRedemptions = async () => {
|
||||
Modal.confirm({
|
||||
const batchDeleteRedemptions = () => {
|
||||
confirmTableAction({
|
||||
title: t('确定清除所有失效兑换码?'),
|
||||
content: t('将删除已使用、已禁用及过期的兑换码,此操作不可撤销。'),
|
||||
focusable: { autoFocusButton: 'cancel' },
|
||||
onOk: async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await API.delete('/api/redemption/invalid');
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
if (!success) {
|
||||
showError(message);
|
||||
return false;
|
||||
}
|
||||
showSuccess(t('已删除 {{count}} 条失效兑换码', { count: data }));
|
||||
await refresh();
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
} catch (error) {
|
||||
if (!error.isAxiosError) showError(error.message);
|
||||
return false;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -324,7 +310,6 @@ export const useRedemptionsData = () => {
|
||||
handlePageChange,
|
||||
handlePageSizeChange,
|
||||
rowSelection,
|
||||
handleRow,
|
||||
closeEdit,
|
||||
getFormValues,
|
||||
|
||||
|
||||
@@ -1560,6 +1560,9 @@
|
||||
"兑换": "Redeem",
|
||||
"兑换成功!": "Redemption successful!",
|
||||
"兑换额度": "Redeem",
|
||||
"兑换码": "Redemption code",
|
||||
"兑换码列表": "Redemption codes",
|
||||
"编辑兑换码信息": "Edit redemption code",
|
||||
"兑换码充值": "Redemption code recharge",
|
||||
"兑换码创建成功": "Redemption Code Created",
|
||||
"兑换码创建成功,是否下载兑换码?": "Redemption code created successfully. Do you want to download it?",
|
||||
|
||||
@@ -1512,6 +1512,9 @@
|
||||
"兑换": "échange",
|
||||
"兑换成功!": "Échange réussi !",
|
||||
"兑换额度": "Utiliser",
|
||||
"兑换码": "Code d’échange",
|
||||
"兑换码列表": "Codes d’échange",
|
||||
"编辑兑换码信息": "Modifier les informations du code d’échange",
|
||||
"兑换码充值": "Recharge par code d'échange",
|
||||
"兑换码创建成功": "Code d'échange créé",
|
||||
"兑换码创建成功,是否下载兑换码?": "Code d'échange créé avec succès. Voulez-vous le télécharger ?",
|
||||
|
||||
@@ -1560,6 +1560,9 @@
|
||||
"兑换": "引き換え",
|
||||
"兑换成功!": "引き換えに成功しました",
|
||||
"兑换额度": "引き換え",
|
||||
"兑换码": "引き換えコード",
|
||||
"兑换码列表": "引き換えコード一覧",
|
||||
"编辑兑换码信息": "引き換えコード情報を編集",
|
||||
"兑换码充值": "引き換えコードによるチャージ",
|
||||
"兑换码创建成功": "引き換えコードの作成に成功しました",
|
||||
"兑换码创建成功,是否下载兑换码?": "引き換えコードの作成に成功しました。ダウンロードしますか?",
|
||||
|
||||
@@ -1560,6 +1560,9 @@
|
||||
"兑换": "교환",
|
||||
"兑换成功!": "교환되었습니다!",
|
||||
"兑换额度": "할당량 교환",
|
||||
"兑换码": "교환 코드",
|
||||
"兑换码列表": "교환 코드 목록",
|
||||
"编辑兑换码信息": "교환 코드 정보 편집",
|
||||
"兑换码充值": "교환 코드 충전",
|
||||
"兑换码创建成功": "교환 코드가 생성되었습니다",
|
||||
"兑换码创建成功,是否下载兑换码?": "교환 코드가 생성되었습니다. 내려받으시겠습니까?",
|
||||
|
||||
@@ -1532,6 +1532,9 @@
|
||||
"兑换": "Обмен валюты",
|
||||
"兑换成功!": "Обмен успешен!",
|
||||
"兑换额度": "Обменять квоту",
|
||||
"兑换码": "Код активации",
|
||||
"兑换码列表": "Список кодов активации",
|
||||
"编辑兑换码信息": "Редактировать данные кода активации",
|
||||
"兑换码充值": "Пополнение кодом купона",
|
||||
"兑换码创建成功": "Код купона успешно создан",
|
||||
"兑换码创建成功,是否下载兑换码?": "Код купона успешно создан, скачать код купона?",
|
||||
|
||||
@@ -1560,6 +1560,9 @@
|
||||
"兑换": "แลก",
|
||||
"兑换成功!": "แลกสำเร็จ!",
|
||||
"兑换额度": "แลก",
|
||||
"兑换码": "รหัสแลก",
|
||||
"兑换码列表": "รายการรหัสแลก",
|
||||
"编辑兑换码信息": "แก้ไขข้อมูลรหัสแลก",
|
||||
"兑换码充值": "เติมเงินด้วยรหัสแลก",
|
||||
"兑换码创建成功": "สร้างรหัสแลกแล้ว",
|
||||
"兑换码创建成功,是否下载兑换码?": "สร้างรหัสแลกสำเร็จ ต้องการดาวน์โหลดหรือไม่?",
|
||||
|
||||
@@ -1560,6 +1560,9 @@
|
||||
"兑换": "Đổi",
|
||||
"兑换成功!": "Đổi thành công!",
|
||||
"兑换额度": "Đổi",
|
||||
"兑换码": "Mã đổi thưởng",
|
||||
"兑换码列表": "Danh sách mã đổi thưởng",
|
||||
"编辑兑换码信息": "Chỉnh sửa thông tin mã đổi thưởng",
|
||||
"兑换码充值": "Nạp tiền bằng mã đổi thưởng",
|
||||
"兑换码创建成功": "Đã tạo mã đổi thưởng",
|
||||
"兑换码创建成功,是否下载兑换码?": "Tạo mã đổi thưởng thành công. Bạn có muốn tải xuống không?",
|
||||
|
||||
@@ -1560,6 +1560,9 @@
|
||||
"兑换": "兌換",
|
||||
"兑换成功!": "兌換成功!",
|
||||
"兑换额度": "兌換額度",
|
||||
"兑换码": "兌換碼",
|
||||
"兑换码列表": "兌換碼清單",
|
||||
"编辑兑换码信息": "編輯兌換碼資訊",
|
||||
"兑换码充值": "兌換碼儲值",
|
||||
"兑换码创建成功": "兌換碼建立成功",
|
||||
"兑换码创建成功,是否下载兑换码?": "兌換碼建立成功,是否下載兌換碼?",
|
||||
|
||||
@@ -1532,6 +1532,9 @@
|
||||
"兑换": "兑换",
|
||||
"兑换成功!": "兑换成功!",
|
||||
"兑换额度": "兑换额度",
|
||||
"兑换码": "兑换码",
|
||||
"兑换码列表": "兑换码列表",
|
||||
"编辑兑换码信息": "编辑兑换码信息",
|
||||
"兑换码充值": "兑换码充值",
|
||||
"兑换码创建成功": "兑换码创建成功",
|
||||
"兑换码创建成功,是否下载兑换码?": "兑换码创建成功,是否下载兑换码?",
|
||||
|
||||
@@ -731,6 +731,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
() =>
|
||||
(ranking || []).map((row, index) => ({
|
||||
...row,
|
||||
rank: index + 1,
|
||||
rank_row_key: `${row.user_id ?? 'unknown'}-${index}`,
|
||||
})),
|
||||
[ranking],
|
||||
@@ -740,10 +741,15 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
() => [
|
||||
{
|
||||
title: t('排名'),
|
||||
dataIndex: 'rank',
|
||||
width: 90,
|
||||
render: (_, __, index) => (
|
||||
<span className={`oc-exp-rank oc-exp-rank-${index + 1}`}>
|
||||
{index + 1}
|
||||
render: (rank) => (
|
||||
<span
|
||||
className={
|
||||
rank <= 3 ? `oc-exp-rank oc-exp-rank-${rank}` : 'oc-exp-rank'
|
||||
}
|
||||
>
|
||||
{rank}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
|
||||
+14
-10
@@ -527,10 +527,6 @@ html.dark .org-center .oc-page {
|
||||
--oc-stat-rose: #cf4c69;
|
||||
--oc-stat-blue-bg: #2981ce10;
|
||||
--oc-stat-blue: #2981ce;
|
||||
--oc-rank-1: #e0ad21;
|
||||
--oc-rank-2: #8795a8;
|
||||
--oc-rank-3: #bc7847;
|
||||
--oc-rank-text: #fff;
|
||||
}
|
||||
|
||||
.org-center .oc-page .oc-exp-stats {
|
||||
@@ -631,18 +627,26 @@ html.dark .org-center .oc-page {
|
||||
}
|
||||
|
||||
.org-center .oc-page .oc-exp-rank-1 {
|
||||
background: var(--oc-rank-1);
|
||||
color: var(--oc-rank-text);
|
||||
background-color: var(--brand-selection-bg);
|
||||
color: var(--brand-selection-text);
|
||||
}
|
||||
|
||||
.org-center .oc-page .oc-exp-rank-2 {
|
||||
background: var(--oc-rank-2);
|
||||
color: var(--oc-rank-text);
|
||||
background-color: color-mix(
|
||||
in srgb,
|
||||
var(--brand-selection-bg) 65%,
|
||||
var(--oc-soft)
|
||||
);
|
||||
color: var(--brand-selection-text);
|
||||
}
|
||||
|
||||
.org-center .oc-page .oc-exp-rank-3 {
|
||||
background: var(--oc-rank-3);
|
||||
color: var(--oc-rank-text);
|
||||
background-color: color-mix(
|
||||
in srgb,
|
||||
var(--brand-selection-bg) 35%,
|
||||
var(--oc-soft)
|
||||
);
|
||||
color: var(--brand-selection-text);
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
|
||||
@@ -16,6 +16,7 @@ const DEV_PROXY_TARGET = 'http://134.175.227.134:13000';
|
||||
*/
|
||||
const JSX_IN_JS_RE = /src\/.*\.js$/;
|
||||
const REACT_RUNTIME_RE = /\/node_modules\/(?:react|react-dom|scheduler)\//;
|
||||
const NPM_CONFIG_PATH_RE = /(?:^|[\\/])\.npmrc[. ]*(?:[\\/]|$)/i;
|
||||
|
||||
/**
|
||||
* 让 JSX_IN_JS_RE 命中的 .js 按 JSX 语法解析。
|
||||
@@ -59,6 +60,29 @@ function disableDevImportGlob() {
|
||||
};
|
||||
}
|
||||
|
||||
function blockNpmConfigRequests() {
|
||||
return {
|
||||
name: 'block-npm-config-requests',
|
||||
configureServer(server) {
|
||||
server.middlewares.use((request, response, next) => {
|
||||
let pathname;
|
||||
try {
|
||||
pathname = decodeURIComponent(
|
||||
(request.url ?? '').split(/[?#]/, 1)[0],
|
||||
);
|
||||
} catch {
|
||||
return next();
|
||||
}
|
||||
if (!NPM_CONFIG_PATH_RE.test(pathname)) return next();
|
||||
|
||||
// Stop before Vite tries to load the file or broadcasts an HMR error.
|
||||
response.statusCode = 404;
|
||||
response.end();
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 向 index.html 注入统计脚本。
|
||||
*
|
||||
@@ -123,6 +147,7 @@ export default defineConfig(({ mode, command }) => {
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
blockNpmConfigRequests(),
|
||||
disableDevImportGlob(),
|
||||
jsxInJsPlugin(),
|
||||
react(),
|
||||
@@ -172,6 +197,10 @@ export default defineConfig(({ mode, command }) => {
|
||||
// 监听局域网接口,供本机、后端及测试人员联调。
|
||||
host: '0.0.0.0',
|
||||
port: 5174,
|
||||
fs: {
|
||||
// Setting deny replaces the Vite defaults.
|
||||
deny: ['.env', '.env.*', '*.{crt,pem}', '**/.git/**', '.npmrc'],
|
||||
},
|
||||
warmup: {
|
||||
clientFiles: [
|
||||
'./src/index.jsx',
|
||||
|
||||
Reference in New Issue
Block a user