feat: 本次提交更新内容如下 存一下进度

This commit is contained in:
笔记本里的永平
2025-07-22 16:54:08 +08:00
parent 3024e0b5e1
commit 345be377af
4 changed files with 271 additions and 133 deletions

View File

@@ -178,7 +178,7 @@ const AutoLike: React.FC = () => {
// 查看任务 // 查看任务
const handleView = (taskId: string) => { const handleView = (taskId: string) => {
navigate(`/workspace/auto-like/detail/${taskId}`); navigate(`/workspace/auto-like/record/${taskId}`);
}; };
// 复制任务 // 复制任务

View File

@@ -4,6 +4,7 @@ import {
PlusOutlined, PlusOutlined,
MinusOutlined, MinusOutlined,
ArrowLeftOutlined, ArrowLeftOutlined,
CheckOutlined,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { Button, Input, Switch, message, Spin } from "antd"; import { Button, Input, Switch, message, Spin } from "antd";
import { NavBar } from "antd-mobile"; import { NavBar } from "antd-mobile";
@@ -15,7 +16,6 @@ import {
} from "./api"; } from "./api";
import { import {
CreateLikeTaskData, CreateLikeTaskData,
UpdateLikeTaskData,
ContentType, ContentType,
} from "@/pages/workspace/auto-like/record/api"; } from "@/pages/workspace/auto-like/record/api";
import style from "./new.module.scss"; import style from "./new.module.scss";
@@ -27,6 +27,12 @@ const contentTypeLabels: Record<ContentType, string> = {
link: "链接", link: "链接",
}; };
const steps = [
{ title: "基础设置", desc: "设置点赞规则" },
{ title: "设备选择", desc: "选择执行设备" },
{ title: "好友设置", desc: "选择目标人群" },
];
const NewAutoLike: React.FC = () => { const NewAutoLike: React.FC = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const { id } = useParams<{ id: string }>(); const { id } = useParams<{ id: string }>();
@@ -122,21 +128,57 @@ const NewAutoLike: React.FC = () => {
} }
}; };
// 步骤器
const renderStepIndicator = () => (
<div className={style.stepIndicatorWrapper}>
<div className={style.stepIndicator}>
{steps.map((s, i) => (
<div
key={s.title}
className={
style.stepItem +
" " +
(currentStep === i + 1
? style.stepActive
: i + 1 < currentStep
? style.stepDone
: "")
}
>
<span className={style.stepNum}>
{i + 1 < currentStep ? <CheckOutlined /> : i + 1}
</span>
<span className={style.stepTitle}>{s.title}</span>
<span className={style.stepDesc}>{s.desc}</span>
</div>
))}
</div>
<div className={style.stepProgressBarBg}>
<div
className={style.stepProgressBar}
style={{
width: `${((currentStep - 1) / (steps.length - 1)) * 100}%`,
}}
></div>
</div>
</div>
);
// 步骤1基础设置 // 步骤1基础设置
const renderBasicSettings = () => ( const renderBasicSettings = () => (
<div className={style["form-section"]}> <div className={style.basicSection}>
<div className={style["form-item"]}> <div className={style.formItem}>
<label className={style["form-label"]}></label> <div className={style.formLabel}></div>
<Input <Input
placeholder="请输入任务名称" placeholder="请输入任务名称"
value={formData.name} value={formData.name}
onChange={(e) => handleUpdateFormData({ name: e.target.value })} onChange={(e) => handleUpdateFormData({ name: e.target.value })}
className={style["form-input"]} className={style.input}
/> />
</div> </div>
<div className={style["form-item"]}> <div className={style.formItem}>
<label className={style["form-label"]}></label> <div className={style.formLabel}></div>
<div className={style["stepper-group"]}> <div className={style.counterRow}>
<Button <Button
icon={<MinusOutlined />} icon={<MinusOutlined />}
onClick={() => onClick={() =>
@@ -144,21 +186,21 @@ const NewAutoLike: React.FC = () => {
interval: Math.max(1, formData.interval - 1), interval: Math.max(1, formData.interval - 1),
}) })
} }
className={style["stepper-btn"]} className={style.counterBtn}
/> />
<span className={style["stepper-value"]}>{formData.interval} </span> <span className={style.counterValue}>{formData.interval} </span>
<Button <Button
icon={<PlusOutlined />} icon={<PlusOutlined />}
onClick={() => onClick={() =>
handleUpdateFormData({ interval: formData.interval + 1 }) handleUpdateFormData({ interval: formData.interval + 1 })
} }
className={style["stepper-btn"]} className={style.counterBtn}
/> />
</div> </div>
</div> </div>
<div className={style["form-item"]}> <div className={style.formItem}>
<label className={style["form-label"]}></label> <div className={style.formLabel}></div>
<div className={style["stepper-group"]}> <div className={style.counterRow}>
<Button <Button
icon={<MinusOutlined />} icon={<MinusOutlined />}
onClick={() => onClick={() =>
@@ -166,48 +208,48 @@ const NewAutoLike: React.FC = () => {
maxLikes: Math.max(1, formData.maxLikes - 10), maxLikes: Math.max(1, formData.maxLikes - 10),
}) })
} }
className={style["stepper-btn"]} className={style.counterBtn}
/> />
<span className={style["stepper-value"]}>{formData.maxLikes} </span> <span className={style.counterValue}>{formData.maxLikes} </span>
<Button <Button
icon={<PlusOutlined />} icon={<PlusOutlined />}
onClick={() => onClick={() =>
handleUpdateFormData({ maxLikes: formData.maxLikes + 10 }) handleUpdateFormData({ maxLikes: formData.maxLikes + 10 })
} }
className={style["stepper-btn"]} className={style.counterBtn}
/> />
</div> </div>
</div> </div>
<div className={style["form-item"]}> <div className={style.formItem}>
<label className={style["form-label"]}></label> <div className={style.formLabel}></div>
<div className={style["time-range"]}> <div className={style.timeRow}>
<Input <Input
type="time" type="time"
value={formData.startTime} value={formData.startTime}
onChange={(e) => onChange={(e) =>
handleUpdateFormData({ startTime: e.target.value }) handleUpdateFormData({ startTime: e.target.value })
} }
className={style["time-input"]} className={style.inputTime}
/> />
<span className={style["time-separator"]}></span> <span className={style.timeTo}></span>
<Input <Input
type="time" type="time"
value={formData.endTime} value={formData.endTime}
onChange={(e) => handleUpdateFormData({ endTime: e.target.value })} onChange={(e) => handleUpdateFormData({ endTime: e.target.value })}
className={style["time-input"]} className={style.inputTime}
/> />
</div> </div>
</div> </div>
<div className={style["form-item"]}> <div className={style.formItem}>
<label className={style["form-label"]}></label> <div className={style.formLabel}></div>
<div className={style["content-types"]}> <div className={style.contentTypes}>
{(["text", "image", "video", "link"] as ContentType[]).map((type) => ( {(["text", "image", "video"] as ContentType[]).map((type) => (
<span <span
key={type} key={type}
className={ className={
formData.contentTypes.includes(type) formData.contentTypes.includes(type)
? style["content-type-tag-active"] ? style.contentTypeTagActive
: style["content-type-tag"] : style.contentTypeTag
} }
onClick={() => { onClick={() => {
const newTypes = formData.contentTypes.includes(type) const newTypes = formData.contentTypes.includes(type)
@@ -221,88 +263,125 @@ const NewAutoLike: React.FC = () => {
))} ))}
</div> </div>
</div> </div>
<div className={style["form-item"]}> <div className={style.formItem}>
<label className={style["form-label"]}></label> <div className={style.switchRow}>
<Switch checked={autoEnabled} onChange={setAutoEnabled} /> <span className={style.switchLabel}></span>
<Switch
checked={formData.enableFriendTags}
onChange={(checked) =>
handleUpdateFormData({ enableFriendTags: checked })
}
className={style.switch}
/>
</div>
{formData.enableFriendTags && (
<div className={style.formItem}>
<div className={style.formLabel}></div>
<Input
placeholder="请输入标签"
value={formData.friendTags}
onChange={(e) =>
handleUpdateFormData({ friendTags: e.target.value })
}
className={style.input}
/>
<div className={style.counterTip}></div>
</div>
)}
</div>
<div className={style.formItem}>
<div className={style.switchRow}>
<span className={style.switchLabel}></span>
<Switch
checked={autoEnabled}
onChange={setAutoEnabled}
className={style.switch}
/>
</div> </div>
<div className={style["form-actions"]}>
<Button
type="primary"
block
onClick={handleNext}
size="large"
className={style["main-btn"]}
>
</Button>
</div> </div>
</div> </div>
); );
// 步骤2设备选择(占位) // 步骤2设备选择
const renderDeviceSelection = () => ( const renderDeviceSelection = () => (
<div className={style["form-section"]}> <div className={style.basicSection}>
<div className={style["placeholder-content"]}> <div className={style.formItem}>
<span className={style["placeholder-icon"]}>[]</span> <div className={style.formLabel}></div>
<div className={style["placeholder-text"]}>...</div> <Input
<div className={style["placeholder-subtext"]}> placeholder="请选择设备"
{formData.devices?.length || 0} value={formData.devices.join(", ")}
readOnly
onClick={() => message.info("这里应弹出设备选择器")}
className={style.input}
/>
{formData.devices.length > 0 && (
<div className={style.selectedTip}>
: {formData.devices.length}
</div> </div>
</div> )}
<div className={style["form-actions"]}>
<Button
onClick={handlePrev}
size="large"
className={style["secondary-btn"]}
>
</Button>
<Button
type="primary"
onClick={handleNext}
size="large"
className={style["main-btn"]}
>
</Button>
</div> </div>
</div> </div>
); );
// 步骤3好友设置(占位) // 步骤3好友设置
const renderFriendSettings = () => ( const renderFriendSettings = () => (
<div className={style["form-section"]}> <div className={style.basicSection}>
<div className={style["placeholder-content"]}> <div className={style.formItem}>
<span className={style["placeholder-icon"]}>[]</span> <div className={style.formLabel}></div>
<div className={style["placeholder-text"]}>...</div> <Input
<div className={style["placeholder-subtext"]}> placeholder="请选择微信好友"
{formData.friends?.length || 0} value={formData.friends.join(", ")}
readOnly
onClick={() => message.info("这里应弹出好友选择器")}
className={style.input}
/>
{formData.friends.length > 0 && (
<div className={style.selectedTip}>
: {formData.friends.length}
</div>
)}
</div> </div>
</div> </div>
<div className={style["form-actions"]}> );
<Button
onClick={handlePrev} // 底部按钮
size="large" const renderFooterBtn = () => (
className={style["secondary-btn"]} <div className={style.footerBtnBar}>
> {currentStep > 1 && (
<Button onClick={handlePrev} className={style.prevBtn}>
</Button> </Button>
)}
{currentStep < 3 && (
<Button
type="primary"
onClick={handleNext}
className={style.nextBtn}
disabled={
(currentStep === 1 && !formData.name.trim()) ||
(currentStep === 2 && formData.devices.length === 0)
}
>
</Button>
)}
{currentStep === 3 && (
<Button <Button
type="primary" type="primary"
onClick={handleComplete} onClick={handleComplete}
size="large"
loading={isSubmitting} loading={isSubmitting}
className={style["main-btn"]} className={style.completeBtn}
> >
{isEditMode ? "更新任务" : "创建任务"} {isEditMode ? "更新任务" : "创建任务"}
</Button> </Button>
</div> )}
</div> </div>
); );
return ( return (
<Layout <Layout
header={ header={
<>
<NavBar <NavBar
back={null} back={null}
style={{ background: "#fff" }} style={{ background: "#fff" }}
@@ -319,24 +398,24 @@ const NewAutoLike: React.FC = () => {
{isEditMode ? "编辑自动点赞" : "新建自动点赞"} {isEditMode ? "编辑自动点赞" : "新建自动点赞"}
</span> </span>
</NavBar> </NavBar>
{renderStepIndicator()}
</>
} }
footer={renderFooterBtn()}
> >
<div className={style["new-page-bg"]}> <div className={style.formBg}>
<div className={style["new-page-center"]}> {isLoading ? (
{/* 步骤器保留新项目的 */} <div className={style.formLoading}>
{/* 你可以在这里插入新项目的步骤器组件 */} <Spin />
<div className={style["form-card"]}> </div>
) : (
<>
{currentStep === 1 && renderBasicSettings()} {currentStep === 1 && renderBasicSettings()}
{currentStep === 2 && renderDeviceSelection()} {currentStep === 2 && renderDeviceSelection()}
{currentStep === 3 && renderFriendSettings()} {currentStep === 3 && renderFriendSettings()}
{isLoading && ( </>
<div className={style["loading"]}>
<Spin />
</div>
)} )}
</div> </div>
</div>
</div>
</Layout> </Layout>
); );
}; };

View File

@@ -1,20 +1,25 @@
.formBg { .formBg {
background: #f8f6f3; background: #f8f6f3;
min-height: 100vh; min-height: 100vh;
padding: 32px 0 32px 0; padding: 0 0 80px 0;
display: flex; position: relative;
flex-direction: column;
align-items: center;
} }
.formSteps { .stepIndicatorWrapper {
position: sticky;
top: 0;
z-index: 20;
background: #f8f6f3;
padding: 16px 0 8px 0;
}
.stepIndicator {
display: flex; display: flex;
justify-content: center; justify-content: center;
margin-bottom: 32px;
gap: 32px; gap: 32px;
} }
.formStepIndicator { .stepItem {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
@@ -22,18 +27,19 @@
font-size: 13px; font-size: 13px;
font-weight: 400; font-weight: 400;
transition: color 0.2s; transition: color 0.2s;
min-width: 80px;
} }
.formStepActive { .stepActive {
color: #188eee; color: #188eee;
font-weight: 600; font-weight: 600;
} }
.formStepDone { .stepDone {
color: #19c37d; color: #19c37d;
} }
.formStepNum { .stepNum {
width: 28px; width: 28px;
height: 28px; height: 28px;
border-radius: 50%; border-radius: 50%;
@@ -46,24 +52,56 @@
margin-bottom: 4px; margin-bottom: 4px;
} }
.formStepActive .formStepNum { .stepActive .stepNum {
background: #188eee; background: #188eee;
color: #fff; color: #fff;
} }
.formStepDone .formStepNum { .stepDone .stepNum {
background: #19c37d; background: #19c37d;
color: #fff; color: #fff;
} }
.formStep { .stepTitle {
background: #fff; font-size: 14px;
border-radius: 10px; margin-top: 2px;
box-shadow: 0 2px 8px rgba(0,0,0,0.06); font-weight: 500;
padding: 32px 24px 24px 24px; }
.stepDesc {
font-size: 12px;
color: #888;
margin-top: 2px;
text-align: center;
}
.stepProgressBarBg {
position: relative;
width: 80%;
height: 4px;
background: #e5e7eb;
border-radius: 2px;
margin: 12px auto 0 auto;
}
.stepProgressBar {
position: absolute;
left: 0;
top: 0;
height: 100%;
background: #188eee;
border-radius: 2px;
transition: width 0.3s;
}
.basicSection {
background: none;
border-radius: 0;
box-shadow: none;
padding: 24px 16px 0 16px;
width: 100%; width: 100%;
max-width: 420px; max-width: 600px;
margin: 0 auto 24px auto; margin: 0 auto;
} }
.formItem { .formItem {
@@ -225,3 +263,24 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.footerBtnBar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 30;
background: #fff;
box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
padding: 16px 24px 24px 24px;
display: flex;
justify-content: center;
gap: 16px;
}
.prevBtn, .nextBtn, .completeBtn {
height: 44px;
border-radius: 8px;
font-size: 15px;
min-width: 120px;
}

View File

@@ -35,7 +35,7 @@ const workspaceRoutes = [
auth: true, auth: true,
}, },
{ {
path: "/workspace/auto-like/:id", path: "/workspace/auto-like/record/:id",
element: <RecordAutoLike />, element: <RecordAutoLike />,
auth: true, auth: true,
}, },