Import apps/android/src/screens/bot/ds-bot-settings-subpages.tsx
This commit is contained in:
parent
de3c19aed4
commit
feeab084cc
|
|
@ -89,12 +89,12 @@ export function DsBotConnectorsSubpage({
|
||||||
<View style={{ flex: 1, minWidth: 0 }}>
|
<View style={{ flex: 1, minWidth: 0 }}>
|
||||||
<Text style={styles.rowTitle} numberOfLines={1}>{conn.name}</Text>
|
<Text style={styles.rowTitle} numberOfLines={1}>{conn.name}</Text>
|
||||||
<Text style={styles.rowSub} numberOfLines={1}>
|
<Text style={styles.rowSub} numberOfLines={1}>
|
||||||
{isConnected && toolCount > 0 ? `已连接 · ${toolCount} 个工具` : conn.desc}
|
{isConnected && toolCount > 0 ? s.dsBotSettings.connectedTools(toolCount) : conn.desc}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
accessibilityLabel={`${isConnected ? '已连接' : '连接'} ${conn.name}`}
|
accessibilityLabel={isConnected ? s.dsBotSettings.connectedName(conn.name) : s.dsBotSettings.connectName(conn.name)}
|
||||||
onPress={() => setSelectedConnector(conn)}
|
onPress={() => setSelectedConnector(conn)}
|
||||||
style={({ pressed }) => [
|
style={({ pressed }) => [
|
||||||
styles.connectBtn,
|
styles.connectBtn,
|
||||||
|
|
@ -103,7 +103,7 @@ export function DsBotConnectorsSubpage({
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Text style={[styles.connectBtnText, isConnected && { color: colors.primary }]}>
|
<Text style={[styles.connectBtnText, isConnected && { color: colors.primary }]}>
|
||||||
{isConnected ? '已连接' : '连接'}
|
{isConnected ? s.dsBotSettings.connected : s.dsBotSettings.connect}
|
||||||
</Text>
|
</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -120,7 +120,7 @@ export function DsBotConnectorsSubpage({
|
||||||
<TextInput
|
<TextInput
|
||||||
value={connectorQuery}
|
value={connectorQuery}
|
||||||
onChangeText={setConnectorQuery}
|
onChangeText={setConnectorQuery}
|
||||||
placeholder="搜索连接器"
|
placeholder={s.dsBotSettings.searchConnectors}
|
||||||
placeholderTextColor={colors.muted}
|
placeholderTextColor={colors.muted}
|
||||||
style={styles.searchInput}
|
style={styles.searchInput}
|
||||||
/>
|
/>
|
||||||
|
|
@ -136,7 +136,7 @@ export function DsBotConnectorsSubpage({
|
||||||
style={({ pressed }) => [styles.inlineCreateBtn, pressed && { opacity: 0.75 }]}
|
style={({ pressed }) => [styles.inlineCreateBtn, pressed && { opacity: 0.75 }]}
|
||||||
>
|
>
|
||||||
<Plus size={15} color={colors.ink} />
|
<Plus size={15} color={colors.ink} />
|
||||||
<Text style={styles.inlineCreateBtnText}>自定义</Text>
|
<Text style={styles.inlineCreateBtnText}>{s.dsBotSettings.custom}</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ export function DsBotConnectorsSubpage({
|
||||||
|
|
||||||
{connectorCat === 'all' && !q ? (
|
{connectorCat === 'all' && !q ? (
|
||||||
<>
|
<>
|
||||||
<SectionTitle>推荐</SectionTitle>
|
<SectionTitle>{s.dsBotSettings.recommended}</SectionTitle>
|
||||||
<GroupCard>
|
<GroupCard>
|
||||||
{DS_BOT_RECOMMENDED_CONNECTOR_IDS.map(
|
{DS_BOT_RECOMMENDED_CONNECTOR_IDS.map(
|
||||||
id => DS_BOT_CONNECTOR_CATALOG.find(c => c.id === id)!,
|
id => DS_BOT_CONNECTOR_CATALOG.find(c => c.id === id)!,
|
||||||
|
|
@ -196,7 +196,7 @@ export function DsBotConnectorsSubpage({
|
||||||
return (
|
return (
|
||||||
<GroupCard>
|
<GroupCard>
|
||||||
<View style={styles.emptyCardBox}>
|
<View style={styles.emptyCardBox}>
|
||||||
<Text style={styles.mutedText}>没有匹配的连接器</Text>
|
<Text style={styles.mutedText}>{s.dsBotSettings.noMatchingConnectors}</Text>
|
||||||
</View>
|
</View>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
)
|
)
|
||||||
|
|
@ -222,22 +222,22 @@ export function DsBotConnectorsSubpage({
|
||||||
<GroupRow
|
<GroupRow
|
||||||
first
|
first
|
||||||
icon={Plug}
|
icon={Plug}
|
||||||
label="认证方式"
|
label={s.dsBotSettings.authMethod}
|
||||||
value={
|
value={
|
||||||
selectedConnector.authKind === 'oauth'
|
selectedConnector.authKind === 'oauth'
|
||||||
? 'OAuth 浏览器授权'
|
? s.dsBotSettings.authOauth
|
||||||
: selectedConnector.authKind === 'mail'
|
: selectedConnector.authKind === 'mail'
|
||||||
? 'IMAP / SMTP 授权码'
|
? s.dsBotSettings.authMail
|
||||||
: selectedConnector.authKind === 'key'
|
: selectedConnector.authKind === 'key'
|
||||||
? 'API 密钥'
|
? s.dsBotSettings.authKey
|
||||||
: '免密直连 MCP'
|
: s.dsBotSettings.authNone
|
||||||
}
|
}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
<GroupRow
|
<GroupRow
|
||||||
icon={Monitor}
|
icon={Monitor}
|
||||||
label="配置说明"
|
label={s.dsBotSettings.setupNotes}
|
||||||
detail="为保护第三方账号凭证安全,连接器授权与密钥填写需在电脑端 DS Bot「设置 → 连接器」中操作,连接后所有 Bot 即可在手机端对话中直接调用。"
|
detail={s.dsBotSettings.connectorSetupDetail}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
|
|
@ -252,29 +252,29 @@ export function DsBotConnectorsSubpage({
|
||||||
<ModalSurface onClose={() => setCustomConnectorGuideOpen(false)}>
|
<ModalSurface onClose={() => setCustomConnectorGuideOpen(false)}>
|
||||||
<View style={{ gap: 12 }}>
|
<View style={{ gap: 12 }}>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||||
<Text style={styles.sheetTitle}>添加自定义连接器</Text>
|
<Text style={styles.sheetTitle}>{s.dsBotSettings.addCustomConnector}</Text>
|
||||||
<IconButton label={s.common.close} icon={X} onPress={() => setCustomConnectorGuideOpen(false)} />
|
<IconButton label={s.common.close} icon={X} onPress={() => setCustomConnectorGuideOpen(false)} />
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.rowSub}>
|
<Text style={styles.rowSub}>
|
||||||
支持接入远程 HTTP MCP 地址、本地命令行 MCP 服务,或从 Claude Desktop、Cursor、VS Code 一键导入。
|
{s.dsBotSettings.customConnectorIntro}
|
||||||
</Text>
|
</Text>
|
||||||
<GroupCard>
|
<GroupCard>
|
||||||
<GroupRow
|
<GroupRow
|
||||||
first
|
first
|
||||||
icon={Globe}
|
icon={Globe}
|
||||||
label="远程 MCP 地址"
|
label={s.dsBotSettings.remoteMcp}
|
||||||
detail="支持 HTTP/SSE MCP 端点与自定义 Header 密钥"
|
detail={s.dsBotSettings.remoteMcpDetail}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
<GroupRow
|
<GroupRow
|
||||||
icon={Terminal}
|
icon={Terminal}
|
||||||
label="本地命令行 MCP"
|
label={s.dsBotSettings.localMcp}
|
||||||
detail="支持标准 stdio 协议的本地 MCP 服务进程"
|
detail={s.dsBotSettings.localMcpDetail}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
<Text style={styles.helperNote}>
|
<Text style={styles.helperNote}>
|
||||||
由于自定义 MCP 涉及主机进程与本地配置读取,请在电脑端 DS Bot「设置 → 连接器 → + 自定义」中添加。
|
{s.dsBotSettings.customConnectorNote}
|
||||||
</Text>
|
</Text>
|
||||||
<Button label={s.common.close} variant="secondary" onPress={() => setCustomConnectorGuideOpen(false)} />
|
<Button label={s.common.close} variant="secondary" onPress={() => setCustomConnectorGuideOpen(false)} />
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -301,7 +301,7 @@ export function DsBotImSubpage({
|
||||||
<>
|
<>
|
||||||
{connectedImList.length > 0 && (
|
{connectedImList.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<SectionTitle>{`已连接 · ${connectedImList.length}`}</SectionTitle>
|
<SectionTitle>{s.dsBotSettings.imConnectedTitle(connectedImList.length)}</SectionTitle>
|
||||||
<GroupCard>
|
<GroupCard>
|
||||||
{connectedImList.map((conn, idx) => {
|
{connectedImList.map((conn, idx) => {
|
||||||
const cid = text(conn.id) || `im-${idx}`
|
const cid = text(conn.id) || `im-${idx}`
|
||||||
|
|
@ -316,8 +316,8 @@ export function DsBotImSubpage({
|
||||||
first={idx === 0}
|
first={idx === 0}
|
||||||
icon={MessageSquareShare}
|
icon={MessageSquareShare}
|
||||||
label={text(conn.name) || plat?.name || platId}
|
label={text(conn.name) || plat?.name || platId}
|
||||||
detail={`消息交给 ${botTarget}`}
|
detail={s.dsBotSettings.imRoutesTo(botTarget)}
|
||||||
value={online ? '运行中' : '已配置'}
|
value={online ? s.dsBotSettings.running : s.dsBotSettings.configured}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
@ -326,7 +326,7 @@ export function DsBotImSubpage({
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<SectionTitle>选择平台</SectionTitle>
|
<SectionTitle>{s.dsBotSettings.choosePlatform}</SectionTitle>
|
||||||
<GroupCard>
|
<GroupCard>
|
||||||
{DS_BOT_IM_PLATFORMS.map((plat, idx) => {
|
{DS_BOT_IM_PLATFORMS.map((plat, idx) => {
|
||||||
const configuredCount = connectedImList.filter(b => text(b.platform) === plat.id).length
|
const configuredCount = connectedImList.filter(b => text(b.platform) === plat.id).length
|
||||||
|
|
@ -341,7 +341,7 @@ export function DsBotImSubpage({
|
||||||
</View>
|
</View>
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
accessibilityLabel={`连接 ${plat.name}`}
|
accessibilityLabel={s.dsBotSettings.connectName(plat.name)}
|
||||||
onPress={() => setSelectedImPlatform(plat)}
|
onPress={() => setSelectedImPlatform(plat)}
|
||||||
style={({ pressed }) => [
|
style={({ pressed }) => [
|
||||||
styles.connectBtn,
|
styles.connectBtn,
|
||||||
|
|
@ -350,7 +350,7 @@ export function DsBotImSubpage({
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Text style={[styles.connectBtnText, configuredCount > 0 && { color: colors.primary }]}>
|
<Text style={[styles.connectBtnText, configuredCount > 0 && { color: colors.primary }]}>
|
||||||
{configuredCount > 0 ? `已连接 (${configuredCount})` : '连接'}
|
{configuredCount > 0 ? s.dsBotSettings.imConnectedCount(configuredCount) : s.dsBotSettings.connect}
|
||||||
</Text>
|
</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -363,7 +363,7 @@ export function DsBotImSubpage({
|
||||||
<ModalSurface onClose={() => setSelectedImPlatform(null)}>
|
<ModalSurface onClose={() => setSelectedImPlatform(null)}>
|
||||||
<View style={{ gap: 12 }}>
|
<View style={{ gap: 12 }}>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||||
<Text style={styles.sheetTitle}>{`连接 ${selectedImPlatform.name}`}</Text>
|
<Text style={styles.sheetTitle}>{s.dsBotSettings.connectName(selectedImPlatform.name)}</Text>
|
||||||
<IconButton label={s.common.close} icon={X} onPress={() => setSelectedImPlatform(null)} />
|
<IconButton label={s.common.close} icon={X} onPress={() => setSelectedImPlatform(null)} />
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.rowSub}>{selectedImPlatform.sub}</Text>
|
<Text style={styles.rowSub}>{selectedImPlatform.sub}</Text>
|
||||||
|
|
@ -371,14 +371,14 @@ export function DsBotImSubpage({
|
||||||
<GroupRow
|
<GroupRow
|
||||||
first
|
first
|
||||||
icon={KeyRound}
|
icon={KeyRound}
|
||||||
label="所需凭据"
|
label={s.dsBotSettings.requiredCredentials}
|
||||||
value={selectedImPlatform.fieldsHint}
|
value={selectedImPlatform.fieldsHint}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
<GroupRow
|
<GroupRow
|
||||||
icon={Monitor}
|
icon={Monitor}
|
||||||
label="接入方式"
|
label={s.dsBotSettings.imSetupMethod}
|
||||||
detail={`请在电脑端 DS Bot「设置 → IM → ${selectedImPlatform.name}」中完成绑定与扫码配对;连接后该平台的私聊和群消息将自动转发给对应 Bot。`}
|
detail={s.dsBotSettings.imSetupDetail(selectedImPlatform.name)}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
|
|
@ -413,7 +413,7 @@ export function DsBotCapabilitiesSubpage({
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Text style={styles.helperNote}>
|
<Text style={styles.helperNote}>
|
||||||
选择目标 Bot,管理其工作区权限预设及可用的内置工具能力。
|
{s.dsBotSettings.capabilitiesNote}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
|
@ -436,12 +436,12 @@ export function DsBotCapabilitiesSubpage({
|
||||||
})}
|
})}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<SectionTitle>工具执行权限</SectionTitle>
|
<SectionTitle>{s.dsBotSettings.sectionToolPermissions}</SectionTitle>
|
||||||
<GroupCard>
|
<GroupCard>
|
||||||
{([
|
{([
|
||||||
{ id: 'default', label: '标准权限(敏感操作需确认)', desc: '读写工作区外文件或执行高风险命令时询问你' },
|
{ id: 'default', label: s.dsBotSettings.permDefault, desc: s.dsBotSettings.permDefaultDetail },
|
||||||
{ id: 'workspace-write', label: '工作区内自动读写', desc: '允许在 Bot 工作文件夹内直接修改文件' },
|
{ id: 'workspace-write', label: s.dsBotSettings.permWorkspaceWrite, desc: s.dsBotSettings.permWorkspaceWriteDetail },
|
||||||
{ id: 'danger-full-access', label: '完全权限(自动批准)', desc: '无需每次询问直接执行终端与文件操作' },
|
{ id: 'danger-full-access', label: s.dsBotSettings.permFullAccess, desc: s.dsBotSettings.permFullAccessDetail },
|
||||||
] as const).map((opt, idx) => {
|
] as const).map((opt, idx) => {
|
||||||
const chosen = currentPerm === opt.id
|
const chosen = currentPerm === opt.id
|
||||||
return (
|
return (
|
||||||
|
|
@ -465,47 +465,47 @@ export function DsBotCapabilitiesSubpage({
|
||||||
})}
|
})}
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
|
|
||||||
<SectionTitle>内置能力模块</SectionTitle>
|
<SectionTitle>{s.dsBotSettings.sectionBuiltinCapabilities}</SectionTitle>
|
||||||
<GroupCard>
|
<GroupCard>
|
||||||
<GroupRow
|
<GroupRow
|
||||||
first
|
first
|
||||||
icon={Folder}
|
icon={Folder}
|
||||||
label="工作区文件与终端"
|
label={s.dsBotSettings.capWorkspace}
|
||||||
detail="读取、编写代码文件,运行构建与终端命令"
|
detail={s.dsBotSettings.capWorkspaceDetail}
|
||||||
value="已启用"
|
value={s.dsBotSettings.enabled}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
<GroupRow
|
<GroupRow
|
||||||
icon={Globe}
|
icon={Globe}
|
||||||
label="网络搜索与浏览器"
|
label={s.dsBotSettings.capWeb}
|
||||||
detail="搜索网页、抓取正文及驱动专属浏览器标签页"
|
detail={s.dsBotSettings.capWebDetail}
|
||||||
value={effectiveState.browser !== false ? '已启用' : '已关闭'}
|
value={effectiveState.browser !== false ? s.dsBotSettings.enabled : s.dsBotSettings.disabled}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
<GroupRow
|
<GroupRow
|
||||||
icon={Users}
|
icon={Users}
|
||||||
label="团队协作与群聊"
|
label={s.dsBotSettings.capTeam}
|
||||||
detail="向其他 Bot 委派子任务、读取对话与群聊协作"
|
detail={s.dsBotSettings.capTeamDetail}
|
||||||
value={targetBot?.private ? '隐私隔离' : '已启用'}
|
value={targetBot?.private ? s.dsBotSettings.privateIsolated : s.dsBotSettings.enabled}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
<GroupRow
|
<GroupRow
|
||||||
icon={CalendarClock}
|
icon={CalendarClock}
|
||||||
label="定时任务、长期记忆与密钥"
|
label={s.dsBotSettings.capMemory}
|
||||||
detail="创建自动化提醒、跨对话记忆与安全使用环境变量密钥"
|
detail={s.dsBotSettings.capMemoryDetail}
|
||||||
value={effectiveState.memory !== false ? '已启用' : '仅任务/密钥'}
|
value={effectiveState.memory !== false ? s.dsBotSettings.enabled : s.dsBotSettings.tasksAndSecretsOnly}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
|
|
||||||
{(effectiveState.capabilities ?? []).length > 0 && (
|
{(effectiveState.capabilities ?? []).length > 0 && (
|
||||||
<>
|
<>
|
||||||
<SectionTitle>已安装的共享能力与技能</SectionTitle>
|
<SectionTitle>{s.dsBotSettings.sectionSharedCapabilities}</SectionTitle>
|
||||||
<GroupCard>
|
<GroupCard>
|
||||||
{(effectiveState.capabilities ?? []).map((cap, idx) => {
|
{(effectiveState.capabilities ?? []).map((cap, idx) => {
|
||||||
const cid = text(cap.id) || `cap-${idx}`
|
const cid = text(cap.id) || `cap-${idx}`
|
||||||
const statusObj = object(effectiveState.capabilityStatuses?.[cid])
|
const statusObj = object(effectiveState.capabilityStatuses?.[cid])
|
||||||
const statusText = text(statusObj.state) || text(cap.kind) || '已就绪'
|
const statusText = text(statusObj.state) || text(cap.kind) || s.dsBotSettings.ready
|
||||||
return (
|
return (
|
||||||
<GroupRow
|
<GroupRow
|
||||||
key={cid}
|
key={cid}
|
||||||
|
|
@ -537,25 +537,25 @@ export function DsBotComputerSubpage({
|
||||||
<GroupRow
|
<GroupRow
|
||||||
first
|
first
|
||||||
icon={Monitor}
|
icon={Monitor}
|
||||||
label="允许 Bot 使用电脑"
|
label={s.dsBotSettings.allowComputerUse}
|
||||||
detail={s.bots.computerDesc}
|
detail={s.bots.computerDesc}
|
||||||
value={effectiveState.computer?.enabled === true ? s.bots.computerIdle : '已关闭'}
|
value={effectiveState.computer?.enabled === true ? s.bots.computerIdle : s.dsBotSettings.disabled}
|
||||||
chevron={false}
|
chevron={false}
|
||||||
/>
|
/>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
|
|
||||||
<SectionTitle>各 Bot 电脑操控等级</SectionTitle>
|
<SectionTitle>{s.dsBotSettings.sectionComputerLevels}</SectionTitle>
|
||||||
<GroupCard>
|
<GroupCard>
|
||||||
{effectiveState.bots.map((bot, idx) => {
|
{effectiveState.bots.map((bot, idx) => {
|
||||||
const rawLevel = text(object(effectiveState.computer?.levels)[bot.id]) || 'off'
|
const rawLevel = text(object(effectiveState.computer?.levels)[bot.id]) || 'off'
|
||||||
const levelLabel =
|
const levelLabel =
|
||||||
rawLevel === 'foreground'
|
rawLevel === 'foreground'
|
||||||
? '可以动前台'
|
? s.dsBotSettings.levelForeground
|
||||||
: rawLevel === 'background'
|
: rawLevel === 'background'
|
||||||
? '后台操作'
|
? s.dsBotSettings.levelBackground
|
||||||
: rawLevel === 'view'
|
: rawLevel === 'view'
|
||||||
? '只看'
|
? s.dsBotSettings.levelView
|
||||||
: '关'
|
: s.dsBotSettings.off
|
||||||
return (
|
return (
|
||||||
<GroupRow
|
<GroupRow
|
||||||
key={bot.id}
|
key={bot.id}
|
||||||
|
|
@ -570,7 +570,7 @@ export function DsBotComputerSubpage({
|
||||||
})}
|
})}
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
<Text style={styles.helperNote}>
|
<Text style={styles.helperNote}>
|
||||||
电脑操控开关、系统辅助功能与屏幕录制授权仅限在电脑端 DS Bot 窗口内开启或撤销。
|
{s.dsBotSettings.computerNote}
|
||||||
</Text>
|
</Text>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
@ -604,14 +604,8 @@ export function DsBotUsageSubpage({
|
||||||
showsHorizontalScrollIndicator={false}
|
showsHorizontalScrollIndicator={false}
|
||||||
contentContainerStyle={{ gap: 8 }}
|
contentContainerStyle={{ gap: 8 }}
|
||||||
>
|
>
|
||||||
{([
|
{(['24h', '7d', '30d', '12w', '12m', 'all'] as const).map(id => {
|
||||||
['24h', '24 小时'],
|
const label = s.dsBotSettings.ranges[id]
|
||||||
['7d', '7 天'],
|
|
||||||
['30d', '30 天'],
|
|
||||||
['12w', '12 周'],
|
|
||||||
['12m', '12 个月'],
|
|
||||||
['all', '全部用量'],
|
|
||||||
] as const).map(([id, label]) => {
|
|
||||||
const on = usageRange === id
|
const on = usageRange === id
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
|
|
@ -629,7 +623,7 @@ export function DsBotUsageSubpage({
|
||||||
<GroupCard>
|
<GroupCard>
|
||||||
<View style={styles.loadingCardRow}>
|
<View style={styles.loadingCardRow}>
|
||||||
<ActivityIndicator size="small" color={colors.primary} />
|
<ActivityIndicator size="small" color={colors.primary} />
|
||||||
<Text style={styles.mutedText}>正在读取聊天记录…</Text>
|
<Text style={styles.mutedText}>{s.dsBotSettings.loadingUsage}</Text>
|
||||||
</View>
|
</View>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -637,37 +631,37 @@ export function DsBotUsageSubpage({
|
||||||
<View style={styles.kpiGrid}>
|
<View style={styles.kpiGrid}>
|
||||||
<GroupCard style={styles.kpiCard}>
|
<GroupCard style={styles.kpiCard}>
|
||||||
<Text style={styles.kpiLabel}>
|
<Text style={styles.kpiLabel}>
|
||||||
{usageRange === 'all' ? '全部用量 · Token' : `最近 ${usageView.rangeLabel} · Token`}
|
{usageRange === 'all' ? s.dsBotSettings.allUsageTokens : s.dsBotSettings.recentTokens(usageView.rangeLabel)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={styles.kpiValue}>{formatCompactTokens(usageView.current.tokens)}</Text>
|
<Text style={styles.kpiValue}>{formatCompactTokens(usageView.current.tokens)}</Text>
|
||||||
<Text style={styles.kpiSub} numberOfLines={1}>
|
<Text style={styles.kpiSub} numberOfLines={1}>
|
||||||
{`输入 ${formatCompactTokens(usageView.current.input + usageView.current.cacheRead + usageView.current.cacheWrite)} · 输出 ${formatCompactTokens(usageView.current.output)}`}
|
{s.dsBotSettings.inputOutput(formatCompactTokens(usageView.current.input + usageView.current.cacheRead + usageView.current.cacheWrite), formatCompactTokens(usageView.current.output))}
|
||||||
</Text>
|
</Text>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
|
|
||||||
<GroupCard style={styles.kpiCard}>
|
<GroupCard style={styles.kpiCard}>
|
||||||
<Text style={styles.kpiLabel}>缓存命中率</Text>
|
<Text style={styles.kpiLabel}>{s.dsBotSettings.cacheHitRate}</Text>
|
||||||
<Text style={styles.kpiValue}>{`${usageView.current.hitRate}%`}</Text>
|
<Text style={styles.kpiValue}>{`${usageView.current.hitRate}%`}</Text>
|
||||||
<Text style={styles.kpiSub} numberOfLines={1}>
|
<Text style={styles.kpiSub} numberOfLines={1}>
|
||||||
{`缓存命中 ${formatCompactTokens(usageView.current.cacheRead)} · 输入 ${formatCompactTokens(usageView.current.input)}`}
|
{s.dsBotSettings.cacheHitInput(formatCompactTokens(usageView.current.cacheRead), formatCompactTokens(usageView.current.input))}
|
||||||
</Text>
|
</Text>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
|
|
||||||
<GroupCard style={styles.kpiCard}>
|
<GroupCard style={styles.kpiCard}>
|
||||||
<Text style={styles.kpiLabel}>输出</Text>
|
<Text style={styles.kpiLabel}>{s.dsBotSettings.output}</Text>
|
||||||
<Text style={styles.kpiValue}>{formatCompactTokens(usageView.current.output)}</Text>
|
<Text style={styles.kpiValue}>{formatCompactTokens(usageView.current.output)}</Text>
|
||||||
<Text style={styles.kpiSub} numberOfLines={1}>
|
<Text style={styles.kpiSub} numberOfLines={1}>
|
||||||
{usageView.current.tokens > 0
|
{usageView.current.tokens > 0
|
||||||
? `占最近 ${usageView.rangeLabel}全部用量的 ${Math.round((usageView.current.output / usageView.current.tokens) * 100)}%`
|
? s.dsBotSettings.outputShare(usageView.rangeLabel, Math.round((usageView.current.output / usageView.current.tokens) * 100))
|
||||||
: '暂无输出 Token'}
|
: s.dsBotSettings.noOutputTokens}
|
||||||
</Text>
|
</Text>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
|
|
||||||
<GroupCard style={styles.kpiCard}>
|
<GroupCard style={styles.kpiCard}>
|
||||||
<Text style={styles.kpiLabel}>调用次数</Text>
|
<Text style={styles.kpiLabel}>{s.dsBotSettings.calls}</Text>
|
||||||
<Text style={styles.kpiValue}>{usageView.current.calls.toLocaleString()}</Text>
|
<Text style={styles.kpiValue}>{usageView.current.calls.toLocaleString()}</Text>
|
||||||
<Text style={styles.kpiSub} numberOfLines={1}>
|
<Text style={styles.kpiSub} numberOfLines={1}>
|
||||||
{`${usageView.stepLabel} · 峰值 ${formatCompactTokens(usageView.peakBucketTokens)}`}
|
{s.dsBotSettings.stepPeak(usageView.stepLabel, formatCompactTokens(usageView.peakBucketTokens))}
|
||||||
</Text>
|
</Text>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -675,13 +669,13 @@ export function DsBotUsageSubpage({
|
||||||
<GroupCard style={{ padding: 15, gap: 12 }}>
|
<GroupCard style={{ padding: 15, gap: 12 }}>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'baseline', gap: 8 }}>
|
<View style={{ flexDirection: 'row', alignItems: 'baseline', gap: 8 }}>
|
||||||
<Text style={styles.rowTitle}>Token 走势</Text>
|
<Text style={styles.rowTitle}>{s.dsBotSettings.tokenTrend}</Text>
|
||||||
<Text style={styles.rowSub}>{`${formatCompactTokens(usageView.current.tokens)} Token`}</Text>
|
<Text style={styles.rowSub}>{`${formatCompactTokens(usageView.current.tokens)} Token`}</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.inlinePills}>
|
<View style={styles.inlinePills}>
|
||||||
{([
|
{([
|
||||||
['owner', '按 Bot'],
|
['owner', s.dsBotSettings.byBot],
|
||||||
['model', '按模型'],
|
['model', s.dsBotSettings.byModel],
|
||||||
] as const).map(([id, label]) => {
|
] as const).map(([id, label]) => {
|
||||||
const on = usageChartGroup === id
|
const on = usageChartGroup === id
|
||||||
return (
|
return (
|
||||||
|
|
@ -741,9 +735,9 @@ export function DsBotUsageSubpage({
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
|
|
||||||
<GroupCard style={{ padding: 15, gap: 12 }}>
|
<GroupCard style={{ padding: 15, gap: 12 }}>
|
||||||
<Text style={styles.rowTitle}>按 Bot</Text>
|
<Text style={styles.rowTitle}>{s.dsBotSettings.byBot}</Text>
|
||||||
{usageView.byOwner.length === 0 ? (
|
{usageView.byOwner.length === 0 ? (
|
||||||
<Text style={styles.rowSub}>这段时间没有用量。</Text>
|
<Text style={styles.rowSub}>{s.dsBotSettings.noUsageInRange}</Text>
|
||||||
) : (
|
) : (
|
||||||
usageView.byOwner.map(item => {
|
usageView.byOwner.map(item => {
|
||||||
const matchedBot = effectiveState.bots.find(b => b.id === item.id || b.name === item.name)
|
const matchedBot = effectiveState.bots.find(b => b.id === item.id || b.name === item.name)
|
||||||
|
|
@ -763,7 +757,7 @@ export function DsBotUsageSubpage({
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.rowSub}>
|
<Text style={styles.rowSub}>
|
||||||
{`${item.calls} 次调用 · 输入 ${formatCompactTokens(item.input + item.cacheRead + item.cacheWrite)} · 输出 ${formatCompactTokens(item.output)}`}
|
{s.dsBotSettings.callsInputOutput(item.calls, formatCompactTokens(item.input + item.cacheRead + item.cacheWrite), formatCompactTokens(item.output))}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -782,9 +776,9 @@ export function DsBotUsageSubpage({
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
|
|
||||||
<GroupCard style={{ padding: 15, gap: 12 }}>
|
<GroupCard style={{ padding: 15, gap: 12 }}>
|
||||||
<Text style={styles.rowTitle}>按模型</Text>
|
<Text style={styles.rowTitle}>{s.dsBotSettings.byModel}</Text>
|
||||||
{usageView.byModel.length === 0 ? (
|
{usageView.byModel.length === 0 ? (
|
||||||
<Text style={styles.rowSub}>这段时间没有用量。</Text>
|
<Text style={styles.rowSub}>{s.dsBotSettings.noUsageInRange}</Text>
|
||||||
) : (
|
) : (
|
||||||
usageView.byModel.map(item => (
|
usageView.byModel.map(item => (
|
||||||
<View key={item.key} style={{ gap: 6 }}>
|
<View key={item.key} style={{ gap: 6 }}>
|
||||||
|
|
@ -805,7 +799,7 @@ export function DsBotUsageSubpage({
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.rowSub}>
|
<Text style={styles.rowSub}>
|
||||||
{`${item.calls} 次调用 · 输入 ${formatCompactTokens(item.input + item.cacheRead + item.cacheWrite)} · 输出 ${formatCompactTokens(item.output)}`}
|
{s.dsBotSettings.callsInputOutput(item.calls, formatCompactTokens(item.input + item.cacheRead + item.cacheWrite), formatCompactTokens(item.output))}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -824,8 +818,8 @@ export function DsBotUsageSubpage({
|
||||||
|
|
||||||
<GroupCard style={{ padding: 15, gap: 10 }}>
|
<GroupCard style={{ padding: 15, gap: 10 }}>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||||
<Text style={styles.rowTitle}>活跃度</Text>
|
<Text style={styles.rowTitle}>{s.dsBotSettings.activity}</Text>
|
||||||
<Text style={styles.rowSub}>{`近一年有 ${activityYear.activeDays} 天在用`}</Text>
|
<Text style={styles.rowSub}>{s.dsBotSettings.activeDays(activityYear.activeDays)}</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<ScrollView horizontal showsHorizontalScrollIndicator={false}>
|
<ScrollView horizontal showsHorizontalScrollIndicator={false}>
|
||||||
|
|
@ -856,7 +850,7 @@ export function DsBotUsageSubpage({
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-end', gap: 4 }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-end', gap: 4 }}>
|
||||||
<Text style={styles.chartAxisLabel}>少</Text>
|
<Text style={styles.chartAxisLabel}>{s.dsBotSettings.less}</Text>
|
||||||
{[0, 1, 2, 3, 4].map(lvl => {
|
{[0, 1, 2, 3, 4].map(lvl => {
|
||||||
const cellColors = [
|
const cellColors = [
|
||||||
colors.grouped,
|
colors.grouped,
|
||||||
|
|
@ -872,7 +866,7 @@ export function DsBotUsageSubpage({
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
<Text style={styles.chartAxisLabel}>多</Text>
|
<Text style={styles.chartAxisLabel}>{s.dsBotSettings.more}</Text>
|
||||||
</View>
|
</View>
|
||||||
</GroupCard>
|
</GroupCard>
|
||||||
</>
|
</>
|
||||||
|
|
@ -890,15 +884,15 @@ export function DsBotSecretsSubpage({
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Text style={styles.helperNote}>
|
<Text style={styles.helperNote}>
|
||||||
你的 Bot 请求过的密钥。Bot 永远看不到明文值:它们在 shell 里通过 $DSH_SECRET_NAME 使用,而且发给模型之前,每个值都会被替换成 [secret:NAME]。
|
{s.dsBotSettings.secretsNote}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<SectionTitle>{`密钥 · ${(effectiveState.secrets ?? []).length}`}</SectionTitle>
|
<SectionTitle>{s.dsBotSettings.secretsTitle((effectiveState.secrets ?? []).length)}</SectionTitle>
|
||||||
<GroupCard>
|
<GroupCard>
|
||||||
{(effectiveState.secrets ?? []).length === 0 ? (
|
{(effectiveState.secrets ?? []).length === 0 ? (
|
||||||
<View style={styles.emptyCardBox}>
|
<View style={styles.emptyCardBox}>
|
||||||
<Text style={styles.mutedText}>
|
<Text style={styles.mutedText}>
|
||||||
还没有密钥。Bot 需要时,会在对话里弹出一张卡片,也可在电脑端 DS Bot 设置中添加。
|
{s.dsBotSettings.noSecrets}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -906,8 +900,8 @@ export function DsBotSecretsSubpage({
|
||||||
const name = text(sec.name) || `SECRET_${idx}`
|
const name = text(sec.name) || `SECRET_${idx}`
|
||||||
const scopeText =
|
const scopeText =
|
||||||
Array.isArray(sec.bots) && sec.bots.length > 0
|
Array.isArray(sec.bots) && sec.bots.length > 0
|
||||||
? `仅 ${sec.bots.length} 个 Bot 可用`
|
? s.dsBotSettings.secretBotsOnly(sec.bots.length)
|
||||||
: '所有 Bot 可用'
|
: s.dsBotSettings.secretAllBots
|
||||||
return (
|
return (
|
||||||
<GroupRow
|
<GroupRow
|
||||||
key={name}
|
key={name}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue