From a339dd898b454c8f5059252e46f3781894e1e752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Fri, 8 Aug 2025 10:10:28 +0800 Subject: [PATCH] =?UTF-8?q?FEAT=20=3D>=20=E6=9C=AC=E6=AC=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=A1=B9=E7=9B=AE=E4=B8=BA=EF=BC=9A=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E9=81=B8=E6=93=87=E6=B8=AC=E8=A9=A6=E7=B5=84=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=92=B0=E5=A2=83=E8=AE=8A=E6=95=B8=EF=BC=8C?= =?UTF-8?q?=E5=84=AA=E5=8C=96=E5=85=A7=E5=AE=B9=E8=A1=A8=E5=96=AE=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=A5=BD=E5=8F=8B=E5=92=8C=E7=BE=A4=E7=B5=84=E9=81=B8?= =?UTF-8?q?=E6=93=87=E9=82=8F=E8=BC=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nkebao/.env.development | 4 +- nkebao/src/components/FriendSelection/data.ts | 7 ++ nkebao/src/components/SelectionTest.tsx | 67 ------------------- .../src/pages/mobile/content/form/index.tsx | 36 ++++++++-- nkebao/src/pages/mobile/test/select.tsx | 42 +++++------- nkebao/src/router/module/other.tsx | 11 --- 6 files changed, 54 insertions(+), 113 deletions(-) create mode 100644 nkebao/src/components/FriendSelection/data.ts delete mode 100644 nkebao/src/components/SelectionTest.tsx delete mode 100644 nkebao/src/router/module/other.tsx diff --git a/nkebao/.env.development b/nkebao/.env.development index 7afdd84c..c008d630 100644 --- a/nkebao/.env.development +++ b/nkebao/.env.development @@ -1,4 +1,4 @@ # 基础环境变量示例 -# VITE_API_BASE_URL=http://www.yishi.com -VITE_API_BASE_URL=https://ckbapi.quwanzhi.com +VITE_API_BASE_URL=http://www.yishi.com +# VITE_API_BASE_URL=https://ckbapi.quwanzhi.com VITE_APP_TITLE=存客宝 diff --git a/nkebao/src/components/FriendSelection/data.ts b/nkebao/src/components/FriendSelection/data.ts new file mode 100644 index 00000000..5a7e2cbd --- /dev/null +++ b/nkebao/src/components/FriendSelection/data.ts @@ -0,0 +1,7 @@ +export interface FriendSelectionItem { + id: number; + wechatId: string; + nickname: string; + avatar: string; + [key: string]: any; +} diff --git a/nkebao/src/components/SelectionTest.tsx b/nkebao/src/components/SelectionTest.tsx deleted file mode 100644 index 08bc8be2..00000000 --- a/nkebao/src/components/SelectionTest.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import React, { useState } from "react"; -import DeviceSelection from "./DeviceSelection"; -import FriendSelection from "./FriendSelection"; -import GroupSelection from "./GroupSelection"; -import { Button, Space } from "antd-mobile"; - -export default function SelectionTest() { - // 设备选择 - const [selectedDevices, setSelectedDevices] = useState([]); - const [deviceDialogOpen, setDeviceDialogOpen] = useState(false); - - // 好友选择 - const [selectedFriends, setSelectedFriends] = useState([]); - const [friendDialogOpen, setFriendDialogOpen] = useState(false); - - // 群组选择 - const [selectedGroups, setSelectedGroups] = useState([]); - const [groupDialogOpen, setGroupDialogOpen] = useState(false); - - return ( -
-

选择弹窗测试

