mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
Style/add provider.notes (#2138)
* style(FailoverQueueManager): 显示供应商备注信息 * style(FailoverQueueItem): 添加供应商备注字段以支持备注信息显示 * style(FailoverQueueManager): 显示供应商备注信息 * style(FailoverQueueItem): 添加供应商备注字段以支持备注信息显示 * style(FailoverQueueManager): 更新供应商备注信息的显示样式 * style(FailoverQueueItem): 添加条件序列化以优化供应商备注字段
This commit is contained in:
@@ -14,6 +14,8 @@ pub struct FailoverQueueItem {
|
||||
pub provider_id: String,
|
||||
pub provider_name: String,
|
||||
pub sort_index: Option<usize>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub provider_notes: Option<String>,
|
||||
}
|
||||
|
||||
impl Database {
|
||||
@@ -23,7 +25,7 @@ impl Database {
|
||||
|
||||
let mut stmt = conn
|
||||
.prepare(
|
||||
"SELECT id, name, sort_index
|
||||
"SELECT id, name, sort_index, notes
|
||||
FROM providers
|
||||
WHERE app_type = ?1 AND in_failover_queue = 1
|
||||
ORDER BY COALESCE(sort_index, 999999), id ASC",
|
||||
@@ -36,6 +38,7 @@ impl Database {
|
||||
provider_id: row.get(0)?,
|
||||
provider_name: row.get(1)?,
|
||||
sort_index: row.get(2)?,
|
||||
provider_notes: row.get(3)?,
|
||||
})
|
||||
})
|
||||
.map_err(|e| AppError::Database(e.to_string()))?
|
||||
|
||||
@@ -182,6 +182,11 @@ export function FailoverQueueManager({
|
||||
{availableProviders?.map((provider) => (
|
||||
<SelectItem key={provider.id} value={provider.id}>
|
||||
{provider.name}
|
||||
{provider.notes && (
|
||||
<span className="ml-1 text-xs text-muted-foreground">
|
||||
({provider.notes})
|
||||
</span>
|
||||
)}
|
||||
</SelectItem>
|
||||
))}
|
||||
{(!availableProviders || availableProviders.length === 0) && (
|
||||
@@ -278,6 +283,11 @@ function QueueItem({
|
||||
<div className="flex-1 min-w-0">
|
||||
<span className="text-sm font-medium truncate block">
|
||||
{item.providerName}
|
||||
{item.providerNotes && (
|
||||
<span className="ml-1 text-xs text-muted-foreground">
|
||||
({item.providerNotes})
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ export interface ProxyUsageRecord {
|
||||
export interface FailoverQueueItem {
|
||||
providerId: string;
|
||||
providerName: string;
|
||||
providerNotes?: string;
|
||||
sortIndex?: number;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user