Files
cunkebao_v3/nkebao/src/pages/mobile/test/select.tsx

166 lines
6.1 KiB
TypeScript

import React, { useState } from "react";
import { Tabs, Tag } from "antd-mobile";
import Layout from "@/components/Layout/Layout";
import NavCommon from "@/components/NavCommon";
import DeviceSelection from "@/components/DeviceSelection";
import FriendSelection from "@/components/FriendSelection";
import GroupSelection from "@/components/GroupSelection";
import ContentSelection from "@/components/ContentSelection";
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";
import { AccountItem } from "@/components/AccountSelection/data";
const ComponentTest: React.FC = () => {
const [activeTab, setActiveTab] = useState("accounts");
// 设备选择状态
const [selectedDevices, setSelectedDevices] = useState<string[]>([]);
// 群组选择状态
const [selectedGroups, setSelectedGroups] = useState<GroupSelectionItem[]>(
[],
);
// 内容库选择状态
const [selectedContent, setSelectedContent] = useState<ContentItem[]>([]);
const [selectedAccounts, setSelectedAccounts] = useState<AccountItem[]>([]);
const [selectedFriendsOptions, setSelectedFriendsOptions] = useState<
FriendSelectionItem[]
>([]);
return (
<Layout header={<NavCommon title="组件调试" />}>
<div style={{ padding: 16 }}>
{isDevelopment && (
<div style={{ marginBottom: 16, textAlign: "center" }}>
<Tag color="orange" style={{ fontSize: "12px" }}>
-
</Tag>
</div>
)}
<Tabs activeKey={activeTab} onChange={setActiveTab}>
<Tabs.Tab title="好友选择" key="friends">
<div style={{ padding: "16px 0" }}>
<h3 style={{ marginBottom: 16 }}>FriendSelection </h3>
<FriendSelection
selectedOptions={selectedFriendsOptions}
onSelect={setSelectedFriendsOptions}
placeholder="请选择微信好友"
showSelectedList={true}
selectedListMaxHeight={300}
/>
</div>
</Tabs.Tab>
<Tabs.Tab title="内容库选择" key="libraries">
<div style={{ padding: "16px 0" }}>
<h3 style={{ marginBottom: 16 }}>ContentSelection </h3>
<ContentSelection
selectedContent={selectedContent}
onSelect={setSelectedContent}
placeholder="请选择内容库"
showSelectedList={true}
selectedListMaxHeight={300}
/>
<div
style={{
marginTop: 16,
padding: 12,
background: "#f5f5f5",
borderRadius: 8,
}}
>
<strong>:</strong> {selectedContent.length}
<br />
<strong>ID:</strong>{" "}
{selectedContent.map(c => c.id).join(", ") || "无"}
</div>
</div>
</Tabs.Tab>
<Tabs.Tab title="群组选择" key="groups">
<div style={{ padding: "16px 0" }}>
<h3 style={{ marginBottom: 16 }}>GroupSelection </h3>
<GroupSelection
selectedGroups={selectedGroups}
onSelect={setSelectedGroups}
placeholder="请选择微信群组"
showSelectedList={true}
selectedListMaxHeight={300}
/>
<div
style={{
marginTop: 16,
padding: 12,
background: "#f5f5f5",
borderRadius: 8,
}}
>
<strong>:</strong> {selectedGroups.length}
<br />
<strong>ID:</strong>{" "}
{selectedGroups.map(g => g.id).join(", ") || "无"}
</div>
</div>
</Tabs.Tab>
<Tabs.Tab title="设备选择" key="devices">
<div style={{ padding: "16px 0" }}>
<h3 style={{ marginBottom: 16 }}>DeviceSelection </h3>
<DeviceSelection
selectedOptions={selectedDevices}
onSelect={setSelectedDevices}
placeholder="请选择设备"
showSelectedList={true}
selectedListMaxHeight={300}
/>
<div
style={{
marginTop: 16,
padding: 12,
background: "#f5f5f5",
borderRadius: 8,
}}
>
<strong>:</strong> {selectedDevices.length}
<br />
<strong>ID:</strong> {selectedDevices.join(", ") || "无"}
</div>
</div>
</Tabs.Tab>
<Tabs.Tab title="账号选择" key="accounts">
<div style={{ padding: "16px 0" }}>
<h3 style={{ marginBottom: 16 }}>AccountSelection </h3>
<AccountSelection
selectedOptions={selectedAccounts}
onSelect={setSelectedAccounts}
placeholder="请选择账号"
showSelectedList={true}
selectedListMaxHeight={300}
/>
<div
style={{
marginTop: 16,
padding: 12,
background: "#f5f5f5",
borderRadius: 8,
}}
>
<strong>:</strong> {selectedAccounts.length}
<br />
<strong>ID:</strong>{" "}
{selectedAccounts.map(a => a.id).join(", ") || "无"}
</div>
</div>
</Tabs.Tab>
</Tabs>
</div>
</Layout>
);
};
export default ComponentTest;