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