Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
style: 任务界面优化
牛文政9cfe80a2576f
diff --git a/src/components/CronSchedule.tsx b/src/components/CronSchedule.tsxindex 9cfd7e3e..5c6d5c9c 100644--- a/src/components/CronSchedule.tsx+++ b/src/components/CronSchedule.tsx@@ -1,4 +1,4 @@-import { useState } from 'react';+import { useState, useEffect } from 'react';import { Select, Input, Button, message, Form } from 'antd';interface CronScheduleProps {@@ -109,4 +109,32 @@ const CronSchedule: React.FC<CronScheduleProps> = ({ onSubmit }) => {);};-export default CronSchedule;+// 解析组件+const ParseCronSchedule: React.FC<{ cronExpression: string }> = ({+ cronExpression,+}) => {+ const [parsedText, setParsedText] = useState('');++ useEffect(() => {+ const [type, value] = cronExpression.split('-');+ let parsed = '';+ switch (type) {+ case 'day':+ parsed = `天:${value}号`;+ break;+ case 'week':+ parsed = `周:${value}`;+ break;+ case 'month':+ parsed = `月:${value}号`;+ break;+ default:+ parsed = '未知类型';+ }+ setParsedText(parsed);+ }, [cronExpression]);++ return <p>{parsedText}</p>;+};++export { CronSchedule, ParseCronSchedule };diff --git a/src/views/reply/components/addAutoRun.tsx b/src/views/reply/components/addAutoRun.tsxindex c3e80d55..c25a150b 100644--- a/src/views/reply/components/addAutoRun.tsx+++ b/src/views/reply/components/addAutoRun.tsx@@ -8,7 +8,7 @@import { ipcCreateAutoRunOfReply } from '@/icp/reply';import { Modal } from 'antd';import { forwardRef, useImperativeHandle, useState } from 'react';-import CronSchedule from '@/components/CronSchedule';+import { CronSchedule } from '@/components/CronSchedule';export interface AddAutoRunRef {init: (accountId: number, dataId: string) => Promise<void>;@@ -37,7 +37,7 @@ const Com = forwardRef<AddAutoRunRef>((props: any, ref) => {async function handleCron(cron: string) {console.log('生成的定时表达式:----', cron);setCycleType(cron);- const res = await ipcCreateAutoRunOfReply(accountId, dataId, cycleType);+ const res = await ipcCreateAutoRunOfReply(accountId, dataId, cron);console.log('-------- res', res);}diff --git a/src/views/reply/components/autoRunRecord.tsx b/src/views/reply/components/autoRunRecord.tsxindex bb50a3de..98b8098a 100644--- a/src/views/reply/components/autoRunRecord.tsx+++ b/src/views/reply/components/autoRunRecord.tsx@@ -1,6 +1,7 @@import { AutoRun, AutoRunRecord, ipcGetAutoRunRecordList } from '@/icp/autoRun';import { Modal, Table } from 'antd';import React from 'react';+import { ParseCronSchedule } from '@/components/CronSchedule';const { Column } = Table;export interface AutoRunRecordRef {@@ -80,7 +81,13 @@ const Com = React.forwardRef<AutoRunRecordRef>((props: any, ref) => {<Column title="任务DI" dataIndex="autoRunId" key="autoRunId" /><Column title="状态" dataIndex="status" key="status" /><Column title="类型" dataIndex="type" key="type" />- <Column title="触发周期" dataIndex="cycleType" key="cycleType" />+ <Column+ title="触发周期"+ key="cycleType"+ render={(cycleType: string) => (+ <ParseCronSchedule cronExpression={cycleType} />+ )}+ /><Columntitle="创建时间"key="createTime"