feat: 本次提交更新内容如下
暂存一下
This commit is contained in:
@@ -238,11 +238,19 @@ const MomentsSync: React.FC = () => {
|
|||||||
trigger={["click"]}
|
trigger={["click"]}
|
||||||
placement="bottomRight"
|
placement="bottomRight"
|
||||||
>
|
>
|
||||||
<Button
|
<button
|
||||||
type="text"
|
|
||||||
icon={<MoreOutlined />}
|
|
||||||
className={style.moreBtn}
|
className={style.moreBtn}
|
||||||
/>
|
style={{
|
||||||
|
background: "none",
|
||||||
|
border: "none",
|
||||||
|
padding: 0,
|
||||||
|
cursor: "pointer",
|
||||||
|
}}
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label="更多操作"
|
||||||
|
>
|
||||||
|
<MoreOutlined />
|
||||||
|
</button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
.formBg {
|
.formBg {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
.formStepBtnRow{
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 32px;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
.formSteps {
|
.formSteps {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import React, { useState, useEffect, useCallback } from "react";
|
import React, { useState, useEffect, useCallback } from "react";
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { Button, Input, Switch, message, Spin } from "antd";
|
import { Button, Input, Switch, message, Spin } from "antd";
|
||||||
import { ArrowLeftOutlined } from "@ant-design/icons";
|
import { MinusOutlined, PlusOutlined } from "@ant-design/icons";
|
||||||
import { NavBar } from "antd-mobile";
|
|
||||||
|
|
||||||
import Layout from "@/components/Layout/Layout";
|
import Layout from "@/components/Layout/Layout";
|
||||||
import style from "./index.module.scss";
|
import style from "./index.module.scss";
|
||||||
@@ -15,6 +14,7 @@ import {
|
|||||||
} from "./api";
|
} from "./api";
|
||||||
import DeviceSelection from "@/components/DeviceSelection";
|
import DeviceSelection from "@/components/DeviceSelection";
|
||||||
import ContentLibrarySelection from "@/components/ContentLibrarySelection";
|
import ContentLibrarySelection from "@/components/ContentLibrarySelection";
|
||||||
|
import NavCommon from "@/components/NavCommon";
|
||||||
|
|
||||||
const steps = [
|
const steps = [
|
||||||
{ id: 1, title: "基础设置", subtitle: "基础设置" },
|
{ id: 1, title: "基础设置", subtitle: "基础设置" },
|
||||||
@@ -27,10 +27,15 @@ const defaultForm = {
|
|||||||
startTime: "06:00",
|
startTime: "06:00",
|
||||||
endTime: "23:59",
|
endTime: "23:59",
|
||||||
syncCount: 5,
|
syncCount: 5,
|
||||||
accountType: "business" as "business" | "personal",
|
syncInterval: 30,
|
||||||
|
syncType: 1, // 1=业务号 2=人设号
|
||||||
|
accountType: "business" as "business" | "personal", // 仅UI用
|
||||||
enabled: true,
|
enabled: true,
|
||||||
selectedDevices: [] as string[],
|
selectedDevices: [] as string[],
|
||||||
selectedLibraries: [] as string[],
|
selectedLibraries: [] as (string | number)[],
|
||||||
|
contentTypes: ["text", "image", "video"],
|
||||||
|
targetTags: [] as string[],
|
||||||
|
filterKeywords: [] as string[],
|
||||||
};
|
};
|
||||||
|
|
||||||
const NewMomentsSync: React.FC = () => {
|
const NewMomentsSync: React.FC = () => {
|
||||||
@@ -53,10 +58,15 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
startTime: res.timeRange?.start || "06:00",
|
startTime: res.timeRange?.start || "06:00",
|
||||||
endTime: res.timeRange?.end || "23:59",
|
endTime: res.timeRange?.end || "23:59",
|
||||||
syncCount: res.config?.syncCount || res.syncCount || 5,
|
syncCount: res.config?.syncCount || res.syncCount || 5,
|
||||||
|
syncInterval: res.config?.syncInterval || res.syncInterval || 30,
|
||||||
|
syncType: res.accountType === 1 ? 1 : 2,
|
||||||
accountType: res.accountType === 1 ? "business" : "personal",
|
accountType: res.accountType === 1 ? "business" : "personal",
|
||||||
enabled: res.status === 1,
|
enabled: res.status === 1,
|
||||||
selectedDevices: res.config?.devices || [],
|
selectedDevices: res.config?.devices || [],
|
||||||
selectedLibraries: res.config?.contentLibraryNames || [],
|
selectedLibraries: res.config?.contentLibraryNames || [],
|
||||||
|
contentTypes: res.config?.contentTypes || ["text", "image", "video"],
|
||||||
|
targetTags: res.config?.targetTags || [],
|
||||||
|
filterKeywords: res.config?.filterKeywords || [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@@ -79,6 +89,15 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
setFormData((prev) => ({ ...prev, ...data }));
|
setFormData((prev) => ({ ...prev, ...data }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// UI选择账号类型时同步syncType和accountType
|
||||||
|
const handleAccountTypeChange = (type: "business" | "personal") => {
|
||||||
|
setFormData((prev) => ({
|
||||||
|
...prev,
|
||||||
|
accountType: type,
|
||||||
|
syncType: type === "business" ? 1 : 2,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
// 提交
|
// 提交
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!formData.taskName.trim()) {
|
if (!formData.taskName.trim()) {
|
||||||
@@ -98,13 +117,18 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
const params = {
|
const params = {
|
||||||
name: formData.taskName,
|
name: formData.taskName,
|
||||||
devices: formData.selectedDevices,
|
devices: formData.selectedDevices,
|
||||||
contentLibraries: formData.selectedLibraries,
|
contentLibraries: formData.selectedLibraries.map(Number),
|
||||||
|
syncInterval: formData.syncInterval,
|
||||||
syncCount: formData.syncCount,
|
syncCount: formData.syncCount,
|
||||||
|
syncType: formData.syncType, // 账号类型真实传参
|
||||||
|
accountType: formData.accountType === "business" ? 1 : 2, // 也要传
|
||||||
startTime: formData.startTime,
|
startTime: formData.startTime,
|
||||||
endTime: formData.endTime,
|
endTime: formData.endTime,
|
||||||
accountType: formData.accountType === "business" ? 1 : 2,
|
contentTypes: formData.contentTypes,
|
||||||
status: formData.enabled ? 1 : 2,
|
targetTags: formData.targetTags,
|
||||||
|
filterKeywords: formData.filterKeywords,
|
||||||
type: 2,
|
type: 2,
|
||||||
|
status: formData.enabled ? 1 : 2,
|
||||||
};
|
};
|
||||||
if (isEditMode && id) {
|
if (isEditMode && id) {
|
||||||
await updateMomentsSync({ id, ...params });
|
await updateMomentsSync({ id, ...params });
|
||||||
@@ -122,7 +146,7 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 步骤内容
|
// 步骤内容(去除按钮)
|
||||||
const renderStep = () => {
|
const renderStep = () => {
|
||||||
if (currentStep === 0) {
|
if (currentStep === 0) {
|
||||||
return (
|
return (
|
||||||
@@ -166,7 +190,7 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
updateForm({ syncCount: Math.max(1, formData.syncCount - 1) })
|
updateForm({ syncCount: Math.max(1, formData.syncCount - 1) })
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
-
|
<MinusOutlined />
|
||||||
</button>
|
</button>
|
||||||
<span className={style.counterValue}>{formData.syncCount}</span>
|
<span className={style.counterValue}>{formData.syncCount}</span>
|
||||||
<button
|
<button
|
||||||
@@ -175,7 +199,7 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
updateForm({ syncCount: formData.syncCount + 1 })
|
updateForm({ syncCount: formData.syncCount + 1 })
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
+
|
<PlusOutlined />
|
||||||
</button>
|
</button>
|
||||||
<span className={style.counterUnit}>条朋友圈</span>
|
<span className={style.counterUnit}>条朋友圈</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -186,13 +210,13 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
<div className={style.accountTypeRow}>
|
<div className={style.accountTypeRow}>
|
||||||
<button
|
<button
|
||||||
className={`${style.accountTypeBtn} ${formData.accountType === "business" ? style.accountTypeActive : ""}`}
|
className={`${style.accountTypeBtn} ${formData.accountType === "business" ? style.accountTypeActive : ""}`}
|
||||||
onClick={() => updateForm({ accountType: "business" })}
|
onClick={() => handleAccountTypeChange("business")}
|
||||||
>
|
>
|
||||||
业务号
|
业务号
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`${style.accountTypeBtn} ${formData.accountType === "personal" ? style.accountTypeActive : ""}`}
|
className={`${style.accountTypeBtn} ${formData.accountType === "personal" ? style.accountTypeActive : ""}`}
|
||||||
onClick={() => updateForm({ accountType: "personal" })}
|
onClick={() => handleAccountTypeChange("personal")}
|
||||||
>
|
>
|
||||||
人设号
|
人设号
|
||||||
</button>
|
</button>
|
||||||
@@ -209,12 +233,6 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={style.formStepBtnRow}>
|
|
||||||
<Button type="primary" onClick={next} className={style.nextBtn}>
|
|
||||||
下一步
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -231,14 +249,6 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
selectedListMaxHeight={200}
|
selectedListMaxHeight={200}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={style.formStepBtnRow}>
|
|
||||||
<Button onClick={prev} className={style.prevBtn}>
|
|
||||||
上一步
|
|
||||||
</Button>
|
|
||||||
<Button type="primary" onClick={next} className={style.nextBtn}>
|
|
||||||
下一步
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -260,8 +270,46 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 统一底部按钮
|
||||||
|
const renderFooter = () => {
|
||||||
|
if (loading) return null;
|
||||||
|
if (currentStep === 0) {
|
||||||
|
return (
|
||||||
<div className={style.formStepBtnRow}>
|
<div className={style.formStepBtnRow}>
|
||||||
<Button onClick={prev} className={style.prevBtn}>
|
<Button
|
||||||
|
type="primary"
|
||||||
|
disabled={!formData.taskName.trim()}
|
||||||
|
onClick={next}
|
||||||
|
className={style.nextBtn}
|
||||||
|
block
|
||||||
|
>
|
||||||
|
下一步
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (currentStep === 1) {
|
||||||
|
return (
|
||||||
|
<div className={style.formStepBtnRow}>
|
||||||
|
<Button onClick={prev} className={style.prevBtn} block>
|
||||||
|
上一步
|
||||||
|
</Button>
|
||||||
|
<Button type="primary" onClick={next} className={style.nextBtn} block>
|
||||||
|
下一步
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (currentStep === 2) {
|
||||||
|
return (
|
||||||
|
<div className={style.formStepBtnRow}>
|
||||||
|
<Button onClick={prev} className={style.prevBtn} block>
|
||||||
上一步
|
上一步
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
@@ -269,11 +317,11 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
className={style.completeBtn}
|
className={style.completeBtn}
|
||||||
|
block
|
||||||
>
|
>
|
||||||
完成
|
完成
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -282,21 +330,9 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<Layout
|
<Layout
|
||||||
header={
|
header={
|
||||||
<NavBar
|
<NavCommon title={isEditMode ? "编辑朋友圈同步" : "新建朋友圈同步"} />
|
||||||
back={null}
|
|
||||||
style={{ background: "#fff" }}
|
|
||||||
left={
|
|
||||||
<div className="nav-title">
|
|
||||||
<ArrowLeftOutlined
|
|
||||||
twoToneColor="#1677ff"
|
|
||||||
onClick={() => navigate(-1)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{isEditMode ? "编辑朋友圈同步" : "新建朋友圈同步"}
|
|
||||||
</NavBar>
|
|
||||||
}
|
}
|
||||||
|
footer={renderFooter()}
|
||||||
>
|
>
|
||||||
<div className={style.formBg}>
|
<div className={style.formBg}>
|
||||||
<StepIndicator currentStep={currentStep + 1} steps={steps} />
|
<StepIndicator currentStep={currentStep + 1} steps={steps} />
|
||||||
|
|||||||
Reference in New Issue
Block a user