feat(cursor): add contributor profile link and improve UI for Cursor account card

- Integrated a tooltip with a button to open the contributor's GitHub profile in the CursorAccountCard component.
- Updated the layout of the account card for better visual organization.
- Removed routing mode options from the configuration view and adjusted related translations in multiple languages.
- Cleaned up unused routing mode logic in the app state management.
This commit is contained in:
leookun
2026-08-02 22:53:57 +08:00
parent 674de0b041
commit a5437e60fe
22 changed files with 293 additions and 753 deletions
-48
View File
@@ -36,7 +36,6 @@ export const EXTRA_PARAMS_DEFAULT_JSON = `{
export const CUSTOM_HEADERS_DEFAULT_JSON = `{
}`;
const SUPPORTED_OPENAI_ENDPOINTS = new Set([OPENAI_ENDPOINT_RESPONSES, OPENAI_ENDPOINT_CHAT_COMPLETIONS, OPENAI_ENDPOINT_CUSTOM]);
const SUPPORTED_ROUTE_MODES = new Set(["local", "upstream"]);
const PROXY_STATE_EVENT = "proxy:state";
const USER_CONFIG_CHANGED_EVENT = "user-config:changed";
const UPDATE_STATE_EVENT = "update:state";
@@ -47,11 +46,6 @@ const MODEL_ADAPTER_TEST_UPDATED_EVENT = "model-adapter-test:updated";
const SUPPORTED_MODEL_ADAPTER_TEST_STATUSES = new Set(["idle", "running", "success", "error"]);
const HOME_METRICS_MIN_LOADING_MS = 600;
export const ROUTE_MODE_OPTIONS = [
{ label: "本地服务模式", value: "local" },
{ label: "直连 Cursor 模式", value: "upstream" },
];
function asString(value) {
if (typeof value === "string") {
return value.trim();
@@ -126,14 +120,6 @@ function formatReleaseDate(value) {
return parsed.format("YYYY-MM-DD HH:mm");
}
function normalizeRouteMode(value, fallback = "local") {
const text = asString(value).toLowerCase();
if (SUPPORTED_ROUTE_MODES.has(text)) {
return text;
}
return fallback;
}
function normalizeBaseURL(value) {
const text = asString(value);
if (!text) {
@@ -479,13 +465,6 @@ export function validateModelAdapters(source) {
return "";
}
function validateConfigPayload(payload) {
if (!SUPPORTED_ROUTE_MODES.has(normalizeRouteMode(payload?.routing?.mode, ""))) {
return "运行模式仅支持 local 或 upstream";
}
return "";
}
function canUseLocalStorage() {
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
}
@@ -531,7 +510,6 @@ function loadCachedState() {
function normalizeConfig(source) {
const raw = source && typeof source === "object" ? source : {};
const routing = raw.routing && typeof raw.routing === "object" ? raw.routing : {};
const homeMetrics = raw.homeMetrics && typeof raw.homeMetrics === "object" ? raw.homeMetrics : {};
return {
log: asBoolean(raw.log),
@@ -539,9 +517,6 @@ function normalizeConfig(source) {
backendListenAddr: asString(raw.configBackendListenAddr) || asString(raw.backendListenAddr),
proxyListenAddr: asString(raw.configProxyListenAddr) || asString(raw.proxyListenAddr),
modelAdapters: normalizeModelAdapters(raw.modelAdapters),
routing: {
mode: normalizeRouteMode(routing.mode),
},
homeMetrics: {
includeCacheWriteInHitRate: asBoolean(homeMetrics.includeCacheWriteInHitRate),
},
@@ -584,7 +559,6 @@ function buildConfigPayload(source = appState) {
backendListenAddr: normalized.backendListenAddr,
proxyListenAddr: normalized.proxyListenAddr,
modelAdapters: normalized.modelAdapters.map(({ id, ...adapter }) => adapter),
routing: normalized.routing,
homeMetrics: normalized.homeMetrics,
lastAgentModelHash: normalized.lastAgentModelHash,
};
@@ -599,7 +573,6 @@ function applyConfigToState(config, { modelAdaptersOnly = false } = {}) {
appState.modelAdapters = normalized.modelAdapters;
appState.configBackendListenAddr = normalized.backendListenAddr;
appState.configProxyListenAddr = normalized.proxyListenAddr;
appState.routingMode = normalized.routing.mode;
appState.includeCacheWriteInHitRate = normalized.homeMetrics.includeCacheWriteInHitRate;
return normalized;
}
@@ -610,13 +583,6 @@ async function loadPersistedUserConfig() {
async function persistConfigPayload(config, { modelAdaptersOnly = false } = {}) {
const payload = buildConfigPayload(config);
const configValidationError = validateConfigPayload(payload);
if (configValidationError) {
return {
ok: false,
error: configValidationError,
};
}
const validationError = validateModelAdapters(payload.modelAdapters);
if (validationError) {
return {
@@ -830,7 +796,6 @@ export const appState = reactive({
modelAdapterTestResults: {},
configBackendListenAddr: cachedConfig.backendListenAddr,
configProxyListenAddr: cachedConfig.proxyListenAddr,
routingMode: cachedConfig.routing.mode,
includeCacheWriteInHitRate: cachedConfig.homeMetrics.includeCacheWriteInHitRate,
serviceRunning: asBoolean(cachedState.serviceRunning),
@@ -1118,9 +1083,6 @@ export async function persistUserConfig() {
return persistConfigPayload({
...currentConfig,
modelAdapters: normalizeModelAdapters(appState.modelAdapters),
routing: {
mode: appState.routingMode,
},
homeMetrics: {
...currentConfig.homeMetrics,
includeCacheWriteInHitRate: appState.includeCacheWriteInHitRate,
@@ -1146,16 +1108,6 @@ export async function saveIncludeCacheWriteInHitRate(value) {
return result;
}
export async function saveRoutingMode(mode) {
const currentConfig = await loadPersistedUserConfig();
return persistConfigPayload({
...currentConfig,
routing: {
mode: normalizeRouteMode(mode),
},
});
}
export async function reloadUserConfig(options = {}) {
const config = await loadPersistedUserConfig();
applyConfigToState(config, options);