ck 复制格式优化,修复错误

This commit is contained in:
yml2213
2026-06-25 09:16:23 +08:00
parent 4681136484
commit f21f82cbed
4 changed files with 12 additions and 10 deletions
-2
View File
@@ -69,7 +69,6 @@ class CookieEnricher:
self.CSRF_API, self.CSRF_API,
headers=headers, headers=headers,
timeout=self.TIMEOUT, timeout=self.TIMEOUT,
max_retries=1,
) )
response.raise_for_status() response.raise_for_status()
@@ -120,7 +119,6 @@ class CookieEnricher:
self.ACF_CCN_API, self.ACF_CCN_API,
headers=headers, headers=headers,
timeout=self.TIMEOUT, timeout=self.TIMEOUT,
max_retries=1,
) )
response.raise_for_status() response.raise_for_status()
+3 -1
View File
@@ -63,14 +63,16 @@ def list_cookies(
"assigned_username": acc.assigned_user.username if acc and acc.assigned_user else None, "assigned_username": acc.assigned_user.username if acc and acc.assigned_user else None,
"created_at": _fmt_dt(t.finished_at), "created_at": _fmt_dt(t.finished_at),
} }
# 只有有 cookie:view 权限才返回 cookie 内容 # 只有有 cookie:view 权限才返回 cookie 和密码(用于自定义格式复制)
if user_has_permission(current, "cookie:view"): if user_has_permission(current, "cookie:view"):
cookie = t.cookie or "" cookie = t.cookie or ""
item["cookie"] = cookie item["cookie"] = cookie
item["cookie_preview"] = cookie[:50] + "..." if len(cookie) > 50 else cookie item["cookie_preview"] = cookie[:50] + "..." if len(cookie) > 50 else cookie
item["account_password"] = acc.password if acc else ""
else: else:
item["cookie"] = "" item["cookie"] = ""
item["cookie_preview"] = "***" item["cookie_preview"] = "***"
item["account_password"] = ""
result.append(item) result.append(item)
return result return result
+1
View File
@@ -102,6 +102,7 @@ export interface CookieItem {
created_at: string | null; created_at: string | null;
cookie: string; cookie: string;
cookie_preview: string; cookie_preview: string;
account_password: string;
} }
// ==================== Proxy ==================== // ==================== Proxy ====================
+8 -7
View File
@@ -83,13 +83,14 @@ export default function CookiePage() {
} }
}; };
const handleCopyCookie = (cookie: string, username: string) => { const handleCopyCookie = (record: CookieItem) => {
if (!cookie) { if (!record.cookie) {
message.warning('Cookie 为空'); message.warning('Cookie 为空');
return; return;
} }
copyToClipboard(cookie).then(() => { const text = `${record.account_username}----${record.account_password || ''}----${record.cookie}`;
message.success(`已复制 ${username} 的 Cookie`); copyToClipboard(text).then(() => {
message.success(`已复制 ${record.account_username} 的 Cookie`);
}).catch(() => { }).catch(() => {
message.error('复制失败'); message.error('复制失败');
}); });
@@ -102,8 +103,8 @@ export default function CookiePage() {
} }
const selected = cookies.filter((c) => selectedRowKeys.includes(c.id)); const selected = cookies.filter((c) => selectedRowKeys.includes(c.id));
const text = selected const text = selected
.map((c) => `${c.account_username}: ${c.cookie || '(空)'}`) .map((c) => `${c.account_username}----${c.account_password || ''}----${c.cookie || ''}`)
.join('\n'); .join('\r\n');
copyToClipboard(text).then(() => { copyToClipboard(text).then(() => {
message.success(`已复制 ${selected.length} 条 Cookie`); message.success(`已复制 ${selected.length} 条 Cookie`);
}).catch(() => { }).catch(() => {
@@ -190,7 +191,7 @@ export default function CookiePage() {
<Button <Button
size="small" size="small"
icon={<CopyOutlined />} icon={<CopyOutlined />}
onClick={() => handleCopyCookie(record.cookie, record.account_username)} onClick={() => handleCopyCookie(record)}
> >
</Button> </Button>