feat(widget): 优化访客在线轨迹、GeoIP与多站点渠道
CI / Frontend (typecheck + lint + build) (push) Successful in 2m5s
CI / Backend (go vet + test) (push) Failing after 5m20s

This commit is contained in:
yml2213
2026-11-06 18:21:30 +08:00
parent 24fac1bcf1
commit 38d6fc1684
37 changed files with 1071 additions and 123 deletions
+29 -12
View File
@@ -266,16 +266,28 @@ const Settings = () => {
}
}
const ensureWebChannel = async () => {
const addWebChannel = async () => {
const count = channels.filter(channel => channel.type === 'web').length + 1
try {
await createChannel({ type: 'web', name: '网页聊天' })
message.success('已创建网页渠道')
await createChannel({ type: 'web', name: `网站 ${count}` })
message.success('已添加网站渠道')
await loadChannels()
} catch (e) {
message.error(e instanceof Error ? e.message : '创建失败')
}
}
const updateChannelMeta = async (id: number, data: { name?: string; site_domain?: string }) => {
try {
const res = await updateChannel(id, data)
setChannels(prev => prev.map(channel => channel.id === id ? res.data : channel))
message.success('网站渠道已更新')
} catch (e) {
message.error(e instanceof Error ? e.message : '更新失败')
throw e
}
}
const addChannelType = async (t: string) => {
try {
await createChannel({ type: t, name: typeMeta[t].label })
@@ -288,14 +300,18 @@ const Settings = () => {
const missingTypes = Object.keys(typeMeta).filter(t => !channels.some(c => c.type === t))
const panelHeaderAction = activeTab === 'channels' && missingTypes.includes('web') ? (
<Button type="primary" size="small" icon={<PlusOutlined />} className="!h-8" onClick={ensureWebChannel}>
开通网页渠道
</Button>
) : activeTab === 'channels' && missingTypes.length > 0 ? (
<Button type="primary" size="small" icon={<PlusOutlined />} className="!h-8" onClick={() => addChannelType(missingTypes[0])}>
添加新渠道
</Button>
const otherMissingTypes = missingTypes.filter(t => t !== 'web')
const panelHeaderAction = activeTab === 'channels' ? (
<div className="flex items-center gap-2">
{otherMissingTypes.length > 0 && (
<Button size="small" icon={<PlusOutlined />} className="!h-8" onClick={() => addChannelType(otherMissingTypes[0])}>
添加{typeMeta[otherMissingTypes[0]].label}
</Button>
)}
<Button type="primary" size="small" icon={<PlusOutlined />} className="!h-8" onClick={addWebChannel}>
{channels.some(channel => channel.type === 'web') ? '添加网站' : '开通网页渠道'}
</Button>
</div>
) : null
const currentGroup = visibleTabGroups.find(g => g.items.some(i => i.key === activeTab))
@@ -391,8 +407,9 @@ const Settings = () => {
missingTypes={missingTypes}
togglingId={togglingId}
toggleChannel={toggleChannel}
ensureWebChannel={ensureWebChannel}
ensureWebChannel={addWebChannel}
addChannelType={addChannelType}
updateChannelMeta={updateChannelMeta}
/>
)}