fix:lint
This commit is contained in:
1 parent
00730bb375
commit
7a6d51cc9c
7 files changed
+33
-25
No files matched your search
+1
-1
@@ -497,7 +497,7 @@ const App = () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(result.token);
|
||||
setNotice(`令牌已复制到剪贴板:${result.token}`);
|
||||
} catch (clipboardError) {
|
||||
} catch (_clipboardError) {
|
||||
setNotice(`令牌: ${result.token}`);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
import { type Context, Hono } from "hono";
|
||||
import type { AppEnv } from "../env";
|
||||
import { newApiAuth } from "../middleware/newApiAuth";
|
||||
import {
|
||||
mergeMetadata,
|
||||
modelsToJson,
|
||||
normalizeBaseUrlInput,
|
||||
normalizeChannelInput,
|
||||
toNewApiChannel,
|
||||
withNewApiDefaults,
|
||||
} from "../services/newapi";
|
||||
import {
|
||||
collectUniqueModelIds,
|
||||
extractModelIds,
|
||||
@@ -28,6 +20,14 @@ import {
|
||||
fetchChannelModels,
|
||||
updateChannelTestResult,
|
||||
} from "../services/channel-testing";
|
||||
import {
|
||||
mergeMetadata,
|
||||
modelsToJson,
|
||||
normalizeBaseUrlInput,
|
||||
normalizeChannelInput,
|
||||
toNewApiChannel,
|
||||
withNewApiDefaults,
|
||||
} from "../services/newapi";
|
||||
import { generateToken } from "../utils/crypto";
|
||||
import { safeJsonParse } from "../utils/json";
|
||||
import { newApiFailure, newApiSuccess } from "../utils/newapi-response";
|
||||
@@ -58,7 +58,6 @@ async function handleModelsList(c: Context<AppEnv>) {
|
||||
return newApiSuccess(c, data);
|
||||
}
|
||||
|
||||
|
||||
newapi.get("/", async (c) => {
|
||||
const page = normalizePage(c.req.query("p") ?? c.req.query("page"), 1);
|
||||
const pageSize = normalizePageSize(
|
||||
@@ -291,7 +290,7 @@ newapi.post("/", async (c) => {
|
||||
type: parsed.type ?? 1,
|
||||
group_name: parsed.group_name ?? null,
|
||||
priority: parsed.priority ?? 0,
|
||||
metadata_json: parsed.metadata_json,
|
||||
metadata_json: parsed.metadata_json ?? null,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
});
|
||||
@@ -489,4 +488,3 @@ newapi.get("/:id", async (c) => {
|
||||
});
|
||||
|
||||
export default newapi;
|
||||
|
||||
@@ -67,8 +67,10 @@ export async function listChannels(
|
||||
const statement = db.prepare(
|
||||
`SELECT * FROM channels ${whereSql} ${orderSql} ${limitSql}`,
|
||||
);
|
||||
const rows = await bindIfNeeded(statement, [...bindings, ...limitBindings])
|
||||
.all<ChannelRow>();
|
||||
const rows = await bindIfNeeded(statement, [
|
||||
...bindings,
|
||||
...limitBindings,
|
||||
]).all<ChannelRow>();
|
||||
return rows.results ?? [];
|
||||
}
|
||||
|
||||
@@ -80,7 +82,9 @@ export async function countChannels(
|
||||
const statement = db.prepare(
|
||||
`SELECT COUNT(*) as count FROM channels ${whereSql}`,
|
||||
);
|
||||
const row = await bindIfNeeded(statement, bindings).first<{ count: number }>();
|
||||
const row = await bindIfNeeded(statement, bindings).first<{
|
||||
count: number;
|
||||
}>();
|
||||
return Number(row?.count ?? 0);
|
||||
}
|
||||
|
||||
@@ -220,9 +224,6 @@ export async function updateChannel(
|
||||
.run();
|
||||
}
|
||||
|
||||
export async function deleteChannel(
|
||||
db: D1Database,
|
||||
id: string,
|
||||
): Promise<void> {
|
||||
export async function deleteChannel(db: D1Database, id: string): Promise<void> {
|
||||
await db.prepare("DELETE FROM channels WHERE id = ?").bind(id).run();
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { D1Database } from "@cloudflare/workers-types";
|
||||
import { nowIso } from "../utils/time";
|
||||
import { normalizeBaseUrl } from "../utils/url";
|
||||
import { normalizeModelsInput, modelsToJson } from "./channel-models";
|
||||
import { modelsToJson, normalizeModelsInput } from "./channel-models";
|
||||
|
||||
export type ChannelTestResult = {
|
||||
ok: boolean;
|
||||
@@ -52,14 +52,17 @@ export async function updateChannelTestResult(
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const status = result.ok ? "active" : "error";
|
||||
const modelsJson =
|
||||
result.modelsJson ?? (result.models ? modelsToJson(result.models) : undefined);
|
||||
result.modelsJson ??
|
||||
(result.models ? modelsToJson(result.models) : undefined);
|
||||
const sql = modelsJson
|
||||
? "UPDATE channels SET status = ?, models_json = ?, test_time = ?, response_time_ms = ?, updated_at = ? WHERE id = ?"
|
||||
: "UPDATE channels SET status = ?, test_time = ?, response_time_ms = ?, updated_at = ? WHERE id = ?";
|
||||
|
||||
const stmt = db.prepare(sql);
|
||||
if (modelsJson) {
|
||||
await stmt.bind(status, modelsJson, now, result.elapsed, nowIso(), id).run();
|
||||
await stmt
|
||||
.bind(status, modelsJson, now, result.elapsed, nowIso(), id)
|
||||
.run();
|
||||
} else {
|
||||
await stmt.bind(status, now, result.elapsed, nowIso(), id).run();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { ChannelRecord } from "./channel-types";
|
||||
import { extractModels } from "./channel-models";
|
||||
import type { ChannelRecord } from "./channel-types";
|
||||
|
||||
export type { ChannelRecord } from "./channel-types";
|
||||
export type { ModelEntry } from "./channel-models";
|
||||
export type { ChannelRecord } from "./channel-types";
|
||||
export { extractModels };
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { safeJsonParse } from "../utils/json";
|
||||
import { normalizeBaseUrl } from "../utils/url";
|
||||
import type { ChannelRow } from "./channel-types";
|
||||
import {
|
||||
extractModelIds,
|
||||
modelsToJson,
|
||||
normalizeModelsInput,
|
||||
} from "./channel-models";
|
||||
import { toInternalStatus, toNewApiStatus } from "./channel-status";
|
||||
import type { ChannelRow } from "./channel-types";
|
||||
|
||||
export { extractModelIds, modelsToJson, normalizeModelsInput };
|
||||
export { toInternalStatus, toNewApiStatus };
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
## [Unreleased]
|
||||
|
||||
### 微调
|
||||
- **[admin-ui]**: 处理剪贴板异常时忽略未使用的错误变量
|
||||
- 类型: 微调(无方案包)
|
||||
- 文件: apps/ui/src/App.tsx:500
|
||||
- **[worker]**: 创建渠道时 metadata_json 为空则写入 null 以满足类型约束
|
||||
- 类型: 微调(无方案包)
|
||||
- 文件: apps/worker/src/routes/newapiChannels.ts:293
|
||||
- **[admin-ui]**: 令牌查看自动复制并提示
|
||||
- 类型: 微调(无方案包)
|
||||
- 文件: apps/ui/src/App.tsx:440-455
|
||||
|
||||
Reference in new issue
Block a user