FEAT => 本次更新项目为:将 FriendSelection 组件的 selectedOptions 属性改为可选,并在相关组件中进行相应调整,以提升代码的灵活性和可读性。同时,更新导航路径以统一路由结构。

This commit is contained in:
超级老白兔
2025-08-11 11:18:02 +08:00
parent 1d5441b84a
commit 90f29da343
6 changed files with 13 additions and 16 deletions

View File

@@ -8,7 +8,7 @@ export interface FriendSelectionItem {
// 组件属性接口
export interface FriendSelectionProps {
selectedOptions: FriendSelectionItem[];
selectedOptions?: FriendSelectionItem[];
onSelect: (friends: FriendSelectionItem[]) => void;
deviceIds?: string[];
enableDeviceFilter?: boolean;

View File

@@ -7,7 +7,7 @@ import { FriendSelectionProps } from "./data";
import SelectionPopup from "./selectionPopup";
export default function FriendSelection({
selectedOptions,
selectedOptions = [],
onSelect,
deviceIds = [],
enableDeviceFilter = true,
@@ -39,14 +39,14 @@ export default function FriendSelection({
// 获取显示文本
const getDisplayText = () => {
if (selectedOptions.length === 0) return "";
if (!selectedOptions || selectedOptions.length === 0) return "";
return `已选择 ${selectedOptions.length} 个好友`;
};
// 删除已选好友
const handleRemoveFriend = (id: number) => {
if (readonly) return;
onSelect(selectedOptions.filter(v => v.id !== id));
onSelect((selectedOptions || []).filter(v => v.id !== id));
};
// 弹窗确认回调
@@ -80,7 +80,7 @@ export default function FriendSelection({
</div>
)}
{/* 已选好友列表窗口 */}
{showSelectedList && selectedOptions.length > 0 && (
{showSelectedList && (selectedOptions || []).length > 0 && (
<div
className={style.selectedListWindow}
style={{
@@ -92,7 +92,7 @@ export default function FriendSelection({
background: "#fff",
}}
>
{selectedOptions.map(friend => (
{(selectedOptions || []).map(friend => (
<div key={friend.id} className={style.selectedListRow}>
<div className={style.selectedListRowContent}>
<Avatar src={friend.avatar} />
@@ -128,7 +128,7 @@ export default function FriendSelection({
<SelectionPopup
visible={realVisible && !readonly}
onVisibleChange={setRealVisible}
selectedOptions={selectedOptions}
selectedOptions={selectedOptions || []}
onSelect={onSelect}
deviceIds={deviceIds}
enableDeviceFilter={enableDeviceFilter}

View File

@@ -123,7 +123,7 @@ export default function ContentForm() {
await request("/v1/content/library/create", payload, "POST");
Toast.show({ content: "创建成功", position: "top" });
}
navigate("/content");
navigate("/mine/content");
} catch (e: any) {
Toast.show({
content: e?.message || (isEdit ? "保存失败" : "创建失败"),

View File

@@ -128,7 +128,7 @@ const ContentLibraryList: React.FC = () => {
}, [fetchLibraries]);
const handleCreateNew = () => {
navigate("/content/new");
navigate("/mine/content/new");
};
const handleEdit = (id: string) => {

View File

@@ -123,7 +123,7 @@ export default function ContentForm() {
await request("/v1/content/library/create", payload, "POST");
Toast.show({ content: "创建成功", position: "top" });
}
navigate("/content");
navigate("/mine/content");
} catch (e: any) {
Toast.show({
content: e?.message || (isEdit ? "保存失败" : "创建失败"),
@@ -195,7 +195,7 @@ export default function ContentForm() {
>
<Tabs.Tab title="选择微信好友" key="friends">
<FriendSelection
selectedFriends={friendsGroupsOptions}
selectedOptions={friendsGroupsOptions}
onSelect={handleFriendsChange}
placeholder="选择微信好友"
/>

View File

@@ -128,7 +128,7 @@ const ContentLibraryList: React.FC = () => {
}, [fetchLibraries]);
const handleCreateNew = () => {
navigate("/content/new");
navigate("/mine/content/new");
};
const handleEdit = (id: string) => {
@@ -171,10 +171,6 @@ const ContentLibraryList: React.FC = () => {
navigate(`/content/materials/${id}`);
};
const handleSearch = () => {
fetchLibraries();
};
const handleRefresh = () => {
fetchLibraries();
};
@@ -191,6 +187,7 @@ const ContentLibraryList: React.FC = () => {
<>
<NavCommon
title="内容库"
backFn={() => navigate("/mine")}
right={
<Button size="small" color="primary" onClick={handleCreateNew}>
<PlusOutlined />