mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-06 13:44:21 +08:00
feat: add configurable Cursor TAB routing
This commit is contained in:
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "cursor-byok-desktop",
|
||||
"version": "0.1.0-beta.1",
|
||||
"version": "0.1.0-beta.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cursor-byok-desktop",
|
||||
"version": "0.1.0-beta.1",
|
||||
"version": "0.1.0-beta.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@floating-ui/dom": "^1.8.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cursor-byok-desktop",
|
||||
"version": "0.1.0-beta.1",
|
||||
"version": "0.1.0-beta.2",
|
||||
"description": "Cursor BYOK desktop management application",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cursor-byok-desktop"
|
||||
version = "0.1.0-beta.1"
|
||||
version = "0.1.0-beta.2"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Cursor BYOK",
|
||||
"version": "0.1.0-beta.1",
|
||||
"version": "0.1.0-beta.2",
|
||||
"identifier": "dev.cursorbyok.desktop",
|
||||
"build": {
|
||||
"beforeDevCommand": "npm run dev",
|
||||
|
||||
@@ -97,6 +97,13 @@ export interface ProxySettingsInput {
|
||||
password?: string;
|
||||
}
|
||||
|
||||
export type TabMode = "public" | "direct" | "custom";
|
||||
|
||||
export interface TabSettings {
|
||||
mode: TabMode;
|
||||
address: string;
|
||||
}
|
||||
|
||||
export interface OverviewMetrics {
|
||||
llm_calls: number;
|
||||
successful_calls: number;
|
||||
@@ -283,4 +290,6 @@ export const api = {
|
||||
clearStatisticsStorage: () => request<StatisticsStorage>("/settings/storage/statistics", { method: "DELETE" }),
|
||||
proxySettings: () => request<ProxySettings>("/settings/proxy"),
|
||||
setProxySettings: (settings: ProxySettingsInput) => request<ProxySettings>("/settings/proxy", { method: "PUT", body: JSON.stringify(settings) }),
|
||||
tabSettings: () => request<TabSettings>("/settings/tab"),
|
||||
setTabSettings: (settings: TabSettings) => request<TabSettings>("/settings/tab", { method: "PUT", body: JSON.stringify(settings) }),
|
||||
};
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
@use "../../styles/typography" as type;
|
||||
|
||||
.page {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.gate {
|
||||
min-height: 250px;
|
||||
display: flex;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
@use "../../styles/typography" as type;
|
||||
|
||||
.title {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.row {
|
||||
min-height: 62px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
padding: 12px 16px;
|
||||
|
||||
& + & {
|
||||
border-top: 1px solid var(--vscode-sideBar-border);
|
||||
}
|
||||
}
|
||||
|
||||
.description {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
|
||||
small {
|
||||
color: var(--vscode-descriptionForeground);
|
||||
font-size: type.$font-size-xs;
|
||||
}
|
||||
}
|
||||
|
||||
.selectControl,
|
||||
.addressInput {
|
||||
width: min(300px, 44%);
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
@media (max-width: 620px) {
|
||||
.row {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.selectControl,
|
||||
.addressInput {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import cursorIconUrl from "../../assets/icons/cursor.svg";
|
||||
import type { TabMode, TabSettings } from "../../api";
|
||||
import { Button } from "../ui/Button";
|
||||
import { TextInput } from "../ui/FormControls";
|
||||
import { Icon } from "../ui/Icon";
|
||||
import { Select } from "../ui/Select";
|
||||
import { TitledCard } from "../ui/TitledCard";
|
||||
import styles from "./TabSettingsCard.module.scss";
|
||||
|
||||
export function TabSettingsCard({ settings, saving, onChange, onSave }: {
|
||||
settings: TabSettings;
|
||||
saving: boolean;
|
||||
onChange: (settings: TabSettings) => void;
|
||||
onSave: () => void;
|
||||
}) {
|
||||
return <TitledCard
|
||||
title={<div className={styles.title}><Icon src={cursorIconUrl} size="1.1em" /><span>{t("TAB 设置")}</span></div>}
|
||||
action={<Button size="small" variant="primary" disabled={saving} onClick={onSave}>{saving ? t("保存中…") : t("保存")}</Button>}
|
||||
>
|
||||
<div className={styles.row}>
|
||||
<div className={styles.description}>
|
||||
<strong>{t("TAB 选择")}</strong>
|
||||
<small>{t("控制 Cursor TAB 相关接口的连接方式。")}</small>
|
||||
</div>
|
||||
<div className={styles.selectControl}>
|
||||
<Select
|
||||
value={settings.mode}
|
||||
ariaLabel={t("TAB 选择")}
|
||||
options={[
|
||||
{ value: "public", label: t("使用公益服务") },
|
||||
{ value: "direct", label: t("直连") },
|
||||
{ value: "custom", label: t("自定义") },
|
||||
]}
|
||||
onChange={(mode) => onChange({ ...settings, mode: mode as TabMode })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{settings.mode === "custom" && <div className={styles.row}>
|
||||
<div className={styles.description}>
|
||||
<strong>{t("TAB 服务地址")}</strong>
|
||||
<small>{t("原接口路径会追加到此服务地址。")}</small>
|
||||
</div>
|
||||
<TextInput
|
||||
className={styles.addressInput}
|
||||
value={settings.address}
|
||||
placeholder="https://tab.leokun.cn"
|
||||
aria-label={t("TAB 服务地址")}
|
||||
onChange={(event) => onChange({ ...settings, address: event.target.value })}
|
||||
onKeyDown={(event) => { if (event.key === "Enter") onSave(); }}
|
||||
/>
|
||||
</div>}
|
||||
</TitledCard>;
|
||||
}
|
||||
@@ -175,7 +175,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 156,
|
||||
"line": 180,
|
||||
"column": 89
|
||||
}
|
||||
]
|
||||
@@ -278,12 +278,12 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/charts/DailyTokenUsageChart.tsx",
|
||||
"line": 108,
|
||||
"line": 109,
|
||||
"column": 47
|
||||
},
|
||||
{
|
||||
"file": "components/charts/DailyTokenUsageChart.tsx",
|
||||
"line": 172,
|
||||
"line": 173,
|
||||
"column": 15
|
||||
}
|
||||
]
|
||||
@@ -353,7 +353,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 155,
|
||||
"line": 179,
|
||||
"column": 36
|
||||
},
|
||||
{
|
||||
@@ -440,17 +440,17 @@
|
||||
},
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 120,
|
||||
"line": 144,
|
||||
"column": 40
|
||||
},
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 120,
|
||||
"line": 144,
|
||||
"column": 119
|
||||
},
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 123,
|
||||
"line": 147,
|
||||
"column": 63
|
||||
}
|
||||
]
|
||||
@@ -515,7 +515,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 79,
|
||||
"line": 87,
|
||||
"column": 86
|
||||
}
|
||||
]
|
||||
@@ -573,17 +573,17 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 98,
|
||||
"line": 106,
|
||||
"column": 32
|
||||
},
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 98,
|
||||
"line": 106,
|
||||
"column": 119
|
||||
},
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 133,
|
||||
"line": 157,
|
||||
"column": 44
|
||||
}
|
||||
]
|
||||
@@ -766,7 +766,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "layouts/AppLayout.tsx",
|
||||
"line": 216,
|
||||
"line": 220,
|
||||
"column": 14
|
||||
}
|
||||
]
|
||||
@@ -805,12 +805,12 @@
|
||||
},
|
||||
{
|
||||
"file": "layouts/AppLayout.tsx",
|
||||
"line": 217,
|
||||
"line": 221,
|
||||
"column": 19
|
||||
},
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 133,
|
||||
"line": 157,
|
||||
"column": 67
|
||||
},
|
||||
{
|
||||
@@ -877,7 +877,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 141,
|
||||
"line": 165,
|
||||
"column": 70
|
||||
},
|
||||
{
|
||||
@@ -887,6 +887,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"2f4a9609285d8f49": {
|
||||
"source": "TAB 设置已保存",
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 128,
|
||||
"column": 15
|
||||
}
|
||||
]
|
||||
},
|
||||
"2f5f1d6fbfb061ed": {
|
||||
"source": "未设置",
|
||||
"kind": "text",
|
||||
@@ -932,7 +944,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 133,
|
||||
"line": 157,
|
||||
"column": 89
|
||||
}
|
||||
]
|
||||
@@ -944,7 +956,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "layouts/AppLayout.tsx",
|
||||
"line": 218,
|
||||
"line": 222,
|
||||
"column": 20
|
||||
}
|
||||
]
|
||||
@@ -1024,12 +1036,12 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/charts/DailyTokenUsageChart.tsx",
|
||||
"line": 106,
|
||||
"line": 107,
|
||||
"column": 50
|
||||
},
|
||||
{
|
||||
"file": "components/charts/DailyTokenUsageChart.tsx",
|
||||
"line": 154,
|
||||
"line": 155,
|
||||
"column": 15
|
||||
}
|
||||
]
|
||||
@@ -1137,6 +1149,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"3f6c25aa329163a4": {
|
||||
"source": "原接口路径会追加到此服务地址。",
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 41,
|
||||
"column": 17
|
||||
}
|
||||
]
|
||||
},
|
||||
"3fd47edce45b3603": {
|
||||
"source": "关闭",
|
||||
"kind": "text",
|
||||
@@ -1144,7 +1168,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 126,
|
||||
"line": 150,
|
||||
"column": 71
|
||||
}
|
||||
]
|
||||
@@ -1168,12 +1192,12 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/charts/DailyTokenUsageChart.tsx",
|
||||
"line": 105,
|
||||
"line": 106,
|
||||
"column": 46
|
||||
},
|
||||
{
|
||||
"file": "components/charts/DailyTokenUsageChart.tsx",
|
||||
"line": 145,
|
||||
"line": 146,
|
||||
"column": 15
|
||||
}
|
||||
]
|
||||
@@ -1338,8 +1362,8 @@
|
||||
},
|
||||
{
|
||||
"file": "layouts/AppLayout.tsx",
|
||||
"line": 197,
|
||||
"column": 84
|
||||
"line": 194,
|
||||
"column": 67
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1348,6 +1372,11 @@
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 32,
|
||||
"column": 39
|
||||
},
|
||||
{
|
||||
"file": "components/overview/OverviewTimeRangeFilter.tsx",
|
||||
"line": 89,
|
||||
@@ -1389,6 +1418,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"5401344227e49e2f": {
|
||||
"source": "TAB 设置",
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 17,
|
||||
"column": 90
|
||||
}
|
||||
]
|
||||
},
|
||||
"54644705e9c61009": {
|
||||
"source": "端口设置",
|
||||
"kind": "text",
|
||||
@@ -1449,11 +1490,40 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 120,
|
||||
"line": 144,
|
||||
"column": 52
|
||||
}
|
||||
]
|
||||
},
|
||||
"59346e82b3dd2998": {
|
||||
"source": "TAB 服务地址",
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 40,
|
||||
"column": 18
|
||||
},
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 47,
|
||||
"column": 21
|
||||
}
|
||||
]
|
||||
},
|
||||
"5a3bd99fa69a40c1": {
|
||||
"source": "使用公益服务",
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 30,
|
||||
"column": 39
|
||||
}
|
||||
]
|
||||
},
|
||||
"5ae715656ffbc35d": {
|
||||
"source": "合并到该上游所有模型的请求体。",
|
||||
"kind": "text",
|
||||
@@ -1502,7 +1572,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "layouts/AppLayout.tsx",
|
||||
"line": 222,
|
||||
"line": 226,
|
||||
"column": 11
|
||||
}
|
||||
]
|
||||
@@ -1528,12 +1598,12 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/charts/DailyTokenUsageChart.tsx",
|
||||
"line": 107,
|
||||
"line": 108,
|
||||
"column": 51
|
||||
},
|
||||
{
|
||||
"file": "components/charts/DailyTokenUsageChart.tsx",
|
||||
"line": 163,
|
||||
"line": 164,
|
||||
"column": 15
|
||||
}
|
||||
]
|
||||
@@ -1614,7 +1684,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "api.ts",
|
||||
"line": 265,
|
||||
"line": 272,
|
||||
"column": 43
|
||||
}
|
||||
]
|
||||
@@ -1876,7 +1946,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "api.ts",
|
||||
"line": 260,
|
||||
"line": 267,
|
||||
"column": 43
|
||||
}
|
||||
]
|
||||
@@ -1919,6 +1989,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"7e0891860c9e6374": {
|
||||
"source": "TAB 服务地址不能为空",
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 125,
|
||||
"column": 83
|
||||
}
|
||||
]
|
||||
},
|
||||
"7e1845870b528392": {
|
||||
"source": "启用模型",
|
||||
"kind": "text",
|
||||
@@ -2003,7 +2085,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "api.ts",
|
||||
"line": 214,
|
||||
"line": 221,
|
||||
"column": 21
|
||||
}
|
||||
]
|
||||
@@ -2049,7 +2131,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 150,
|
||||
"line": 174,
|
||||
"column": 21
|
||||
}
|
||||
]
|
||||
@@ -2158,11 +2240,23 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "layouts/AppLayout.tsx",
|
||||
"line": 224,
|
||||
"line": 228,
|
||||
"column": 16
|
||||
}
|
||||
]
|
||||
},
|
||||
"8f9b0d6cc477d334": {
|
||||
"source": "控制 Cursor TAB 相关接口的连接方式。",
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 23,
|
||||
"column": 17
|
||||
}
|
||||
]
|
||||
},
|
||||
"90800c48a1dd0655": {
|
||||
"source": "{label} 必须是 JSON 对象",
|
||||
"kind": "template",
|
||||
@@ -2172,7 +2266,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 142,
|
||||
"line": 166,
|
||||
"column": 87
|
||||
},
|
||||
{
|
||||
@@ -2237,7 +2331,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 134,
|
||||
"line": 158,
|
||||
"column": 11
|
||||
}
|
||||
]
|
||||
@@ -2278,6 +2372,23 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"966498853d801a52": {
|
||||
"source": "TAB 选择",
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 22,
|
||||
"column": 18
|
||||
},
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 28,
|
||||
"column": 22
|
||||
}
|
||||
]
|
||||
},
|
||||
"9850ed41a5bfbb0c": {
|
||||
"source": "已选 {count} 项",
|
||||
"kind": "template",
|
||||
@@ -2434,6 +2545,11 @@
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 18,
|
||||
"column": 109
|
||||
},
|
||||
{
|
||||
"file": "components/settings/ProxySettingsCard.tsx",
|
||||
"line": 33,
|
||||
@@ -2482,7 +2598,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/charts/DailyTokenUsageChart.tsx",
|
||||
"line": 186,
|
||||
"line": 187,
|
||||
"column": 24
|
||||
}
|
||||
]
|
||||
@@ -2680,16 +2796,28 @@
|
||||
},
|
||||
{
|
||||
"file": "layouts/AppLayout.tsx",
|
||||
"line": 237,
|
||||
"line": 241,
|
||||
"column": 64
|
||||
},
|
||||
{
|
||||
"file": "layouts/AppLayout.tsx",
|
||||
"line": 237,
|
||||
"line": 241,
|
||||
"column": 125
|
||||
}
|
||||
]
|
||||
},
|
||||
"b06325c5660f0c29": {
|
||||
"source": "直连",
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 31,
|
||||
"column": 39
|
||||
}
|
||||
]
|
||||
},
|
||||
"b4411558b932266f": {
|
||||
"source": "上游类型",
|
||||
"kind": "text",
|
||||
@@ -2788,7 +2916,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 126,
|
||||
"line": 150,
|
||||
"column": 93
|
||||
}
|
||||
]
|
||||
@@ -2892,7 +3020,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "layouts/AppLayout.tsx",
|
||||
"line": 229,
|
||||
"line": 233,
|
||||
"column": 24
|
||||
}
|
||||
]
|
||||
@@ -3000,17 +3128,17 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 97,
|
||||
"line": 105,
|
||||
"column": 32
|
||||
},
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 97,
|
||||
"line": 105,
|
||||
"column": 95
|
||||
},
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 123,
|
||||
"line": 147,
|
||||
"column": 51
|
||||
}
|
||||
]
|
||||
@@ -3198,7 +3326,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 77,
|
||||
"line": 85,
|
||||
"column": 45
|
||||
}
|
||||
]
|
||||
@@ -3292,7 +3420,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 128,
|
||||
"line": 152,
|
||||
"column": 18
|
||||
}
|
||||
]
|
||||
@@ -3328,7 +3456,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/charts/DailyTokenUsageChart.tsx",
|
||||
"line": 104,
|
||||
"line": 105,
|
||||
"column": 14
|
||||
}
|
||||
]
|
||||
@@ -3465,7 +3593,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/charts/DailyTokenUsageChart.tsx",
|
||||
"line": 134,
|
||||
"line": 135,
|
||||
"column": 15
|
||||
}
|
||||
]
|
||||
@@ -3542,7 +3670,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 78,
|
||||
"line": 86,
|
||||
"column": 72
|
||||
}
|
||||
]
|
||||
@@ -3619,7 +3747,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 129,
|
||||
"line": 153,
|
||||
"column": 16
|
||||
}
|
||||
]
|
||||
@@ -3648,7 +3776,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 126,
|
||||
"line": 150,
|
||||
"column": 45
|
||||
}
|
||||
]
|
||||
@@ -3665,7 +3793,7 @@
|
||||
},
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 122,
|
||||
"line": 146,
|
||||
"column": 25
|
||||
}
|
||||
]
|
||||
@@ -3701,7 +3829,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "pages/CursorSettingsPage.tsx",
|
||||
"line": 54,
|
||||
"line": 62,
|
||||
"column": 187
|
||||
},
|
||||
{
|
||||
@@ -3995,6 +4123,11 @@
|
||||
"kind": "text",
|
||||
"placeholders": [],
|
||||
"refs": [
|
||||
{
|
||||
"file": "components/cursor/TabSettingsCard.tsx",
|
||||
"line": 18,
|
||||
"column": 97
|
||||
},
|
||||
{
|
||||
"file": "components/settings/ProxySettingsCard.tsx",
|
||||
"line": 33,
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"2eb2bf7c6597ab9a": "Detailed records",
|
||||
"2f1b67cdaa23351a": "Custom full request URL",
|
||||
"2f4a361f878176d1": "{label} must be valid JSON",
|
||||
"2f4a9609285d8f49": "TAB settings saved",
|
||||
"2f5f1d6fbfb061ed": "Not set",
|
||||
"2f6416a2c424856b": "Final request URL",
|
||||
"2f7dec3be28d7597": "{count} selected",
|
||||
@@ -75,6 +76,7 @@
|
||||
"3cfae5728b92b334": "Token usage: {tokens}",
|
||||
"3d13868593ae4eeb": "Display language",
|
||||
"3da0bf1610ff5db5": "Recommended",
|
||||
"3f6c25aa329163a4": "The original endpoint path is appended to this service address.",
|
||||
"3fd47edce45b3603": "Close",
|
||||
"4125fc7ba333524c": "Default light",
|
||||
"42655ed8e4108ae2": "Input (non-cached)",
|
||||
@@ -93,11 +95,14 @@
|
||||
"4eafa9e925b30bcd": "Custom",
|
||||
"51d04bc3d286f018": "Last calendar day",
|
||||
"5228358a6db59fe7": "For example: now, 2026-08-23 18:00",
|
||||
"5401344227e49e2f": "TAB settings",
|
||||
"54644705e9c61009": "Port settings",
|
||||
"54c53e5fe791d1f3": "Initialize CA",
|
||||
"550eddc3c7fefa99": "Sponsored",
|
||||
"555737734a6371e6": "Delete provider",
|
||||
"56432ba297009bdc": "Initialize the CA first",
|
||||
"59346e82b3dd2998": "TAB service address",
|
||||
"5a3bd99fa69a40c1": "Use public service",
|
||||
"5ae715656ffbc35d": "Merge into the request body for every model from this provider.",
|
||||
"5c55a67935af8f45": "All",
|
||||
"5f8d556a9c47da3c": "Launch at login disabled",
|
||||
@@ -132,6 +137,7 @@
|
||||
"7a3cec4ca715de80": "Call statistics",
|
||||
"7ba2d6728fe2531b": "Confirm clear",
|
||||
"7d9f043f8f7ab45c": "Version {version} is available in Settings",
|
||||
"7e0891860c9e6374": "TAB service address is required",
|
||||
"7e1845870b528392": "Enable model",
|
||||
"7e1f06318e80c3af": "Statistics cleared",
|
||||
"7e9ab9ada2cbf2cb": "Name and Base URL are required",
|
||||
@@ -149,6 +155,7 @@
|
||||
"8b6ff498515bcc2f": "Time",
|
||||
"8d0c47eb9eac2d34": "Call type",
|
||||
"8df48894086d6fbd": "Reason (optional)",
|
||||
"8f9b0d6cc477d334": "Choose how Cursor connects to TAB endpoints.",
|
||||
"90800c48a1dd0655": "{label} must be a JSON object",
|
||||
"919cb0ce0c8db4e7": "Leave blank to keep the current password",
|
||||
"91aaf184cfc17ffd": "Overview",
|
||||
@@ -158,6 +165,7 @@
|
||||
"94803f35c825e47a": "Full request URL",
|
||||
"94df1e7f04815daf": "Used only for display; does not change the model name sent to the provider.",
|
||||
"95f76d30c25d5eda": "CA installation is not supported on this system",
|
||||
"966498853d801a52": "TAB connection",
|
||||
"9850ed41a5bfbb0c": "{count} selected",
|
||||
"997ec8201c2adeda": "Open terminal to install CA",
|
||||
"9a026819dd1af5c5": "Enter a model identifier directly or select one returned by the current provider.",
|
||||
@@ -186,6 +194,7 @@
|
||||
"ad6a60ee93d3ba3e": "Loading call details…",
|
||||
"ae2d0b7f79cea4a3": "Model output: {tokens} × ${price}/1M = {cost}",
|
||||
"aee88743413144a2": "Refresh",
|
||||
"b06325c5660f0c29": "Direct",
|
||||
"b4411558b932266f": "Provider type",
|
||||
"b502b1d414664337": "Prompt: {tokens}",
|
||||
"b5141d3d19e9a048": "Yes",
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"2eb2bf7c6597ab9a": "详细记录",
|
||||
"2f1b67cdaa23351a": "自定义请求完整地址",
|
||||
"2f4a361f878176d1": "{label} 必须是有效 JSON",
|
||||
"2f4a9609285d8f49": "TAB 设置已保存",
|
||||
"2f5f1d6fbfb061ed": "未设置",
|
||||
"2f6416a2c424856b": "最终请求地址",
|
||||
"2f7dec3be28d7597": "已选择 {count} 个",
|
||||
@@ -75,6 +76,7 @@
|
||||
"3cfae5728b92b334": "Token 用量:{tokens}",
|
||||
"3d13868593ae4eeb": "界面语言",
|
||||
"3da0bf1610ff5db5": "推荐内容",
|
||||
"3f6c25aa329163a4": "原接口路径会追加到此服务地址。",
|
||||
"3fd47edce45b3603": "关闭",
|
||||
"4125fc7ba333524c": "默认亮色",
|
||||
"42655ed8e4108ae2": "输入(非缓存)",
|
||||
@@ -93,11 +95,14 @@
|
||||
"4eafa9e925b30bcd": "自定义",
|
||||
"51d04bc3d286f018": "近1自然日",
|
||||
"5228358a6db59fe7": "如:现在、2026-08-23 18:00",
|
||||
"5401344227e49e2f": "TAB 设置",
|
||||
"54644705e9c61009": "端口设置",
|
||||
"54c53e5fe791d1f3": "初始化 CA",
|
||||
"550eddc3c7fefa99": "推广",
|
||||
"555737734a6371e6": "删除上游",
|
||||
"56432ba297009bdc": "请先初始化 CA",
|
||||
"59346e82b3dd2998": "TAB 服务地址",
|
||||
"5a3bd99fa69a40c1": "使用公益服务",
|
||||
"5ae715656ffbc35d": "合并到该上游所有模型的请求体。",
|
||||
"5c55a67935af8f45": "全部",
|
||||
"5f8d556a9c47da3c": "已关闭开机启动",
|
||||
@@ -132,6 +137,7 @@
|
||||
"7a3cec4ca715de80": "调用统计",
|
||||
"7ba2d6728fe2531b": "确认清理",
|
||||
"7d9f043f8f7ab45c": "发现新版本 {version},可在设置中安装",
|
||||
"7e0891860c9e6374": "TAB 服务地址不能为空",
|
||||
"7e1845870b528392": "启用模型",
|
||||
"7e1f06318e80c3af": "统计数据已清理",
|
||||
"7e9ab9ada2cbf2cb": "名称和 Base URL 不能为空",
|
||||
@@ -149,6 +155,7 @@
|
||||
"8b6ff498515bcc2f": "时间",
|
||||
"8d0c47eb9eac2d34": "调用类型",
|
||||
"8df48894086d6fbd": "原因(可选)",
|
||||
"8f9b0d6cc477d334": "控制 Cursor TAB 相关接口的连接方式。",
|
||||
"90800c48a1dd0655": "{label} 必须是 JSON 对象",
|
||||
"919cb0ce0c8db4e7": "留空表示保留当前密码",
|
||||
"91aaf184cfc17ffd": "数据概览",
|
||||
@@ -158,6 +165,7 @@
|
||||
"94803f35c825e47a": "请求完整地址",
|
||||
"94df1e7f04815daf": "仅用于界面展示,不会改变发送给上游的模型名称。",
|
||||
"95f76d30c25d5eda": "当前系统暂不支持安装 CA",
|
||||
"966498853d801a52": "TAB 选择",
|
||||
"9850ed41a5bfbb0c": "已选 {count} 项",
|
||||
"997ec8201c2adeda": "打开终端安装 CA",
|
||||
"9a026819dd1af5c5": "可以直接输入模型标识,也可以从当前上游返回的模型列表中选择。",
|
||||
@@ -186,6 +194,7 @@
|
||||
"ad6a60ee93d3ba3e": "正在加载调用详情…",
|
||||
"ae2d0b7f79cea4a3": "模型输出:{tokens} × ${price}/1M = {cost}",
|
||||
"aee88743413144a2": "刷新",
|
||||
"b06325c5660f0c29": "直连",
|
||||
"b4411558b932266f": "上游类型",
|
||||
"b502b1d414664337": "提示词:{tokens}",
|
||||
"b5141d3d19e9a048": "是",
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { api, type Model, type ProviderSelection } from "../api";
|
||||
import { api, type Model, type ProviderSelection, type TabSettings } from "../api";
|
||||
import { CursorCaGate, CursorCaProvider, CursorModelGate, CursorModelProvider } from "../components/cursor/CursorGates";
|
||||
import { CursorModelEditor, emptyCursorModelDraft, type CursorModelDraft } from "../components/cursor/CursorModelEditor";
|
||||
import { TabSettingsCard } from "../components/cursor/TabSettingsCard";
|
||||
import styles from "../components/cursor/CursorSettings.module.scss";
|
||||
import { PageContent } from "../components/layout/PageContent";
|
||||
import controls from "../components/ui/Controls.module.scss";
|
||||
@@ -24,12 +25,19 @@ export function CursorSettingsPage() {
|
||||
const [caCommand, setCaCommand] = useState<string | null>(null);
|
||||
const [waitingForCaRefresh, setWaitingForCaRefresh] = useState(false);
|
||||
const [deleting, setDeleting] = useState<Model | null>(null);
|
||||
const [tabDraft, setTabDraft] = useState<TabSettings | null>(null);
|
||||
const [savingTab, setSavingTab] = useState(false);
|
||||
const grouped = useMemo(() => providers.map((provider) => ({ provider, models: models.filter((model) => model.provider_id === provider.provider_id) })).filter((group) => group.models.length > 0), [providers, models]);
|
||||
const caReady = cursorHarness?.ca === "ready";
|
||||
useEffect(() => {
|
||||
if (!caCommand) return;
|
||||
void api.copyCursorText(caCommand);
|
||||
}, [caCommand]);
|
||||
useEffect(() => {
|
||||
void api.tabSettings()
|
||||
.then(setTabDraft)
|
||||
.catch((cause) => message(cause instanceof Error ? cause.message : String(cause)));
|
||||
}, [message]);
|
||||
const initializeCa = async () => {
|
||||
const status = await appStore.initializeCursorCa();
|
||||
if (status?.ca === "untrusted" && status.ca_install_command) setCaCommand(status.ca_install_command);
|
||||
@@ -111,15 +119,31 @@ export function CursorSettingsPage() {
|
||||
setCaCommand(null);
|
||||
setWaitingForCaRefresh(true);
|
||||
};
|
||||
const saveTab = async () => {
|
||||
if (!tabDraft) return;
|
||||
try {
|
||||
if (tabDraft.mode === "custom" && !tabDraft.address.trim()) throw new Error(t("TAB 服务地址不能为空"));
|
||||
setSavingTab(true);
|
||||
setTabDraft(await api.setTabSettings(tabDraft));
|
||||
message(t("TAB 设置已保存"));
|
||||
} catch (cause) {
|
||||
message(cause instanceof Error ? cause.message : String(cause));
|
||||
} finally {
|
||||
setSavingTab(false);
|
||||
}
|
||||
};
|
||||
const content = <CursorCaProvider><CursorCaGate busy={cursorBusy} waitingForRefresh={waitingForCaRefresh} onInitialize={() => void initializeCa()} onRefresh={() => void refreshCa()}>
|
||||
<CursorModelProvider><CursorModelGate onAdd={openNew}>{list}</CursorModelGate></CursorModelProvider>
|
||||
<div className={styles.page}>
|
||||
{tabDraft && <TabSettingsCard settings={tabDraft} saving={savingTab} onChange={setTabDraft} onSave={() => void saveTab()} />}
|
||||
<CursorModelProvider><CursorModelGate onAdd={openNew}>{list}</CursorModelGate></CursorModelProvider>
|
||||
</div>
|
||||
</CursorCaGate></CursorCaProvider>;
|
||||
|
||||
return <>
|
||||
<PageActions>
|
||||
<TooltipTrigger label={caReady ? t("添加模型") : t("请先初始化 CA")}><button className={controls.iconButton} aria-label={t("添加模型")} disabled={!caReady || cursorBusy} onClick={openNew}><Icon icon={addIcon} size="1.1em" /></button></TooltipTrigger>
|
||||
</PageActions>
|
||||
<PageContent title={t("Cursor 设置")} sections={[{ key: "cursor-settings", estimatedHeight: Math.max(280, models.length * 55 + grouped.length * 62), content }]} />
|
||||
<PageContent title={t("Cursor 设置")} sections={[{ key: "cursor-settings", estimatedHeight: Math.max(430, models.length * 55 + grouped.length * 62 + 145), content }]} />
|
||||
<Modal open={draft !== null} title={editing ? t("编辑模型") : t("添加模型")} busy={cursorBusy} onClose={() => setDraft(null)} onSubmit={() => void save()}>
|
||||
{draft && <CursorModelEditor draft={draft} providers={providers} editing={editing !== null} modelOptions={modelOptions} discovering={discovering} onChange={setDraft} onDiscover={() => void discover()} />}
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user