- -
- DeviceSelection(内嵌输入框+弹窗) - -
-
- FriendSelection - - -
-
- GroupSelection - - -
-
-
-
已选设备ID: {selectedDevices.join(", ")}
-
已选好友ID: {selectedFriends.join(", ")}
-
已选群组ID: {selectedGroups.join(", ")}
-
-
- ); -} diff --git a/nkebao/src/pages/mobile/content/form/index.tsx b/nkebao/src/pages/mobile/content/form/index.tsx index 7df91566..1eb91a06 100644 --- a/nkebao/src/pages/mobile/content/form/index.tsx +++ b/nkebao/src/pages/mobile/content/form/index.tsx @@ -9,6 +9,8 @@ import Layout from "@/components/Layout/Layout"; import style from "./index.module.scss"; import request from "@/api/request"; import { getContentLibraryDetail, updateContentLibrary } from "./api"; +import { GroupSelectionItem } from "@/components/GroupSelection/data"; +import { FriendSelectionItem } from "@/components/FriendSelection/data"; const { TextArea } = AntdInput; @@ -27,8 +29,14 @@ export default function ContentForm() { const isEdit = !!id; const [sourceType, setSourceType] = useState<"friends" | "groups">("friends"); const [name, setName] = useState(""); - const [selectedFriends, setSelectedFriends] = useState([]); + const [friendsGroups, setSelectedFriends] = useState([]); + const [friendsGroupsOptions, setSelectedFriendsOptions] = useState< + FriendSelectionItem[] + >([]); const [selectedGroups, setSelectedGroups] = useState([]); + const [selectedGroupsOptions, setSelectedGroupsOptions] = useState< + GroupSelectionItem[] + >([]); const [useAI, setUseAI] = useState(false); const [aiPrompt, setAIPrompt] = useState(""); const [enabled, setEnabled] = useState(true); @@ -52,7 +60,11 @@ export default function ContentForm() { setName(data.name || ""); setSourceType(data.sourceType === 1 ? "friends" : "groups"); setSelectedFriends(data.sourceFriends || []); - setSelectedGroups(data.sourceGroups || []); + setSelectedGroups(data.selectedGroups || []); + setSelectedGroupsOptions(data.selectedGroupsOptions || []); + + setSelectedFriendsOptions(data.sourceFriendsOptions || []); + setKeywordsInclude((data.keywordInclude || []).join(",")); setKeywordsExclude((data.keywordExclude || []).join(",")); setAIPrompt(data.aiPrompt || ""); @@ -87,7 +99,7 @@ export default function ContentForm() { const payload = { name, sourceType: sourceType === "friends" ? 1 : 2, - friends: selectedFriends, + friends: friendsGroups, groups: selectedGroups, groupMembers: {}, keywordInclude: keywordsInclude @@ -122,6 +134,16 @@ export default function ContentForm() { } }; + const handleGroupsChange = (groups: GroupSelectionItem[]) => { + setSelectedGroups(groups.map(g => g.id.toString())); + setSelectedGroupsOptions(groups); + }; + + const handleFriendsChange = (friends: FriendSelectionItem[]) => { + setSelectedFriends(friends.map(f => f.id.toString())); + setSelectedFriendsOptions(friends); + }; + return ( } @@ -173,15 +195,15 @@ export default function ContentForm() { > diff --git a/nkebao/src/pages/mobile/test/select.tsx b/nkebao/src/pages/mobile/test/select.tsx index 1b6ae862..3665a917 100644 --- a/nkebao/src/pages/mobile/test/select.tsx +++ b/nkebao/src/pages/mobile/test/select.tsx @@ -10,6 +10,7 @@ import AccountSelection from "@/components/AccountSelection"; import { isDevelopment } from "@/utils/env"; import { GroupSelectionItem } from "@/components/GroupSelection/data"; import { ContentItem } from "@/components/ContentSelection/data"; +import { FriendSelectionItem } from "@/components/FriendSelection/data"; const ComponentTest: React.FC = () => { const [activeTab, setActiveTab] = useState("libraries"); @@ -28,7 +29,9 @@ const ComponentTest: React.FC = () => { const [selectedContent, setSelectedContent] = useState([]); const [selectedAccounts, setSelectedAccounts] = useState([]); - + const [selectedFriendsOptions, setSelectedFriendsOptions] = useState< + FriendSelectionItem[] + >([]); return ( }>
@@ -41,6 +44,18 @@ const ComponentTest: React.FC = () => { )} + +
+

FriendSelection 组件测试

+ +
+

ContentSelection 组件测试

@@ -118,31 +133,6 @@ const ComponentTest: React.FC = () => {
- -
-

FriendSelection 组件测试

- -
- 已选好友: {selectedFriends.length} 个 -
- 好友ID: {selectedFriends.join(", ") || "无"} -
-
-
-

AccountSelection 组件测试

diff --git a/nkebao/src/router/module/other.tsx b/nkebao/src/router/module/other.tsx deleted file mode 100644 index faedbee3..00000000 --- a/nkebao/src/router/module/other.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import SelectionTest from "@/components/SelectionTest"; - -const otherRoutes = [ - { - path: "/selection-test", - element: , - auth: false, - }, -]; - -export default otherRoutes;