feat: 本次提交更新内容如下
保存项目构建完成
This commit is contained in:
@@ -357,7 +357,9 @@ export default function NewMomentsSyncTask() {
|
|||||||
>
|
>
|
||||||
<ChevronLeft className="h-6 w-6" />
|
<ChevronLeft className="h-6 w-6" />
|
||||||
</Button>
|
</Button>
|
||||||
<h1 className="ml-2 text-lg font-medium">新建朋友圈同步</h1>
|
<h1 className="ml-2 text-lg font-medium">
|
||||||
|
{isEditMode ? "编辑朋友圈同步" : "新建朋友圈同步"}
|
||||||
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -436,7 +438,7 @@ export default function NewMomentsSyncTask() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
className="flex-1 h-12 bg-blue-500 hover:bg-blue-600 rounded-lg text-white"
|
className="flex-1 h-12 bg-blue-500 hover:bg-blue-600 rounded-lg text-white"
|
||||||
>
|
>
|
||||||
{loading ? "创建中..." : "完成"}
|
{loading ? (isEditMode ? "保存中..." : "创建中...") : "完成"}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
# 基础环境变量示例
|
# 基础环境变量示例
|
||||||
VITE_API_BASE_URL=http://www.yishi.com
|
# VITE_API_BASE_URL=http://www.yishi.com
|
||||||
|
VITE_API_BASE_URL=https://ckbapi.quwanzhi.com
|
||||||
|
|
||||||
VITE_APP_TITLE=Nkebao Base
|
VITE_APP_TITLE=Nkebao Base
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { Input as AntdInput, Switch } from "antd";
|
import { Input as AntdInput, Switch } from "antd";
|
||||||
import { Button, Collapse, Toast, DatePicker, Tabs } from "antd-mobile";
|
import { Button, Collapse, Toast, DatePicker, Tabs } from "antd-mobile";
|
||||||
import NavCommon from "@/components/NavCommon";
|
import NavCommon from "@/components/NavCommon";
|
||||||
@@ -8,6 +8,7 @@ import GroupSelection from "@/components/GroupSelection";
|
|||||||
import Layout from "@/components/Layout/Layout";
|
import Layout from "@/components/Layout/Layout";
|
||||||
import style from "./index.module.scss";
|
import style from "./index.module.scss";
|
||||||
import request from "@/api/request";
|
import request from "@/api/request";
|
||||||
|
import { getContentLibraryDetail, updateContentLibrary } from "./api";
|
||||||
|
|
||||||
const { TextArea } = AntdInput;
|
const { TextArea } = AntdInput;
|
||||||
|
|
||||||
@@ -22,6 +23,8 @@ function formatDate(date: Date | null) {
|
|||||||
|
|
||||||
export default function ContentForm() {
|
export default function ContentForm() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { id } = useParams<{ id?: string }>();
|
||||||
|
const isEdit = !!id;
|
||||||
const [sourceType, setSourceType] = useState<"friends" | "groups">("friends");
|
const [sourceType, setSourceType] = useState<"friends" | "groups">("friends");
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
const [selectedFriends, setSelectedFriends] = useState<string[]>([]);
|
const [selectedFriends, setSelectedFriends] = useState<string[]>([]);
|
||||||
@@ -38,6 +41,40 @@ export default function ContentForm() {
|
|||||||
const [keywordsInclude, setKeywordsInclude] = useState("");
|
const [keywordsInclude, setKeywordsInclude] = useState("");
|
||||||
const [keywordsExclude, setKeywordsExclude] = useState("");
|
const [keywordsExclude, setKeywordsExclude] = useState("");
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
// 编辑模式下拉详情并回填
|
||||||
|
useEffect(() => {
|
||||||
|
if (isEdit && id) {
|
||||||
|
setLoading(true);
|
||||||
|
getContentLibraryDetail(id)
|
||||||
|
.then((data) => {
|
||||||
|
setName(data.name || "");
|
||||||
|
setSourceType(data.sourceType === 1 ? "friends" : "groups");
|
||||||
|
setSelectedFriends(data.sourceFriends || []);
|
||||||
|
setSelectedGroups(data.sourceGroups || []);
|
||||||
|
setKeywordsInclude((data.keywordInclude || []).join(","));
|
||||||
|
setKeywordsExclude((data.keywordExclude || []).join(","));
|
||||||
|
setAIPrompt(data.aiPrompt || "");
|
||||||
|
setUseAI(!!data.aiPrompt);
|
||||||
|
setEnabled(data.status === 1);
|
||||||
|
// 时间范围
|
||||||
|
let start = data.timeStart || data.startTime;
|
||||||
|
let end = data.timeEnd || data.endTime;
|
||||||
|
setDateRange([
|
||||||
|
start ? new Date(start) : null,
|
||||||
|
end ? new Date(end) : null,
|
||||||
|
]);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
Toast.show({
|
||||||
|
content: e?.message || "获取详情失败",
|
||||||
|
position: "top",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}
|
||||||
|
}, [isEdit, id]);
|
||||||
|
|
||||||
const handleSubmit = async (e?: React.FormEvent) => {
|
const handleSubmit = async (e?: React.FormEvent) => {
|
||||||
if (e) e.preventDefault();
|
if (e) e.preventDefault();
|
||||||
@@ -67,11 +104,19 @@ export default function ContentForm() {
|
|||||||
endTime: dateRange[1] ? formatDate(dateRange[1]) : "",
|
endTime: dateRange[1] ? formatDate(dateRange[1]) : "",
|
||||||
status: enabled ? 1 : 0,
|
status: enabled ? 1 : 0,
|
||||||
};
|
};
|
||||||
await request("/v1/content/library/create", payload, "POST");
|
if (isEdit && id) {
|
||||||
Toast.show({ content: "创建成功", position: "top" });
|
await updateContentLibrary({ id, ...payload });
|
||||||
|
Toast.show({ content: "保存成功", position: "top" });
|
||||||
|
} else {
|
||||||
|
await request("/v1/content/library/create", payload, "POST");
|
||||||
|
Toast.show({ content: "创建成功", position: "top" });
|
||||||
|
}
|
||||||
navigate("/content");
|
navigate("/content");
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
Toast.show({ content: e?.message || "创建失败", position: "top" });
|
Toast.show({
|
||||||
|
content: e?.message || (isEdit ? "保存失败" : "创建失败"),
|
||||||
|
position: "top",
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
}
|
}
|
||||||
@@ -79,17 +124,23 @@ export default function ContentForm() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout
|
<Layout
|
||||||
header={<NavCommon title="新建内容库" />}
|
header={<NavCommon title={isEdit ? "编辑内容库" : "新建内容库"} />}
|
||||||
footer={
|
footer={
|
||||||
<div style={{ padding: "16px", backgroundColor: "#fff" }}>
|
<div style={{ padding: "16px", backgroundColor: "#fff" }}>
|
||||||
<Button
|
<Button
|
||||||
block
|
block
|
||||||
color="primary"
|
color="primary"
|
||||||
loading={submitting}
|
loading={submitting || loading}
|
||||||
disabled={submitting}
|
disabled={submitting || loading}
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
>
|
>
|
||||||
创建内容库
|
{isEdit
|
||||||
|
? submitting
|
||||||
|
? "保存中..."
|
||||||
|
: "保存内容库"
|
||||||
|
: submitting
|
||||||
|
? "创建中..."
|
||||||
|
: "创建内容库"}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user