mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 22:16:41 +00:00
fix(cliproxy): use backend-specific GitHub repos for version fetching
Root cause: fetchLatestVersion and fetchAllVersions were hardcoded to
CLIProxyAPIPlus repo, ignoring backend selection.
Changes:
- Add getGitHubApiUrls(backend) helper to types.ts
- Make fetchLatestVersion and fetchAllVersions backend-aware
- Make version list cache backend-specific (bin/{backend}/.version-list-cache.json)
- Update /api/cliproxy/versions route to use configured backend
- Allow version management even when proxy not running (ProxyStatusWidget)
- Show settings button in all states for easier access
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { getCliproxyDir, getBinDir } from '../config-generator';
|
||||
import { getBinDir } from '../config-generator';
|
||||
import {
|
||||
VersionCache,
|
||||
VERSION_CACHE_DURATION_MS,
|
||||
@@ -181,17 +181,19 @@ export function migrateVersionPin(backend: CLIProxyBackend): void {
|
||||
const VERSION_LIST_CACHE_FILE = '.version-list-cache.json';
|
||||
|
||||
/**
|
||||
* Get path to version list cache file
|
||||
* Get path to version list cache file (backend-specific)
|
||||
*/
|
||||
export function getVersionListCachePath(): string {
|
||||
return path.join(getCliproxyDir(), VERSION_LIST_CACHE_FILE);
|
||||
export function getVersionListCachePath(backend: CLIProxyBackend = DEFAULT_BACKEND): string {
|
||||
return path.join(getBinDir(), backend, VERSION_LIST_CACHE_FILE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read version list cache if still valid
|
||||
* Read version list cache if still valid (backend-specific)
|
||||
*/
|
||||
export function readVersionListCache(): VersionListCache | null {
|
||||
const cachePath = getVersionListCachePath();
|
||||
export function readVersionListCache(
|
||||
backend: CLIProxyBackend = DEFAULT_BACKEND
|
||||
): VersionListCache | null {
|
||||
const cachePath = getVersionListCachePath(backend);
|
||||
if (!fs.existsSync(cachePath)) {
|
||||
return null;
|
||||
}
|
||||
@@ -212,10 +214,13 @@ export function readVersionListCache(): VersionListCache | null {
|
||||
}
|
||||
|
||||
/**
|
||||
* Write version list to cache
|
||||
* Write version list to cache (backend-specific)
|
||||
*/
|
||||
export function writeVersionListCache(cache: VersionListCache): void {
|
||||
const cachePath = getVersionListCachePath();
|
||||
export function writeVersionListCache(
|
||||
cache: VersionListCache,
|
||||
backend: CLIProxyBackend = DEFAULT_BACKEND
|
||||
): void {
|
||||
const cachePath = getVersionListCachePath(backend);
|
||||
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(cachePath), { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user