This commit is contained in:
@@ -512,4 +512,9 @@ export const api = {
|
||||
getCfSettings: () => request<CfAppSettings>('/api/cloudflare/settings'),
|
||||
saveCfSettings: (payload: CfAppSettingsInput) =>
|
||||
request<CfAppSettings>('/api/cloudflare/settings', { method: 'PUT', body: JSON.stringify(payload) }),
|
||||
testCfToken: (token: string) =>
|
||||
request<{ ok: boolean; message: string }>('/api/cloudflare/settings/test', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ token }),
|
||||
}, 60_000),
|
||||
}
|
||||
|
||||
@@ -133,6 +133,13 @@
|
||||
/>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<div class="cf-code-toolbar">
|
||||
<n-button size="small" :loading="tokenTesting" @click="testToken">测试连接</n-button>
|
||||
<n-button size="small" tag="a" href="https://one.dash.cloudflare.com/" target="_blank" rel="noopener">获取 Token</n-button>
|
||||
</div>
|
||||
<n-alert v-if="tokenTestResult" :type="tokenTestOk ? 'success' : 'error'" :bordered="false" class="cf-mode-alert">
|
||||
{{ tokenTestResult }}
|
||||
</n-alert>
|
||||
<p class="cf-hint">保存后,新建隧道时可以留空 token,直接使用这里的默认值。</p>
|
||||
|
||||
<n-divider title-placement="left">默认网络设置</n-divider>
|
||||
@@ -175,6 +182,9 @@ const binaryLoading = ref(false)
|
||||
const settingsVisible = ref(false)
|
||||
const settingsLoading = ref(false)
|
||||
const settingsSaving = ref(false)
|
||||
const tokenTesting = ref(false)
|
||||
const tokenTestResult = ref('')
|
||||
const tokenTestOk = ref(false)
|
||||
const appSettings = ref<CfAppSettings>({
|
||||
default_token_configured: false,
|
||||
default_token_masked: '',
|
||||
@@ -395,6 +405,7 @@ async function openSettings() {
|
||||
|
||||
async function loadAppSettings() {
|
||||
settingsLoading.value = true
|
||||
tokenTestResult.value = ''
|
||||
try {
|
||||
const result = await api.getCfSettings()
|
||||
appSettings.value = result
|
||||
@@ -406,6 +417,21 @@ async function loadAppSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
async function testToken() {
|
||||
tokenTesting.value = true
|
||||
tokenTestResult.value = ''
|
||||
try {
|
||||
const result = await api.testCfToken(settingsForm.value.token)
|
||||
tokenTestOk.value = true
|
||||
tokenTestResult.value = result.message || '连接成功'
|
||||
} catch (error) {
|
||||
tokenTestOk.value = false
|
||||
tokenTestResult.value = error instanceof Error ? error.message : '连接失败'
|
||||
} finally {
|
||||
tokenTesting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function saveSettings() {
|
||||
settingsSaving.value = true
|
||||
try {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<n-alert type="success" :bordered="false" class="example-alert" title="v1.6.4 示例页面验证标识已生效">
|
||||
<n-alert type="success" :bordered="false" class="example-alert" title="v1.6.5 示例页面验证标识已生效">
|
||||
当前页面由 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.6.4。
|
||||
看到这个新区块,说明前端资源已经从旧版本切换到 v1.6.5。
|
||||
</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.6.4 前端资源已加载" tone="teal">
|
||||
<StatCard label="页面状态" value="已更新" sub="v1.6.5 前端资源已加载" tone="teal">
|
||||
<template #icon><n-icon :component="CheckmarkCircleOutline" /></template>
|
||||
</StatCard>
|
||||
</div>
|
||||
|
||||
<FonuCard title="本次示例页变化" subtitle="用于确认升级后的页面内容确实发生变化">
|
||||
<ul class="example-changes">
|
||||
<li>页面版本提示更新为 v1.6.4。</li>
|
||||
<li>「本次升级验证」区块和页面状态同步更新为 v1.6.4。</li>
|
||||
<li>验证标识更新为 <span class="mono">v1.6.4-example-page</span>。</li>
|
||||
<li>页面版本提示更新为 v1.6.5。</li>
|
||||
<li>「本次升级验证」区块和页面状态同步更新为 v1.6.5。</li>
|
||||
<li>验证标识更新为 <span class="mono">v1.6.5-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.6.4'
|
||||
const verificationMarker = 'v1.6.4-example-page'
|
||||
const verificationRound = 'v1.6.5'
|
||||
const verificationMarker = 'v1.6.5-example-page'
|
||||
|
||||
async function refreshVersion() {
|
||||
refreshing.value = true
|
||||
|
||||
Reference in New Issue
Block a user