feat: add Yuheng ticket bind, trial SMS off, shared bindings

Ship ticket-exchange and bind/policy for Z13, keep trial binds SMS-free, allow shared company bindings, and align SyncPage plus sync docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
whm
2026-08-05 15:09:49 +08:00
parent f90245db9c
commit d195aa4804
19 changed files with 957 additions and 96 deletions

View File

@@ -25,6 +25,7 @@ import {
} from "@ant-design/icons";
import {
AgentAccount,
BindCode,
Session,
SyncBinding,
SyncChannel,
@@ -38,6 +39,9 @@ import {
listApps,
listSyncBindings,
listSyncChannels,
listBindCodes,
createBindCode,
revokeBindCode,
previewSyncTable,
reconcileSyncChannel,
startSyncChannel,
@@ -163,6 +167,7 @@ export function SyncPage(props: {
const { message } = AntApp.useApp();
const [items, setItems] = useState<SyncChannel[]>([]);
const [bindings, setBindings] = useState<SyncBinding[]>([]);
const [bindCodes, setBindCodes] = useState<BindCode[]>([]);
const [agents, setAgents] = useState<AgentAccount[]>([]);
const [appOptions, setAppOptions] = useState<{ value: string; label: string }[]>([]);
const [loading, setLoading] = useState(false);
@@ -190,15 +195,17 @@ export function SyncPage(props: {
async function refresh() {
setLoading(true);
try {
const [ch, bind, ag, apps] = await Promise.all([
const [ch, bind, ag, apps, codes] = await Promise.all([
listSyncChannels(session),
listSyncBindings(session).catch(() => ({ items: [] as SyncBinding[] })),
listAgents(session).catch(() => ({ items: [] as AgentAccount[] })),
listApps(session).catch(() => ({ items: [] as { slug: string; name: string; status: string }[] })),
listBindCodes(session).catch(() => ({ items: [] as BindCode[] })),
]);
setItems(ch.items || []);
setBindings(bind.items || []);
setAgents(ag.items || []);
setBindCodes(codes.items || []);
setAppOptions(
(apps.items || [])
.filter((a) => a.status === "published" || !a.status)
@@ -581,6 +588,101 @@ export function SyncPage(props: {
]}
/>
<Typography.Title level={5} style={{ marginTop: 28 }}>
</Typography.Title>
<Typography.Paragraph type="secondary" style={{ marginTop: 0 }}>
<Typography.Text code>POST /auth/bind-code/redeem</Typography.Text>{" "}
<Typography.Text code>13531041944</Typography.Text>
</Typography.Paragraph>
<Space style={{ marginBottom: 12 }}>
<Button
type="primary"
disabled={busy}
onClick={async () => {
setBusy(true);
try {
const bc = await createBindCode(session, { max_uses: 1, expires_hours: 168 });
message.success(`已生成绑定码 ${bc.code}`);
setInfo(`绑定码 ${bc.code}(可复制发给用户)`);
await refresh();
} catch (e: any) {
message.error(e.message || String(e));
} finally {
setBusy(false);
}
}}
>
</Button>
</Space>
<Table
rowKey="code"
loading={loading}
dataSource={bindCodes}
pagination={false}
locale={{ emptyText: "暂无绑定码" }}
columns={[
{
title: "绑定码",
dataIndex: "code",
render: (c: string) => <Typography.Text copyable code>{c}</Typography.Text>,
},
{
title: "通道",
dataIndex: "channel_id",
render: (id: string) =>
id ? <Typography.Text copyable={{ text: id }}>{id.slice(0, 8)}</Typography.Text> : "—",
},
{
title: "次数",
render: (_: unknown, r: BindCode) => `${r.used_count}/${r.max_uses}`,
width: 80,
},
{
title: "过期",
dataIndex: "expires_at",
render: (t: string) => (t ? new Date(t).toLocaleString() : "—"),
},
{
title: "状态",
width: 90,
render: (_: unknown, r: BindCode) => {
if (r.revoked) return <Tag color="default"></Tag>;
if (r.used_count >= r.max_uses) return <Tag></Tag>;
if (r.expires_at && new Date(r.expires_at).getTime() < Date.now())
return <Tag color="warning"></Tag>;
return <Tag color="success"></Tag>;
},
},
{
title: "操作",
width: 90,
render: (_: unknown, r: BindCode) => (
<Button
size="small"
danger
disabled={!!r.revoked || busy}
onClick={async () => {
setBusy(true);
try {
await revokeBindCode(session, r.code);
setInfo(`已撤销 ${r.code}`);
await refresh();
} catch (e: any) {
message.error(e.message || String(e));
} finally {
setBusy(false);
}
}}
>
</Button>
),
},
]}
/>
<Typography.Title level={5} style={{ marginTop: 28 }}>
线
</Typography.Title>
@@ -677,6 +779,12 @@ export function SyncPage(props: {
},
},
{ title: "备注", dataIndex: "note", ellipsis: true },
{
title: "共享",
width: 70,
render: (_: unknown, b: SyncBinding) =>
b.shared ? <Tag color="blue"></Tag> : <Typography.Text type="secondary"></Typography.Text>,
},
]}
/>
@@ -684,6 +792,7 @@ export function SyncPage(props: {
LWW 5
= agent push
线 push Binding
Binding <Typography.Text code>shared=true</Typography.Text>
</Typography.Paragraph>
<Modal