mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-06-16 13:34:04 +08:00
style: format code with prettier and rustfmt
This commit is contained in:
@@ -145,8 +145,7 @@ async fn fetch_npm_latest_version(client: &reqwest::Client, package: &str) -> Op
|
||||
/// 从版本输出中提取纯版本号
|
||||
fn extract_version(raw: &str) -> String {
|
||||
// 匹配 semver 格式: x.y.z 或 x.y.z-xxx
|
||||
let re = regex::Regex::new(r"\d+\.\d+\.\d+(-[\w.]+)?")
|
||||
.expect("Invalid version regex pattern");
|
||||
let re = regex::Regex::new(r"\d+\.\d+\.\d+(-[\w.]+)?").expect("Invalid version regex pattern");
|
||||
re.find(raw)
|
||||
.map(|m| m.as_str().to_string())
|
||||
.unwrap_or_else(|| raw.to_string())
|
||||
|
||||
@@ -73,8 +73,9 @@ impl Database {
|
||||
params![
|
||||
server.id,
|
||||
server.name,
|
||||
serde_json::to_string(&server.server)
|
||||
.map_err(|e| AppError::Database(format!("Failed to serialize server config: {e}")))?,
|
||||
serde_json::to_string(&server.server).map_err(|e| AppError::Database(format!(
|
||||
"Failed to serialize server config: {e}"
|
||||
)))?,
|
||||
server.description,
|
||||
server.homepage,
|
||||
server.docs,
|
||||
|
||||
@@ -220,8 +220,9 @@ impl Database {
|
||||
WHERE id = ?13 AND app_type = ?14",
|
||||
params![
|
||||
provider.name,
|
||||
serde_json::to_string(&provider.settings_config)
|
||||
.map_err(|e| AppError::Database(format!("Failed to serialize settings_config: {e}")))?,
|
||||
serde_json::to_string(&provider.settings_config).map_err(|e| {
|
||||
AppError::Database(format!("Failed to serialize settings_config: {e}"))
|
||||
})?,
|
||||
provider.website_url,
|
||||
provider.category,
|
||||
provider.created_at,
|
||||
@@ -229,8 +230,9 @@ impl Database {
|
||||
provider.notes,
|
||||
provider.icon,
|
||||
provider.icon_color,
|
||||
serde_json::to_string(&meta_clone)
|
||||
.map_err(|e| AppError::Database(format!("Failed to serialize meta: {e}")))?,
|
||||
serde_json::to_string(&meta_clone).map_err(|e| AppError::Database(format!(
|
||||
"Failed to serialize meta: {e}"
|
||||
)))?,
|
||||
is_current,
|
||||
in_failover_queue,
|
||||
provider.id,
|
||||
@@ -328,8 +330,9 @@ impl Database {
|
||||
conn.execute(
|
||||
"UPDATE providers SET settings_config = ?1 WHERE id = ?2 AND app_type = ?3",
|
||||
params![
|
||||
serde_json::to_string(settings_config)
|
||||
.map_err(|e| AppError::Database(format!("Failed to serialize settings_config: {e}")))?,
|
||||
serde_json::to_string(settings_config).map_err(|e| AppError::Database(format!(
|
||||
"Failed to serialize settings_config: {e}"
|
||||
)))?,
|
||||
provider_id,
|
||||
app_type
|
||||
],
|
||||
|
||||
+6
-4
@@ -624,10 +624,12 @@ function App() {
|
||||
<Settings className="w-4 h-4" />
|
||||
</Button>
|
||||
</div>
|
||||
<UpdateBadge onClick={() => {
|
||||
setSettingsDefaultTab("about");
|
||||
setCurrentView("settings");
|
||||
}} />
|
||||
<UpdateBadge
|
||||
onClick={() => {
|
||||
setSettingsDefaultTab("about");
|
||||
setCurrentView("settings");
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -389,9 +389,12 @@ export function ProxyPanel() {
|
||||
id="listen-address"
|
||||
value={listenAddress}
|
||||
onChange={(e) => setListenAddress(e.target.value)}
|
||||
placeholder={t("proxy.settings.fields.listenAddress.placeholder", {
|
||||
defaultValue: "127.0.0.1",
|
||||
})}
|
||||
placeholder={t(
|
||||
"proxy.settings.fields.listenAddress.placeholder",
|
||||
{
|
||||
defaultValue: "127.0.0.1",
|
||||
},
|
||||
)}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t("proxy.settings.fields.listenAddress.description", {
|
||||
@@ -414,9 +417,12 @@ export function ProxyPanel() {
|
||||
onChange={(e) =>
|
||||
setListenPort(parseInt(e.target.value) || 15721)
|
||||
}
|
||||
placeholder={t("proxy.settings.fields.listenPort.placeholder", {
|
||||
defaultValue: "15721",
|
||||
})}
|
||||
placeholder={t(
|
||||
"proxy.settings.fields.listenPort.placeholder",
|
||||
{
|
||||
defaultValue: "15721",
|
||||
},
|
||||
)}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t("proxy.settings.fields.listenPort.description", {
|
||||
|
||||
@@ -405,9 +405,7 @@ export const providerPresets: ProviderPreset[] = [
|
||||
},
|
||||
},
|
||||
// 请求地址候选(用于地址管理/测速)
|
||||
endpointCandidates: [
|
||||
"https://api.aigocode.com",
|
||||
],
|
||||
endpointCandidates: ["https://api.aigocode.com"],
|
||||
category: "third_party",
|
||||
isPartner: true, // 合作伙伴
|
||||
partnerPromotionKey: "aigocode", // 促销信息 i18n key
|
||||
|
||||
@@ -181,7 +181,11 @@ requires_openai_auth = true`,
|
||||
apiKeyUrl: "https://aigocode.com/invite/CC-SWITCH",
|
||||
category: "third_party",
|
||||
auth: generateThirdPartyAuth(""),
|
||||
config: generateThirdPartyConfig("aigocode", "https://api.aigocode.com/openai", "gpt-5.2"),
|
||||
config: generateThirdPartyConfig(
|
||||
"aigocode",
|
||||
"https://api.aigocode.com/openai",
|
||||
"gpt-5.2",
|
||||
),
|
||||
endpointCandidates: ["https://api.aigocode.com"],
|
||||
isPartner: true, // 合作伙伴
|
||||
partnerPromotionKey: "aigocode", // 促销信息 i18n key
|
||||
|
||||
@@ -70,7 +70,7 @@ export const geminiProviderPresets: GeminiProviderPreset[] = [
|
||||
"https://www.packyapi.com",
|
||||
],
|
||||
icon: "packycode",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Cubence",
|
||||
websiteUrl: "https://cubence.com",
|
||||
|
||||
Reference in New Issue
Block a user