From 1be407d34ef8b6299b1fea4ea9a6781f7e25e741 Mon Sep 17 00:00:00 2001 From: callmeyan Date: Mon, 14 Apr 2025 21:34:46 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=20=E8=AE=A2=E5=8D=95=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/core.scss | 4 +- src/components/scoller/infinite-scroller.tsx | 3 +- src/i18n/translations/en-US.json | 7 +++ src/i18n/translations/zh-CN.json | 7 +++ src/pages/news/components/style.module.scss | 19 ++++++++ src/pages/order/index.tsx | 48 ++++++++++++++------ src/pages/recycle/index.tsx | 6 +-- src/routes/index.tsx | 2 +- src/service/api/order.ts | 5 +- src/service/api/recycle.ts | 7 +-- src/types/api.d.ts | 5 ++ 11 files changed, 83 insertions(+), 30 deletions(-) diff --git a/src/assets/core.scss b/src/assets/core.scss index 8d2cea6..9fd54bc 100644 --- a/src/assets/core.scss +++ b/src/assets/core.scss @@ -263,7 +263,9 @@ } } } - +.w-min-60px{ + min-width: 60px; +} .list-scroller-container { overflow: auto; margin-right: -20px; diff --git a/src/components/scoller/infinite-scroller.tsx b/src/components/scoller/infinite-scroller.tsx index 8fda0c3..716e78b 100644 --- a/src/components/scoller/infinite-scroller.tsx +++ b/src/components/scoller/infinite-scroller.tsx @@ -2,6 +2,7 @@ import React, {CSSProperties, useCallback, useEffect, useImperativeHandle, useRe import {useInViewport, useScroll} from "ahooks"; import { LoadingOutlined } from '@ant-design/icons'; import {Spin} from "antd"; +import {t} from "i18next"; export type InfiniteScrollerRef = { scrollToPosition: (top: number) => void @@ -65,7 +66,7 @@ const InfiniteScroller = React.forwardRef} {props?.pagination && props.pagination.total > props.pagination.limit * props.pagination.page && (props.loadingPlaceholder ||
-
加载中...
+
{t('loading')}
)} {props?.empty && !props.loading && props.pagination?.total == 0 &&
diff --git a/src/i18n/translations/en-US.json b/src/i18n/translations/en-US.json index 4e91cd7..ac8b207 100644 --- a/src/i18n/translations/en-US.json +++ b/src/i18n/translations/en-US.json @@ -38,6 +38,7 @@ "playlist_count": "{{count}} videos in total", "title": "Livestream" }, + "loading": "Loading...", "login": { "code_sending": "Sending...", "invalid_username_or_pwd": "Invalid phone number or code", @@ -149,6 +150,12 @@ "remaining_duration_warning": "Unable to generate videos due to insufficient remaining time?", "text": "Orders" }, + "page": { + "size_10": "10 per page", + "size_20": "20 per page", + "size_30": "30 per page", + "total_item": "{{total}} videos in total" + }, "recycle": { "remove_forever": "Remove Forever", "restore_video": "Restore" diff --git a/src/i18n/translations/zh-CN.json b/src/i18n/translations/zh-CN.json index bc6a2f9..13efc0f 100644 --- a/src/i18n/translations/zh-CN.json +++ b/src/i18n/translations/zh-CN.json @@ -38,6 +38,7 @@ "playlist_count": "当前播放列表共 {{count}} 条", "title": "直播界面" }, + "loading": "加载中...", "login": { "code_sending": "发送中", "invalid_username_or_pwd": "账号或密码错误", @@ -149,6 +150,12 @@ "remaining_duration_warning": "视频生成剩余时长为零,将无法生成视频,请尽快充值额度。", "text": "订单记录" }, + "page": { + "size_10": "10条/页", + "size_20": "20条/页", + "size_30": "30条/页", + "total_item": "共计{{total}}条" + }, "recycle": { "remove_forever": "彻底删除", "restore_video": "还原视频" diff --git a/src/pages/news/components/style.module.scss b/src/pages/news/components/style.module.scss index 14f97c6..60ca092 100644 --- a/src/pages/news/components/style.module.scss +++ b/src/pages/news/components/style.module.scss @@ -96,4 +96,23 @@ } } +} +.orderDataList{ + + :global { + .id{ + @apply pl-0; + width: 120px; + &:after{ + display: none; + } + } + .title { + @apply flex-1 pl-4; + min-width: 100px; + &:after { + display: block; + } + } + } } \ No newline at end of file diff --git a/src/pages/order/index.tsx b/src/pages/order/index.tsx index 2c79144..02a0c36 100644 --- a/src/pages/order/index.tsx +++ b/src/pages/order/index.tsx @@ -5,7 +5,7 @@ import styles from "@/pages/news/components/style.module.scss"; import {formatDurationToTime, formatTime} from "@/util/strings.ts"; import {IconDelete, IconEdit, IconWarningCircle} from "@/components/icons"; -import {Empty, Popconfirm} from "antd"; +import {Empty, Pagination, PaginationProps, Popconfirm} from "antd"; import {useRequest, useSetState} from "ahooks"; import {getList} from "@/service/api/order.ts"; @@ -14,36 +14,38 @@ function OrderIndex() { const {t} = useTranslation() const [params, setParams] = useState({ pagination: {page: 1, limit: 12}, - time_flag: 1, + time_flag: 0, }) - const {data} = useRequest(()=>getList(params),{ - refreshDeps:[params], + const {data} = useRequest(() => getList(params), { + refreshDeps: [params], }) return
{t('order.left_time')}: {formatDurationToTime(data?.remaining_duration)}
} /> -
-
+
+
-
{t('order.list.id')}
+
{t('order.list.id')}
{t('order.list.cover')}
-
{t('order.list.title')}
+
{t('order.list.title')}
{t('order.list.order_time')}
{t('order.list.consume_time')}
{t('order.list.operator')}
-
- {data?.list.length === 0 &&
- -
} +
+ {data?.list.length === 0 &&
+ +
} {data?.list.map((item, i) => { return
-
+
{item.order_id}
@@ -51,7 +53,7 @@ function OrderIndex() {
-
+
{item.title}
@@ -66,6 +68,22 @@ function OrderIndex() {
})} + +
+
{t('page.total_item', {total})}
} + showSizeChanger={{ + options: [ + {value: 10, label: t('page.size_10')}, + {value: 20, label: t('page.size_20')}, + {value: 30, label: t('page.size_30')} + ] + }} + showQuickJumper={true} + hideOnSinglePage={true} + /> +
diff --git a/src/pages/recycle/index.tsx b/src/pages/recycle/index.tsx index 4ee15f1..e96980f 100644 --- a/src/pages/recycle/index.tsx +++ b/src/pages/recycle/index.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useMemo, useRef, useState} from "react"; +import React, {useEffect, useRef, useState} from "react"; import {Checkbox, Modal, Space} from "antd"; import {useRequest, useSetState} from "ahooks"; import {useTranslation} from "react-i18next"; @@ -42,9 +42,9 @@ export default function RecycleIndex() { onSuccess: (data) => { setData(prev => { // 判断页码是否是第1页 - //if (data.pagination.page == 1) return data; + if (data.pagination.page == 1) return data; return { - list: data?.list || [], //[...(prev?.list || []), ...(data?.list || [])], + list: [...(prev?.list || []), ...(data?.list || [])], pagination: data.pagination || { page: 1, limit: DEFAULT_PAGE_LIMIT.limit diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 06fd65f..93e65ba 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -36,7 +36,7 @@ const AppRouter = () => { const initRemainingDuration = () => { getRemainingDuration().then(remain => { - if(remain > 0){ + if(remain <= 0){ Modal.warning({ wrapClassName:'root-modal-confirm', title: t('confirm.title'), diff --git a/src/service/api/order.ts b/src/service/api/order.ts index bba99d6..8689916 100644 --- a/src/service/api/order.ts +++ b/src/service/api/order.ts @@ -5,10 +5,7 @@ type OrderInfoData = DataList & { } export function getList(params: OrderSearchParam) { - return post('/order/list', { - page_num: params.pagination.page || 1, - page_size: params.pagination.limit || 10, - }) + return post('/order/list', params) } diff --git a/src/service/api/recycle.ts b/src/service/api/recycle.ts index 73b1213..60bc596 100644 --- a/src/service/api/recycle.ts +++ b/src/service/api/recycle.ts @@ -1,10 +1,7 @@ import {post} from "@/service/request.ts"; -export function getList(params: VideoSearchParams) { - return post>('/recycle/list', { - page_num: params.pagination.page || 1, - page_size: params.pagination.limit || 10, - }) +export function getList(params: NormalSearchParams) { + return post>('/recycle/list', params) } export function remove(ids: Id[]) { return post('/recycle/remove', {ids}) diff --git a/src/types/api.d.ts b/src/types/api.d.ts index 804ae88..10cd5e0 100644 --- a/src/types/api.d.ts +++ b/src/types/api.d.ts @@ -86,6 +86,11 @@ declare interface ListCrawlerNewsItem extends BasicArticleInfo { // 内部文章关联id internal_article_id: number; } +declare interface NormalSearchParams extends ApiRequestPageParams{ + // 标题 + title?: string; + time_flag?: number; +} declare interface VideoSearchParams extends ApiRequestPageParams{ // 标题 title?: string;