fix(cloudflare): 测试连接使用当前输入的 Account ID 并发布 v1.6.9

This commit is contained in:
2026-09-28 18:30:34 +08:00
parent 8f78aad19b
commit af07ebd462
11 changed files with 50 additions and 27 deletions
+14
View File
@@ -2,6 +2,20 @@
All notable changes to this project will be documented in this file.
## [v1.6.9] - 2026-09-28
### 修复
- **测试连接未使用当前输入的 Account ID**:测试连接原先只读取数据库中已保存的 Account ID,未保存直接点测试会误报「请先填写 Account ID」。现在前端会把输入框里的 Account ID 与 API Token 一起提交,后端优先使用输入值,留空时才回退到已保存配置
### 变更
- 版本号提升到 1.6.9;`AgentVersion` 保持 **0.14.1**
### 测试
- `go test ./...`、`go vet ./...`、`npm run typecheck`、`npm test`、`npm run build` 通过
## [v1.6.8] - 2026-09-28
### 变更
+1 -1
View File
@@ -1 +1 @@
1.6.8
1.6.9
+1 -1
View File
@@ -1,7 +1,7 @@
# Fonu 文档索引
> 维护约定:新增方案 / 审查文档时在下方登记;方案落地后在「状态」列标注实施结果,并给已被推翻的描述加时效说明。
> 最近更新:2026-09-28(v1.6.8)
> 最近更新:2026-09-28(v1.6.9)
## 方案与设计(本目录)
+4 -4
View File
@@ -238,16 +238,16 @@ FONU_VERSION=<旧版本> docker compose up -d --no-deps --force-recreate fonu
## 10. 在线升级验证
示例页面用于验证升级结果。v1.6.8 的验证流程:
示例页面用于验证升级结果。v1.6.9 的验证流程:
1. 确认当前线上实例为 v1.3.0,且 `fonu-updater` sidecar 已运行。
2. 确认远端 `main` 分支的 `VERSION` 为 `1.6.8`。
2. 确认远端 `main` 分支的 `VERSION` 为 `1.6.9`。
3. 在侧栏看到「一键升级」后点击并确认。
4. 等待升级弹窗显示成功,页面自动刷新。
5. 打开侧栏「示例页面」,确认:
- 页面路由为 `/example`;
- 页面显示的版本为 `1.6.8`;
- 页面显示验证标识 `v1.6.8-example-page`;
- 页面显示的版本为 `1.6.9`;
- 页面显示验证标识 `v1.6.9-example-page`;
- 页面显示独立的「本次升级验证」区块;
- 「升级验证」显示为「通过」。
+4 -3
View File
@@ -191,14 +191,15 @@ func (h *CloudflareHandler) SaveAppSettings(w http.ResponseWriter, r *http.Reque
func (h *CloudflareHandler) TestToken(w http.ResponseWriter, r *http.Request) {
var request struct {
Token string `json:"token"`
Kind string `json:"kind"`
AccountID string `json:"account_id"`
Token string `json:"token"`
Kind string `json:"kind"`
}
if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 1<<20)).Decode(&request); err != nil {
writeError(r, w, http.StatusBadRequest, "请求格式无效")
return
}
message, err := h.svc.TestToken(r.Context(), request.Token, request.Kind)
message, err := h.svc.TestToken(r.Context(), request.AccountID, request.Token, request.Kind)
if err != nil {
writeError(r, w, http.StatusBadGateway, err.Error())
return
+8 -4
View File
@@ -297,12 +297,16 @@ func (s *Service) cloudflareAPI(ctx context.Context) (*CloudflareAPI, error) {
}
// VerifyAPIToken 用 Account ID + API Token 调用 Cloudflare 账号级 tokens/verify 接口。
func (s *Service) VerifyAPIToken(ctx context.Context, input string) (string, error) {
// accountID / input 为空时回退到应用配置中已保存的值。
func (s *Service) VerifyAPIToken(ctx context.Context, accountID, input string) (string, error) {
row, err := s.store.GetSettingsRaw(ctx)
if err != nil {
return "", err
}
accountID := strings.TrimSpace(row.AccountID)
accountID = strings.TrimSpace(accountID)
if accountID == "" {
accountID = strings.TrimSpace(row.AccountID)
}
if accountID == "" {
return "", fmt.Errorf("请先填写 Account ID")
}
@@ -320,8 +324,8 @@ func (s *Service) VerifyAPIToken(ctx context.Context, input string) (string, err
}
// TestToken 验证 Account ID + API Token 是否可用。
func (s *Service) TestToken(ctx context.Context, input, _ string) (string, error) {
return s.VerifyAPIToken(ctx, input)
func (s *Service) TestToken(ctx context.Context, accountID, input, _ string) (string, error) {
return s.VerifyAPIToken(ctx, accountID, input)
}
// attachConfig 从 config.yml 回填域名与回源 service,供编辑弹窗使用。
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "fonu-web",
"version": "1.6.8",
"version": "1.6.9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "fonu-web",
"version": "1.6.8",
"version": "1.6.9",
"dependencies": {
"@codemirror/commands": "^6.11.1",
"@codemirror/lang-javascript": "^6.2.5",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "fonu-web",
"private": true,
"version": "1.6.8",
"version": "1.6.9",
"packageManager": "npm@10.9.4",
"type": "module",
"scripts": {
+2 -2
View File
@@ -512,9 +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, kind: 'tunnel' | 'api') =>
testCfToken: (accountId: string, token: string, kind: 'tunnel' | 'api') =>
request<{ ok: boolean; message: string }>('/api/cloudflare/settings/test', {
method: 'POST',
body: JSON.stringify({ token, kind }),
body: JSON.stringify({ account_id: accountId, token, kind }),
}, 60_000),
}
+5 -1
View File
@@ -416,7 +416,11 @@ async function testToken() {
tokenTesting.value = true
tokenTestResult.value = ''
try {
const result = await api.testCfToken((settingsForm.value.api_token || '').trim(), 'api')
const result = await api.testCfToken(
(settingsForm.value.account_id || '').trim(),
(settingsForm.value.api_token || '').trim(),
'api',
)
tokenTestOk.value = true
tokenTestResult.value = result.message || '连接成功'
} catch (error) {
+8 -8
View File
@@ -8,7 +8,7 @@
</template>
</PageHeader>
<n-alert type="success" :bordered="false" class="example-alert" title="v1.6.8 示例页面验证标识已生效">
<n-alert type="success" :bordered="false" class="example-alert" title="v1.6.9 示例页面验证标识已生效">
当前页面由 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.8。
看到这个新区块,说明前端资源已经从旧版本切换到 v1.6.9。
</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.8 前端资源已加载" tone="teal">
<StatCard label="页面状态" value="已更新" sub="v1.6.9 前端资源已加载" tone="teal">
<template #icon><n-icon :component="CheckmarkCircleOutline" /></template>
</StatCard>
</div>
<FonuCard title="本次示例页变化" subtitle="用于确认升级后的页面内容确实发生变化">
<ul class="example-changes">
<li>页面版本提示更新为 v1.6.8。</li>
<li>「本次升级验证」区块和页面状态同步更新为 v1.6.8。</li>
<li>验证标识更新为 <span class="mono">v1.6.8-example-page</span>。</li>
<li>页面版本提示更新为 v1.6.9。</li>
<li>「本次升级验证」区块和页面状态同步更新为 v1.6.9。</li>
<li>验证标识更新为 <span class="mono">v1.6.9-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.8'
const verificationMarker = 'v1.6.8-example-page'
const verificationRound = 'v1.6.9'
const verificationMarker = 'v1.6.9-example-page'
async function refreshVersion() {
refreshing.value = true