feat(cloudflare): 新增全局托管开关并发布 v1.8.0
CI / verify (push) Canceled after 0s

This commit is contained in:
2026-09-30 11:56:56 +08:00
parent 1434cfd72b
commit 2d0f63517b
17 changed files with 198 additions and 27 deletions
+5
View File
@@ -517,4 +517,9 @@ export const api = {
method: 'POST',
body: JSON.stringify({ account_id: accountId, token, kind }),
}, 60_000),
setCfEnabled: (enabled: boolean) =>
request<CfAppSettings>('/api/cloudflare/enabled', {
method: 'POST',
body: JSON.stringify({ enabled }),
}),
}
+2
View File
@@ -1102,6 +1102,7 @@ export interface CfTunnelPayload {
export interface CfAppSettings {
account_id: string
enabled: boolean
default_token_configured: boolean
default_token_masked: string
api_token_configured: boolean
@@ -1112,6 +1113,7 @@ export interface CfAppSettings {
export interface CfAppSettingsInput {
account_id: string
enabled?: boolean
token: string
api_token: string
mirror: string
+39 -1
View File
@@ -6,6 +6,14 @@
</template>
</PageHeader>
<div class="cf-global" :class="{ 'cf-global--off': !appSettings.enabled }">
<div class="cf-global__text">
<strong>全局托管</strong>
<span>{{ appSettings.enabled ? '已启用:隧道进程由 Fonu 托管,auto_start 的隧道会在应用启动时恢复' : '已停用:所有隧道已停止,应用重启后也不会自动拉起' }}</span>
</div>
<n-switch :value="appSettings.enabled" :loading="globalLoading" @update:value="toggleGlobal" />
</div>
<n-alert v-if="binaryVersion" type="info" :bordered="false" class="cf-alert">
已安装:<span class="mono">{{ binaryVersion }}</span>
</n-alert>
@@ -26,7 +34,7 @@
<div class="cf-row__actions">
<n-button size="small" @click="openDetail(item)">详情</n-button>
<n-button size="small" @click="openEdit(item)">编辑</n-button>
<n-button v-if="item.status !== 'connected' && item.status !== 'starting'" size="small" type="success" @click="startTunnel(item)">启动</n-button>
<n-button v-if="item.status !== 'connected' && item.status !== 'starting'" size="small" type="success" :disabled="!appSettings.enabled" @click="startTunnel(item)">启动</n-button>
<n-button v-else size="small" type="warning" @click="stopTunnel(item)">停止</n-button>
<n-button size="small" @click="restartTunnel(item)">重启</n-button>
<n-popconfirm @positive-click="removeTunnel(item)">
@@ -178,6 +186,7 @@ const candidates = ref<string[]>([])
const loading = ref(false)
const saving = ref(false)
const binaryLoading = ref(false)
const globalLoading = ref(false)
const settingsVisible = ref(false)
const settingsLoading = ref(false)
const settingsSaving = ref(false)
@@ -186,6 +195,7 @@ const tokenTestResult = ref('')
const tokenTestOk = ref(false)
const appSettings = ref<CfAppSettings>({
account_id: '',
enabled: true,
default_token_configured: false,
default_token_masked: '',
api_token_configured: false,
@@ -251,6 +261,20 @@ async function load() {
}
}
async function toggleGlobal(value: boolean) {
globalLoading.value = true
try {
const result = await api.setCfEnabled(value)
appSettings.value = result
message.success(value ? '全局托管已启用' : '全局托管已停用,所有隧道已停止')
await load()
} catch (error) {
message.error(error instanceof Error ? error.message : '切换全局托管失败')
} finally {
globalLoading.value = false
}
}
async function loadBinary() {
try {
const result = await api.getCfBinary()
@@ -496,6 +520,20 @@ useVisibilityPolling(refreshDetail, 3000, { enabled: detailVisible })
</script>
<style scoped>
.cf-global {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--fonu-space-4);
padding: 12px var(--fonu-space-5);
margin-bottom: var(--fonu-space-4);
border: 1px solid var(--fonu-border);
border-radius: var(--fonu-radius-sm);
background: var(--fonu-surface);
}
.cf-global--off { border-color: var(--fonu-warning); background: var(--fonu-bg); }
.cf-global__text { display: grid; gap: 4px; font-size: 13px; }
.cf-global__text span { color: var(--fonu-text-secondary); }
.cf-alert { margin-bottom: var(--fonu-space-4); }
.cf-empty { padding: 24px 0; color: var(--fonu-text-muted); }
.cf-row {
+8 -8
View File
@@ -8,7 +8,7 @@
</template>
</PageHeader>
<n-alert type="success" :bordered="false" class="example-alert" title="v1.7.0 示例页面验证标识已生效">
<n-alert type="success" :bordered="false" class="example-alert" title="v1.8.0 示例页面验证标识已生效">
当前页面由 v{{ version }} 提供,验证标识为 <span class="mono">{{ verificationMarker }}</span>。
如果你是在升级后首次看到这行内容,说明前端构建、镜像重建和服务重启均已成功。
</n-alert>
@@ -19,7 +19,7 @@
<strong class="example-proof__value">{{ verificationRound }}</strong>
</div>
<div class="example-proof__hint">
看到这个新区块,说明前端资源已经从旧版本切换到 v1.7.0。
看到这个新区块,说明前端资源已经从旧版本切换到 v1.8.0。
</div>
</div>
@@ -33,16 +33,16 @@
<StatCard label="本次验证标识" :value="verificationMarker" sub="用于区分升级前后的前端资源" tone="blue" value-small>
<template #icon><n-icon :component="FlashOutline" /></template>
</StatCard>
<StatCard label="页面状态" value="已更新" sub="v1.7.0 前端资源已加载" tone="teal">
<StatCard label="页面状态" value="已更新" sub="v1.8.0 前端资源已加载" tone="teal">
<template #icon><n-icon :component="CheckmarkCircleOutline" /></template>
</StatCard>
</div>
<FonuCard title="本次示例页变化" subtitle="用于确认升级后的页面内容确实发生变化">
<ul class="example-changes">
<li>页面版本提示更新为 v1.7.0。</li>
<li>「本次升级验证」区块和页面状态同步更新为 v1.7.0。</li>
<li>验证标识更新为 <span class="mono">v1.7.0-example-page</span>。</li>
<li>页面版本提示更新为 v1.8.0。</li>
<li>「本次升级验证」区块和页面状态同步更新为 v1.8.0。</li>
<li>验证标识更新为 <span class="mono">v1.8.0-example-page</span>。</li>
</ul>
</FonuCard>
@@ -87,8 +87,8 @@ const message = useMessage()
const version = ref(__APP_VERSION__)
const checkedAt = ref('')
const refreshing = ref(false)
const verificationRound = 'v1.7.0'
const verificationMarker = 'v1.7.0-example-page'
const verificationRound = 'v1.8.0'
const verificationMarker = 'v1.8.0-example-page'
async function refreshVersion() {
refreshing.value = true