Initial commit
This commit is contained in:
commit
57fc3525eb
7311 files changed
+1291398
No files matched your search
@@ -0,0 +1,695 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN" data-guide-lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>受控浏览器引导</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg-top: #09111d;
|
||||
--bg-bottom: #13253e;
|
||||
--guide-bg-image: none;
|
||||
--panel: rgba(9, 18, 34, 0.46);
|
||||
--panel-soft: rgba(13, 26, 47, 0.28);
|
||||
--border: rgba(219, 234, 254, 0.18);
|
||||
--text: #f8fafc;
|
||||
--body: #d9e4f5;
|
||||
--muted: #9fb0c9;
|
||||
--accent: #7dd3fc;
|
||||
--success: #34d399;
|
||||
--warm: #fbbf24;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; min-height: 100%; }
|
||||
body {
|
||||
font-family: "Microsoft YaHei UI", "Segoe UI Variable", "PingFang SC", sans-serif;
|
||||
color: var(--text);
|
||||
background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
|
||||
position: relative;
|
||||
}
|
||||
body::before,
|
||||
body::after {
|
||||
content: "";
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
body::before {
|
||||
background:
|
||||
linear-gradient(180deg, rgba(8, 15, 30, 0.05), rgba(8, 15, 30, 0.1)),
|
||||
var(--guide-bg-image, none) 78% center / cover no-repeat;
|
||||
transform: scale(1.02);
|
||||
z-index: -2;
|
||||
}
|
||||
body::after {
|
||||
background:
|
||||
radial-gradient(circle at 14% 14%, rgba(56, 189, 248, 0.14), transparent 28%),
|
||||
linear-gradient(180deg, rgba(9, 17, 29, 0.42), rgba(19, 37, 62, 0.5));
|
||||
z-index: -1;
|
||||
}
|
||||
.guide-shell {
|
||||
width: min(1100px, calc(100vw - 28px));
|
||||
margin: 0 auto;
|
||||
padding: 24px 0 40px;
|
||||
}
|
||||
.card {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 26px;
|
||||
background: linear-gradient(180deg, var(--panel), rgba(11, 22, 41, 0.3));
|
||||
box-shadow: 0 24px 72px rgba(2, 6, 23, 0.2);
|
||||
}
|
||||
.hero { padding: 24px 28px 30px; }
|
||||
.hero-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 10px 16px;
|
||||
border-radius: 999px;
|
||||
background: rgba(125, 211, 252, 0.08);
|
||||
border: 1px solid rgba(125, 211, 252, 0.16);
|
||||
color: var(--accent);
|
||||
font-size: 0.92rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.lang-switch {
|
||||
display: inline-flex;
|
||||
gap: 6px;
|
||||
padding: 6px;
|
||||
border-radius: 999px;
|
||||
background: rgba(15, 23, 42, 0.76);
|
||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
||||
}
|
||||
.lang-btn, .action-btn {
|
||||
border: 0;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
|
||||
}
|
||||
.lang-btn {
|
||||
min-width: 92px;
|
||||
padding: 10px 16px;
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
color: var(--body);
|
||||
font-size: 0.95rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
.lang-btn.active {
|
||||
background: rgba(125, 211, 252, 0.96);
|
||||
color: #0f2942;
|
||||
}
|
||||
.lang-btn:hover, .action-btn:hover { transform: translateY(-1px); }
|
||||
.lang-btn:focus-visible, .action-btn:focus-visible {
|
||||
outline: 3px solid rgba(248, 250, 252, 0.92);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
.hero-title {
|
||||
margin: 0;
|
||||
max-width: 860px;
|
||||
font-size: clamp(2.3rem, 4.8vw, 4rem);
|
||||
line-height: 1.02;
|
||||
letter-spacing: 0.01em;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
html[data-guide-lang="zh"] .hero-title {
|
||||
white-space: nowrap;
|
||||
}
|
||||
html[data-guide-lang="en"] .hero-title {
|
||||
max-width: 100%;
|
||||
font-size: clamp(1.95rem, 4vw, 3.35rem);
|
||||
line-height: 1.08;
|
||||
white-space: normal;
|
||||
text-wrap: balance;
|
||||
}
|
||||
.hero-copy, .section-copy, .note-copy, .utility-copy {
|
||||
color: var(--body);
|
||||
line-height: 1.76;
|
||||
font-weight: 600;
|
||||
}
|
||||
.hero-copy {
|
||||
max-width: 860px;
|
||||
margin: 22px 0 0;
|
||||
font-size: clamp(1.06rem, 1.55vw, 1.24rem);
|
||||
}
|
||||
.hero-copy strong, .section-copy strong, .note-copy strong, .utility-copy strong { color: #fff; }
|
||||
.action-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 24px; }
|
||||
.action-btn {
|
||||
min-height: 56px;
|
||||
padding: 16px 24px;
|
||||
border-radius: 18px;
|
||||
font-size: 1rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
.action-btn.primary {
|
||||
background: linear-gradient(135deg, #f4c84f 0%, #e7b93e 100%);
|
||||
color: #111827;
|
||||
box-shadow: 0 14px 34px rgba(231, 185, 62, 0.22);
|
||||
}
|
||||
.action-btn.secondary {
|
||||
background: rgba(125, 211, 252, 0.1);
|
||||
border: 1px solid rgba(125, 211, 252, 0.22);
|
||||
color: var(--text);
|
||||
}
|
||||
.status {
|
||||
margin-top: 16px;
|
||||
color: var(--success);
|
||||
font-size: 0.96rem;
|
||||
line-height: 1.65;
|
||||
font-weight: 700;
|
||||
}
|
||||
.stack { display: grid; gap: 18px; margin-top: 18px; }
|
||||
.reveal {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transform: translateY(20px);
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
padding: 0 26px;
|
||||
transition: opacity 0.35s ease, transform 0.35s ease, max-height 0.45s ease, padding 0.35s ease;
|
||||
}
|
||||
.reveal.visible {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
transform: translateY(0);
|
||||
max-height: 4000px;
|
||||
padding-top: 24px;
|
||||
padding-bottom: 26px;
|
||||
}
|
||||
.kicker {
|
||||
margin: 0;
|
||||
color: var(--warm);
|
||||
font-size: 0.9rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.section-title {
|
||||
margin: 14px 0 0;
|
||||
font-size: clamp(1.72rem, 2.9vw, 2.4rem);
|
||||
line-height: 1.24;
|
||||
}
|
||||
.section-subtitle, .summary {
|
||||
margin: 10px 0 0;
|
||||
color: var(--muted);
|
||||
font-size: 0.98rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.section-copy { margin: 16px 0 0; font-size: 1rem; }
|
||||
.note {
|
||||
margin-top: 18px;
|
||||
padding: 18px 20px;
|
||||
border-radius: 20px;
|
||||
background: linear-gradient(135deg, rgba(125, 211, 252, 0.08), rgba(52, 211, 153, 0.06));
|
||||
border: 1px solid rgba(125, 211, 252, 0.14);
|
||||
}
|
||||
.note-title, .utility-title {
|
||||
margin: 0;
|
||||
font-size: 1.3rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.note-copy, .utility-copy { margin: 12px 0 0; font-size: 0.98rem; }
|
||||
.site-grid, .utility-grid {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.site-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
|
||||
.utility-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
|
||||
.site-card, .utility {
|
||||
padding: 18px;
|
||||
border-radius: 20px;
|
||||
border: 1px solid rgba(219, 234, 254, 0.14);
|
||||
background: var(--panel-soft);
|
||||
}
|
||||
.site-title { margin: 0; font-size: 1.06rem; line-height: 1.45; word-break: break-word; }
|
||||
.site-url {
|
||||
margin: 10px 0 0;
|
||||
color: var(--muted);
|
||||
font-size: 0.92rem;
|
||||
line-height: 1.65;
|
||||
word-break: break-all;
|
||||
}
|
||||
.site-card .action-btn { width: 100%; margin-top: 14px; min-height: 50px; padding: 13px 16px; font-size: 0.94rem; }
|
||||
.utility-kicker {
|
||||
display: inline-block;
|
||||
color: var(--accent);
|
||||
font-size: 0.86rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.url-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 48px;
|
||||
margin-top: 16px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 16px;
|
||||
background: rgba(8, 15, 30, 0.42);
|
||||
border: 1px solid rgba(148, 163, 184, 0.12);
|
||||
color: var(--accent);
|
||||
font-size: 0.94rem;
|
||||
line-height: 1.6;
|
||||
word-break: break-all;
|
||||
}
|
||||
.feedback {
|
||||
min-height: 1.5em;
|
||||
margin-top: 12px;
|
||||
color: var(--success);
|
||||
font-size: 0.94rem;
|
||||
line-height: 1.6;
|
||||
font-weight: 700;
|
||||
}
|
||||
.empty-state {
|
||||
padding: 22px 20px;
|
||||
border-radius: 18px;
|
||||
border: 1px dashed rgba(148, 163, 184, 0.18);
|
||||
background: rgba(8, 15, 30, 0.28);
|
||||
color: var(--body);
|
||||
font-size: 0.98rem;
|
||||
line-height: 1.72;
|
||||
font-weight: 600;
|
||||
}
|
||||
@media (max-width: 860px) {
|
||||
.guide-shell { width: min(100vw - 20px, 1100px); padding: 12px 0 28px; }
|
||||
.hero { padding: 18px 18px 22px; }
|
||||
.hero-top { flex-direction: column; align-items: stretch; }
|
||||
.lang-switch { width: 100%; }
|
||||
.lang-btn { flex: 1 1 0; min-width: 0; }
|
||||
.hero-title { font-size: clamp(1.75rem, 7vw, 2.5rem); }
|
||||
html[data-guide-lang="en"] .hero-title {
|
||||
font-size: clamp(1.55rem, 5.8vw, 2.3rem);
|
||||
line-height: 1.1;
|
||||
}
|
||||
.reveal.visible { padding-left: 18px; padding-right: 18px; }
|
||||
.action-btn { width: 100%; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="guide-shell">
|
||||
<section class="card hero">
|
||||
<div class="hero-top">
|
||||
<div id="heroBadge" class="badge">受控浏览器</div>
|
||||
<div id="languageSwitch" class="lang-switch" role="group" aria-label="切换语言">
|
||||
<button type="button" class="lang-btn" data-lang-option="zh">中文</button>
|
||||
<button type="button" class="lang-btn" data-lang-option="en">English</button>
|
||||
</div>
|
||||
</div>
|
||||
<h1 id="heroTitle" class="hero-title">此浏览器为受控浏览器</h1>
|
||||
<p id="heroCopy" class="hero-copy">请把这个窗口留给你要接入的 AI 网站。<strong>教程页、搜索页、邮箱、资讯页都不要在这里打开。</strong></p>
|
||||
<div class="action-row">
|
||||
<button id="confirmControlledBtn" type="button" class="action-btn primary">我知道了</button>
|
||||
</div>
|
||||
<p id="stepOneStatus" class="status" hidden>已确认:这是受控浏览器。</p>
|
||||
</section>
|
||||
|
||||
<div class="stack">
|
||||
<section id="stepTwo" class="card reveal">
|
||||
<p id="stepTwoKicker" class="kicker">第二步</p>
|
||||
<h2 id="stepTwoTitle" class="section-title">不要在这里打开除目标 AI 站点之外的任何网站</h2>
|
||||
<p id="stepTwoSubtitle" class="section-subtitle">只把这个浏览器留给你真正要访问的 AI 站点。</p>
|
||||
<p id="stepTwoCopy" class="section-copy">这个浏览器主要是给脚本调度和识别页面用的。你之后想访问哪个 AI,就在这里打开哪个 AI;其它无关网站请继续放在普通浏览器里。</p>
|
||||
<div class="action-row">
|
||||
<button id="confirmDisciplineBtn" type="button" class="action-btn primary">只在这里打开 AI 站点</button>
|
||||
</div>
|
||||
<p id="stepTwoStatus" class="status" hidden>已确认:受控浏览器只用于目标 AI 站点。</p>
|
||||
</section>
|
||||
|
||||
<section id="finalStage" class="card reveal">
|
||||
<p id="finalKicker" class="kicker">开始使用</p>
|
||||
<h2 id="finalTitle" class="section-title">现在就从下方站点里选一个打开</h2>
|
||||
<p id="finalSubtitle" class="section-subtitle">下方按钮会直接在这个受控浏览器里打开目标站点。</p>
|
||||
|
||||
<div class="note">
|
||||
<h3 id="noteTitle" class="note-title">这是引导页,之后可以直接关闭,没有任何影响</h3>
|
||||
<p id="noteCopy" class="note-copy">这个标签页只是启动时的说明页。看完后你可以直接关闭,不会影响服务、标签页池、登录态和后续 API 调用。</p>
|
||||
</div>
|
||||
|
||||
<p id="siteSummary" class="summary">正在加载当前已适配站点...</p>
|
||||
<div id="siteGrid" class="site-grid" aria-live="polite"></div>
|
||||
|
||||
<div class="utility-grid">
|
||||
<article class="utility">
|
||||
<span id="dashboardKicker" class="utility-kicker">控制面板</span>
|
||||
<h3 id="dashboardTitle" class="utility-title">控制面板建议在普通浏览器打开</h3>
|
||||
<p id="dashboardBody" class="utility-copy">如果你要复制 Base URL、改设置、看日志,请在普通浏览器使用控制面板,别把这个受控浏览器拿去做普通浏览。</p>
|
||||
<div id="dashboardUrl" class="url-pill">正在加载控制面板地址...</div>
|
||||
<div class="action-row">
|
||||
<button id="copyDashboardBtn" type="button" class="action-btn secondary">复制控制面板地址</button>
|
||||
</div>
|
||||
<p id="dashboardCopyFeedback" class="feedback" aria-live="polite"></p>
|
||||
</article>
|
||||
|
||||
<article class="utility">
|
||||
<span id="closingKicker" class="utility-kicker">关闭提示</span>
|
||||
<h3 id="closingTitle" class="utility-title">看完这页就可以关掉</h3>
|
||||
<p id="closingBody" class="utility-copy">关闭这个引导页不会影响登录态、站点访问、标签页池或后续 API 调用。你真正要操作的是后面打开的 AI 网站标签页。</p>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
const backgroundStamp = Date.now();
|
||||
const guideBackgroundCandidates = ['jpg', 'jpeg', 'png', 'webp']
|
||||
.map(ext => `/static/images/controlled-browser-guide-bg.${ext}?v=${backgroundStamp}`);
|
||||
|
||||
const translations = {
|
||||
zh: {
|
||||
lang: 'zh-CN',
|
||||
title: '受控浏览器引导',
|
||||
languageLabel: '切换语言',
|
||||
heroBadge: '受控浏览器',
|
||||
heroTitle: '此浏览器为受控浏览器',
|
||||
heroCopy: '请把这个窗口留给你要接入的 AI 网站。<strong>教程页、搜索页、邮箱、资讯页都不要在这里打开。</strong>',
|
||||
confirmControlled: '我知道了',
|
||||
stepOneStatus: '已确认:这是受控浏览器。',
|
||||
stepTwoKicker: '第二步',
|
||||
stepTwoTitle: '不要在这里打开除目标 AI 站点之外的任何网站',
|
||||
stepTwoSubtitle: '只把这个浏览器留给你真正要访问的 AI 站点。',
|
||||
stepTwoCopy: '这个浏览器主要是给脚本调度和识别页面用的。你之后想访问哪个 AI,就在这里打开哪个 AI;其它无关网站请继续放在普通浏览器里。',
|
||||
confirmDiscipline: '只在这里打开 AI 站点',
|
||||
stepTwoStatus: '已确认:受控浏览器只用于目标 AI 站点。',
|
||||
finalKicker: '开始使用',
|
||||
finalTitle: '现在就从下方站点里选一个打开',
|
||||
finalSubtitle: '下方按钮会直接在这个受控浏览器里打开目标站点。',
|
||||
noteTitle: '这是引导页,之后可以直接关闭,没有任何影响',
|
||||
noteCopy: '这个标签页只是启动时的说明页。看完后你可以直接关闭,不会影响服务、标签页池、登录态和后续 API 调用。',
|
||||
dashboardKicker: '控制面板',
|
||||
dashboardTitle: '控制面板建议在普通浏览器打开',
|
||||
dashboardBody: '如果你要复制 Base URL、改设置、看日志,请在普通浏览器使用控制面板,别把这个受控浏览器拿去做普通浏览。',
|
||||
copyDashboard: '复制控制面板地址',
|
||||
dashboardLoading: '正在加载控制面板地址...',
|
||||
dashboardCopied: '已复制控制面板地址,请到普通浏览器打开。',
|
||||
dashboardCopyFailed: '复制失败,请手动复制上面的地址。',
|
||||
closingKicker: '关闭提示',
|
||||
closingTitle: '看完这页就可以关掉',
|
||||
closingBody: '关闭这个引导页不会影响登录态、站点访问、标签页池或后续 API 调用。你真正要操作的是后面打开的 AI 网站标签页。',
|
||||
siteOpen: '在此浏览器打开',
|
||||
siteSummaryLoaded: count => `当前已适配 ${count} 个站点。你可以直接点下方按钮在此受控浏览器打开。`,
|
||||
siteSummaryEmpty: '暂时没有读到已适配站点,你仍然可以手动在这个受控浏览器里打开目标 AI 网站。',
|
||||
emptySites: '当前没有读取到站点列表。你仍然可以手动在这个受控浏览器里打开目标 AI 网站。'
|
||||
},
|
||||
en: {
|
||||
lang: 'en',
|
||||
title: 'Controlled Browser Guide',
|
||||
languageLabel: 'Switch language',
|
||||
heroBadge: 'Controlled Browser',
|
||||
heroTitle: 'This browser is controlled by the script.',
|
||||
heroCopy: 'Keep this window dedicated to the AI site you want to automate. <strong>Do not use it for tutorial pages, search, mail, news, or general browsing.</strong>',
|
||||
confirmControlled: 'I understand',
|
||||
stepOneStatus: 'Confirmed: this is the controlled browser.',
|
||||
stepTwoKicker: 'Second Step',
|
||||
stepTwoTitle: 'Do not open anything here except the AI site you actually want to use',
|
||||
stepTwoSubtitle: 'Keep this browser dedicated to the target AI site only.',
|
||||
stepTwoCopy: 'This browser is mainly reserved for the script. Open only the AI site you want to automate here, and keep unrelated browsing in your regular browser.',
|
||||
confirmDiscipline: 'I will only open AI sites here',
|
||||
stepTwoStatus: 'Confirmed: only target AI sites will be opened here.',
|
||||
finalKicker: 'Start Here',
|
||||
finalTitle: 'Choose one supported site below and open it now',
|
||||
finalSubtitle: 'The buttons below will open the target site directly in this controlled browser.',
|
||||
noteTitle: 'This is only a guide page. You can close it later with no impact.',
|
||||
noteCopy: 'This tab is only a startup guide. After reading it, you can close it at any time without affecting the service, tab pool, login state, or later API calls.',
|
||||
dashboardKicker: 'Dashboard',
|
||||
dashboardTitle: 'Open the dashboard in your regular browser',
|
||||
dashboardBody: 'If you need the Base URL, settings, or logs, use the dashboard in your regular browser and keep this controlled browser focused on AI sites only.',
|
||||
copyDashboard: 'Copy dashboard URL',
|
||||
dashboardLoading: 'Loading dashboard URL...',
|
||||
dashboardCopied: 'Dashboard URL copied. Open it in your regular browser.',
|
||||
dashboardCopyFailed: 'Copy failed. Please copy the URL above manually.',
|
||||
closingKicker: 'Closing Note',
|
||||
closingTitle: 'You can close this page after reading',
|
||||
closingBody: 'Closing this guide will not affect login state, site access, the tab pool, or later API calls. The AI site tab you open next is what really matters.',
|
||||
siteOpen: 'Open here',
|
||||
siteSummaryLoaded: count => `${count} supported sites are available below. Click a button to open one in this controlled browser.`,
|
||||
siteSummaryEmpty: 'No supported site list was loaded right now, but you can still open your target AI site manually in this controlled browser.',
|
||||
emptySites: 'No supported site list was loaded right now. You can still open your target AI site manually in this controlled browser.'
|
||||
}
|
||||
};
|
||||
|
||||
const state = {
|
||||
currentLanguage: normalizeLanguage(localStorage.getItem('controlled-browser-guide-language') || 'zh'),
|
||||
sites: [],
|
||||
dashboardUrl: `${window.location.origin}/`,
|
||||
dashboardCopyStatus: ''
|
||||
};
|
||||
|
||||
function loadGuideBackground(index = 0) {
|
||||
if (index >= guideBackgroundCandidates.length) return;
|
||||
|
||||
const url = guideBackgroundCandidates[index];
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
document.documentElement.style.setProperty('--guide-bg-image', `url("${url}")`);
|
||||
};
|
||||
img.onerror = () => loadGuideBackground(index + 1);
|
||||
img.src = url;
|
||||
}
|
||||
|
||||
const els = {
|
||||
languageSwitch: document.getElementById('languageSwitch'),
|
||||
languageButtons: document.querySelectorAll('[data-lang-option]'),
|
||||
heroBadge: document.getElementById('heroBadge'),
|
||||
heroTitle: document.getElementById('heroTitle'),
|
||||
heroCopy: document.getElementById('heroCopy'),
|
||||
confirmControlledBtn: document.getElementById('confirmControlledBtn'),
|
||||
stepOneStatus: document.getElementById('stepOneStatus'),
|
||||
stepTwo: document.getElementById('stepTwo'),
|
||||
stepTwoKicker: document.getElementById('stepTwoKicker'),
|
||||
stepTwoTitle: document.getElementById('stepTwoTitle'),
|
||||
stepTwoSubtitle: document.getElementById('stepTwoSubtitle'),
|
||||
stepTwoCopy: document.getElementById('stepTwoCopy'),
|
||||
confirmDisciplineBtn: document.getElementById('confirmDisciplineBtn'),
|
||||
stepTwoStatus: document.getElementById('stepTwoStatus'),
|
||||
finalStage: document.getElementById('finalStage'),
|
||||
finalKicker: document.getElementById('finalKicker'),
|
||||
finalTitle: document.getElementById('finalTitle'),
|
||||
finalSubtitle: document.getElementById('finalSubtitle'),
|
||||
noteTitle: document.getElementById('noteTitle'),
|
||||
noteCopy: document.getElementById('noteCopy'),
|
||||
siteSummary: document.getElementById('siteSummary'),
|
||||
siteGrid: document.getElementById('siteGrid'),
|
||||
dashboardKicker: document.getElementById('dashboardKicker'),
|
||||
dashboardTitle: document.getElementById('dashboardTitle'),
|
||||
dashboardBody: document.getElementById('dashboardBody'),
|
||||
dashboardUrl: document.getElementById('dashboardUrl'),
|
||||
copyDashboardBtn: document.getElementById('copyDashboardBtn'),
|
||||
dashboardCopyFeedback: document.getElementById('dashboardCopyFeedback'),
|
||||
closingKicker: document.getElementById('closingKicker'),
|
||||
closingTitle: document.getElementById('closingTitle'),
|
||||
closingBody: document.getElementById('closingBody')
|
||||
};
|
||||
|
||||
function normalizeLanguage(language) {
|
||||
return String(language || '').toLowerCase().startsWith('en') ? 'en' : 'zh';
|
||||
}
|
||||
|
||||
function bundle() {
|
||||
return translations[state.currentLanguage] || translations.zh;
|
||||
}
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value || '')
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll("'", ''');
|
||||
}
|
||||
|
||||
function normalizeHttpUrl(value) {
|
||||
const raw = String(value || '').trim();
|
||||
if (!raw) return '';
|
||||
try {
|
||||
const parsed = new URL(raw);
|
||||
return ['http:', 'https:'].includes(parsed.protocol) ? parsed.href : '';
|
||||
} catch (error) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function setRevealVisible(element) {
|
||||
if (!element || element.classList.contains('visible')) return;
|
||||
element.classList.add('visible');
|
||||
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
|
||||
function updateLanguageButtons() {
|
||||
els.languageButtons.forEach(button => {
|
||||
const active = button.dataset.langOption === state.currentLanguage;
|
||||
button.classList.toggle('active', active);
|
||||
button.setAttribute('aria-pressed', active ? 'true' : 'false');
|
||||
});
|
||||
}
|
||||
|
||||
function renderDashboardUrl() {
|
||||
els.dashboardUrl.textContent = state.dashboardUrl || bundle().dashboardLoading;
|
||||
}
|
||||
|
||||
function renderDashboardFeedback() {
|
||||
if (state.dashboardCopyStatus === 'success') {
|
||||
els.dashboardCopyFeedback.textContent = bundle().dashboardCopied;
|
||||
} else if (state.dashboardCopyStatus === 'error') {
|
||||
els.dashboardCopyFeedback.textContent = bundle().dashboardCopyFailed;
|
||||
} else {
|
||||
els.dashboardCopyFeedback.textContent = '';
|
||||
}
|
||||
}
|
||||
|
||||
function renderSites() {
|
||||
const texts = bundle();
|
||||
const sites = (Array.isArray(state.sites) ? state.sites : [])
|
||||
.map(site => ({ ...site, url: normalizeHttpUrl(site && site.url) }))
|
||||
.filter(site => site.url);
|
||||
els.siteSummary.textContent = sites.length ? texts.siteSummaryLoaded(sites.length) : texts.siteSummaryEmpty;
|
||||
|
||||
if (!sites.length) {
|
||||
els.siteGrid.innerHTML = `<div class="empty-state">${texts.emptySites}</div>`;
|
||||
return;
|
||||
}
|
||||
|
||||
els.siteGrid.innerHTML = sites.map(site => `
|
||||
<article class="site-card">
|
||||
<h3 class="site-title">${escapeHtml(site.name || site.domain)}</h3>
|
||||
<p class="site-url">${escapeHtml(site.url)}</p>
|
||||
<button type="button" class="action-btn secondary" data-site-url="${escapeHtml(site.url)}">${escapeHtml(texts.siteOpen)}</button>
|
||||
</article>
|
||||
`).join('');
|
||||
|
||||
els.siteGrid.querySelectorAll('[data-site-url]').forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
const url = button.getAttribute('data-site-url') || '';
|
||||
if (url) window.location.assign(url);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function applyLanguage(language) {
|
||||
state.currentLanguage = normalizeLanguage(language);
|
||||
localStorage.setItem('controlled-browser-guide-language', state.currentLanguage);
|
||||
const texts = bundle();
|
||||
|
||||
document.documentElement.lang = texts.lang;
|
||||
document.documentElement.dataset.guideLang = state.currentLanguage;
|
||||
document.title = texts.title;
|
||||
els.languageSwitch.setAttribute('aria-label', texts.languageLabel);
|
||||
els.heroBadge.textContent = texts.heroBadge;
|
||||
els.heroTitle.textContent = texts.heroTitle;
|
||||
els.heroCopy.innerHTML = texts.heroCopy;
|
||||
els.confirmControlledBtn.textContent = texts.confirmControlled;
|
||||
els.stepOneStatus.textContent = texts.stepOneStatus;
|
||||
els.stepTwoKicker.textContent = texts.stepTwoKicker;
|
||||
els.stepTwoTitle.textContent = texts.stepTwoTitle;
|
||||
els.stepTwoSubtitle.textContent = texts.stepTwoSubtitle;
|
||||
els.stepTwoCopy.textContent = texts.stepTwoCopy;
|
||||
els.confirmDisciplineBtn.textContent = texts.confirmDiscipline;
|
||||
els.stepTwoStatus.textContent = texts.stepTwoStatus;
|
||||
els.finalKicker.textContent = texts.finalKicker;
|
||||
els.finalTitle.textContent = texts.finalTitle;
|
||||
els.finalSubtitle.textContent = texts.finalSubtitle;
|
||||
els.noteTitle.textContent = texts.noteTitle;
|
||||
els.noteCopy.textContent = texts.noteCopy;
|
||||
els.dashboardKicker.textContent = texts.dashboardKicker;
|
||||
els.dashboardTitle.textContent = texts.dashboardTitle;
|
||||
els.dashboardBody.textContent = texts.dashboardBody;
|
||||
els.copyDashboardBtn.textContent = texts.copyDashboard;
|
||||
els.closingKicker.textContent = texts.closingKicker;
|
||||
els.closingTitle.textContent = texts.closingTitle;
|
||||
els.closingBody.textContent = texts.closingBody;
|
||||
|
||||
updateLanguageButtons();
|
||||
renderSites();
|
||||
renderDashboardUrl();
|
||||
renderDashboardFeedback();
|
||||
}
|
||||
|
||||
async function copyToClipboard(text) {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
return;
|
||||
}
|
||||
const helper = document.createElement('textarea');
|
||||
helper.value = text;
|
||||
helper.setAttribute('readonly', 'readonly');
|
||||
helper.style.position = 'fixed';
|
||||
helper.style.opacity = '0';
|
||||
helper.style.pointerEvents = 'none';
|
||||
document.body.appendChild(helper);
|
||||
helper.focus();
|
||||
helper.select();
|
||||
try {
|
||||
const copied = document.execCommand('copy');
|
||||
if (!copied) throw new Error('copy_failed');
|
||||
} finally {
|
||||
document.body.removeChild(helper);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadGuideData() {
|
||||
try {
|
||||
const response = await fetch('/api/startup/controlled-browser-guide-data', { cache: 'no-store' });
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
const payload = await response.json();
|
||||
state.sites = Array.isArray(payload.sites) ? payload.sites : state.sites;
|
||||
if (payload.dashboard_url) state.dashboardUrl = payload.dashboard_url;
|
||||
} catch (error) {
|
||||
console.log('loadGuideData failed (using default fallback sites):', error.message || error);
|
||||
if (!state.sites || !state.sites.length) {
|
||||
state.sites = [
|
||||
{ name: 'ChatGPT', domain: 'chatgpt.com', url: 'https://chatgpt.com' },
|
||||
{ name: 'Claude', domain: 'claude.ai', url: 'https://claude.ai' },
|
||||
{ name: 'Gemini', domain: 'gemini.google.com', url: 'https://gemini.google.com' },
|
||||
{ name: 'DeepSeek', domain: 'chat.deepseek.com', url: 'https://chat.deepseek.com' }
|
||||
];
|
||||
}
|
||||
}
|
||||
renderSites();
|
||||
renderDashboardUrl();
|
||||
}
|
||||
|
||||
els.confirmControlledBtn.addEventListener('click', () => {
|
||||
els.confirmControlledBtn.disabled = true;
|
||||
els.confirmControlledBtn.style.opacity = '0.78';
|
||||
els.stepOneStatus.hidden = false;
|
||||
setRevealVisible(els.stepTwo);
|
||||
});
|
||||
|
||||
els.confirmDisciplineBtn.addEventListener('click', () => {
|
||||
els.confirmDisciplineBtn.disabled = true;
|
||||
els.confirmDisciplineBtn.style.opacity = '0.78';
|
||||
els.stepTwoStatus.hidden = false;
|
||||
setRevealVisible(els.finalStage);
|
||||
});
|
||||
|
||||
els.copyDashboardBtn.addEventListener('click', async () => {
|
||||
state.dashboardCopyStatus = '';
|
||||
renderDashboardFeedback();
|
||||
try {
|
||||
await copyToClipboard(state.dashboardUrl || `${window.location.origin}/`);
|
||||
state.dashboardCopyStatus = 'success';
|
||||
} catch (error) {
|
||||
state.dashboardCopyStatus = 'error';
|
||||
}
|
||||
renderDashboardFeedback();
|
||||
});
|
||||
|
||||
els.languageButtons.forEach(button => {
|
||||
button.addEventListener('click', () => applyLanguage(button.dataset.langOption || 'zh'));
|
||||
});
|
||||
|
||||
applyLanguage(state.currentLanguage);
|
||||
loadGuideData();
|
||||
loadGuideBackground();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,26 @@
|
||||
/* R2-8:站点适配器维护面板(健康巡检 / 选择器稳健度 / 适配器更新) */
|
||||
.adapter-panel { display: flex; flex-direction: column; gap: 16px; }
|
||||
.adapter-card { padding: 16px 18px; }
|
||||
.adapter-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
|
||||
.adapter-card-header h4 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
|
||||
.adapter-card-header p { margin: 0; font-size: 13px; opacity: .75; line-height: 1.5; }
|
||||
.adapter-btn { flex-shrink: 0; padding: 6px 14px; border-radius: 8px; border: 1px solid rgba(99, 102, 241, .45);
|
||||
background: rgba(99, 102, 241, .08); color: inherit; font-size: 13px; cursor: pointer; margin-top: 8px; }
|
||||
.adapter-btn:hover:not(:disabled) { background: rgba(99, 102, 241, .16); }
|
||||
.adapter-btn:disabled { opacity: .5; cursor: not-allowed; }
|
||||
.adapter-btn.is-small { padding: 2px 10px; margin-top: 0; font-size: 12px; }
|
||||
.adapter-result { margin-top: 12px; font-size: 13px; }
|
||||
.adapter-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 12.5px; }
|
||||
.adapter-table th, .adapter-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(127, 127, 127, .18); vertical-align: top; }
|
||||
.adapter-table code { font-size: 12px; word-break: break-all; }
|
||||
.adapter-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: rgba(127, 127, 127, .15); }
|
||||
.adapter-badge.is-good { background: rgba(34, 197, 94, .15); color: #15803d; }
|
||||
.adapter-badge.is-warn { background: rgba(234, 179, 8, .18); color: #a16207; }
|
||||
.adapter-badge.is-bad { background: rgba(239, 68, 68, .15); color: #b91c1c; }
|
||||
.adapter-error { color: #dc2626; font-size: 13px; margin-top: 8px; }
|
||||
.adapter-good { color: #15803d; margin: 6px 0; }
|
||||
.adapter-muted { opacity: .65; margin-left: 8px; }
|
||||
.adapter-problems { margin: 6px 0 6px 18px; list-style: disc; }
|
||||
html.dark .adapter-badge.is-good, .dark .adapter-badge.is-good { color: #4ade80; }
|
||||
html.dark .adapter-badge.is-warn, .dark .adapter-badge.is-warn { color: #facc15; }
|
||||
html.dark .adapter-badge.is-bad, .dark .adapter-badge.is-bad { color: #f87171; }
|
||||
@@ -0,0 +1,622 @@
|
||||
/* ============================================================================
|
||||
dashboard-dark.css — 夜间模式主题层 + 全局细节增强
|
||||
加载顺序:dashboard.css → dashboard-migration.css → dashboard-reference.css
|
||||
→ onboarding-guide.css → 本文件(最后加载,负责夜间模式统一)
|
||||
设计目标:
|
||||
1. 让参考主题(uwa- / app- 前缀)在夜间模式下拥有完整、协调的暖绿深色配色;
|
||||
2. 通过 Tailwind 中性色变量,让旧组件(弹窗、标签页池、设置页等)的
|
||||
dark: 工具类自动落在同一套暖绿色板上,而不是冷蓝灰;
|
||||
3. 附带全局的焦点可见性、选区颜色、滚动条与动效偏好等细节增强。
|
||||
========================================================================== */
|
||||
|
||||
/* ==================== 1. Tailwind 中性色变量(亮色 = 官方默认值) ==================== */
|
||||
:root {
|
||||
color-scheme: light;
|
||||
|
||||
--twc-gray-50: 249 250 251;
|
||||
--twc-gray-100: 243 244 246;
|
||||
--twc-gray-200: 229 231 235;
|
||||
--twc-gray-300: 209 213 219;
|
||||
--twc-gray-400: 156 163 175;
|
||||
--twc-gray-500: 107 114 128;
|
||||
--twc-gray-600: 75 85 99;
|
||||
--twc-gray-700: 55 65 81;
|
||||
--twc-gray-800: 31 41 55;
|
||||
--twc-gray-900: 17 24 39;
|
||||
--twc-gray-950: 3 7 18;
|
||||
|
||||
--twc-slate-50: 248 250 252;
|
||||
--twc-slate-100: 241 245 249;
|
||||
--twc-slate-200: 226 232 240;
|
||||
--twc-slate-300: 203 213 225;
|
||||
--twc-slate-400: 148 163 184;
|
||||
--twc-slate-500: 100 116 139;
|
||||
--twc-slate-600: 71 85 105;
|
||||
--twc-slate-700: 51 65 85;
|
||||
--twc-slate-800: 30 41 59;
|
||||
--twc-slate-900: 15 23 42;
|
||||
--twc-slate-950: 2 6 23;
|
||||
|
||||
--twc-stone-50: 250 250 249;
|
||||
--twc-stone-100: 245 245 244;
|
||||
--twc-stone-200: 231 229 228;
|
||||
--twc-stone-300: 214 211 209;
|
||||
--twc-stone-400: 168 162 158;
|
||||
--twc-stone-500: 120 113 108;
|
||||
--twc-stone-600: 87 83 78;
|
||||
--twc-stone-700: 68 64 60;
|
||||
--twc-stone-800: 41 37 36;
|
||||
--twc-stone-900: 28 25 23;
|
||||
--twc-stone-950: 12 10 9;
|
||||
}
|
||||
|
||||
/* 夜间:三套中性色统一收敛到暖绿深色板,与橄榄主题同源 */
|
||||
.dark {
|
||||
color-scheme: dark;
|
||||
|
||||
--twc-gray-50: 239 243 233;
|
||||
--twc-gray-100: 228 234 221;
|
||||
--twc-gray-200: 211 219 204;
|
||||
--twc-gray-300: 183 193 178;
|
||||
--twc-gray-400: 150 161 148;
|
||||
--twc-gray-500: 117 128 114;
|
||||
--twc-gray-600: 51 61 53;
|
||||
--twc-gray-700: 38 46 40;
|
||||
--twc-gray-800: 29 36 31;
|
||||
--twc-gray-900: 21 26 23;
|
||||
--twc-gray-950: 15 19 15;
|
||||
|
||||
--twc-slate-50: 239 243 233;
|
||||
--twc-slate-100: 228 234 221;
|
||||
--twc-slate-200: 211 219 204;
|
||||
--twc-slate-300: 183 193 178;
|
||||
--twc-slate-400: 150 161 148;
|
||||
--twc-slate-500: 117 128 114;
|
||||
--twc-slate-600: 51 61 53;
|
||||
--twc-slate-700: 38 46 40;
|
||||
--twc-slate-800: 29 36 31;
|
||||
--twc-slate-900: 21 26 23;
|
||||
--twc-slate-950: 15 19 15;
|
||||
|
||||
--twc-stone-50: 239 243 233;
|
||||
--twc-stone-100: 228 234 221;
|
||||
--twc-stone-200: 211 219 204;
|
||||
--twc-stone-300: 183 193 178;
|
||||
--twc-stone-400: 150 161 148;
|
||||
--twc-stone-500: 117 128 114;
|
||||
--twc-stone-600: 51 61 53;
|
||||
--twc-stone-700: 38 46 40;
|
||||
--twc-stone-800: 29 36 31;
|
||||
--twc-stone-900: 21 26 23;
|
||||
--twc-stone-950: 15 19 15;
|
||||
}
|
||||
|
||||
/* ==================== 2. 参考主题令牌(uwa-)夜间取值 ==================== */
|
||||
.dark {
|
||||
--uwa-paper: #141915;
|
||||
--uwa-paper-strong: #1c231d;
|
||||
--uwa-paper-soft: #242c25;
|
||||
--uwa-ink: #d8dfd0;
|
||||
--uwa-ink-strong: #edf1e6;
|
||||
--uwa-muted: #a0ab97;
|
||||
--uwa-muted-soft: #7f8b76;
|
||||
--uwa-line: #333d34;
|
||||
--uwa-line-soft: #2a332b;
|
||||
--uwa-olive: #94b374;
|
||||
--uwa-olive-dark: #b4cf9a;
|
||||
--uwa-leaf: #8fbc8f;
|
||||
--uwa-leaf-soft: #31402a;
|
||||
--uwa-green-card: #2e3d26;
|
||||
--uwa-ochre: #caa365;
|
||||
--uwa-clay: #c98f7a;
|
||||
--uwa-blue: #82a9b5;
|
||||
}
|
||||
|
||||
/* ==================== 3. 参考主题里的硬编码颜色 → 夜间覆盖 ==================== */
|
||||
|
||||
/* --- 侧边栏 --- */
|
||||
.dark .app-nav-item:hover {
|
||||
background: rgba(60, 74, 54, .45) !important;
|
||||
}
|
||||
|
||||
.dark .app-guide-link,
|
||||
.dark .app-theme-toggle {
|
||||
color: var(--uwa-muted) !important;
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
.dark .app-guide-link:hover,
|
||||
.dark .app-theme-toggle:hover {
|
||||
color: var(--uwa-ink) !important;
|
||||
background: rgba(60, 74, 54, .45) !important;
|
||||
}
|
||||
|
||||
.dark .app-theme-toggle i {
|
||||
background: #3a463b !important;
|
||||
}
|
||||
|
||||
.dark .app-theme-toggle[aria-pressed="true"] i {
|
||||
background: var(--uwa-olive) !important;
|
||||
}
|
||||
|
||||
.dark .app-sidebar-primary {
|
||||
color: #16200f !important;
|
||||
box-shadow: 0 3px 10px rgba(0, 0, 0, .35) !important;
|
||||
}
|
||||
|
||||
/* 亮色强调块上的白色文字,在夜间换成深墨绿,保证对比度 */
|
||||
.dark .uwa-site-mark,
|
||||
.dark .uwa-domain-avatar,
|
||||
.dark .uwa-feature-icon,
|
||||
.dark .uwa-token-kpi-icon,
|
||||
.dark .uwa-primary-button,
|
||||
.dark .uwa-button.is-primary,
|
||||
.dark .uwa-ranking-tabs button.is-active,
|
||||
.dark .uwa-segmented button.is-active,
|
||||
.dark .uwa-page-button.is-active {
|
||||
color: #16200f;
|
||||
}
|
||||
|
||||
.dark .uwa-editor-site-icon {
|
||||
border-color: var(--uwa-line);
|
||||
color: var(--uwa-ink);
|
||||
background: var(--uwa-paper-strong);
|
||||
}
|
||||
|
||||
/* --- 首页 Hero 插画 --- */
|
||||
.dark .uwa-hero-art .shape-a { background: #4e6a46; }
|
||||
.dark .uwa-hero-art .shape-b { background: #223021; }
|
||||
.dark .uwa-hero-art .shape-c { background: #3a3527; }
|
||||
.dark .uwa-hero-art .line-a,
|
||||
.dark .uwa-hero-art .line-b { background: #5a7350; }
|
||||
.dark .uwa-hero-art .node-a,
|
||||
.dark .uwa-hero-art .node-b,
|
||||
.dark .uwa-hero-art .node-c { border-color: #87a274; }
|
||||
|
||||
/* --- 首页卡片 --- */
|
||||
.dark .uwa-action-card {
|
||||
box-shadow: 0 12px 28px rgba(0, 0, 0, .32);
|
||||
}
|
||||
|
||||
.dark .uwa-action-card.is-api { background: #322c1f; }
|
||||
|
||||
.dark .uwa-soft-tag {
|
||||
border-color: rgba(148, 179, 116, .28);
|
||||
background: rgba(20, 25, 21, .55);
|
||||
}
|
||||
|
||||
.dark .uwa-endpoint-box,
|
||||
.dark .uwa-browser-preview,
|
||||
.dark .uwa-request-preview,
|
||||
.dark .uwa-empty-preview {
|
||||
border-color: rgba(148, 179, 116, .24);
|
||||
background: rgba(20, 25, 21, .5);
|
||||
}
|
||||
|
||||
/* --- 配置页工作区 --- */
|
||||
.dark .uwa-config-workspace {
|
||||
background: rgba(28, 35, 29, .55);
|
||||
}
|
||||
|
||||
.dark .uwa-site-rail {
|
||||
background: rgba(36, 44, 37, .6);
|
||||
}
|
||||
|
||||
.dark .uwa-rail-site:hover { background: rgba(44, 54, 45, .6); }
|
||||
|
||||
.dark .uwa-rail-site.is-active {
|
||||
border-color: #46573c;
|
||||
background: #2f4126;
|
||||
box-shadow: 0 3px 9px rgba(0, 0, 0, .28);
|
||||
}
|
||||
|
||||
.dark .uwa-switcher-site.is-active { border-color: #46573c; }
|
||||
|
||||
.dark .uwa-switcher-actions button {
|
||||
background: rgba(28, 35, 29, .9);
|
||||
}
|
||||
|
||||
.dark .uwa-site-switcher-popover {
|
||||
box-shadow: 0 22px 55px rgba(0, 0, 0, .5);
|
||||
}
|
||||
|
||||
.dark .uwa-switch-label i { background: #3a463b; }
|
||||
.dark .uwa-filter-toggle i { background: #3a463b; }
|
||||
|
||||
.dark .uwa-config-editor .config-preset-card {
|
||||
background: rgba(36, 44, 37, .5) !important;
|
||||
}
|
||||
|
||||
/* --- 配置页 v3.2 重排:新元素的夜间取值 --- */
|
||||
.dark .uwa-config-toolbar-meta > span {
|
||||
border-color: var(--uwa-line-soft);
|
||||
background: rgba(28, 35, 29, .6);
|
||||
}
|
||||
|
||||
.dark .uwa-config-workspace {
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 14px 34px rgba(0, 0, 0, .28);
|
||||
}
|
||||
|
||||
.dark .config-preset-chip {
|
||||
border-color: rgba(148, 179, 116, .3);
|
||||
}
|
||||
|
||||
.dark .preset-more[open] > summary {
|
||||
border-color: #46573c;
|
||||
}
|
||||
|
||||
.dark .preset-more-pop {
|
||||
box-shadow: 0 18px 42px rgba(0, 0, 0, .5);
|
||||
}
|
||||
|
||||
.dark .uwa-config-search-pop {
|
||||
box-shadow: 0 18px 42px rgba(0, 0, 0, .5);
|
||||
}
|
||||
.dark .uwa-dropdown-menu {
|
||||
border-color: var(--uwa-line);
|
||||
background: var(--uwa-paper-strong);
|
||||
box-shadow: 0 18px 42px rgba(0, 0, 0, .5);
|
||||
}
|
||||
|
||||
.dark .uwa-dropdown-icon {
|
||||
background: var(--uwa-paper-soft);
|
||||
color: #a3c28e;
|
||||
}
|
||||
|
||||
.dark .uwa-dropdown-item:hover:not(:disabled):not(.is-disabled) {
|
||||
background: var(--uwa-paper-soft);
|
||||
}
|
||||
|
||||
|
||||
.dark .uwa-config-editor .config-preset-card .preset-more-pop button.is-danger {
|
||||
color: #d99a8c !important;
|
||||
}
|
||||
|
||||
.dark .uwa-config-editor .config-preset-card .preset-btn.is-primary {
|
||||
color: #16200f !important;
|
||||
}
|
||||
|
||||
.dark .uwa-config-editor .config-preset-card .config-preset-hint {
|
||||
border-color: var(--uwa-line);
|
||||
background: rgba(20, 25, 21, .55);
|
||||
}
|
||||
|
||||
.dark .uwa-config-section-nav {
|
||||
background: rgba(20, 25, 21, .5);
|
||||
}
|
||||
|
||||
.dark .uwa-config-section-nav button.is-active {
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
|
||||
}
|
||||
|
||||
.dark .uwa-config-editor .config-fixed-panel > div:first-child,
|
||||
.dark .uwa-config-editor .config-fixed-panel > div:first-child:hover {
|
||||
background: rgba(36, 44, 37, .4) !important;
|
||||
}
|
||||
|
||||
.dark .uwa-config-editor .config-fixed-panel button.selector-add-btn {
|
||||
border-color: var(--uwa-line) !important;
|
||||
color: var(--uwa-ink) !important;
|
||||
background: var(--uwa-paper-strong) !important;
|
||||
}
|
||||
|
||||
.dark .uwa-config-editor .config-fixed-panel button.selector-add-btn:hover {
|
||||
background: var(--uwa-paper-soft) !important;
|
||||
}
|
||||
|
||||
/* --- 请求监控:Token 用量卡片 --- */
|
||||
.dark .uwa-token-kpis article {
|
||||
border-color: #3c4a33;
|
||||
background: #2b3724;
|
||||
box-shadow: 0 10px 24px rgba(0, 0, 0, .3);
|
||||
}
|
||||
|
||||
.dark .uwa-token-kpis article.is-input { border-color: #4a442f; background: #322d1f; }
|
||||
.dark .uwa-token-kpis article.is-output { border-color: #524a36; background: #393325; }
|
||||
.dark .uwa-token-kpis article.is-calls { border-color: #485a3c; background: #2b3724; }
|
||||
|
||||
.dark .uwa-token-kpi-icon { background: #6d8156; }
|
||||
.dark .uwa-token-kpis article.is-calls .uwa-token-kpi-icon { background: #5b7048; }
|
||||
|
||||
.dark .uwa-token-legend i { background: #c2d0b0; }
|
||||
.dark .uwa-token-legend i.is-input { background: #8ed29a; }
|
||||
.dark .uwa-token-legend i.is-output { background: #f0a35e; }
|
||||
|
||||
.dark .uwa-token-line-chart path.is-input { stroke: #8ed29a; }
|
||||
.dark .uwa-token-line-chart path.is-output { stroke: #f0a35e; }
|
||||
.dark .uwa-daily-token-chart rect.is-input { fill: #8ed29a; }
|
||||
.dark .uwa-daily-token-chart rect.is-output { fill: #f0a35e; }
|
||||
.dark .uwa-daily-token-chart path { stroke: #c2d0b0; }
|
||||
|
||||
.dark .uwa-donut-track { stroke: #2c362d; }
|
||||
.dark .uwa-model-usage-list b { background: #2c362d; }
|
||||
.dark .uwa-system-load-panel i { background: #2c362d; }
|
||||
.dark .uwa-domain-row i { background: #2c362d; }
|
||||
|
||||
.dark .uwa-inline-error {
|
||||
border-color: #5e372e;
|
||||
color: #eba896;
|
||||
background: rgba(150, 70, 55, .16);
|
||||
}
|
||||
|
||||
/* --- 请求监控:图表与列表 --- */
|
||||
.dark .uwa-ranking-tabs,
|
||||
.dark .uwa-segmented {
|
||||
background: rgba(28, 35, 29, .75);
|
||||
}
|
||||
|
||||
.dark .uwa-trend-chart polygon { fill: rgba(148, 179, 116, .16); }
|
||||
|
||||
.dark .uwa-trend-health-legend i { background: #3a463b; }
|
||||
.dark .uwa-trend-health-legend i.is-success { background: #79aa77; }
|
||||
.dark .uwa-trend-health-legend i.is-failed { background: var(--uwa-clay); }
|
||||
.dark .uwa-trend-health > div.is-idle { background: #2c362d; }
|
||||
|
||||
.dark .uwa-request-table-wrap { background: rgba(28, 35, 29, .6); }
|
||||
.dark .uwa-request-table-header { background: rgba(36, 44, 37, .6); }
|
||||
.dark .uwa-request-row:hover { background: rgba(58, 72, 52, .35); }
|
||||
|
||||
/* --- 日志页 --- */
|
||||
.dark .uwa-simple-page .logs-workspace > div:first-child {
|
||||
background: rgba(36, 44, 37, .6) !important;
|
||||
}
|
||||
|
||||
/* ==================== 4. 旧组件字面量颜色 → 暖绿夜间色 ==================== */
|
||||
|
||||
/* 滚动条 */
|
||||
.dark ::-webkit-scrollbar-thumb { background: #3b463d; }
|
||||
.dark ::-webkit-scrollbar-thumb:hover { background: #4c584e; }
|
||||
|
||||
/* 设置页分组卡片 */
|
||||
.dark .settings-group {
|
||||
background-color: #1c231d;
|
||||
border-color: #333d34;
|
||||
}
|
||||
|
||||
.dark .settings-group-header {
|
||||
background-color: #1c231d;
|
||||
border-color: #333d34;
|
||||
}
|
||||
|
||||
.dark .settings-group-header:hover { background-color: #161c17; }
|
||||
.dark .settings-group-title { color: #edf1e6; }
|
||||
.dark .settings-row { border-color: #2a332b; }
|
||||
.dark .settings-label { color: #edf1e6; }
|
||||
.dark .settings-desc { color: #8b967f; }
|
||||
|
||||
.dark .settings-input {
|
||||
background-color: #141915;
|
||||
border-color: #3b463d;
|
||||
color: #edf1e6;
|
||||
}
|
||||
|
||||
.dark .settings-input::placeholder { color: #6d7a68; }
|
||||
|
||||
.dark .settings-input:focus {
|
||||
border-color: var(--uwa-accent, #88a66f);
|
||||
box-shadow: 0 0 0 2px rgba(136, 166, 111, .35);
|
||||
}
|
||||
|
||||
.dark .toggle-bg { background-color: #3a463b; }
|
||||
.dark .toggle-label input:checked + .toggle-bg { background-color: #6f8f55; }
|
||||
|
||||
/* 标签页池控制台令牌 */
|
||||
.dark .tab-pool-console {
|
||||
--tp-bg: #141915;
|
||||
--tp-panel: #1c231d;
|
||||
--tp-soft: #161c17;
|
||||
--tp-soft-strong: #242c25;
|
||||
--tp-border: #333d34;
|
||||
--tp-text: #edf1e6;
|
||||
--tp-muted: #b7c1af;
|
||||
--tp-faint: #7f8b76;
|
||||
--tp-accent: #94b374;
|
||||
--tp-accent-soft: rgba(148, 179, 116, .18);
|
||||
--tp-code: #242c25;
|
||||
}
|
||||
|
||||
/* 新手引导卡片:由冷蓝渐变换成暖绿渐变 */
|
||||
.dark .dashboard-guide-card {
|
||||
border-color: rgba(90, 105, 80, .5);
|
||||
background:
|
||||
radial-gradient(circle at top right, rgba(148, 179, 116, .12), transparent 44%),
|
||||
linear-gradient(135deg, rgba(22, 28, 23, .96), rgba(28, 35, 29, .96));
|
||||
box-shadow: 0 18px 36px rgba(0, 0, 0, .28);
|
||||
}
|
||||
|
||||
.dark .dashboard-guide-badge {
|
||||
background: rgba(148, 179, 116, .14);
|
||||
color: #c9d8b6;
|
||||
}
|
||||
|
||||
.dark .dashboard-guide-toggle {
|
||||
border-color: rgba(90, 105, 80, .55);
|
||||
background: rgba(20, 25, 21, .74);
|
||||
color: #c9d8b6;
|
||||
}
|
||||
|
||||
.dark .dashboard-guide-btn--secondary {
|
||||
border-color: rgba(90, 105, 80, .6);
|
||||
background: rgba(20, 25, 21, .72);
|
||||
color: #d8dfd0;
|
||||
}
|
||||
|
||||
.dark .dashboard-guide-step,
|
||||
.dark .dashboard-mini-card,
|
||||
.dark .dashboard-checklist-item,
|
||||
.dark .dashboard-empty-state,
|
||||
.dark .dashboard-field-tooltip {
|
||||
background: rgba(20, 25, 21, .62);
|
||||
border-color: rgba(90, 105, 80, .52);
|
||||
color: #c4cdbb;
|
||||
}
|
||||
|
||||
.dark .dashboard-guide-step strong,
|
||||
.dark .dashboard-mini-card-title { color: #edf1e6; }
|
||||
|
||||
/* ==================== 5. 全局细节增强(亮暗通用) ==================== */
|
||||
|
||||
/* 键盘导航焦点可见性:统一使用主题强调色 */
|
||||
#app :focus-visible {
|
||||
outline: 2px solid var(--uwa-olive, #5d6b4d);
|
||||
outline-offset: 2px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
#app input:focus-visible,
|
||||
#app select:focus-visible,
|
||||
#app textarea:focus-visible {
|
||||
outline: none; /* 输入框已有 focus 边框与阴影,避免双重描边 */
|
||||
}
|
||||
|
||||
/* 文字选区 */
|
||||
::selection {
|
||||
background: rgba(143, 188, 143, .38);
|
||||
}
|
||||
|
||||
.dark ::selection {
|
||||
background: rgba(148, 179, 116, .4);
|
||||
}
|
||||
|
||||
/* 主要表面的主题切换过渡,让明暗切换更柔和 */
|
||||
body,
|
||||
.app-sidebar,
|
||||
.dashboard-main,
|
||||
.dashboard-scroll-region,
|
||||
.uwa-action-card,
|
||||
.uwa-config-workspace,
|
||||
.settings-group {
|
||||
transition: background-color .25s ease, border-color .25s ease;
|
||||
}
|
||||
|
||||
/* 尊重"减少动态效果"系统偏好 */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: .01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: .01ms !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==================== 6. Toast 通知(统一主题样式) ==================== */
|
||||
.uwa-toast-stack {
|
||||
position: fixed;
|
||||
top: 18px;
|
||||
right: 18px;
|
||||
z-index: 60;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
width: min(340px, calc(100vw - 36px));
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.uwa-toast {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
padding: 11px 14px;
|
||||
border: 1px solid var(--uwa-line, #ddd4c3);
|
||||
border-left: 3px solid var(--uwa-olive, #5d6b4d);
|
||||
border-radius: 8px;
|
||||
color: var(--uwa-ink, #33402c);
|
||||
background: var(--uwa-paper-strong, #fffdf8);
|
||||
box-shadow: 0 10px 28px rgba(47, 55, 39, .18);
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
animation: uwa-toast-in .22s ease-out;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.dark .uwa-toast {
|
||||
box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
|
||||
}
|
||||
|
||||
.uwa-toast-dot {
|
||||
flex: 0 0 8px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
margin-top: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--uwa-olive, #5d6b4d);
|
||||
}
|
||||
|
||||
.uwa-toast.is-success { border-left-color: #6ea56d; }
|
||||
.uwa-toast.is-success .uwa-toast-dot { background: #6ea56d; }
|
||||
.uwa-toast.is-error { border-left-color: #a86159; }
|
||||
.uwa-toast.is-error .uwa-toast-dot { background: #a86159; }
|
||||
.uwa-toast.is-warning { border-left-color: #b99359; }
|
||||
.uwa-toast.is-warning .uwa-toast-dot { background: #b99359; }
|
||||
.uwa-toast.is-info { border-left-color: #7397a2; }
|
||||
.uwa-toast.is-info .uwa-toast-dot { background: #7397a2; }
|
||||
|
||||
@keyframes uwa-toast-in {
|
||||
from {
|
||||
transform: translateX(14px);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==================== 请求工作流面板(uwa-workflow-panel)夜间取值 ==================== */
|
||||
|
||||
/* 主按钮(新增步骤):夜间浅绿底配深字,保证对比度 */
|
||||
.dark .uwa-workflow-panel > div:first-child .flex.gap-2 button.bg-blue-500 {
|
||||
color: #142011 !important;
|
||||
}
|
||||
|
||||
/* 步骤卡片悬停描边 */
|
||||
.dark .uwa-workflow-panel > div:last-child > div.rounded-lg:not(.uwa-wf-hint):hover {
|
||||
border-color: #46573c !important;
|
||||
}
|
||||
|
||||
/* 删除类操作 */
|
||||
.dark .uwa-workflow-panel button[class*="hover:text-red"]:hover {
|
||||
color: #d8988a !important;
|
||||
background: rgba(201, 143, 122, .16) !important;
|
||||
}
|
||||
|
||||
/* 只读提示语气卡 */
|
||||
.dark .uwa-workflow-panel .uwa-wf-hint.is-info {
|
||||
border-color: rgba(130, 169, 181, .38) !important;
|
||||
background: rgba(130, 169, 181, .12) !important;
|
||||
color: #b8d2da !important;
|
||||
}
|
||||
|
||||
.dark .uwa-workflow-panel .uwa-wf-hint.is-success {
|
||||
border-color: rgba(148, 179, 116, .4) !important;
|
||||
background: rgba(148, 179, 116, .13) !important;
|
||||
color: #c4d8ad !important;
|
||||
}
|
||||
|
||||
.dark .uwa-workflow-panel .uwa-wf-hint.is-warning {
|
||||
border-color: rgba(202, 163, 101, .4) !important;
|
||||
background: rgba(202, 163, 101, .13) !important;
|
||||
color: #e0c294 !important;
|
||||
}
|
||||
|
||||
.dark .uwa-workflow-panel .uwa-wf-hint.is-danger {
|
||||
border-color: rgba(201, 143, 122, .42) !important;
|
||||
background: rgba(201, 143, 122, .13) !important;
|
||||
color: #e4b1a1 !important;
|
||||
}
|
||||
|
||||
/* 提示卡内的编辑小按钮:夜间用深色玻璃底 */
|
||||
.dark .uwa-workflow-panel .uwa-wf-hint button[class*="bg-white/"] {
|
||||
background: rgba(15, 19, 15, .35) !important;
|
||||
}
|
||||
|
||||
/* 页面直发说明框 */
|
||||
.dark .uwa-workflow-panel .uwa-wf-note {
|
||||
border-color: rgba(130, 169, 181, .38);
|
||||
background: rgba(130, 169, 181, .12);
|
||||
color: #b8d2da;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,915 @@
|
||||
.uwa-onboarding-root {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 5000;
|
||||
color: var(--uwa-ink-strong, #263321);
|
||||
font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.uwa-onboarding-backdrop,
|
||||
.uwa-tour-shade {
|
||||
position: fixed;
|
||||
background: rgba(29, 35, 27, .62);
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.uwa-onboarding-backdrop {
|
||||
inset: 0;
|
||||
}
|
||||
|
||||
.uwa-onboarding-backdrop.is-strong {
|
||||
background: rgba(29, 35, 27, .72);
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
|
||||
.uwa-tour-shade {
|
||||
z-index: 5001;
|
||||
transition: all .22s ease;
|
||||
}
|
||||
|
||||
.uwa-tour-spotlight {
|
||||
position: fixed;
|
||||
z-index: 5002;
|
||||
border: 2px solid #9fbd83;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 0 0 4px rgba(220, 232, 201, .28), 0 12px 34px rgba(22, 28, 19, .2);
|
||||
pointer-events: auto;
|
||||
transition: all .22s ease;
|
||||
}
|
||||
|
||||
.uwa-welcome-dialog,
|
||||
.uwa-module-card,
|
||||
.uwa-sop-dialog {
|
||||
border: 1px solid var(--uwa-line, #ddd4c3);
|
||||
border-radius: 8px;
|
||||
background: var(--uwa-paper-strong, #fffdf8);
|
||||
box-shadow: 0 30px 90px rgba(25, 31, 22, .34);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.uwa-welcome-dialog {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: min(560px, calc(100vw - 32px));
|
||||
padding: 38px 42px 30px;
|
||||
transform: translate(-50%, -50%);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.uwa-tour-icon-button {
|
||||
display: inline-flex;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.uwa-tour-icon-button:hover {
|
||||
color: var(--uwa-ink-strong, #263321);
|
||||
background: var(--uwa-paper-soft, #f1ecdf);
|
||||
}
|
||||
|
||||
.uwa-tour-icon-button:focus-visible,
|
||||
.uwa-tour-button:focus-visible,
|
||||
.uwa-tour-skip:focus-visible,
|
||||
.uwa-sop-rail button:focus-visible {
|
||||
outline: 2px solid var(--uwa-olive, #5d6b4d);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.uwa-welcome-dialog > .uwa-tour-icon-button {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
}
|
||||
|
||||
.uwa-welcome-mark {
|
||||
display: inline-flex;
|
||||
position: relative;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.uwa-welcome-mark img {
|
||||
width: 76px;
|
||||
height: 76px;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--uwa-line, #ddd4c3);
|
||||
border-radius: 8px;
|
||||
background: var(--uwa-paper, #f7f3ea);
|
||||
}
|
||||
|
||||
.uwa-welcome-mark span {
|
||||
position: absolute;
|
||||
right: -34px;
|
||||
bottom: -7px;
|
||||
min-width: 72px;
|
||||
padding: 5px 8px;
|
||||
border-radius: 5px;
|
||||
color: #fff;
|
||||
background: var(--uwa-clay, #bd806c);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.uwa-tour-kicker {
|
||||
margin: 0 0 8px;
|
||||
color: var(--uwa-olive, #5d6b4d);
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
letter-spacing: .13em !important;
|
||||
}
|
||||
|
||||
.uwa-welcome-dialog h2 {
|
||||
margin: 0;
|
||||
font-size: 30px;
|
||||
line-height: 1.25;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-welcome-copy {
|
||||
max-width: 430px;
|
||||
margin: 14px auto 0;
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
font-size: 14px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.uwa-welcome-preview {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr auto 1fr auto;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin: 28px 0;
|
||||
padding: 18px 20px;
|
||||
border-top: 1px solid var(--uwa-line-soft, #e8e1d5);
|
||||
border-bottom: 1px solid var(--uwa-line-soft, #e8e1d5);
|
||||
}
|
||||
|
||||
.uwa-welcome-preview span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.uwa-welcome-preview i {
|
||||
display: inline-flex;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: var(--uwa-olive, #5d6b4d);
|
||||
font-style: normal;
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-welcome-preview b {
|
||||
height: 1px;
|
||||
background: var(--uwa-line, #ddd4c3);
|
||||
}
|
||||
|
||||
.uwa-welcome-actions,
|
||||
.uwa-tour-footer,
|
||||
.uwa-sop-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.uwa-welcome-actions .uwa-tour-button {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.uwa-tour-button {
|
||||
display: inline-flex;
|
||||
min-height: 44px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 9px;
|
||||
padding: 0 20px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 7px;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
transition: background .16s ease, border-color .16s ease, transform .16s ease;
|
||||
}
|
||||
|
||||
.uwa-tour-button:not(:disabled):active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.uwa-tour-button.is-primary {
|
||||
color: #fff;
|
||||
border-color: var(--uwa-olive, #5d6b4d);
|
||||
background: var(--uwa-olive, #5d6b4d);
|
||||
}
|
||||
|
||||
.uwa-tour-button.is-primary:hover {
|
||||
background: var(--uwa-olive-dark, #48553c);
|
||||
}
|
||||
|
||||
.uwa-tour-button.is-secondary {
|
||||
color: var(--uwa-ink, #33402c);
|
||||
border-color: var(--uwa-line, #ddd4c3);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.uwa-tour-button.is-secondary:hover {
|
||||
background: var(--uwa-paper-soft, #f1ecdf);
|
||||
}
|
||||
|
||||
.uwa-tour-button.is-compact {
|
||||
min-height: 38px;
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
.uwa-tour-button:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: .42;
|
||||
}
|
||||
|
||||
.uwa-tour-button svg,
|
||||
.uwa-tour-icon-button svg {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
}
|
||||
|
||||
.uwa-welcome-footnote {
|
||||
margin: 17px 0 0;
|
||||
color: var(--uwa-muted-soft, #929883);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.uwa-module-card {
|
||||
position: fixed;
|
||||
z-index: 5003;
|
||||
padding: 22px;
|
||||
}
|
||||
|
||||
.uwa-tour-card-header,
|
||||
.uwa-sop-topbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.uwa-tour-card-header > div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.uwa-tour-stage {
|
||||
color: var(--uwa-olive, #5d6b4d);
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-tour-step-count {
|
||||
color: var(--uwa-muted-soft, #929883);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.uwa-tour-progress {
|
||||
height: 3px;
|
||||
margin: 15px 0 20px;
|
||||
border-radius: 2px;
|
||||
background: var(--uwa-line-soft, #e8e1d5);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.uwa-tour-progress i,
|
||||
.uwa-sop-rail-progress i {
|
||||
display: block;
|
||||
height: 100%;
|
||||
border-radius: inherit;
|
||||
background: var(--uwa-olive, #5d6b4d);
|
||||
transition: width .22s ease;
|
||||
}
|
||||
|
||||
.uwa-module-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 13px;
|
||||
}
|
||||
|
||||
.uwa-module-number {
|
||||
display: inline-flex;
|
||||
width: 46px;
|
||||
height: 46px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 7px;
|
||||
color: var(--uwa-ink-strong, #263321);
|
||||
background: var(--uwa-leaf-soft, #dce8c9);
|
||||
font-family: Consolas, monospace;
|
||||
font-size: 15px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-module-heading p {
|
||||
margin: 0 0 3px;
|
||||
color: var(--uwa-muted-soft, #929883);
|
||||
font-family: Consolas, monospace;
|
||||
font-size: 10px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.uwa-module-heading h2 {
|
||||
margin: 0;
|
||||
font-size: 22px;
|
||||
line-height: 1.2;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-module-card h3 {
|
||||
margin: 20px 0 7px;
|
||||
font-size: 14px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-module-detail {
|
||||
min-height: 63px;
|
||||
margin: 0;
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
font-size: 13px;
|
||||
line-height: 1.65;
|
||||
}
|
||||
|
||||
.uwa-tour-footer {
|
||||
margin-top: 20px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--uwa-line-soft, #e8e1d5);
|
||||
}
|
||||
|
||||
.uwa-tour-footer > div,
|
||||
.uwa-sop-footer > div {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.uwa-tour-skip {
|
||||
padding: 6px 0;
|
||||
border: 0;
|
||||
color: var(--uwa-muted-soft, #929883);
|
||||
background: transparent;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.uwa-tour-skip:hover {
|
||||
color: var(--uwa-ink-strong, #263321);
|
||||
}
|
||||
|
||||
.uwa-sop-dialog {
|
||||
display: grid;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: min(920px, calc(100vw - 40px));
|
||||
height: min(650px, calc(100vh - 40px));
|
||||
grid-template-columns: 220px minmax(0, 1fr);
|
||||
overflow: hidden;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.uwa-sop-rail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 30px 22px 24px;
|
||||
border-right: 1px solid var(--uwa-line, #ddd4c3);
|
||||
background: var(--uwa-paper, #f7f3ea);
|
||||
}
|
||||
|
||||
.uwa-sop-rail-heading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.uwa-sop-rail-heading strong {
|
||||
margin-top: 8px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.uwa-sop-rail-heading small {
|
||||
margin-top: 3px;
|
||||
color: var(--uwa-muted-soft, #929883);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.uwa-sop-rail nav {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
margin-top: 34px;
|
||||
}
|
||||
|
||||
.uwa-sop-rail nav button {
|
||||
display: flex;
|
||||
min-height: 42px;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0 10px;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
background: transparent;
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.uwa-sop-rail nav button:hover {
|
||||
background: rgba(220, 232, 201, .45);
|
||||
}
|
||||
|
||||
.uwa-sop-rail nav button.is-active {
|
||||
color: var(--uwa-ink-strong, #263321);
|
||||
background: var(--uwa-leaf-soft, #dce8c9);
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-sop-rail nav button i {
|
||||
display: inline-flex;
|
||||
width: 23px;
|
||||
height: 23px;
|
||||
flex: 0 0 23px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid var(--uwa-line, #ddd4c3);
|
||||
border-radius: 50%;
|
||||
background: var(--uwa-paper-strong, #fffdf8);
|
||||
font-style: normal;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.uwa-sop-rail nav button.is-active i,
|
||||
.uwa-sop-rail nav button.is-done i {
|
||||
color: #fff;
|
||||
border-color: var(--uwa-olive, #5d6b4d);
|
||||
background: var(--uwa-olive, #5d6b4d);
|
||||
}
|
||||
|
||||
.uwa-sop-rail-progress {
|
||||
margin-top: auto;
|
||||
color: var(--uwa-muted-soft, #929883);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.uwa-sop-rail-progress strong {
|
||||
float: right;
|
||||
color: var(--uwa-ink, #33402c);
|
||||
}
|
||||
|
||||
.uwa-sop-rail-progress > div {
|
||||
height: 4px;
|
||||
margin-top: 9px;
|
||||
border-radius: 2px;
|
||||
background: var(--uwa-line, #ddd4c3);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.uwa-sop-content {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.uwa-sop-topbar {
|
||||
min-height: 58px;
|
||||
padding: 0 24px 0 34px;
|
||||
border-bottom: 1px solid var(--uwa-line-soft, #e8e1d5);
|
||||
}
|
||||
|
||||
.uwa-sop-topbar > span {
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-sop-scroll {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
padding: 34px 44px 24px;
|
||||
}
|
||||
|
||||
.uwa-sop-scroll h2 {
|
||||
max-width: 600px;
|
||||
margin: 0;
|
||||
font-size: 28px;
|
||||
line-height: 1.3;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-sop-intro {
|
||||
max-width: 650px;
|
||||
margin: 14px 0 0;
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
font-size: 14px;
|
||||
line-height: 1.75;
|
||||
}
|
||||
|
||||
.uwa-bridge-flow {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 22px 1fr 22px 1fr;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.uwa-bridge-flow > div {
|
||||
display: flex;
|
||||
min-height: 140px;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
padding: 18px;
|
||||
border: 1px solid var(--uwa-line, #ddd4c3);
|
||||
border-radius: 7px;
|
||||
background: var(--uwa-paper, #f7f3ea);
|
||||
}
|
||||
|
||||
.uwa-bridge-flow > div.is-accent {
|
||||
border-color: #b9cba7;
|
||||
background: var(--uwa-leaf-soft, #dce8c9);
|
||||
}
|
||||
|
||||
.uwa-bridge-flow > div > span {
|
||||
display: inline-flex;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 14px;
|
||||
border-radius: 6px;
|
||||
color: var(--uwa-olive, #5d6b4d);
|
||||
background: var(--uwa-paper-strong, #fffdf8);
|
||||
}
|
||||
|
||||
.uwa-bridge-flow svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.uwa-bridge-flow > i {
|
||||
color: var(--uwa-muted-soft, #929883);
|
||||
}
|
||||
|
||||
.uwa-bridge-flow strong,
|
||||
.uwa-browser-body strong,
|
||||
.uwa-check-list strong {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.uwa-bridge-flow small,
|
||||
.uwa-browser-body small,
|
||||
.uwa-check-list small {
|
||||
margin-top: 5px;
|
||||
color: var(--uwa-muted-soft, #929883);
|
||||
font-size: 10px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.uwa-browser-example {
|
||||
margin-top: 28px;
|
||||
border: 1px solid var(--uwa-line, #ddd4c3);
|
||||
border-radius: 7px;
|
||||
background: var(--uwa-paper, #f7f3ea);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.uwa-browser-bar {
|
||||
display: flex;
|
||||
height: 42px;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 0 14px;
|
||||
border-bottom: 1px solid var(--uwa-line, #ddd4c3);
|
||||
}
|
||||
|
||||
.uwa-browser-bar i {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--uwa-clay, #bd806c);
|
||||
}
|
||||
|
||||
.uwa-browser-bar i:nth-child(2) { background: var(--uwa-ochre, #b99359); }
|
||||
.uwa-browser-bar i:nth-child(3) { background: var(--uwa-blue, #7397a2); }
|
||||
|
||||
.uwa-browser-bar span {
|
||||
flex: 1;
|
||||
margin-left: 8px;
|
||||
padding: 6px 12px;
|
||||
border-radius: 5px;
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
background: var(--uwa-paper-strong, #fffdf8);
|
||||
font-family: Consolas, monospace;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.uwa-browser-body {
|
||||
display: flex;
|
||||
min-height: 142px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 17px;
|
||||
}
|
||||
|
||||
.uwa-browser-body > span {
|
||||
display: inline-flex;
|
||||
width: 54px;
|
||||
height: 54px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 7px;
|
||||
color: var(--uwa-olive, #5d6b4d);
|
||||
background: var(--uwa-leaf-soft, #dce8c9);
|
||||
}
|
||||
|
||||
.uwa-browser-body svg { width: 24px; height: 24px; }
|
||||
.uwa-browser-body > div { display: flex; flex-direction: column; }
|
||||
|
||||
.uwa-check-list {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
margin-top: 28px;
|
||||
}
|
||||
|
||||
.uwa-check-list > div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 17px 18px;
|
||||
border: 1px solid var(--uwa-line, #ddd4c3);
|
||||
border-radius: 7px;
|
||||
background: var(--uwa-paper, #f7f3ea);
|
||||
}
|
||||
|
||||
.uwa-check-list > div > i {
|
||||
display: inline-flex;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
flex: 0 0 32px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: var(--uwa-clay, #bd806c);
|
||||
font-style: normal;
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-check-list span { display: flex; min-width: 0; flex-direction: column; }
|
||||
|
||||
.uwa-route-list {
|
||||
display: grid;
|
||||
gap: 9px;
|
||||
margin-top: 26px;
|
||||
}
|
||||
|
||||
.uwa-route-list article {
|
||||
display: grid;
|
||||
grid-template-columns: 112px minmax(0, 1fr);
|
||||
gap: 5px 12px;
|
||||
padding: 13px 15px;
|
||||
border: 1px solid var(--uwa-line, #ddd4c3);
|
||||
border-radius: 7px;
|
||||
background: var(--uwa-paper, #f7f3ea);
|
||||
}
|
||||
|
||||
.uwa-route-list article.is-recommended {
|
||||
border-color: #b9cba7;
|
||||
background: var(--uwa-leaf-soft, #dce8c9);
|
||||
}
|
||||
|
||||
.uwa-route-list span {
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-route-list code,
|
||||
.uwa-client-fields code {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
color: var(--uwa-ink-strong, #263321);
|
||||
font-family: Consolas, monospace;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.uwa-route-list p {
|
||||
grid-column: 2;
|
||||
margin: 0;
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.uwa-client-fields {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
margin-top: 28px;
|
||||
}
|
||||
|
||||
.uwa-client-fields label {
|
||||
display: grid;
|
||||
grid-template-columns: 90px minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 8px 14px;
|
||||
min-height: 66px;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid var(--uwa-line, #ddd4c3);
|
||||
border-radius: 7px;
|
||||
background: var(--uwa-paper, #f7f3ea);
|
||||
}
|
||||
|
||||
.uwa-client-fields label > span {
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-client-fields label > small {
|
||||
grid-column: 2;
|
||||
color: var(--uwa-muted-soft, #929883);
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.uwa-sop-note {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-top: 22px;
|
||||
padding: 12px 14px;
|
||||
border-left: 3px solid var(--uwa-blue, #7397a2);
|
||||
background: rgba(115, 151, 162, .09);
|
||||
}
|
||||
|
||||
.uwa-sop-note span {
|
||||
color: var(--uwa-blue, #7397a2);
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.uwa-sop-note p {
|
||||
margin: 0;
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
font-size: 11px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.uwa-sop-footer {
|
||||
min-height: 70px;
|
||||
padding: 0 30px;
|
||||
border-top: 1px solid var(--uwa-line-soft, #e8e1d5);
|
||||
}
|
||||
|
||||
.app-guide-link {
|
||||
display: flex;
|
||||
min-height: 34px;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
padding: 0 9px;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
color: var(--uwa-muted, #6e775f);
|
||||
background: transparent;
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.app-guide-link:hover {
|
||||
color: var(--uwa-ink-strong, #263321);
|
||||
background: var(--uwa-paper-soft, #f1ecdf);
|
||||
}
|
||||
|
||||
.app-guide-link span:first-child,
|
||||
.app-guide-link svg {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
}
|
||||
|
||||
html.dark .uwa-welcome-dialog,
|
||||
html.dark .uwa-module-card,
|
||||
html.dark .uwa-sop-dialog {
|
||||
border-color: #4f5948;
|
||||
color: #eef1e9;
|
||||
background: #252b22;
|
||||
}
|
||||
|
||||
html.dark .uwa-onboarding-root {
|
||||
--uwa-paper: #1f251d;
|
||||
--uwa-paper-strong: #252b22;
|
||||
--uwa-paper-soft: #343c30;
|
||||
--uwa-ink: #dce2d6;
|
||||
--uwa-ink-strong: #eef1e9;
|
||||
--uwa-muted: #b8c0b0;
|
||||
--uwa-muted-soft: #8f9988;
|
||||
--uwa-line: #4f5948;
|
||||
--uwa-line-soft: #394235;
|
||||
--uwa-olive: #91ad79;
|
||||
--uwa-olive-dark: #7f9b69;
|
||||
--uwa-leaf-soft: #3b4934;
|
||||
--uwa-clay: #cf8e79;
|
||||
--uwa-blue: #8eb1bc;
|
||||
}
|
||||
|
||||
html.dark .uwa-sop-rail,
|
||||
html.dark .uwa-bridge-flow > div,
|
||||
html.dark .uwa-browser-example,
|
||||
html.dark .uwa-check-list > div,
|
||||
html.dark .uwa-route-list article,
|
||||
html.dark .uwa-client-fields label {
|
||||
border-color: #4f5948;
|
||||
background: #2d3329;
|
||||
}
|
||||
|
||||
html.dark .uwa-route-list article.is-recommended,
|
||||
html.dark .uwa-bridge-flow > div.is-accent,
|
||||
html.dark .uwa-sop-rail nav button.is-active {
|
||||
background: #3b4934;
|
||||
}
|
||||
|
||||
html.dark .uwa-welcome-copy,
|
||||
html.dark .uwa-module-detail,
|
||||
html.dark .uwa-sop-intro,
|
||||
html.dark .uwa-route-list p,
|
||||
html.dark .uwa-sop-note p {
|
||||
color: #b8c0b0;
|
||||
}
|
||||
|
||||
html.dark .uwa-tour-button.is-secondary,
|
||||
html.dark .uwa-tour-icon-button {
|
||||
color: #dce2d6;
|
||||
border-color: #4f5948;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.uwa-onboarding-backdrop,
|
||||
.uwa-tour-shade {
|
||||
backdrop-filter: none;
|
||||
}
|
||||
|
||||
.uwa-welcome-dialog {
|
||||
padding: 30px 22px 24px;
|
||||
}
|
||||
|
||||
.uwa-welcome-dialog h2 { font-size: 25px; }
|
||||
.uwa-welcome-preview { grid-template-columns: 1fr; gap: 8px; text-align: left; }
|
||||
.uwa-welcome-preview b { display: none; }
|
||||
.uwa-welcome-preview span { justify-content: center; }
|
||||
.uwa-module-card { max-height: calc(100vh - 28px); padding: 18px; overflow: auto; }
|
||||
.uwa-module-detail { min-height: 0; }
|
||||
.uwa-tour-footer { align-items: flex-end; }
|
||||
.uwa-tour-footer > div { flex-wrap: wrap; justify-content: flex-end; }
|
||||
|
||||
.uwa-sop-dialog {
|
||||
width: calc(100vw - 20px);
|
||||
height: calc(100vh - 20px);
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.uwa-sop-rail {
|
||||
display: block;
|
||||
padding: 14px 16px;
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid var(--uwa-line, #ddd4c3);
|
||||
}
|
||||
|
||||
.uwa-sop-rail-heading { display: none; }
|
||||
.uwa-sop-rail nav { display: flex; justify-content: center; gap: 5px; margin: 0; }
|
||||
.uwa-sop-rail nav button { width: 34px; min-height: 34px; justify-content: center; padding: 0; }
|
||||
.uwa-sop-rail nav button span { display: none; }
|
||||
.uwa-sop-rail-progress { display: none; }
|
||||
.uwa-sop-topbar { min-height: 50px; padding: 0 14px 0 20px; }
|
||||
.uwa-sop-scroll { padding: 24px 20px 18px; }
|
||||
.uwa-sop-scroll h2 { font-size: 23px; }
|
||||
.uwa-bridge-flow { grid-template-columns: 1fr; }
|
||||
.uwa-bridge-flow > div { min-height: 90px; }
|
||||
.uwa-bridge-flow > i { margin: -3px auto; transform: rotate(90deg); }
|
||||
.uwa-route-list article { grid-template-columns: 1fr; }
|
||||
.uwa-route-list p { grid-column: 1; }
|
||||
.uwa-client-fields label { grid-template-columns: 1fr; }
|
||||
.uwa-client-fields label > small { grid-column: 1; }
|
||||
.uwa-sop-footer { min-height: 64px; padding: 0 16px; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.uwa-tour-shade,
|
||||
.uwa-tour-spotlight,
|
||||
.uwa-tour-progress i,
|
||||
.uwa-sop-rail-progress i,
|
||||
.uwa-tour-button {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
/* Operations workspace · uses the existing application palette.
|
||||
Scoped to the pool and monitor; navigation and site configuration are untouched. */
|
||||
.ops-pool, .ops-monitor { --ops-soft: color-mix(in srgb, var(--uwa-olive) 6%, var(--uwa-paper-strong)); --ops-danger: #a15e4d; --ops-warning: #94713e; color: var(--uwa-ink); }
|
||||
.dark .ops-pool, .dark .ops-monitor { --ops-danger: #d99c87; --ops-warning: #c5a56f; }
|
||||
:is(.ops-pool,.ops-monitor) button:focus-visible, :is(.ops-pool,.ops-monitor) summary:focus-visible { outline: 2px solid var(--uwa-olive); outline-offset: 4px; }
|
||||
:is(.ops-pool,.ops-monitor) button:disabled { opacity: .5; cursor: not-allowed; }
|
||||
:is(.ops-pool,.ops-monitor) .ops-eyebrow, .ops-monitor .uwa-eyebrow { display: block; color: var(--uwa-muted-soft); font-size: 10px; letter-spacing: .12em !important; font-weight: 600; }
|
||||
:is(.ops-pool,.ops-monitor) h1 { margin: 8px 0 0; color: var(--uwa-ink-strong); font-size: 27px; line-height: 1.3; font-weight: 650; }
|
||||
:is(.ops-pool,.ops-monitor) .ops-page-description, .ops-monitor .uwa-page-header > div > p:last-child { margin: 9px 0 0; color: var(--uwa-muted); font-size: 12px; line-height: 1.8; }
|
||||
:is(.ops-pool,.ops-monitor) .ops-text-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 0; border: 0; background: transparent; color: var(--uwa-olive); font-size: 12px; cursor: pointer; }
|
||||
:is(.ops-pool,.ops-monitor) .ops-text-button svg { width: 15px; height: 15px; }
|
||||
/* A shared, quiet metric strip. Pool tiles also filter the visible collection. */
|
||||
.ops-pool .ops-pool-summary, .ops-monitor .ops-monitor-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; margin: 0 0 28px; }
|
||||
:is(.ops-pool,.ops-monitor) .ops-stat { min-width: 0; padding: 19px 21px; border: 1px solid var(--uwa-line); border-radius: 11px; background: var(--uwa-paper-strong); color: var(--uwa-ink); text-align: left; box-shadow: none; }
|
||||
:is(.ops-pool,.ops-monitor) .ops-stat > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--uwa-muted); }
|
||||
:is(.ops-pool,.ops-monitor) .ops-stat > span i { display: inline-flex; color: var(--uwa-muted-soft); }
|
||||
:is(.ops-pool,.ops-monitor) .ops-stat svg { width: 17px; height: 17px; }
|
||||
:is(.ops-pool,.ops-monitor) .ops-stat > strong { display: block; margin: 12px 0 8px; font-size: 31px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--uwa-ink-strong); }
|
||||
:is(.ops-pool,.ops-monitor) .ops-stat > strong em { margin-left: 9px; font-size: 11px; font-weight: 400; font-style: normal; color: var(--uwa-muted); }
|
||||
:is(.ops-pool,.ops-monitor) .ops-stat > small { display: block; font-size: 10px; line-height: 1.7; color: var(--uwa-muted); }
|
||||
.ops-pool .ops-stat { cursor: pointer; transition: border-color .15s, background .15s; }
|
||||
.ops-pool .ops-stat:hover { border-color: var(--uwa-olive); }
|
||||
.ops-pool .ops-stat.is-selected, .ops-monitor .ops-stat.is-live { background: var(--ops-soft); border-color: color-mix(in srgb,var(--uwa-olive) 36%,var(--uwa-line)); }
|
||||
.ops-pool .ops-stat.is-idle > span i { color: var(--uwa-olive); }
|
||||
.ops-pool .ops-stat.is-busy > span i { color: var(--ops-warning); }
|
||||
.ops-pool .ops-stat.is-attention > span i { color: var(--ops-danger); }
|
||||
/* Pool: full-width collection, optional routing drawer instead of a second icon rail. */
|
||||
.ops-pool.tab-pool-console { display: block; min-height: 100%; height: auto; background: var(--uwa-paper) !important; --tp-bg: var(--uwa-paper); --tp-panel: var(--uwa-paper-strong); --tp-soft: var(--uwa-paper-soft); --tp-soft-strong: var(--ops-soft); --tp-border: var(--uwa-line); --tp-text: var(--uwa-ink); --tp-muted: var(--uwa-muted); --tp-faint: var(--uwa-muted-soft); --tp-accent: var(--uwa-olive); --tp-accent-soft: var(--ops-soft); --tp-code: var(--uwa-paper-soft); }
|
||||
.ops-pool .tab-pool-main { display: block; width: min(100%,1488px); margin: auto; padding: 36px 46px 44px; background: transparent !important; }
|
||||
.ops-pool .tab-pool-topbar { position: static; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; min-height: 0 !important; padding: 0 0 28px; border: 0; background: transparent !important; }
|
||||
.ops-pool .tab-pool-view-title { flex: 1; min-width: 260px; }
|
||||
.ops-pool .tab-pool-title-line { display: block; }
|
||||
.ops-pool .tab-pool-top-actions { gap: 8px; }
|
||||
.ops-pool .tab-pool-top-actions > button, .ops-pool .tab-pool-settings-wrap > button { min-height: 36px; padding: 0 12px; border: 1px solid var(--uwa-line); border-radius: 7px; background: var(--uwa-paper-strong); color: var(--uwa-ink); font-size: 11px; font-weight: 500; }
|
||||
.ops-pool .tab-pool-top-actions svg { width: 15px; height: 15px; }
|
||||
.ops-pool .tab-pool-refresh { background: var(--uwa-olive) !important; color: var(--uwa-paper-strong) !important; box-shadow: none; }
|
||||
.ops-pool .tab-pool-mobile-menu { display: none; }
|
||||
.ops-pool .tab-pool-scroll { overflow: visible; background: transparent !important; background-image: none; }
|
||||
.ops-pool .tab-pool-content { width: 100%; padding: 0; }
|
||||
.ops-pool .tab-pool-error { margin: 0 0 16px; color: var(--ops-danger); border-color: color-mix(in srgb,var(--ops-danger) 30%,var(--uwa-line)); background: color-mix(in srgb,var(--ops-danger) 6%,var(--uwa-paper-strong)); }
|
||||
.ops-pool .ops-pool-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding-bottom: 20px; border-bottom: 1px solid var(--uwa-line); }
|
||||
.ops-pool .ops-group-chips { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 7px; min-width: 0; }
|
||||
.ops-pool .ops-group-chips button { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 8px 11px; border: 1px solid transparent; border-radius: 7px; color: var(--uwa-muted); background: transparent; font-size: 12px; overflow-wrap: anywhere; }
|
||||
.ops-pool .ops-group-chips button.is-active { background: var(--uwa-paper-strong); border-color: var(--uwa-line); color: var(--uwa-ink); }
|
||||
.ops-pool .ops-group-chips .ops-new-group { font-size: 11px; }
|
||||
.ops-pool .ops-group-chips svg { width: 14px; height: 14px; }
|
||||
.ops-pool .ops-group-chips small { font-size: 10px; color: var(--uwa-muted-soft); }
|
||||
.ops-pool .tab-pool-search { display: flex; width: 245px; max-width: 100%; height: 37px; border-color: var(--uwa-line); border-radius: 7px; background: var(--uwa-paper-strong); }
|
||||
.ops-pool .tab-pool-search input { font-size: 11px; }
|
||||
.ops-pool .tab-pool-list-heading { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 22px 0 15px; }
|
||||
.ops-pool .tab-pool-list-heading h3 { font-size: 13px; font-weight: 600; color: var(--uwa-ink); }
|
||||
.ops-pool .ops-pool-live { display: inline-flex; align-items: center; gap: 7px; font-size: 10px; color: var(--uwa-muted); }
|
||||
.ops-pool .ops-pool-live > i { width: 6px; height: 6px; border-radius: 50%; background: var(--uwa-olive); }
|
||||
.ops-pool .ops-pool-live > i.is-paused { background: var(--uwa-muted-soft); }
|
||||
.ops-pool .ops-pool-live small { color: var(--uwa-muted-soft); font-size: 10px; }
|
||||
.ops-pool .ops-pool-live button { padding: 0 0 0 10px; margin-left: 6px; border: 0; border-left: 1px solid var(--uwa-line); background: transparent; color: var(--uwa-muted); font-size: 10px; }
|
||||
.ops-pool .tab-pool-resource-board { overflow: visible; background: transparent; border: 0; box-shadow: none; }
|
||||
.ops-pool .tab-pool-board-labels { display: none; }
|
||||
.ops-pool .tab-pool-card-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 16px; }
|
||||
.ops-pool .tab-pool-card { display: grid; min-width: 0; grid-template-columns: 34px minmax(0,1fr); gap: 14px 12px; padding: 20px; border: 1px solid var(--uwa-line) !important; border-radius: 11px !important; background: var(--uwa-paper-strong) !important; }
|
||||
.ops-pool .tab-pool-card[data-status="busy"] { border-color: color-mix(in srgb,var(--ops-warning) 40%,var(--uwa-line)) !important; }
|
||||
.ops-pool .tab-pool-card[data-status="error"] { border-color: color-mix(in srgb,var(--ops-danger) 45%,var(--uwa-line)) !important; }
|
||||
.ops-pool .tab-number { width: 34px; height: 36px; border: 1px solid var(--uwa-line-soft); border-radius: 8px; background: var(--ops-soft); color: var(--uwa-olive); font-size: 13px; }
|
||||
.ops-pool .tab-card-status { gap: 7px; flex-wrap: wrap; }
|
||||
.ops-pool .tab-card-status > .status-dot { display: none; }
|
||||
.ops-pool .tab-card-status > strong { flex: 1 1 auto; max-width: 100%; font-size: 14px; font-weight: 600; color: var(--uwa-ink-strong); overflow-wrap: anywhere; }
|
||||
.ops-pool .ops-status { padding: 3px 7px; border-radius: 5px; background: var(--uwa-paper-soft); color: var(--uwa-muted); font-size: 10px; font-weight: 400; font-style: normal; }
|
||||
.ops-pool .ops-status.idle { background: var(--ops-soft); color: var(--uwa-olive); }
|
||||
.ops-pool .ops-status.busy { color: var(--ops-warning); background: color-mix(in srgb,var(--ops-warning) 10%,transparent); }
|
||||
.ops-pool .ops-status.error { color: var(--ops-danger); background: color-mix(in srgb,var(--ops-danger) 10%,transparent); }
|
||||
.ops-pool .tab-pool-pill { border: 0 !important; border-radius: 4px; background: var(--ops-soft) !important; color: var(--uwa-muted) !important; font-size: 9px; font-weight: 400; }
|
||||
.ops-pool .tab-card-url { margin: 7px 0 0; color: var(--uwa-muted-soft); font-size: 10px; }
|
||||
.ops-pool .tab-card-side { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 12px; padding: 15px 0 0; border: 0; border-top: 1px solid var(--uwa-line-soft); }
|
||||
.ops-pool .tab-card-side > div:nth-child(-n+3) { display: flex; grid-column: span 2; flex-direction: column; align-items: flex-start; gap: 4px; }
|
||||
.ops-pool .tab-card-side > div:nth-child(-n+3) span { color: var(--uwa-muted-soft); font-size: 10px; }
|
||||
.ops-pool .tab-card-side > div:nth-child(-n+3) strong, .ops-pool .tab-card-side > div:nth-child(-n+3) code { color: var(--uwa-ink); font-size: 12px; font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.ops-pool .tab-card-side .model-name-control, .ops-pool .tab-card-side .tab-preset-control, .ops-pool .tab-card-side .tab-single-preset { grid-column: span 3; min-width: 0; padding: 10px; border: 1px solid var(--uwa-line-soft); border-radius: 6px; background: transparent; }
|
||||
.ops-pool .model-name-control { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
|
||||
.ops-pool .model-name-control > span, .ops-pool .tab-preset-control > span, .ops-pool .tab-single-preset > span { color: var(--uwa-muted); font-size: 10px; }
|
||||
.ops-pool .model-name-control strong { width: 100%; color: var(--uwa-ink); font-size: 12px; }
|
||||
.ops-pool .model-name-control small { font-size: 9px; color: var(--uwa-muted-soft); }
|
||||
.ops-pool .tab-preset-control select { width: 100%; min-width: 0; margin-top: 6px; height: 30px; border-color: var(--uwa-line); border-radius: 5px; background: var(--uwa-paper-strong); color: var(--uwa-ink); font-size: 11px; }
|
||||
.ops-pool .tab-card-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; padding-top: 0; margin: 0; }
|
||||
.ops-pool .tab-card-actions button { border: 0; background: transparent; color: var(--uwa-muted); font-size: 10px; padding: 4px 0; }
|
||||
.ops-pool .tab-card-actions button.danger { color: var(--ops-danger); }
|
||||
.ops-pool .tab-task-line { margin: 8px 0 0; color: var(--ops-warning); font-size: 10px; overflow-wrap: anywhere; }
|
||||
.ops-pool .ops-routes { margin-top: 10px; }
|
||||
.ops-pool .ops-routes > summary { display: flex; align-items: center; gap: 6px; padding: 4px 0; list-style: none; color: var(--uwa-olive); font-size: 10px; cursor: pointer; }
|
||||
.ops-pool .ops-routes svg { width: 13px; height: 13px; }
|
||||
.ops-pool .ops-routes .ops-chevron { margin-left: auto; }
|
||||
:is(.ops-pool,.ops-monitor) summary::-webkit-details-marker { display: none; }
|
||||
:is(.ops-pool,.ops-monitor) details[open] > summary .ops-chevron { transform: rotate(180deg); }
|
||||
.ops-pool .tab-route-list { margin-top: 9px; padding: 6px 9px; border-radius: 6px; background: var(--ops-soft); }
|
||||
.ops-pool .tab-route-row { display: grid; grid-template-columns: minmax(0,1fr) 22px; gap: 4px; padding: 7px 0; }
|
||||
.ops-pool .tab-route-row > span { grid-column: 1; color: var(--uwa-muted-soft); font-size: 9px; }
|
||||
.ops-pool .tab-route-row code { grid-column: 1; color: var(--uwa-muted); overflow: hidden; text-overflow: ellipsis; font-size: 9px; }
|
||||
.ops-pool .tab-route-row button { grid-column: 2; grid-row: 1 / 3; }
|
||||
/* Empty state is guidance, not a fabricated connection. */
|
||||
.ops-pool .tab-pool-empty { min-height: 350px; padding: 48px 20px; gap: 12px; border: 1px solid var(--uwa-line); border-radius: 12px; background: var(--uwa-paper-strong); color: var(--uwa-muted); font-size: 12px; }
|
||||
.ops-pool .tab-pool-empty > strong { margin-top: 8px; font-size: 19px; font-weight: 600; color: var(--uwa-ink); }
|
||||
.ops-pool .tab-pool-empty > span { max-width: 380px; font-size: 12px; line-height: 1.8; }
|
||||
.ops-pool .ops-empty-art { position: relative; width: 128px; height: 92px; margin: 0 auto 4px; }
|
||||
.ops-pool .ops-empty-art > span { position: absolute; width: 99px; height: 68px; left: 6px; top: 6px; border: 1px solid var(--uwa-line); border-radius: 9px; background: var(--uwa-paper-soft); transform: rotate(-9deg); }
|
||||
.ops-pool .ops-empty-art > span:last-child { left: 23px; top: 19px; background: var(--uwa-paper-strong); transform: rotate(4deg); text-align: left; padding: 6px 8px; }
|
||||
.ops-pool .ops-empty-art i { display: inline-block; vertical-align: top; width: 4px; height: 4px; margin: 0 2px 0 0; border-radius: 50%; background: var(--uwa-line); }
|
||||
.ops-pool .ops-empty-art b { display: grid; place-items: center; height: 38px; border-top: 1px solid var(--uwa-line-soft); color: var(--uwa-olive); }
|
||||
.ops-pool .ops-empty-art svg { width: 25px; height: 25px; }
|
||||
.ops-pool .ops-empty-steps { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 13px; margin-top: 22px; color: var(--uwa-muted-soft); font-size: 10px; }
|
||||
.ops-pool .ops-empty-steps i { width: 22px; height: 1px; background: var(--uwa-line); }
|
||||
/* Routing/settings remain real editors with their existing save guards. */
|
||||
.ops-pool .tab-pool-mobile-backdrop { display: block; position: fixed; inset: 0; z-index: 61; background: #17201455; backdrop-filter: blur(3px); }
|
||||
.ops-pool .tab-pool-group-nav { display: none; }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open { display: flex; position: fixed; z-index: 62; top: 0; right: 0; left: auto; bottom: 0; width: max(290px,var(--tp-group-nav-width,290px)); max-width: 95vw; min-height: 100dvh; transform: none; border: 0; border-left: 1px solid var(--uwa-line); background: var(--uwa-paper-strong) !important; box-shadow: -12px 0 70px #0001; }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-brand-copy, .ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-group-copy, .ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-group-heading span, .ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-global-controls { display: block; }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-group-brand { justify-content: flex-start; gap: 10px; padding: 20px; }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-group-item { justify-content: flex-start; gap: 10px; padding: 12px; }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-group-heading { justify-content: space-between; padding: 16px 12px 8px; }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-global-controls label { display: flex; flex-direction: row; }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-group-empty { padding: 20px 10px; }
|
||||
.ops-pool .tab-pool-nav-collapse { display: none; }
|
||||
.ops-pool .tab-pool-mobile-close { display: inline-flex; margin-left: auto; color: var(--uwa-muted); }
|
||||
.ops-pool .tab-pool-settings-popover { top: 45px; right: 0; width: min(390px,calc(100vw - 32px)); max-height: 75dvh; overflow: auto; padding: 18px; border-radius: 12px !important; box-shadow: 0 14px 50px #0002 !important; }
|
||||
.ops-pool .tab-pool-help, .ops-pool .tab-pool-group-editor { margin: 0 0 20px; border-radius: 10px !important; }
|
||||
.ops-pool .tab-pool-modal { background: var(--uwa-paper-strong); color: var(--uwa-ink); border-color: var(--uwa-line); }
|
||||
/* Monitor: history first; analysis has a separate, persistent view. */
|
||||
.ops-monitor.request-monitor-workspace { background: var(--uwa-paper) !important; }
|
||||
.ops-monitor .uwa-monitor-page { padding: 36px 46px 44px; }
|
||||
.ops-monitor .uwa-monitor-header { min-height: 0; padding-bottom: 28px; border: 0; }
|
||||
.ops-monitor .uwa-page-actions { gap: 8px; }
|
||||
.ops-monitor .uwa-button { min-height: 36px; font-size: 11px; box-shadow: none; }
|
||||
.ops-monitor .ops-view-tabs { display: flex; align-items: center; gap: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--uwa-line); }
|
||||
.ops-monitor .ops-view-tabs button { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 0 0 15px; border: 0; background: transparent; color: var(--uwa-muted); font-size: 13px; }
|
||||
.ops-monitor .ops-view-tabs button.is-active { color: var(--uwa-ink); font-weight: 600; }
|
||||
.ops-monitor .ops-view-tabs button.is-active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--uwa-olive); }
|
||||
.ops-monitor .ops-view-tabs svg { width: 16px; height: 16px; }
|
||||
.ops-monitor .ops-view-tabs small { border-radius: 4px; padding: 1px 6px; background: var(--uwa-paper-soft); font-size: 10px; color: var(--uwa-muted); }
|
||||
.ops-monitor .ops-view-note { margin-left: auto; padding-bottom: 15px; color: var(--uwa-muted-soft); font-size: 10px; }
|
||||
.ops-monitor .ops-history-panel { border: 1px solid var(--uwa-line); border-radius: 12px; background: var(--uwa-paper-strong); overflow: hidden; }
|
||||
.ops-monitor .ops-history-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 22px 23px 18px; }
|
||||
.ops-monitor .ops-history-heading h2 { margin: 0; color: var(--uwa-ink); font-size: 16px; font-weight: 600; }
|
||||
.ops-monitor .ops-history-heading p { margin: 6px 0 0; color: var(--uwa-muted); font-size: 11px; }
|
||||
.ops-monitor .ops-history-heading > span { color: var(--uwa-muted-soft); font-size: 10px; }
|
||||
.ops-monitor .uwa-request-filters { display: flex; flex-wrap: wrap; gap: 12px; padding: 0 23px 18px; margin: 0; border: 0; }
|
||||
.ops-monitor .uwa-request-filters .uwa-search-field { flex: 1 1 200px; width: auto; min-width: 0; height: 35px; background: var(--uwa-paper-strong); }
|
||||
.ops-monitor .uwa-request-filters .uwa-search-field input { width: 100%; font-size: 11px; }
|
||||
.ops-monitor .uwa-request-filters .uwa-segmented { padding: 3px; border-color: var(--uwa-line-soft); background: var(--uwa-paper-soft); }
|
||||
.ops-monitor .uwa-status-tabs button { padding: 5px 10px; font-size: 10px; white-space: nowrap; }
|
||||
.ops-monitor .uwa-status-tabs button.is-active { color: var(--uwa-ink); background: var(--uwa-paper-strong); box-shadow: 0 1px 3px #0001; }
|
||||
.ops-monitor .uwa-filter-toggle { font-size: 10px; }
|
||||
.ops-monitor .uwa-request-table-wrap { border: 0; border-radius: 0; background: transparent; overflow-x: auto; }
|
||||
.ops-monitor .uwa-request-table-header, .ops-monitor .uwa-request-row { grid-template-columns: 70px minmax(130px,1.3fr) minmax(90px,1fr) 88px 72px 62px 15px; gap: 15px; padding-left: 23px; padding-right: 23px; min-width: 720px; }
|
||||
.ops-monitor .uwa-request-table-header { min-height: 36px; background: var(--ops-soft); font-size: 10px; font-weight: 400; color: var(--uwa-muted); border-top: 1px solid var(--uwa-line-soft); border-bottom: 1px solid var(--uwa-line-soft); }
|
||||
.ops-monitor .uwa-request-row { min-height: 76px; background: transparent; border-bottom: 1px solid var(--uwa-line-soft); }
|
||||
.ops-monitor .uwa-request-row:hover { background: var(--ops-soft); }
|
||||
.ops-monitor .uwa-request-route strong { font-size: 12px; font-weight: 600; }
|
||||
.ops-monitor .uwa-request-route small { font-size: 10px; }
|
||||
.ops-monitor .uwa-request-row > span, .ops-monitor .uwa-request-row > code, .ops-monitor .uwa-request-row > time { font-size: 10px; }
|
||||
.ops-monitor .uwa-request-row > strong { font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
|
||||
.ops-monitor .uwa-request-status { gap: 6px; }
|
||||
.ops-monitor .uwa-request-status i { width: 5px; height: 5px; }
|
||||
.ops-monitor .uwa-request-status strong { font-size: 10px; font-weight: 500; }
|
||||
.ops-monitor .uwa-request-status.failed { color: var(--ops-danger); }
|
||||
.ops-monitor .uwa-request-row.is-cancelled .uwa-request-status { color: var(--uwa-muted); }
|
||||
.ops-monitor .uwa-request-row.is-cancelled .uwa-request-status i { background: var(--uwa-muted-soft); }
|
||||
.ops-monitor .uwa-row-arrow svg { width: 14px; height: 14px; }
|
||||
.ops-monitor .uwa-pagination { padding: 15px 23px; font-size: 10px; }
|
||||
.ops-monitor .ops-history-empty { display: flex; align-items: center; flex-direction: column; justify-content: center; gap: 10px; min-height: 255px; padding: 35px 20px; text-align: center; }
|
||||
.ops-monitor .ops-history-empty > span { display: grid; place-items: center; width: 50px; height: 55px; margin: 0 0 7px; border: 1px solid var(--uwa-line); border-radius: 11px; background: var(--ops-soft); color: var(--uwa-olive); }
|
||||
.ops-monitor .ops-history-empty svg { width: 25px; height: 25px; }
|
||||
.ops-monitor .ops-history-empty > strong { font-size: 16px; font-weight: 500; color: var(--uwa-ink); }
|
||||
.ops-monitor .ops-history-empty p { margin: 0; max-width: 400px; color: var(--uwa-muted); font-size: 11px; line-height: 1.8; }
|
||||
.ops-monitor .ops-trend-disclosure { margin-top: 20px; border: 1px solid var(--uwa-line); border-radius: 11px; background: var(--uwa-paper-strong); }
|
||||
.ops-monitor .ops-trend-disclosure > summary { display: flex; align-items: center; gap: 13px; padding: 18px 22px; list-style: none; cursor: pointer; }
|
||||
.ops-monitor .ops-trend-disclosure > summary > span:first-child { color: var(--uwa-olive); }
|
||||
.ops-monitor .ops-trend-disclosure summary svg { width: 18px; height: 18px; }
|
||||
.ops-monitor .ops-trend-disclosure summary strong { display: block; font-size: 12px; font-weight: 500; }
|
||||
.ops-monitor .ops-trend-disclosure summary small { display: block; margin-top: 4px; font-size: 10px; color: var(--uwa-muted); }
|
||||
.ops-monitor .ops-trend-disclosure .ops-chevron { margin-left: auto; color: var(--uwa-muted); }
|
||||
.ops-monitor .uwa-monitor-overview { margin: 0; padding: 0 22px 22px; gap: 15px; }
|
||||
.ops-monitor .uwa-monitor-overview > * { border: 1px solid var(--uwa-line-soft); box-shadow: none; background: transparent; }
|
||||
.ops-monitor .ops-retention-note { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 17px; font-size: 10px; color: var(--uwa-muted-soft); }
|
||||
.ops-monitor .uwa-analytics-toolbar { padding-top: 0; align-items: center; }
|
||||
.ops-monitor .uwa-analytics-toolbar .uwa-eyebrow { display: none; }
|
||||
.ops-monitor .uwa-analytics-toolbar h2 { font-size: 17px; font-weight: 600; }
|
||||
.ops-monitor .uwa-analytics-toolbar > div > p:last-child { font-size: 11px; }
|
||||
.ops-monitor .uwa-token-kpis article { position: relative; min-height: 140px; padding: 21px; border-color: var(--uwa-line); border-radius: 11px; background: var(--uwa-paper-strong); box-shadow: none; }
|
||||
.ops-monitor .uwa-token-kpis article.is-total { background: var(--ops-soft); }
|
||||
.ops-monitor .uwa-token-kpi-icon { position: absolute; right: 20px; top: 20px; width: 22px; height: 22px; transform: none; border-radius: 0; color: var(--uwa-olive); background: transparent !important; }
|
||||
.ops-monitor .uwa-token-kpi-icon svg { width: 18px; height: 18px; }
|
||||
.ops-monitor .uwa-token-kpis small { margin: 0; }
|
||||
.ops-monitor .uwa-token-kpis strong { margin-top: 17px; font-size: 29px; font-weight: 600; }
|
||||
.ops-monitor .uwa-hourly-panel, .ops-monitor .uwa-daily-token-panel, .ops-monitor .uwa-model-usage-panel { border-radius: 11px; }
|
||||
.ops-monitor .uwa-panel-heading h2 { font-size: 14px; font-weight: 600; }
|
||||
.ops-monitor .uwa-system-load-panel { margin-bottom: 20px; background: var(--uwa-paper-strong); border-color: var(--uwa-line); border-radius: 10px; }
|
||||
/* Keep the real detail drawer; make it part of the same workspace. */
|
||||
.ops-monitor .ops-request-drawer { background: #17201466; backdrop-filter: blur(4px); }
|
||||
.ops-monitor .ops-request-drawer > aside { max-width: 880px; background: var(--uwa-paper-strong); border-color: var(--uwa-line); border-radius: 13px; color: var(--uwa-ink); }
|
||||
.ops-monitor .ops-request-drawer :is(.text-slate-950,.text-slate-900,.text-slate-800,.text-slate-700) { color: var(--uwa-ink); }
|
||||
.ops-monitor .ops-request-drawer :is(.text-slate-600,.text-slate-500,.text-slate-400) { color: var(--uwa-muted); }
|
||||
.ops-monitor .ops-request-drawer :is(.border-slate-200,.border-slate-100) { border-color: var(--uwa-line); }
|
||||
.ops-monitor .ops-request-drawer textarea, .ops-monitor .ops-request-drawer pre { background: var(--uwa-paper-soft); color: var(--uwa-ink); border-color: var(--uwa-line); }
|
||||
@media (max-width:1250px) {
|
||||
.ops-pool .tab-pool-main, .ops-monitor .uwa-monitor-page { padding-left: 30px; padding-right: 30px; }
|
||||
.ops-pool .tab-pool-topbar { align-items: flex-start; }
|
||||
:is(.ops-pool,.ops-monitor) .ops-stat { padding: 17px; }
|
||||
:is(.ops-pool,.ops-monitor) .ops-stat > strong { font-size: 26px; }
|
||||
.ops-monitor .uwa-token-analysis-grid { grid-template-columns: 1fr; }
|
||||
}
|
||||
@media (max-width:1050px) {
|
||||
.ops-pool .tab-pool-card-list { grid-template-columns: 1fr; }
|
||||
.ops-pool .ops-pool-summary, .ops-monitor .ops-monitor-summary { gap: 10px; }
|
||||
.ops-monitor .uwa-monitor-overview { grid-template-columns: 1fr; }
|
||||
.ops-monitor .uwa-monitor-header { flex-wrap: wrap; gap: 16px; }
|
||||
.ops-monitor .uwa-system-load-panel { grid-template-columns: repeat(2,minmax(0,1fr)); }
|
||||
}
|
||||
@media (max-width:740px) {
|
||||
.ops-pool .tab-pool-main, .ops-monitor .uwa-monitor-page { padding: 25px 16px 32px; }
|
||||
:is(.ops-pool,.ops-monitor) h1 { font-size: 24px; }
|
||||
.ops-pool .tab-pool-topbar { gap: 17px; }
|
||||
.ops-pool .tab-pool-top-actions { flex-wrap: wrap; }
|
||||
.ops-pool .ops-pool-summary, .ops-monitor .ops-monitor-summary { grid-template-columns: repeat(2,minmax(0,1fr)); margin-bottom: 22px; }
|
||||
:is(.ops-pool,.ops-monitor) .ops-stat > strong { font-size: 27px; }
|
||||
.ops-pool .tab-pool-search { width: 100%; }
|
||||
.ops-pool .tab-pool-list-heading { align-items: flex-start; }
|
||||
.ops-pool .ops-pool-live { flex-wrap: wrap; }
|
||||
.ops-pool .tab-pool-empty { padding: 35px 20px; }
|
||||
.ops-pool .ops-empty-steps { gap: 8px; font-size: 9px; }
|
||||
.ops-pool .ops-empty-steps i { width: 8px; }
|
||||
.ops-pool .tab-pool-card { padding: 17px; }
|
||||
.ops-pool .tab-pool-settings-popover { position: fixed; top: 180px; right: 16px; }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open { width: min(340px,92vw); }
|
||||
.ops-monitor .ops-view-tabs { gap: 24px; }
|
||||
.ops-monitor .ops-view-note { display: none; }
|
||||
.ops-monitor .ops-history-heading { padding: 20px 16px 16px; }
|
||||
.ops-monitor .uwa-request-filters { padding: 0 16px 17px; gap: 10px; }
|
||||
.ops-monitor .uwa-request-filters .uwa-search-field { flex-basis: 100%; }
|
||||
.ops-monitor .uwa-status-tabs { display: flex; flex: 1 1 100%; justify-content: space-between; }
|
||||
.ops-monitor .uwa-status-tabs button { flex: 1; padding: 6px; }
|
||||
.ops-monitor .uwa-request-table-header { display: none; }
|
||||
.ops-monitor .uwa-request-row { min-width: 0; grid-template-columns: minmax(0,1fr) 66px; gap: 8px 12px; padding: 16px; }
|
||||
.ops-monitor .uwa-request-route { grid-column: 1; grid-row: 1; }
|
||||
.ops-monitor .uwa-request-status { grid-column: 2; grid-row: 1; justify-content: flex-end; }
|
||||
.ops-monitor .uwa-request-row > code { grid-column: 1; grid-row: 2; }
|
||||
.ops-monitor .uwa-request-row > strong { grid-column: 2; grid-row: 2; text-align: right; }
|
||||
.ops-monitor .uwa-request-row > span:nth-child(4) { grid-column: 1; grid-row: 3; color: var(--uwa-muted-soft); }
|
||||
.ops-monitor .uwa-request-row > span:nth-child(4)::before { content: '输入 / 输出 '; }
|
||||
.ops-monitor .uwa-request-row > time { grid-column: 2; grid-row: 3; text-align: right; }
|
||||
.ops-monitor .uwa-row-arrow { display: none; }
|
||||
.ops-monitor .uwa-pagination { padding: 14px 16px; flex-direction: column; align-items: flex-start; gap: 12px; }
|
||||
.ops-monitor .ops-trend-disclosure > summary { padding: 17px; }
|
||||
.ops-monitor .uwa-monitor-overview { padding: 0 14px 14px; }
|
||||
.ops-monitor .uwa-analytics-toolbar { flex-wrap: wrap; gap: 16px; }
|
||||
.ops-monitor .uwa-token-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
|
||||
.ops-monitor .uwa-token-kpis article { padding: 17px; }
|
||||
.ops-monitor .uwa-token-kpi-icon { right: 14px; top: 14px; width: 15px; }
|
||||
.ops-monitor .uwa-hourly-panel { padding: 18px 14px; }
|
||||
.ops-monitor .uwa-panel-heading { flex-wrap: wrap; gap: 10px; }
|
||||
.ops-monitor .ops-request-drawer { padding: 6px; }
|
||||
}
|
||||
@media (prefers-reduced-motion:reduce) { :is(.ops-pool,.ops-monitor) * { transition: none !important; } }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-mobile-close { display: grid !important; flex: 0 0 28px; }
|
||||
.ops-pool .tab-card-actions button { flex: 0 0 auto; }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-group-resizer { display: block; left: 0; right: auto; }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open { width: var(--tp-group-nav-width,268px); }
|
||||
.ops-pool .tab-pool-brand-icon { background: var(--ops-soft); color: var(--uwa-olive); box-shadow: none; }
|
||||
.ops-monitor .ops-request-drawer { background: #17201466 !important; }
|
||||
.ops-monitor .uwa-request-row { border-radius: 0; }
|
||||
.ops-pool .tab-pool-group-nav.is-mobile-open .tab-pool-global-controls { margin: 12px; border-radius: 9px; }
|
||||
.ops-pool .tab-pool-switch-row, .ops-monitor .uwa-filter-toggle { position: relative; }
|
||||
.ops-pool .tab-pool-switch-row input { right: 0; top: 50%; transform: translateY(-50%); width: 36px; height: 28px; margin: 0; pointer-events: auto; z-index: 2; cursor: pointer; }
|
||||
.ops-pool .tab-pool-switch-row input:focus-visible + i, .ops-monitor .uwa-filter-toggle input:focus-visible + i { outline: 2px solid var(--uwa-olive); outline-offset: 4px; }
|
||||
.ops-monitor .uwa-filter-toggle input { left: 0; top: 50%; transform: translateY(-50%); width: 35px; height: 28px; margin: 0; z-index: 2; cursor: pointer; }
|
||||
/* Explicit grid placement avoids legacy mobile rules putting the title in the number column. */
|
||||
.ops-pool .tab-pool-card .tab-number { grid-column: 1; grid-row: 1; }
|
||||
.ops-pool .tab-pool-card .tab-card-main { grid-column: 2; grid-row: 1; min-width: 0; }
|
||||
.ops-pool .tab-pool-mobile-menu { display: none !important; }
|
||||
.ops-pool .tab-pool-top-actions > button:first-child { display: inline-flex !important; }
|
||||
.ops-pool .tab-pool-top-actions .tab-pool-refresh > span:last-child { display: inline; }
|
||||
.ops-monitor .ops-error-summary { background: color-mix(in srgb,var(--ops-danger) 6%,var(--uwa-paper-strong)); border-color: color-mix(in srgb,var(--ops-danger) 30%,var(--uwa-line)); color: var(--ops-danger); box-shadow: none; }
|
||||
.ops-monitor .ops-error-summary button, .ops-monitor .ops-error-summary .text-rose-500 { color: var(--ops-danger); }
|
||||
.ops-monitor .ops-request-drawer .text-emerald-600 { color: var(--uwa-olive); }
|
||||
@media (max-width:740px) {
|
||||
.ops-pool .tab-pool-top-actions { width: 100%; }
|
||||
.ops-pool .tab-pool-top-actions .tab-pool-refresh { margin-left: auto; }
|
||||
.ops-pool .tab-pool-card .tab-card-main { grid-column: 2; grid-row: 1; }
|
||||
}
|
||||
.ops-pool .tab-pool-top-actions .tab-pool-refresh { width: auto; min-width: 96px; min-height: 36px; height: 36px; padding: 0 12px; white-space: nowrap; }
|
||||
.ops-monitor .uwa-request-row { border-radius: 0 !important; }
|
||||
.ops-monitor .uwa-request-route strong { font-size: 13px; }
|
||||
.ops-monitor .uwa-request-row > span, .ops-monitor .uwa-request-row > code, .ops-monitor .uwa-request-row > time, .ops-monitor .uwa-request-status strong { font-size: 11px; }
|
||||
@@ -0,0 +1,496 @@
|
||||
/* Site configuration v2. Inherits the application's paper/olive tokens.
|
||||
Deliberately does NOT restyle #app, global navigation, branding or other pages. */
|
||||
#app.site-studio-active .uwa-config-page { --site-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; }
|
||||
#app.site-studio-active .uwa-config-page .uwa-page-header { padding-bottom: 26px; }
|
||||
#app.site-studio-active .uwa-config-page .uwa-page-header h1 { font-size: 32px; }
|
||||
#app.site-studio-active .uwa-config-page .uwa-page-header > div > p:last-child { font-size: 13px; }
|
||||
#app.site-studio-active .uwa-config-page .uwa-button { font-size: 12px; min-height: 38px; }
|
||||
#app.site-studio-active .studio-add-site,
|
||||
#app.site-studio-active .studio-save-button { background: var(--uwa-olive) !important; color: var(--uwa-paper-strong) !important; border-color: var(--uwa-olive) !important; }
|
||||
.dark #app.site-studio-active .studio-add-site,
|
||||
.dark #app.site-studio-active .studio-save-button { color: var(--uwa-paper) !important; }
|
||||
#app.site-studio-active .uwa-config-page button:disabled { opacity: .5; cursor: not-allowed; }
|
||||
#app.site-studio-active .uwa-config-page :is(button,summary,select,textarea,input):focus-visible { outline: 2px solid var(--uwa-olive) !important; outline-offset: 3px; }
|
||||
#app.site-studio-active .uwa-config-page svg { flex-shrink: 0; }
|
||||
|
||||
/* Library: contextual introduction, truthful counts and scannable site cards. */
|
||||
#app.site-studio-active .site-library-intro { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 30px; padding: 27px 30px; border: 1px solid var(--uwa-line); border-radius: 12px; background: var(--uwa-paper-soft); }
|
||||
#app.site-studio-active .site-library-kicker { color: var(--uwa-muted); font-size: 11px; letter-spacing: 1px !important; }
|
||||
#app.site-studio-active .site-library-intro h2 { margin: 9px 0 11px; color: var(--uwa-ink-strong); font-size: 24px; font-weight: 650; line-height: 1.4; }
|
||||
#app.site-studio-active .site-library-intro p { color: var(--uwa-muted); font-size: 12px; line-height: 1.9; }
|
||||
#app.site-studio-active .site-resume { display: inline-flex; align-items: center; gap: 8px; margin-top: 17px; color: var(--uwa-olive-dark); font-size: 12px; font-weight: 600; }
|
||||
#app.site-studio-active .site-resume:hover { text-decoration: underline; text-underline-offset: 4px; }
|
||||
#app.site-studio-active .site-resume svg { width: 15px; height: 15px; }
|
||||
#app.site-studio-active .site-library-stats { display: flex; }
|
||||
#app.site-studio-active .site-library-stats > div { min-width: 112px; padding: 8px 23px; border-left: 1px solid var(--uwa-line); }
|
||||
#app.site-studio-active .site-library-stats strong { display: block; color: var(--uwa-ink-strong); font-size: 38px; font-weight: 500; line-height: 1.3; font-variant-numeric: tabular-nums; }
|
||||
#app.site-studio-active .site-library-stats span { display: block; color: var(--uwa-muted); font-size: 11px; margin-top: 10px; }
|
||||
#app.site-studio-active .site-library-stats small { display: block; margin-top: 5px; color: var(--uwa-muted-soft); font-size: 9px; }
|
||||
#app.site-studio-active .site-library-toolbar { display: flex; align-items: center; gap: 10px; margin: 26px 0 18px; }
|
||||
#app.site-studio-active .site-library-filters { display: flex; align-items: center; gap: 6px; margin-right: auto; }
|
||||
#app.site-studio-active .site-library-filters button { padding: 10px 13px; font-size: 12px; color: var(--uwa-muted); border: 1px solid transparent; }
|
||||
#app.site-studio-active .site-library-filters button.is-active { background: var(--uwa-paper-strong); border-color: var(--uwa-line); color: var(--uwa-ink-strong); font-weight: 600; }
|
||||
#app.site-studio-active .site-library-filters button span { margin-left: 6px; font: 10px var(--site-mono); color: var(--uwa-muted); }
|
||||
#app.site-studio-active .library-search { display: flex; align-items: center; gap: 8px; width: 220px; min-width: 0; padding: 0 11px; height: 38px; border: 1px solid var(--uwa-line); border-radius: 7px; background: var(--uwa-paper-strong); color: var(--uwa-muted); }
|
||||
#app.site-studio-active .library-search input { width: 100%; min-width: 0; border: 0; height: 34px; padding: 0; font-size: 11px; background: transparent !important; box-shadow: none !important; }
|
||||
#app.site-studio-active .library-search input:focus-visible { outline: none !important; }
|
||||
#app.site-studio-active .library-search:focus-within { outline: 2px solid var(--uwa-leaf-soft); border-color: var(--uwa-olive); }
|
||||
#app.site-studio-active .library-search svg { width: 14px; height: 14px; }
|
||||
#app.site-studio-active .library-search kbd { font: 10px var(--site-mono); border: 1px solid var(--uwa-line); padding: 1px 4px; border-radius: 3px; }
|
||||
#app.site-studio-active .site-library-compare { display: inline-flex; align-items: center; gap: 6px; padding: 9px 8px; font-size: 11px; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .site-library-compare:hover { color: var(--uwa-ink-strong); }
|
||||
#app.site-studio-active .site-library-compare svg { width: 14px; height: 14px; }
|
||||
#app.site-studio-active .site-library-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
|
||||
#app.site-studio-active .site-library-card { position: relative; min-width: 0; border: 1px solid var(--uwa-line); border-radius: 12px; background: var(--uwa-paper-strong); transition: box-shadow .18s, border-color .18s, transform .18s; }
|
||||
#app.site-studio-active .site-library-card:hover { border-color: var(--uwa-olive); box-shadow: 0 8px 20px #33402c0a; transform: translateY(-2px); }
|
||||
#app.site-studio-active .site-library-card:focus-within { border-color: var(--uwa-olive); }
|
||||
#app.site-studio-active .site-card-open { display: block; width: 100%; min-width: 0; padding: 21px 20px 0; text-align: left; color: var(--uwa-ink); }
|
||||
#app.site-studio-active .site-card-identity { display: flex; align-items: center; gap: 12px; padding-right: 19px; }
|
||||
#app.site-studio-active .site-card-mark { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 44px; color: var(--uwa-olive-dark); background: var(--uwa-leaf-soft); border-radius: 10px; font-size: 23px; font-weight: 650; }
|
||||
#app.site-studio-active .site-library-card:nth-child(3n+2) .site-card-mark { color: var(--uwa-ochre); background: color-mix(in srgb, var(--uwa-ochre) 13%, var(--uwa-paper-strong)); }
|
||||
#app.site-studio-active .site-library-card:nth-child(3n) .site-card-mark { color: var(--uwa-blue); background: color-mix(in srgb, var(--uwa-blue) 13%, var(--uwa-paper-strong)); }
|
||||
#app.site-studio-active .site-card-identity > span:last-child { min-width: 0; }
|
||||
#app.site-studio-active .site-card-identity strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--uwa-ink-strong); font-size: 14px; font-weight: 650; }
|
||||
#app.site-studio-active .site-card-identity small { display: block; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--uwa-muted); font: 10px var(--site-mono); }
|
||||
#app.site-studio-active .site-card-preset { display: flex; align-items: center; gap: 6px; margin-top: 21px; font-size: 11px; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .site-card-preset svg { width: 13px; height: 13px; }
|
||||
#app.site-studio-active .site-card-preset strong { font-size: 11px; font-weight: 500; color: var(--uwa-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
#app.site-studio-active .site-card-readiness { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; font-size: 11px; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .site-card-readiness strong { color: var(--uwa-olive-dark); font: 600 12px var(--site-mono); }
|
||||
#app.site-studio-active .site-card-readiness small { color: var(--uwa-muted); font: 10px 'Segoe UI', sans-serif; }
|
||||
#app.site-studio-active .site-card-progress { display: flex; gap: 5px; margin-top: 9px; }
|
||||
#app.site-studio-active .site-card-progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--uwa-line-soft); }
|
||||
#app.site-studio-active .site-card-progress i.is-filled { background: var(--uwa-leaf); }
|
||||
#app.site-studio-active .site-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 20px; padding: 13px 0 15px; border-top: 1px solid var(--uwa-line-soft); color: var(--uwa-muted); font-size: 10px; }
|
||||
#app.site-studio-active .site-card-footer > span { min-width: 0; }
|
||||
#app.site-studio-active .site-card-footer i { font-style: normal; opacity: .5; padding: 0 4px; }
|
||||
#app.site-studio-active .site-card-footer b { display: flex; align-items: center; gap: 5px; color: var(--uwa-olive); font-size: 11px; font-weight: 550; white-space: nowrap; }
|
||||
#app.site-studio-active .site-card-footer svg { width: 14px; height: 14px; }
|
||||
#app.site-studio-active .site-card-menu { position: absolute; right: 10px; top: 14px; z-index: 3; }
|
||||
#app.site-studio-active .site-card-menu > summary { border: 0; width: 25px; height: 28px; background: transparent; }
|
||||
#app.site-studio-active .site-card-menu[open] { z-index: 8; }
|
||||
#app.site-studio-active .site-add-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 220px; padding: 28px; border: 1px dashed var(--uwa-line); border-radius: 12px !important; background: transparent; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .site-add-card > span { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--uwa-paper-soft); }
|
||||
#app.site-studio-active .site-add-card svg { width: 24px; height: 24px; }
|
||||
#app.site-studio-active .site-add-card strong { font-size: 14px; font-weight: 550; }
|
||||
#app.site-studio-active .site-add-card small { font-size: 11px; color: var(--uwa-muted-soft); }
|
||||
#app.site-studio-active .site-add-card:hover { color: var(--uwa-olive); border-color: var(--uwa-olive); background: var(--uwa-paper-soft); }
|
||||
#app.site-studio-active .site-library-footnote { display: flex; align-items: center; gap: 7px; color: var(--uwa-muted); font-size: 11px; margin-top: 20px; line-height: 1.8; }
|
||||
#app.site-studio-active .site-library-footnote svg { width: 14px; height: 14px; }
|
||||
#app.site-studio-active .site-library-save { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--uwa-line); color: var(--uwa-muted); font-size: 12px; }
|
||||
#app.site-studio-active .site-library-empty { padding: 60px 20px; text-align: center; }
|
||||
#app.site-studio-active .site-library-empty > span svg { width: 32px; height: 32px; color: var(--uwa-muted-soft); }
|
||||
#app.site-studio-active .site-library-empty h3 { margin: 15px 0 10px; font-size: 18px; }
|
||||
#app.site-studio-active .site-library-empty p { margin-bottom: 20px; color: var(--uwa-muted); font-size: 12px; }
|
||||
|
||||
/* Detail view. A local outline replaces the second global sidebar/tab strip. */
|
||||
#app.site-studio-active .site-editor-breadcrumb { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; font-size: 12px; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .site-editor-breadcrumb button { display: inline-flex; align-items: center; gap: 7px; color: var(--uwa-ink); font-size: 12px; }
|
||||
#app.site-studio-active .site-editor-breadcrumb button svg { width: 13px; height: 13px; transform: rotate(-90deg); }
|
||||
#app.site-studio-active .site-editor-breadcrumb small { margin-left: auto; font-size: 11px; color: var(--uwa-muted-soft); }
|
||||
#app.site-studio-active .uwa-config-workspace { display: block; margin-top: 0; border-radius: 12px; background: var(--uwa-paper-strong); border-color: var(--uwa-line); box-shadow: 0 3px 14px #33402c04; min-height: 0; }
|
||||
#app.site-studio-active .uwa-config-editor { padding: 0; min-width: 0; background: transparent !important; }
|
||||
#app.site-studio-active .uwa-editor-heading { padding: 25px 26px 17px; gap: 20px; align-items: center; border: 0; flex-wrap: wrap; }
|
||||
#app.site-studio-active .uwa-site-switcher > summary { border: 0; padding: 0; gap: 12px; background: transparent; }
|
||||
#app.site-studio-active .uwa-editor-site-icon { width: 48px; height: 50px; border-radius: 10px; color: var(--uwa-olive-dark); background: var(--uwa-leaf-soft); font-size: 26px; }
|
||||
#app.site-studio-active .uwa-site-switcher-current h2 { font-size: 23px; line-height: 1.3; font-weight: 650; }
|
||||
#app.site-studio-active .uwa-site-switcher-current p { font: 11px var(--site-mono); color: var(--uwa-muted); margin-top: 6px; }
|
||||
#app.site-studio-active .uwa-editor-actions { display: flex; gap: 8px; margin-left: auto; }
|
||||
#app.site-studio-active .uwa-switch-label { font-size: 11px; }
|
||||
#app.site-studio-active .studio-editor-caption { display: flex; justify-content: space-between; gap: 12px; margin: 0 26px; padding-bottom: 18px; color: var(--uwa-muted); font-size: 10px; }
|
||||
#app.site-studio-active .studio-save-status { color: var(--uwa-muted-soft); white-space: nowrap; font-size: 10px; }
|
||||
#app.site-studio-active .uwa-config-editor .config-workspace { padding: 0 !important; min-height: 0; background: transparent !important; }
|
||||
#app.site-studio-active .uwa-config-editor .config-preset-card { margin: 0 !important; padding: 14px 26px !important; background: var(--uwa-paper-soft) !important; border-top: 1px solid var(--uwa-line) !important; border-bottom: 1px solid var(--uwa-line) !important; border-radius: 0 !important; }
|
||||
#app.site-studio-active .config-preset-label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; }
|
||||
#app.site-studio-active .config-preset-label svg { width: 14px; height: 14px; }
|
||||
#app.site-studio-active .uwa-config-editor .config-preset-meta { flex-wrap: wrap; }
|
||||
#app.site-studio-active .config-preset-chip { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
|
||||
#app.site-studio-active .uwa-config-editor .config-preset-card select { max-width: 230px; min-width: 120px; font-size: 12px; }
|
||||
#app.site-studio-active .uwa-config-editor .config-workspace > .space-y-4 > .site-edit-layout { display: grid; grid-template-columns: 188px minmax(0,1fr); gap: 0; border: 0 !important; border-radius: 0 0 12px 12px !important; background: transparent !important; overflow: visible; }
|
||||
#app.site-studio-active .site-config-outline { padding: 27px 12px 24px; background: color-mix(in srgb, var(--uwa-paper-soft) 35%, var(--uwa-paper-strong)); border-right: 1px solid var(--uwa-line-soft); border-radius: 0 0 0 12px; min-width: 0; }
|
||||
#app.site-studio-active .site-config-outline > p { margin: 0 11px 18px; color: var(--uwa-muted-soft); font-size: 10px; letter-spacing: 1px !important; }
|
||||
#app.site-studio-active .uwa-config-section-nav { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin: 0 !important; padding: 0; border: 0; border-radius: 0; overflow: visible; background: transparent !important; }
|
||||
#app.site-studio-active .uwa-config-section-nav button { display: flex; align-items: center; gap: 10px; min-height: 65px; padding: 12px 10px; border: 1px solid transparent; border-radius: 8px !important; color: var(--uwa-muted); background: transparent; box-shadow: none; text-align: left; font-weight: 400; }
|
||||
#app.site-studio-active .uwa-config-section-nav button.is-active { border-color: color-mix(in srgb, var(--uwa-olive) 22%, transparent); background: var(--uwa-leaf-soft); color: var(--uwa-ink-strong); box-shadow: none; }
|
||||
#app.site-studio-active .uwa-config-section-nav button:hover:not(.is-active) { background: var(--uwa-paper-soft); }
|
||||
#app.site-studio-active .site-section-number { font: 10px var(--site-mono); opacity: .6; }
|
||||
#app.site-studio-active .uwa-config-section-nav button strong { display: block; font-size: 12px; font-weight: 600; }
|
||||
#app.site-studio-active .uwa-config-section-nav button small { display: block; margin-top: 6px; color: var(--uwa-muted); font-size: 10px; font-weight: 400; }
|
||||
#app.site-studio-active .uwa-config-section-nav button i { margin-left: auto; display: flex; opacity: 0; }
|
||||
#app.site-studio-active .uwa-config-section-nav button.is-active i { opacity: .65; }
|
||||
#app.site-studio-active .uwa-config-section-nav button i svg { width: 12px; height: 12px; }
|
||||
#app.site-studio-active .site-outline-note { margin: 35px 11px 0; padding-top: 18px; border-top: 1px solid var(--uwa-line-soft); }
|
||||
#app.site-studio-active .site-outline-note svg { width: 18px; height: 18px; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .site-outline-note strong { display: block; margin-top: 11px; font-size: 11px; font-weight: 500; color: var(--uwa-ink); }
|
||||
#app.site-studio-active .site-outline-note p { margin-top: 7px; font-size: 10px; line-height: 1.9; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .site-config-content { padding: 25px 27px 30px; min-width: 0; }
|
||||
#app.site-studio-active .site-section-intro { margin-bottom: 25px; }
|
||||
#app.site-studio-active .site-section-intro > span { font-size: 10px; color: var(--uwa-muted-soft); }
|
||||
#app.site-studio-active .site-section-intro h3 { margin: 10px 0 8px; font-size: 21px; line-height: 1.4; font-weight: 650; color: var(--uwa-ink-strong); }
|
||||
#app.site-studio-active .site-section-intro p { color: var(--uwa-muted); font-size: 12px; line-height: 1.8; }
|
||||
#app.site-studio-active .site-config-content > .config-fixed-panel { margin-bottom: 15px; border-color: var(--uwa-line) !important; background: var(--uwa-paper-strong) !important; }
|
||||
#app.site-studio-active .site-config-content > .config-fixed-panel > div:first-child { background: var(--uwa-paper-soft) !important; }
|
||||
#app.site-studio-active .site-section-select { display: none; }
|
||||
|
||||
/* Progressive field editor: scan a group, expand a field, edit with context. */
|
||||
#app.site-studio-active .site-config-content > .studio-selector-panel { border: 0 !important; box-shadow: none !important; background: transparent !important; }
|
||||
#app.site-studio-active .uwa-config-editor .studio-selector-panel > div:first-child { padding: 0 0 12px !important; background: transparent !important; border: 0; min-height: 35px; }
|
||||
#app.site-studio-active .uwa-config-editor .studio-selector-panel > div:first-child h3 { font-size: 12px !important; }
|
||||
#app.site-studio-active .uwa-config-editor .studio-selector-panel > div:last-child { padding: 0 !important; max-height: none; overflow: visible; }
|
||||
#app.site-studio-active .site-core-path { display: flex; align-items: stretch; padding: 15px; border: 1px solid var(--uwa-line); border-radius: 9px; background: var(--uwa-paper-soft); }
|
||||
#app.site-studio-active .site-core-path > button { display: flex; align-items: center; flex: 1; min-width: 0; gap: 9px; }
|
||||
#app.site-studio-active .site-path-node { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid var(--uwa-line); border-radius: 50%; color: var(--uwa-muted); background: var(--uwa-paper-strong); }
|
||||
#app.site-studio-active .site-path-node svg { width: 14px; height: 14px; }
|
||||
#app.site-studio-active .site-core-path .is-filled .site-path-node { background: var(--uwa-leaf-soft); color: var(--uwa-olive-dark); border-color: color-mix(in srgb, var(--uwa-olive) 15%, transparent); }
|
||||
#app.site-studio-active .site-core-path strong { display: block; font-size: 11px; font-weight: 600; }
|
||||
#app.site-studio-active .site-core-path small { display: block; margin-top: 4px; color: var(--uwa-muted); font-size: 10px; }
|
||||
#app.site-studio-active .site-core-path i { margin: 0 auto; color: var(--uwa-muted-soft); }
|
||||
#app.site-studio-active .site-core-path i svg { width: 15px; height: 15px; }
|
||||
#app.site-studio-active .site-missing-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; font-size: 11px; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .site-missing-fields button { display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; border: 1px solid var(--uwa-line); color: var(--uwa-olive-dark); background: var(--uwa-paper-strong); font-size: 11px; }
|
||||
#app.site-studio-active .site-missing-fields svg { width: 13px; height: 13px; }
|
||||
#app.site-studio-active .studio-field-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 0 5px; }
|
||||
#app.site-studio-active .studio-field-filters { display: flex; gap: 2px; }
|
||||
#app.site-studio-active .studio-field-filters button { padding: 7px 9px; min-height: 32px; border: 0; background: transparent; font-size: 11px; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .studio-field-filters button.is-active { color: var(--uwa-ink-strong); background: var(--uwa-paper-soft); font-weight: 600; }
|
||||
#app.site-studio-active .studio-field-filters button > span { font-size: 10px; margin-left: 3px; }
|
||||
#app.site-studio-active .studio-field-search { display: flex; align-items: center; gap: 6px; width: 155px; min-width: 0; color: var(--uwa-muted-soft); }
|
||||
#app.site-studio-active .studio-field-search svg { width: 13px; height: 13px; }
|
||||
#app.site-studio-active .uwa-config-editor .studio-field-search input { min-width: 0; width: 100%; min-height: 30px; height: 30px; padding: 0 6px; border: 0; font-size: 11px; background: transparent !important; box-shadow: none !important; }
|
||||
#app.site-studio-active .site-field-group { margin-top: 19px !important; }
|
||||
#app.site-studio-active .site-field-group-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
|
||||
#app.site-studio-active .site-field-group-heading h4 { color: var(--uwa-ink-strong); font-size: 13px; font-weight: 600; }
|
||||
#app.site-studio-active .site-field-group-heading h4 span { margin-left: 6px; color: var(--uwa-muted-soft); font: 10px var(--site-mono); }
|
||||
#app.site-studio-active .site-field-group-heading p { font-size: 10px; color: var(--uwa-muted); margin-top: 5px; }
|
||||
#app.site-studio-active .site-field-group-heading > button { display: inline-flex; align-items: center; gap: 5px; padding: 6px; font-size: 11px; color: var(--uwa-olive); }
|
||||
#app.site-studio-active .site-field-group-heading > button svg { width: 13px; height: 13px; }
|
||||
#app.site-studio-active .site-field-group.is-auxiliary { padding-top: 20px; border-top: 1px solid var(--uwa-line); }
|
||||
#app.site-studio-active .site-field-group-list { display: flex; flex-direction: column; gap: 9px; }
|
||||
#app.site-studio-active .studio-selector-card { min-width: 0; border: 1px solid var(--uwa-line); border-radius: 9px; background: var(--uwa-paper-strong); overflow: visible; }
|
||||
#app.site-studio-active .studio-selector-card.is-expanded { border-color: color-mix(in srgb, var(--uwa-olive) 58%, var(--uwa-line)); box-shadow: 0 3px 10px #33402c06; }
|
||||
#app.site-studio-active .site-field-toggle { display: flex; align-items: center; width: 100%; min-width: 0; gap: 10px; padding: 15px; text-align: left; background: transparent; color: var(--uwa-ink); }
|
||||
#app.site-studio-active .site-field-toggle:hover { background: color-mix(in srgb, var(--uwa-paper-soft) 45%, transparent); }
|
||||
#app.site-studio-active .site-field-index { align-self: flex-start; padding-top: 2px; color: var(--uwa-muted-soft); font: 10px var(--site-mono); }
|
||||
#app.site-studio-active .site-field-heading { min-width: 0; flex: 1; }
|
||||
#app.site-studio-active .site-field-heading > span { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
|
||||
#app.site-studio-active .site-field-heading strong { font-size: 12px; font-weight: 600; color: var(--uwa-ink-strong); }
|
||||
#app.site-studio-active .site-field-heading code { font: 10px var(--site-mono); color: var(--uwa-muted); }
|
||||
#app.site-studio-active .site-field-heading small { display: block; max-width: 100%; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--uwa-muted-soft); font: 10px var(--site-mono); }
|
||||
#app.site-studio-active .site-field-state { flex-shrink: 0; color: var(--uwa-ochre); font-size: 9px; }
|
||||
#app.site-studio-active .site-field-state.is-filled { color: var(--uwa-olive); }
|
||||
#app.site-studio-active .site-field-chevron { display: flex; color: var(--uwa-muted-soft); }
|
||||
#app.site-studio-active .site-field-chevron svg { width: 12px; height: 12px; }
|
||||
#app.site-studio-active .site-field-expanded { padding: 0 15px 14px; }
|
||||
#app.site-studio-active .site-field-edit-row { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(150px,1fr); gap: 18px; padding-top: 4px; }
|
||||
#app.site-studio-active .site-field-expression { min-width: 0; }
|
||||
#app.site-studio-active .site-field-expression label { display: block; margin-bottom: 8px; font-size: 10px; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .uwa-config-editor .site-field-expression textarea { display: block; width: 100%; min-height: 108px; padding: 11px 12px; border: 1px solid var(--uwa-line) !important; border-radius: 6px !important; background: var(--uwa-paper) !important; color: var(--uwa-ink-strong) !important; font: 12px/1.9 var(--site-mono) !important; overflow-wrap: anywhere; resize: vertical; }
|
||||
#app.site-studio-active .site-field-context { min-width: 0; padding-left: 15px; border-left: 1px solid var(--uwa-line-soft); }
|
||||
#app.site-studio-active .site-field-context > span { font-size: 10px; color: var(--uwa-olive); }
|
||||
#app.site-studio-active .site-field-context p { font-size: 11px; line-height: 1.8; color: var(--uwa-ink); margin-top: 8px; }
|
||||
#app.site-studio-active .site-field-context small { display: block; margin-top: 7px; font-size: 10px; line-height: 1.8; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .studio-field-actions { display: flex; align-items: center; gap: 7px; padding-top: 14px; margin-top: 13px; border-top: 1px solid var(--uwa-line-soft); }
|
||||
#app.site-studio-active .studio-field-actions > span { margin-right: auto; font-size: 10px; color: var(--uwa-muted-soft); }
|
||||
#app.site-studio-active .studio-field-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 32px; padding: 0 9px; font-size: 11px; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .studio-field-actions button svg { width: 13px; height: 13px; }
|
||||
#app.site-studio-active .studio-field-actions .site-test-field { color: var(--uwa-olive-dark); border: 1px solid var(--uwa-line); background: var(--uwa-paper-soft); }
|
||||
#app.site-studio-active .studio-field-actions .site-test-field:hover { border-color: var(--uwa-olive); background: var(--uwa-leaf-soft); }
|
||||
#app.site-studio-active .studio-field-actions .site-delete-field:hover { color: var(--uwa-clay); background: color-mix(in srgb, var(--uwa-clay) 10%, transparent); }
|
||||
#app.site-studio-active .studio-guide-entry { padding-top: 12px; }
|
||||
#app.site-studio-active .studio-guide-entry .dashboard-guide-toggle { padding: 0; border: 0; background: transparent; color: var(--uwa-muted); font-size: 11px; }
|
||||
#app.site-studio-active .studio-fields-empty { padding: 24px 12px; text-align: center; color: var(--uwa-muted); font-size: 12px; }
|
||||
#app.site-studio-active .studio-fields-empty > span svg { width: 25px; height: 25px; margin-bottom: 10px; }
|
||||
#app.site-studio-active .studio-fields-empty strong { display: block; margin-bottom: 7px; }
|
||||
#app.site-studio-active .studio-fields-empty p { font-size: 11px; line-height: 1.8; }
|
||||
#app.site-studio-active .studio-fields-empty button { margin-top: 10px; font-size: 11px; color: var(--uwa-olive); }
|
||||
#app.site-studio-active .studio-spin { display: inline-flex; animation: site-saving 1s linear infinite; }
|
||||
@keyframes site-saving { to { transform: rotate(360deg); } }
|
||||
@media (max-width: 1250px) {
|
||||
#app.site-studio-active .site-library-stats > div { min-width: 88px; padding: 5px 14px; }
|
||||
#app.site-studio-active .site-library-stats strong { font-size: 32px; }
|
||||
#app.site-studio-active .site-library-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
|
||||
#app.site-studio-active .uwa-config-editor .config-workspace > .space-y-4 > .site-edit-layout { grid-template-columns: 163px minmax(0,1fr); }
|
||||
#app.site-studio-active .site-config-outline { padding-left: 8px; padding-right: 8px; }
|
||||
#app.site-studio-active .site-config-content { padding-left: 20px; padding-right: 20px; }
|
||||
#app.site-studio-active .site-field-edit-row { grid-template-columns: minmax(0,1fr); gap: 12px; }
|
||||
#app.site-studio-active .site-field-context { border-left: 0; padding-left: 0; }
|
||||
#app.site-studio-active .site-field-context small { margin-top: 4px; }
|
||||
}
|
||||
@media (max-width: 1050px) {
|
||||
#app.site-studio-active .site-library-intro { grid-template-columns: minmax(0,1fr); gap: 20px; }
|
||||
#app.site-studio-active .site-library-stats { border-top: 1px solid var(--uwa-line); padding-top: 18px; }
|
||||
#app.site-studio-active .site-library-stats > div { flex: 1; min-width: 0; }
|
||||
#app.site-studio-active .site-library-stats > div:first-child { border-left: 0; padding-left: 0; }
|
||||
#app.site-studio-active .site-library-toolbar { flex-wrap: wrap; }
|
||||
#app.site-studio-active .library-search { width: 200px; }
|
||||
}
|
||||
@media (max-width: 740px) {
|
||||
#app.site-studio-active .uwa-config-editor .config-workspace > .space-y-4 > .site-edit-layout { display: block; }
|
||||
#app.site-studio-active .site-config-outline { display: none; }
|
||||
#app.site-studio-active .site-section-select { display: flex; align-items: center; gap: 15px; padding: 14px 20px; border-bottom: 1px solid var(--uwa-line); background: var(--uwa-paper-soft); font-size: 11px; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .site-section-select select { min-width: 0; flex: 1; padding: 8px; font-size: 12px; border: 1px solid var(--uwa-line); }
|
||||
}
|
||||
@media (max-width: 620px) {
|
||||
#app.site-studio-active .uwa-config-page { padding: 23px 16px 35px; }
|
||||
#app.site-studio-active .uwa-config-page .uwa-page-header { gap: 20px; padding-bottom: 22px; }
|
||||
#app.site-studio-active .uwa-config-page .uwa-page-header h1 { font-size: 28px; }
|
||||
#app.site-studio-active .uwa-config-page .uwa-page-header > div > p:last-child { font-size: 12px; line-height: 1.8; }
|
||||
#app.site-studio-active .uwa-page-actions { display: flex; gap: 8px; }
|
||||
#app.site-studio-active .uwa-page-actions .uwa-button,
|
||||
#app.site-studio-active .uwa-page-actions .uwa-dropdown { flex: 0 0 auto; }
|
||||
#app.site-studio-active .uwa-page-actions > .studio-add-site { margin-left: auto; }
|
||||
#app.site-studio-active .uwa-config-page .uwa-button { font-size: 11px; min-height: 38px; padding: 0 11px; }
|
||||
#app.site-studio-active .site-library-intro { padding: 22px; }
|
||||
#app.site-studio-active .site-library-intro h2 { font-size: 22px; }
|
||||
#app.site-studio-active .site-library-intro p { font-size: 11px; }
|
||||
#app.site-studio-active .site-library-stats > div { padding: 0 12px; }
|
||||
#app.site-studio-active .site-library-stats strong { font-size: 31px; }
|
||||
#app.site-studio-active .site-library-stats span { font-size: 10px; }
|
||||
#app.site-studio-active .site-library-stats small { font-size: 8px; }
|
||||
#app.site-studio-active .site-library-toolbar { gap: 10px 6px; margin-top: 20px; }
|
||||
#app.site-studio-active .library-search { order: 3; width: 100%; }
|
||||
#app.site-studio-active .site-library-filters button { padding: 8px 10px; font-size: 11px; }
|
||||
#app.site-studio-active .site-library-compare { padding: 8px 4px; font-size: 10px; }
|
||||
#app.site-studio-active .site-library-grid { grid-template-columns: minmax(0,1fr); gap: 12px; }
|
||||
#app.site-studio-active .site-card-open { padding: 21px 22px 0; }
|
||||
#app.site-studio-active .site-card-identity strong { font-size: 16px; }
|
||||
#app.site-studio-active .site-add-card { min-height: 160px; }
|
||||
#app.site-studio-active .site-library-save { align-items: flex-start; font-size: 11px; }
|
||||
#app.site-studio-active .site-library-save .uwa-button { flex-shrink: 0; }
|
||||
#app.site-studio-active .site-editor-breadcrumb { margin-bottom: 18px; font-size: 11px; gap: 10px; flex-wrap: wrap; }
|
||||
#app.site-studio-active .site-editor-breadcrumb small { display: none; }
|
||||
#app.site-studio-active .uwa-editor-heading { padding: 20px 15px 13px; flex-direction: column; align-items: stretch; gap: 20px; }
|
||||
#app.site-studio-active .uwa-site-switcher-current h2 { font-size: 21px; max-width: calc(100vw - 160px); overflow: hidden; text-overflow: ellipsis; }
|
||||
#app.site-studio-active .uwa-editor-actions { width: 100%; margin: 0; flex-wrap: wrap; gap: 6px; }
|
||||
#app.site-studio-active .uwa-editor-actions .uwa-switch-label { margin-right: auto; font-size: 10px; }
|
||||
#app.site-studio-active .uwa-editor-actions .uwa-actions-divider { display: none; }
|
||||
#app.site-studio-active .uwa-editor-actions .uwa-button { flex: 0 0 auto; }
|
||||
#app.site-studio-active .studio-editor-caption { margin: 0 15px; flex-direction: column; gap: 5px; font-size: 9px; }
|
||||
#app.site-studio-active .studio-save-status { font-size: 9px; }
|
||||
#app.site-studio-active .uwa-config-editor .config-preset-card { padding: 12px 15px !important; }
|
||||
#app.site-studio-active .uwa-config-editor .config-preset-meta,
|
||||
#app.site-studio-active .uwa-config-editor .config-preset-actions { display: flex !important; flex-wrap: wrap; gap: 7px !important; }
|
||||
#app.site-studio-active .config-preset-label svg { display: none; }
|
||||
#app.site-studio-active .config-preset-count { display: none; }
|
||||
#app.site-studio-active .config-preset-chip { max-width: 110px; min-height: 22px; font-size: 9px; padding: 0 6px; }
|
||||
#app.site-studio-active .uwa-config-editor .config-preset-card select { width: auto; min-width: 90px; max-width: 135px; font-size: 11px; }
|
||||
#app.site-studio-active .uwa-config-editor .config-preset-actions > .preset-hint-toggle { margin-left: auto; }
|
||||
#app.site-studio-active .uwa-config-editor .config-preset-card .preset-btn { font-size: 11px !important; padding: 0 9px !important; min-height: 33px; }
|
||||
#app.site-studio-active .site-section-select { padding: 12px 15px; }
|
||||
#app.site-studio-active .site-config-content { padding: 22px 15px 25px; }
|
||||
#app.site-studio-active .site-section-intro { margin-bottom: 20px; }
|
||||
#app.site-studio-active .site-section-intro h3 { font-size: 20px; }
|
||||
#app.site-studio-active .site-section-intro p { font-size: 11px; }
|
||||
#app.site-studio-active .site-core-path { padding: 12px 9px; gap: 8px; }
|
||||
#app.site-studio-active .site-core-path > button { gap: 6px; }
|
||||
#app.site-studio-active .site-core-path strong { font-size: 10px; }
|
||||
#app.site-studio-active .site-core-path small { font-size: 9px; }
|
||||
#app.site-studio-active .site-path-node { width: 22px; height: 22px; flex-shrink: 0; }
|
||||
#app.site-studio-active .site-core-path i { display: none; }
|
||||
#app.site-studio-active .studio-field-toolbar { flex-wrap: wrap; }
|
||||
#app.site-studio-active .studio-field-search { width: 100%; border: 1px solid var(--uwa-line); border-radius: 6px; padding-left: 9px; }
|
||||
#app.site-studio-active .uwa-config-editor .studio-field-search input { min-height: 34px; }
|
||||
#app.site-studio-active .site-field-toggle { padding: 13px 11px; gap: 8px; }
|
||||
#app.site-studio-active .site-field-heading > span { flex-direction: column; align-items: flex-start; gap: 5px; }
|
||||
#app.site-studio-active .site-field-state { font-size: 9px; }
|
||||
#app.site-studio-active .site-field-index { display: none; }
|
||||
#app.site-studio-active .site-field-expanded { padding: 0 11px 12px; }
|
||||
#app.site-studio-active .site-field-edit-row { gap: 13px; }
|
||||
#app.site-studio-active .site-field-context small { font-size: 10px; }
|
||||
#app.site-studio-active .site-field-context > span { display: none; }
|
||||
#app.site-studio-active .site-field-context p { margin-top: 0; }
|
||||
#app.site-studio-active .studio-field-actions { flex-wrap: wrap; gap: 6px; }
|
||||
#app.site-studio-active .studio-field-actions > span { width: 100%; margin-bottom: 4px; }
|
||||
#app.site-studio-active .studio-field-actions .site-test-field { margin-left: auto; min-height: 36px; }
|
||||
#app.site-studio-active .site-card-menu .preset-more-pop { left: auto; right: 0; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
#app.site-studio-active .uwa-config-page * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
|
||||
}
|
||||
|
||||
/* Small alignment details, using the same application tokens. */
|
||||
#app.site-studio-active .studio-editor-caption { margin: 0 26px !important; }
|
||||
#app.site-studio-active .site-core-path > button { text-align: left; }
|
||||
#app.site-studio-active .site-core-path > button:hover .site-path-node { border-color: var(--uwa-olive); }
|
||||
#app.site-studio-active .site-core-path > button:focus-visible { outline-offset: 4px; }
|
||||
@media (max-width: 620px) {
|
||||
#app.site-studio-active .studio-editor-caption { margin: 0 15px !important; }
|
||||
#app.site-studio-active .uwa-config-editor .config-preset-actions .preset-inline-input { width: 150px; min-width: 0; }
|
||||
}
|
||||
|
||||
/* v3 · progressive disclosure. Abilities first, configuration only on demand.
|
||||
Native details keep every draft/control mounted; opening a card changes no config. */
|
||||
#app.site-studio-active .site-config-content > .cap-panel { border: 0 !important; background: transparent !important; box-shadow: none !important; }
|
||||
#app.site-studio-active .uwa-config-editor .cap-panel > div:first-child { min-height: 0; padding: 0 0 14px !important; border: 0; background: transparent !important; }
|
||||
#app.site-studio-active .uwa-config-editor .cap-panel > div:last-child { padding: 0 !important; }
|
||||
#app.site-studio-active .cap-panel > div:first-child h3 { font-size: 12px !important; }
|
||||
#app.site-studio-active .cap-panel > div:first-child .text-sm.text-gray-500 { display: none; }
|
||||
#app.site-studio-active .cap-panel .cap-module-note { padding: 0 0 4px; margin: 0 0 14px; font-size: 12px; line-height: 1.8; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .cap-feature-stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
|
||||
#app.site-studio-active .cap-card { min-width: 0; padding: 20px 20px 0; border: 1px solid var(--uwa-line); border-radius: 11px; background: var(--uwa-paper-strong); }
|
||||
#app.site-studio-active .cap-card.is-enabled { border-color: color-mix(in srgb, var(--uwa-olive) 28%, var(--uwa-line)); }
|
||||
#app.site-studio-active .cap-card-header { display: flex; align-items: flex-start; gap: 12px; }
|
||||
#app.site-studio-active .cap-icon { flex: 0 0 34px; width: 34px; height: 36px; display: grid; place-items: center; border: 1px solid var(--uwa-line-soft); border-radius: 9px; color: var(--uwa-olive); background: var(--uwa-paper-soft); }
|
||||
#app.site-studio-active .cap-icon svg { width: 18px; height: 18px; }
|
||||
#app.site-studio-active .cap-copy { min-width: 0; flex: 1; }
|
||||
#app.site-studio-active .cap-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 1px; }
|
||||
#app.site-studio-active .cap-card h4 { margin: 0; font-size: 15px; font-weight: 600; color: var(--uwa-ink-strong); line-height: 1.5; }
|
||||
#app.site-studio-active .cap-copy > p { margin: 6px 0 0; font-size: 12px; line-height: 1.8; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .cap-scope { display: none; font-size: 9px; font-weight: 400; padding: 2px 5px; border-radius: 4px; background: var(--uwa-paper-soft); color: var(--uwa-muted); }
|
||||
#app.site-studio-active .config-advanced-panel .cap-scope { display: inline-flex; }
|
||||
#app.site-studio-active .cap-switch { display: inline-flex; align-items: center; position: relative; flex-shrink: 0; gap: 7px; padding: 5px 0; cursor: pointer; }
|
||||
#app.site-studio-active .cap-state { font-size: 10px; line-height: 22px; color: var(--uwa-muted-soft); white-space: nowrap; }
|
||||
#app.site-studio-active .cap-state.is-on { color: var(--uwa-olive); }
|
||||
#app.site-studio-active .cap-switch .cap-switch-input { position: absolute; right: 0; top: 3px; width: 40px; height: 26px; margin: 0; opacity: 0; cursor: pointer; z-index: 2; }
|
||||
#app.site-studio-active .cap-switch i { position: relative; display: block; width: 35px; height: 21px; border-radius: 20px; background: var(--uwa-line); transition: background .15s; }
|
||||
#app.site-studio-active .cap-switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: var(--uwa-paper-strong); box-shadow: 0 1px 3px #0002; transition: transform .15s; }
|
||||
#app.site-studio-active .cap-switch input:checked + i { background: var(--uwa-olive); }
|
||||
#app.site-studio-active .cap-switch input:checked + i::after { transform: translateX(14px); }
|
||||
#app.site-studio-active .cap-switch input:focus-visible + i { outline: 2px solid var(--uwa-olive); outline-offset: 4px; }
|
||||
#app.site-studio-active .cap-switch:has(input:disabled) { opacity: .5; cursor: wait; }
|
||||
#app.site-studio-active .cap-switch input:disabled { cursor: wait; }
|
||||
#app.site-studio-active .cap-facts { margin: 13px 0 15px 46px; font-size: 11px; color: var(--uwa-muted); line-height: 1.7; }
|
||||
#app.site-studio-active .cap-facts i { opacity: .5; font-style: normal; padding: 0 7px; }
|
||||
#app.site-studio-active .cap-warning { margin: 13px 0 14px; padding: 9px 12px; border-left: 2px solid var(--uwa-ochre); border-radius: 0 5px 5px 0; background: color-mix(in srgb, var(--uwa-ochre) 8%, var(--uwa-paper-strong)); color: var(--uwa-ink); font-size: 11px; line-height: 1.8; }
|
||||
#app.site-studio-active .cap-card > .cap-warning { margin-left: 46px; }
|
||||
#app.site-studio-active :is(.cap-settings, .cap-technical, .cap-troubleshoot) { min-width: 0; }
|
||||
#app.site-studio-active .cap-settings { margin-top: 16px; border-top: 1px solid var(--uwa-line-soft); }
|
||||
#app.site-studio-active :is(.cap-settings, .cap-technical, .cap-troubleshoot) > summary { display: flex; align-items: center; gap: 12px; padding: 13px 0; list-style: none; cursor: pointer; color: var(--uwa-ink); user-select: none; }
|
||||
#app.site-studio-active :is(.cap-settings, .cap-technical, .cap-troubleshoot) > summary::-webkit-details-marker { display: none; }
|
||||
#app.site-studio-active :is(.cap-settings, .cap-technical, .cap-troubleshoot) > summary > span:first-child { flex: 1; min-width: 0; }
|
||||
#app.site-studio-active :is(.cap-settings, .cap-technical, .cap-troubleshoot) > summary strong { display: block; font-size: 12px; font-weight: 500; line-height: 1.5; }
|
||||
#app.site-studio-active :is(.cap-settings, .cap-technical, .cap-troubleshoot) > summary small { display: block; margin-top: 5px; color: var(--uwa-muted); font-size: 10px; line-height: 1.8; }
|
||||
#app.site-studio-active .cap-card > .cap-settings:not([open]) > summary small { display: none; }
|
||||
#app.site-studio-active .cap-settings > summary strong { color: var(--uwa-olive-dark); }
|
||||
#app.site-studio-active :is(.cap-settings, .cap-technical, .cap-troubleshoot) > summary:hover strong { text-decoration: underline; text-underline-offset: 3px; }
|
||||
#app.site-studio-active .cap-chevron { display: flex; margin-left: auto; color: var(--uwa-muted-soft); }
|
||||
#app.site-studio-active .cap-chevron svg { width: 13px; height: 13px; transition: transform .15s; }
|
||||
#app.site-studio-active details[open] > summary > .cap-chevron svg { transform: rotate(180deg); }
|
||||
#app.site-studio-active .cap-settings-body { display: flex; flex-direction: column; gap: 15px; padding: 5px 0 20px; min-width: 0; }
|
||||
#app.site-studio-active .cap-settings-body > * { margin-top: 0 !important; margin-bottom: 0 !important; }
|
||||
#app.site-studio-active .cap-settings-body label { font-size: 12px; }
|
||||
#app.site-studio-active .cap-settings-body p, #app.site-studio-active .cap-settings-body label > span.block { font-size: 11px; line-height: 1.85; }
|
||||
#app.site-studio-active .cap-settings-body .cap-inline-help { color: var(--uwa-muted); font-size: 11px; line-height: 1.8; }
|
||||
#app.site-studio-active .cap-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; min-width: 0; align-items: start; }
|
||||
#app.site-studio-active .cap-form-grid > :only-child { grid-column: 1 / -1; }
|
||||
#app.site-studio-active .cap-form-grid input { max-width: 100%; min-width: 0; }
|
||||
#app.site-studio-active .cap-settings-body :is(input, select, textarea):not([type=checkbox]) { min-width: 0; max-width: 100%; font-size: 12px !important; }
|
||||
#app.site-studio-active .cap-technical { padding: 0 14px; border: 1px solid var(--uwa-line-soft); border-radius: 8px; background: color-mix(in srgb, var(--uwa-paper-soft) 50%, var(--uwa-paper-strong)); }
|
||||
#app.site-studio-active .cap-technical > summary strong { font-size: 11px; }
|
||||
#app.site-studio-active .cap-troubleshoot { padding: 0 17px; border: 1px dashed var(--uwa-line); border-radius: 9px; background: transparent; }
|
||||
#app.site-studio-active .cap-troubleshoot > summary { padding-top: 16px; padding-bottom: 16px; }
|
||||
#app.site-studio-active .cap-summary-value { padding: 3px 7px; white-space: nowrap; color: var(--uwa-muted); background: var(--uwa-paper-soft); border-radius: 5px; font-size: 10px; }
|
||||
#app.site-studio-active .cap-settings-body .bg-blue-50\/70,
|
||||
#app.site-studio-active .cap-settings-body .bg-blue-50\/40 { background: var(--uwa-paper-soft) !important; border-color: var(--uwa-line) !important; }
|
||||
#app.site-studio-active .cap-panel .cap-legacy-header { display: none; }
|
||||
#app.site-studio-active .cap-padding-panel > div:first-child { display: none; }
|
||||
#app.site-studio-active .cap-padding-panel .cap-troubleshoot { margin-top: 0; }
|
||||
#app.site-studio-active .cap-media-panel > div:first-child > div:first-child > span { display: none; }
|
||||
#app.site-studio-active .cap-media-panel > div:first-child > div:last-child button { font-size: 11px; }
|
||||
#app.site-studio-active .cap-media-panel > div:last-child > div:first-child { margin: 0; }
|
||||
#app.site-studio-active .cap-media-panel .cap-settings-body .mt-4.grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
|
||||
#app.site-studio-active .cap-media-panel .cap-form-grid > div { min-width: 0; }
|
||||
#app.site-studio-active .cap-media-panel > div:last-child > .bg-gray-50 { display: none; }
|
||||
#app.site-studio-active .cap-response-explainer { display: flex; gap: 14px; padding: 18px; border: 1px solid var(--uwa-line); border-radius: 10px; background: var(--uwa-paper-strong); }
|
||||
#app.site-studio-active .cap-response-explainer > div { min-width: 0; }
|
||||
#app.site-studio-active .cap-response-explainer h4 { font-size: 15px; color: var(--uwa-ink-strong); font-weight: 600; }
|
||||
#app.site-studio-active .cap-response-explainer p { margin-top: 8px; font-size: 12px; line-height: 1.8; color: var(--uwa-muted); }
|
||||
#app.site-studio-active .cap-response-explainer small { display: block; margin-top: 10px; font-size: 10px; color: var(--uwa-muted); line-height: 1.8; }
|
||||
@media (max-width: 1250px) {
|
||||
#app.site-studio-active .cap-card-header { flex-wrap: wrap; gap: 10px; }
|
||||
#app.site-studio-active .cap-card-header .cap-switch { margin-left: auto; }
|
||||
#app.site-studio-active .cap-copy { flex-basis: calc(100% - 50px); }
|
||||
#app.site-studio-active .cap-settings-body .md\:grid-cols-3,
|
||||
#app.site-studio-active .cap-settings-body .lg\:grid-cols-4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
|
||||
}
|
||||
@media (max-width: 620px) {
|
||||
#app.site-studio-active .cap-card { padding: 16px 14px 0; }
|
||||
#app.site-studio-active .cap-card h4 { font-size: 15px; }
|
||||
#app.site-studio-active .cap-copy > p { font-size: 12px; }
|
||||
#app.site-studio-active .cap-copy { flex-basis: calc(100% - 48px); }
|
||||
#app.site-studio-active .cap-card-header .cap-switch { margin-top: -2px; }
|
||||
#app.site-studio-active .cap-facts { margin-left: 0; font-size: 10px; }
|
||||
#app.site-studio-active .cap-facts i { padding: 0 3px; }
|
||||
#app.site-studio-active .cap-card > .cap-warning { margin-left: 0; }
|
||||
#app.site-studio-active .cap-settings-body { gap: 14px; }
|
||||
#app.site-studio-active .cap-form-grid,
|
||||
#app.site-studio-active .cap-settings-body .grid { grid-template-columns: minmax(0,1fr) !important; }
|
||||
#app.site-studio-active .cap-technical { padding: 0 10px; }
|
||||
#app.site-studio-active .cap-troubleshoot { padding: 0 13px; }
|
||||
#app.site-studio-active .cap-troubleshoot > summary { flex-wrap: wrap; gap: 7px; }
|
||||
#app.site-studio-active .cap-troubleshoot > summary > span:first-child { flex-basis: calc(100% - 30px); }
|
||||
#app.site-studio-active .cap-summary-value { order: 3; }
|
||||
#app.site-studio-active .cap-response-explainer { padding: 15px; gap: 10px; }
|
||||
#app.site-studio-active .cap-response-explainer .cap-icon { display: none; }
|
||||
#app.site-studio-active .cap-media-panel > div:first-child { flex-wrap: wrap; gap: 10px; }
|
||||
}
|
||||
#app.site-studio-active .uwa-config-editor .cap-input-panel > div:first-child { display: none; }
|
||||
#app.site-studio-active .cap-input-panel > div:last-child > .cap-card:first-child { margin-top: 0 !important; }
|
||||
#app.site-studio-active .cap-panel select:disabled { opacity: .55; cursor: not-allowed; }
|
||||
#app.site-studio-active .uwa-config-editor .cap-response-panel > div:first-child { display: none; }
|
||||
#app.site-studio-active .cap-response-explainer > div { flex: 1; }
|
||||
#app.site-studio-active .cap-response-panel .dashboard-guide-toggle { font-size: 11px; color: var(--uwa-muted); background: transparent; border: 0; padding: 0; }
|
||||
@media (max-width: 1050px) {
|
||||
#app.site-studio-active .cap-response-explainer { flex-wrap: wrap; }
|
||||
#app.site-studio-active .cap-response-explainer > div { flex-basis: calc(100% - 60px); }
|
||||
#app.site-studio-active .cap-response-explainer .cap-switch { margin-left: auto; }
|
||||
}
|
||||
#app.site-studio-active .cap-media-panel > div:first-child h3 { font-weight: 400; color: var(--uwa-muted); }
|
||||
|
||||
/* Site / preset / workflow transfers have distinct, explicit scopes. */
|
||||
#app.site-studio-active .preset-more > summary.preset-btn,
|
||||
#app.site-studio-active .site-tools > summary { width:auto; gap:6px; padding:0 11px; white-space:nowrap; }
|
||||
#app.site-studio-active .preset-more-pop { z-index:60; }
|
||||
#app.site-studio-active .transfer-menu .preset-more-pop { width:285px; }
|
||||
#app.site-studio-active .transfer-menu .preset-more-pop button { align-items:flex-start; padding:10px 11px !important; }
|
||||
.transfer-menu-caption { padding:8px 11px; font-size:10px; color:var(--uwa-muted); overflow-wrap:anywhere; border-bottom:1px solid var(--uwa-line); }
|
||||
.transfer-menu small { display:block; font-size:10px; color:var(--uwa-muted); font-weight:400; margin-top:3px; }
|
||||
.preset-transfer { position:relative; }
|
||||
.transfer-feedback { position:absolute; top:calc(100% + 10px); right:0; width:300px; padding:13px 30px 13px 14px; background:var(--uwa-paper-strong); border:1px solid var(--uwa-line); border-radius:10px; box-shadow:0 8px 25px #0001; font-size:12px; z-index:65; }
|
||||
.transfer-feedback button { position:absolute; top:7px; right:8px; }
|
||||
#app.site-studio-active .site-tools .preset-more-pop { width:240px; }
|
||||
#app.site-studio-active .site-tools .preset-more-pop button { display:flex; gap:8px; align-items:center; padding:12px; font-size:12px; color:#a8564a; text-align:left; width:100%; }
|
||||
.site-tools .preset-more-pop svg { width:16px; height:16px; }
|
||||
.studio-tip { position:relative; }
|
||||
.studio-tip[data-tip]::after { content:attr(data-tip); position:absolute; bottom:calc(100% + 9px); left:0; width:260px; padding:11px 13px; border-radius:9px; border:1px solid var(--uwa-line); box-shadow:0 8px 24px #0001; background:var(--uwa-paper-strong); color:var(--uwa-ink); font:400 11px/1.7 system-ui; text-align:left; white-space:normal; opacity:0; visibility:hidden; transform:translateY(4px); transition:opacity .15s,transform .15s; z-index:80; pointer-events:none; }
|
||||
.studio-tip:hover::after,.studio-tip:focus-visible::after { opacity:1; visibility:visible; transform:none; }
|
||||
.config-preset-label.studio-tip { cursor:help; text-decoration:underline dotted; text-underline-offset:4px; }
|
||||
.preset-transfer-overlay { --transfer-paper:#fffdf8; --transfer-soft:#f7f3ea; --transfer-ink:#33402c; --transfer-muted:#777b6c; --transfer-line:#dddccd; --transfer-accent:#5d6b4d; position:fixed; inset:0; z-index:1000; background:#20251c66; backdrop-filter:blur(5px); display:flex; align-items:center; justify-content:center; padding:24px; }
|
||||
.dark .preset-transfer-overlay { --transfer-paper:#242a23; --transfer-soft:#1e241e; --transfer-ink:#e0e5d7; --transfer-muted:#a4ae9a; --transfer-line:#424b3a; --transfer-accent:#aabb8b; }
|
||||
.preset-transfer-dialog { color:var(--transfer-ink); background:var(--transfer-paper); width:560px; max-width:100%; max-height:90dvh; display:flex; flex-direction:column; border:1px solid var(--transfer-line); border-radius:18px; box-shadow:0 24px 80px #0003; font:13px/1.6 system-ui,sans-serif; overflow:hidden; }
|
||||
.preset-transfer-dialog header { display:flex; justify-content:space-between; align-items:flex-start; padding:24px 26px 18px; border-bottom:1px solid var(--transfer-line); }
|
||||
.transfer-kicker { color:var(--transfer-muted); font-size:10px; letter-spacing:1px; }
|
||||
.preset-transfer-dialog h3 { margin:5px 0; font-size:21px; font-weight:600; }
|
||||
.preset-transfer-dialog header p { margin:0; font-size:12px; color:var(--transfer-muted); overflow-wrap:anywhere; }
|
||||
.preset-transfer-dialog button { font:inherit; cursor:pointer; border:1px solid var(--transfer-line); border-radius:8px; padding:7px 12px; background:var(--transfer-paper); color:var(--transfer-ink); }
|
||||
.preset-transfer-dialog button:disabled { opacity:.45; cursor:not-allowed; }
|
||||
.preset-transfer-dialog button:focus-visible,.preset-transfer-dialog input:focus-visible,.preset-transfer-dialog select:focus-visible { outline:2px solid var(--transfer-accent); outline-offset:3px; }
|
||||
.preset-transfer-dialog header button { background:none; border:0; font-size:23px; padding:0 3px; }
|
||||
.transfer-body { padding:22px 26px; overflow:auto; }
|
||||
.preset-transfer-dialog .transfer-file { width:100%; border:1px dashed var(--transfer-line); padding:24px 15px; display:flex; align-items:center; flex-direction:column; gap:5px; background:var(--transfer-soft); }
|
||||
.transfer-file svg { width:25px; height:25px; margin-bottom:5px; color:var(--transfer-accent); }
|
||||
.transfer-file small { color:var(--transfer-muted); font-size:10px; }
|
||||
.transfer-file strong { overflow-wrap:anywhere; max-width:100%; }
|
||||
.transfer-body label { display:block; margin-top:17px; font-size:12px; }
|
||||
.transfer-body label > input:not([type=checkbox]),.transfer-body select { display:block; width:100%; margin-top:6px; padding:10px 12px; background:var(--transfer-soft); border:1px solid var(--transfer-line); border-radius:8px; color:var(--transfer-ink); font:inherit; }
|
||||
.transfer-note { font-size:11px; color:var(--transfer-muted); margin:12px 0 0; }
|
||||
.transfer-error { color:#b26048; font-size:12px; margin-top:14px; }
|
||||
.transfer-preview { border:1px solid var(--transfer-line); border-radius:10px; margin-top:16px; padding:12px 14px; max-height:190px; overflow:auto; }
|
||||
.transfer-preview strong { font-size:12px; display:block; margin-bottom:8px; }
|
||||
.transfer-preview > div { display:flex; gap:10px; justify-content:space-between; padding:6px 0; border-top:1px solid var(--transfer-line); font-size:12px; }
|
||||
.transfer-preview small { flex-shrink:0; color:var(--transfer-muted); }
|
||||
.transfer-body .transfer-check { display:flex; align-items:center; gap:8px; }
|
||||
.transfer-check input { accent-color:var(--transfer-accent); }
|
||||
.preset-transfer-dialog footer { padding:17px 26px; border-top:1px solid var(--transfer-line); display:flex; gap:8px; align-items:center; }
|
||||
.preset-transfer-dialog footer > span { margin-right:auto; font-size:10px; color:var(--transfer-muted); }
|
||||
.preset-transfer-dialog .transfer-primary { background:var(--transfer-accent); color:var(--transfer-paper); border-color:var(--transfer-accent); }
|
||||
@media(max-width:620px) {
|
||||
.preset-transfer-overlay { padding:12px; }
|
||||
.preset-transfer-dialog header,.transfer-body { padding:18px; }
|
||||
.preset-transfer-dialog footer { padding:14px 18px; flex-wrap:wrap; justify-content:flex-end; }
|
||||
.preset-transfer-dialog footer > span { flex-basis:100%; }
|
||||
.transfer-feedback { width:250px; right:auto; left:-80px; }
|
||||
#app.site-studio-active .transfer-menu .preset-more-pop { width:min(285px,80vw); left:-95px; right:auto; }
|
||||
}
|
||||
|
||||
#app.site-studio-active .site-discovery-note { margin: -4px 0 18px; color: var(--uwa-muted); font-size: 11px; line-height: 1.7; }
|
||||
@@ -0,0 +1,2 @@
|
||||
*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }
|
||||
/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:rgb(var(--twc-gray-200)/1)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:rgb(var(--twc-gray-400)/1)}input::placeholder,textarea::placeholder{opacity:1;color:rgb(var(--twc-gray-400)/1)}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.-bottom-1{bottom:-.25rem}.-top-1{top:-.25rem}.bottom-0{bottom:0}.left-0{left:0}.left-3{left:.75rem}.right-0{right:0}.right-3{right:.75rem}.right-3\.5{right:.875rem}.top-0{top:0}.top-3\.5{top:.875rem}.top-full{top:100%}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-3{grid-column:span 3/span 3}.col-span-4{grid-column:span 4/span 4}.col-span-6{grid-column:span 6/span 6}.col-span-full{grid-column:1/-1}.-m-2{margin:-.5rem}.mx-1{margin-left:.25rem;margin-right:.25rem}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.-ml-0\.5{margin-left:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-3{margin-left:.75rem}.ml-4{margin-left:1rem}.mr-1{margin-right:.25rem}.mr-2{margin-right:.5rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-3\.5{margin-top:.875rem}.mt-4{margin-top:1rem}.mt-5{margin-top:1.25rem}.mt-6{margin-top:1.5rem}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.\!grid{display:grid!important}.grid{display:grid}.hidden{display:none}.h-1{height:.25rem}.h-1\.5{height:.375rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-2{height:.5rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-Line truncated
|
||||
@@ -0,0 +1,4 @@
|
||||
/* R2-8:预编译 Tailwind 的入口(生成 static/css/tailwind.css),与原运行时一样包含基础样式(preflight) */
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,701 @@
|
||||
:host {
|
||||
display: block;
|
||||
color: var(--uwa-ink, #33402c);
|
||||
font:
|
||||
13px/1.5 system-ui,
|
||||
-apple-system,
|
||||
"Segoe UI",
|
||||
sans-serif;
|
||||
--ws-paper: var(--uwa-paper, #f7f3ea);
|
||||
--ws-card: var(--uwa-paper-strong, #fffdf8);
|
||||
--ws-ink: var(--uwa-ink, #33402c);
|
||||
--ws-muted: var(--uwa-muted, #777b6c);
|
||||
--ws-line: var(--uwa-line, #dddccd);
|
||||
--ws-accent: var(--uwa-olive, #5d6b4d);
|
||||
}
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
button,
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
button {
|
||||
cursor: pointer;
|
||||
}
|
||||
button:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
button:focus-visible,
|
||||
input:focus-visible,
|
||||
textarea:focus-visible,
|
||||
select:focus-visible {
|
||||
outline: 2px solid var(--ws-accent);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
button {
|
||||
border: 1px solid var(--ws-line);
|
||||
border-radius: 7px;
|
||||
background: var(--ws-card);
|
||||
padding: 6px 10px;
|
||||
}
|
||||
button:hover:not(:disabled) {
|
||||
border-color: var(--ws-accent);
|
||||
}
|
||||
.studio {
|
||||
border: 1px solid var(--ws-line);
|
||||
border-radius: 14px;
|
||||
background: var(--ws-paper);
|
||||
overflow: hidden;
|
||||
}
|
||||
.head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
padding: 20px 22px;
|
||||
border-bottom: 1px solid var(--ws-line);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.eyebrow {
|
||||
font-size: 10px;
|
||||
letter-spacing: 2px;
|
||||
color: var(--ws-muted);
|
||||
font-weight: 700;
|
||||
}
|
||||
.head h2 {
|
||||
font-size: 21px;
|
||||
margin: 3px 0;
|
||||
font-weight: 650;
|
||||
letter-spacing: -0.6px;
|
||||
}
|
||||
.head p {
|
||||
margin: 4px 0 0;
|
||||
color: var(--ws-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.primary {
|
||||
background: var(--ws-accent);
|
||||
color: var(--ws-card);
|
||||
border-color: var(--ws-accent);
|
||||
}
|
||||
.tabs {
|
||||
display: flex;
|
||||
gap: 7px;
|
||||
padding: 10px 20px;
|
||||
border-bottom: 1px solid var(--ws-line);
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.tabs button {
|
||||
background: none;
|
||||
border-color: transparent;
|
||||
}
|
||||
.tabs button.active {
|
||||
background: var(--ws-card);
|
||||
border-color: var(--ws-line);
|
||||
font-weight: 650;
|
||||
}
|
||||
.counter {
|
||||
margin-left: auto;
|
||||
color: var(--ws-muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
.workspace {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 290px;
|
||||
min-height: 480px;
|
||||
}
|
||||
.canvas {
|
||||
overflow: auto;
|
||||
padding: 26px 24px;
|
||||
max-height: 720px;
|
||||
background-image: radial-gradient(var(--ws-line) 0.7px, transparent 0.7px);
|
||||
background-size: 16px 16px;
|
||||
}
|
||||
.sequence {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
position: relative;
|
||||
min-width: 160px;
|
||||
gap: 0;
|
||||
max-width: 900px;
|
||||
margin: auto;
|
||||
}
|
||||
.sequence.root {
|
||||
min-width: 250px;
|
||||
}
|
||||
.unit {
|
||||
position: relative;
|
||||
margin: 0 0 20px;
|
||||
z-index: 1;
|
||||
}
|
||||
.node {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 11px;
|
||||
text-align: left;
|
||||
background: var(--ws-card);
|
||||
padding: 12px 13px;
|
||||
border: 1px solid var(--ws-line);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 3px #00000003;
|
||||
position: relative;
|
||||
}
|
||||
.node.selected {
|
||||
border-color: var(--ws-accent);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ws-accent) 15%, transparent);
|
||||
}
|
||||
.node.control {
|
||||
border-left: 3px solid var(--ws-accent);
|
||||
}
|
||||
.node.failed {
|
||||
border-color: #b3634d;
|
||||
}
|
||||
.node.completed,
|
||||
.node.captured,
|
||||
.node.assigned {
|
||||
border-right: 3px solid var(--ws-accent);
|
||||
}
|
||||
.symbol {
|
||||
flex-shrink: 0;
|
||||
width: 29px;
|
||||
height: 29px;
|
||||
background: var(--ws-paper);
|
||||
border-radius: 8px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-size: 16px;
|
||||
color: var(--ws-accent);
|
||||
}
|
||||
.node-info {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
.node-name {
|
||||
font-size: 12px;
|
||||
font-weight: 650;
|
||||
display: block;
|
||||
}
|
||||
.node-description {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
color: var(--ws-muted);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 360px;
|
||||
}
|
||||
.node-code {
|
||||
font-size: 9px;
|
||||
font-family: monospace;
|
||||
color: var(--ws-muted);
|
||||
align-self: flex-start;
|
||||
}
|
||||
.inspector {
|
||||
border-left: 1px solid var(--ws-line);
|
||||
background: var(--ws-card);
|
||||
padding: 20px;
|
||||
overflow: auto;
|
||||
max-height: 720px;
|
||||
}
|
||||
.inspector h3 {
|
||||
font-size: 15px;
|
||||
margin: 5px 0 10px;
|
||||
}
|
||||
.hint {
|
||||
color: var(--ws-muted);
|
||||
font-size: 11px;
|
||||
line-height: 1.8;
|
||||
margin: 8px 0 17px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.field {
|
||||
display: block;
|
||||
margin: 12px 0;
|
||||
font-size: 11px;
|
||||
font-weight: 550;
|
||||
}
|
||||
.field > span {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.field input,
|
||||
.field select,
|
||||
.field textarea {
|
||||
width: 100%;
|
||||
background: var(--ws-paper);
|
||||
border: 1px solid var(--ws-line);
|
||||
border-radius: 6px;
|
||||
padding: 8px;
|
||||
min-height: 34px;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
.field textarea {
|
||||
resize: vertical;
|
||||
min-height: 72px;
|
||||
font-family: ui-monospace, monospace;
|
||||
}
|
||||
.field input[type="checkbox"] {
|
||||
width: auto;
|
||||
min-height: 0;
|
||||
vertical-align: middle;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.pair {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
}
|
||||
.danger {
|
||||
color: #a55d43;
|
||||
}
|
||||
.divider {
|
||||
border: 0;
|
||||
border-top: 1px solid var(--ws-line);
|
||||
margin: 20px 0;
|
||||
}
|
||||
.inspector details {
|
||||
margin: 15px 0;
|
||||
}
|
||||
.inspector summary {
|
||||
font-size: 11px;
|
||||
cursor: pointer;
|
||||
color: var(--ws-muted);
|
||||
}
|
||||
.panel {
|
||||
padding: 24px;
|
||||
min-height: 480px;
|
||||
}
|
||||
.panel h3 {
|
||||
font-size: 16px;
|
||||
margin: 0 0 6px;
|
||||
}
|
||||
.empty {
|
||||
padding: 35px 10px;
|
||||
text-align: center;
|
||||
color: var(--ws-muted);
|
||||
}
|
||||
.palette {
|
||||
padding: 20px;
|
||||
background: var(--ws-card);
|
||||
border-bottom: 1px solid var(--ws-line);
|
||||
}
|
||||
.palette-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.palette button {
|
||||
text-align: left;
|
||||
padding: 10px;
|
||||
}
|
||||
.palette small {
|
||||
display: block;
|
||||
color: var(--ws-muted);
|
||||
font-size: 10px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.palette h4 {
|
||||
margin: 8px 0;
|
||||
font-size: 11px;
|
||||
color: var(--ws-muted);
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
.banner {
|
||||
padding: 9px 20px;
|
||||
font-size: 12px;
|
||||
border-bottom: 1px solid var(--ws-line);
|
||||
background: var(--ws-card);
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.banner.error {
|
||||
color: #a55d43;
|
||||
}
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 12px;
|
||||
}
|
||||
.table th,
|
||||
.table td {
|
||||
text-align: left;
|
||||
padding: 12px 10px;
|
||||
border-bottom: 1px solid var(--ws-line);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.table th {
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
color: var(--ws-muted);
|
||||
}
|
||||
code {
|
||||
font:
|
||||
11px ui-monospace,
|
||||
monospace;
|
||||
}
|
||||
.test-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 18px;
|
||||
max-width: 720px;
|
||||
}
|
||||
.trace {
|
||||
margin-top: 20px;
|
||||
max-height: 380px;
|
||||
overflow: auto;
|
||||
}
|
||||
.trace button {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
gap: 12px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--ws-line);
|
||||
border-radius: 0;
|
||||
padding: 9px;
|
||||
}
|
||||
.trace .status {
|
||||
margin-left: auto;
|
||||
color: var(--ws-accent);
|
||||
}
|
||||
.maprow {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 14px 1fr 28px;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
margin: 5px 0;
|
||||
}
|
||||
.maprow input {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
background: var(--ws-paper);
|
||||
border: 1px solid var(--ws-line);
|
||||
border-radius: 5px;
|
||||
padding: 6px;
|
||||
font-size: 11px;
|
||||
}
|
||||
.maprow button {
|
||||
padding: 4px;
|
||||
}
|
||||
.footer {
|
||||
padding: 10px 20px;
|
||||
border-top: 1px solid var(--ws-line);
|
||||
font-size: 10px;
|
||||
color: var(--ws-muted);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
.row-actions {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
@media (max-width: 850px) {
|
||||
.workspace {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.inspector {
|
||||
border-left: 0;
|
||||
border-top: 1px solid var(--ws-line);
|
||||
max-height: 500px;
|
||||
}
|
||||
.canvas {
|
||||
max-height: 560px;
|
||||
}
|
||||
.head {
|
||||
padding: 17px;
|
||||
}
|
||||
.test-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.counter {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:host([data-auto-dark]) {
|
||||
--ws-paper: #252b24;
|
||||
--ws-card: #30372d;
|
||||
--ws-ink: #e0e3d5;
|
||||
--ws-muted: #adb59e;
|
||||
--ws-line: #495241;
|
||||
--ws-accent: #a2b288;
|
||||
color: var(--ws-ink);
|
||||
}
|
||||
}
|
||||
:host([data-dark]) {
|
||||
--ws-paper: #252b24;
|
||||
--ws-card: #30372d;
|
||||
--ws-ink: #e0e3d5;
|
||||
--ws-muted: #adb59e;
|
||||
--ws-line: #495241;
|
||||
--ws-accent: #a2b288;
|
||||
color: var(--ws-ink);
|
||||
}
|
||||
|
||||
/* The injected canvas is movable; dashboard instances keep normal header behavior. */
|
||||
:host([data-draggable]) .head { cursor: grab; touch-action: none; user-select: none; }
|
||||
:host([data-draggable]) .head .eyebrow::after { content: ' · 拖动标题移动'; letter-spacing: 0; }
|
||||
|
||||
/* A quiet canvas first; settings appear only for the selected step. */
|
||||
.head { padding: 10px 18px; justify-content: flex-end; }
|
||||
.drag-handle { margin-right:auto; color:var(--ws-muted); font-size:11px; user-select:none; }
|
||||
.workspace { position:relative; grid-template-columns:minmax(0,1fr) 0px; transition:grid-template-columns .32s cubic-bezier(.22,.8,.3,1); }
|
||||
.workspace.is-inspecting { grid-template-columns:minmax(0,1fr) 290px; }
|
||||
.inspector-slot { min-width:0; overflow:hidden; position:relative; opacity:0; transform:translateX(18px); transition:opacity .24s ease,transform .32s ease; pointer-events:none; }
|
||||
.is-inspecting .inspector-slot { opacity:1; transform:translateX(0); pointer-events:auto; }
|
||||
.inspector { position:absolute; inset:0; width:290px; height:100%; padding:16px 20px; }
|
||||
.inspector-close { display:block; margin:0 0 18px auto; font-size:11px; color:var(--ws-muted); background:transparent; }
|
||||
@media (max-width:850px) {
|
||||
.workspace,.workspace.is-inspecting { grid-template-columns:minmax(0,1fr) 0px; }
|
||||
.inspector-slot { position:absolute; right:0; top:0; bottom:0; width:min(310px,100%); z-index:8; transform:translateX(100%); box-shadow:-12px 0 35px #00000012; }
|
||||
.inspector { width:100%; max-height:100%; border-top:0; border-left:1px solid var(--ws-line); }
|
||||
.head { padding:10px 12px; }
|
||||
.canvas { padding:24px 16px; }
|
||||
}
|
||||
@media (prefers-reduced-motion:reduce) { .workspace,.inspector-slot { transition:none; } }
|
||||
|
||||
/* Reading-first workflow: collapsible stages, vertically ordered alternatives. */
|
||||
[hidden] { display:none !important; }
|
||||
:host { color-scheme:light; }
|
||||
:host([data-dark]) { color-scheme:dark; }
|
||||
.canvas,.inspector,.panel { scrollbar-width:thin; scrollbar-color:var(--ws-line) transparent; }
|
||||
.node-row { position:relative; }
|
||||
.node-info { min-width:0; }
|
||||
.node-name { line-height:1.65; overflow-wrap:anywhere; }
|
||||
.node-description { max-width:none; line-height:1.65; font-size:11px; }
|
||||
.flow-view-tools { display:flex; align-items:center; justify-content:space-between; gap:10px; font-size:10px; color:var(--ws-muted); margin:-10px 0 24px; }
|
||||
.flow-view-tools > div { display:flex; gap:5px; }
|
||||
.flow-view-tools button { font-size:10px; padding:4px 8px; background:var(--ws-paper); }
|
||||
.note-card .node { align-items:flex-start; border-left:3px solid var(--ws-accent); }
|
||||
.note-card .node-description { white-space:pre-wrap; overflow:visible; text-overflow:clip; margin-top:5px; }
|
||||
.note-card .symbol { font-size:15px; }
|
||||
.note-card.tone-warning .node { border-left-color:#b19048; }
|
||||
.note-card.tone-danger .node { border-left-color:#ba755d; }
|
||||
.note-card.tone-success .node { border-left-color:#79915b; }
|
||||
.case-editor { margin:14px 0; padding:12px 10px; border:1px solid var(--ws-line); border-radius:9px; background:var(--ws-paper); }
|
||||
.case-heading { display:flex; align-items:center; justify-content:space-between; gap:4px; font-size:11px; }
|
||||
.case-heading button { padding:3px 5px; font-size:10px; }
|
||||
.panel { max-height:800px; overflow:auto; }
|
||||
.panel-intro { margin-bottom:22px; }
|
||||
.panel-intro h3 { font-size:20px; margin:6px 0 8px; }
|
||||
.panel-kicker { color:var(--ws-muted); font-size:10px; letter-spacing:1px; }
|
||||
.param-section { margin:20px 0; padding-top:18px; border-top:1px solid var(--ws-line); }
|
||||
.param-section h4,.run-option h4,.trace-section h4 { font-size:14px; margin:0 0 6px; }
|
||||
.section-heading { display:flex; align-items:flex-start; gap:12px; margin-bottom:12px; }
|
||||
.section-heading > div { flex:1; }
|
||||
.section-heading p { color:var(--ws-muted); font-size:11px; margin:4px 0; }
|
||||
.section-heading > button { font-size:10px; }
|
||||
.section-number { color:var(--ws-accent); background:var(--ws-card); border:1px solid var(--ws-line); width:28px; height:28px; display:grid; place-items:center; border-radius:8px; font-size:10px; flex-shrink:0; }
|
||||
.param-card { display:flex; align-items:center; gap:14px; padding:14px; background:var(--ws-card); border:1px solid var(--ws-line); border-radius:9px; margin:8px 0; }
|
||||
.param-label { flex:1; min-width:0; }
|
||||
.param-label strong,.param-label code,.param-label small { display:block; }
|
||||
.param-label strong { font-size:12px; }
|
||||
.param-label code { font-size:10px; color:var(--ws-muted); margin:3px 0; overflow-wrap:anywhere; }
|
||||
.param-label small { font-size:10px; color:var(--ws-muted); overflow-wrap:anywhere; }
|
||||
.param-card > button { font-size:10px; flex-shrink:0; }
|
||||
.param-value { width:40%; min-width:100px; }
|
||||
.param-value input:not([type=checkbox]),.param-value textarea,.sample-field input,.sample-field textarea,.sample-field > select,.sample-add input { display:block; width:100%; min-width:0; background:var(--ws-paper); border:1px solid var(--ws-line); border-radius:7px; padding:8px 10px; font:12px system-ui; color:var(--ws-ink); }
|
||||
.param-value textarea { min-height:75px; resize:vertical; }
|
||||
.param-boolean { display:flex; align-items:center; gap:8px; font-size:12px; }
|
||||
input[type=checkbox] { accent-color:var(--ws-accent); }
|
||||
.value-badge { background:var(--ws-paper); border:1px solid var(--ws-line); border-radius:20px; padding:4px 9px; font-size:10px; color:var(--ws-muted); white-space:nowrap; }
|
||||
.context-cards,.run-options { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
|
||||
.context-cards > div,.run-option { border:1px solid var(--ws-line); padding:16px; border-radius:10px; background:var(--ws-card); }
|
||||
.context-cards strong,.context-cards code { display:block; }
|
||||
.context-cards p,.run-option p { font-size:11px; line-height:1.8; color:var(--ws-muted); margin:8px 0 0; }
|
||||
.context-cards code { margin-top:6px; color:var(--ws-muted); }
|
||||
.technical { margin:15px 0; border-top:1px solid var(--ws-line); padding-top:12px; }
|
||||
.technical summary { font-size:11px; color:var(--ws-muted); cursor:pointer; }
|
||||
.technical pre { white-space:pre-wrap; overflow-wrap:anywhere; font-size:10px; max-height:260px; overflow:auto; }
|
||||
.section-empty { color:var(--ws-muted); font-size:11px; padding:12px 0; }
|
||||
.run-option.chosen { border-color:var(--ws-accent); }
|
||||
.run-option h4 { margin-top:12px; }
|
||||
.run-option button { margin-top:12px; font-size:11px; }
|
||||
.sample-field { padding:12px 14px; border:1px solid var(--ws-line); background:var(--ws-card); border-radius:9px; margin:8px 0; }
|
||||
.sample-label { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:8px; }
|
||||
.sample-label strong { font-size:12px; }
|
||||
.sample-label code { font-size:10px; color:var(--ws-muted); }
|
||||
.sample-label > select { margin-left:auto; font-size:10px; border:0; background:var(--ws-paper); padding:3px; border-radius:4px; }
|
||||
.sample-add { display:flex; gap:8px; margin:12px 0; }
|
||||
.sample-add button { white-space:nowrap; font-size:11px; }
|
||||
.sample-warning { color:#b0774b; font-size:11px; }
|
||||
.run-actions { display:flex; align-items:center; gap:14px; margin:22px 0; }
|
||||
.run-actions > span { font-size:11px; color:var(--ws-muted); }
|
||||
.trace-section { border-top:1px solid var(--ws-line); padding-top:20px; }
|
||||
.trace { margin-top:10px; }
|
||||
.trace button { align-items:flex-start; border:1px solid var(--ws-line); border-radius:8px; margin:6px 0; padding:12px; }
|
||||
.trace-index { width:23px; font-size:10px; color:var(--ws-muted); }
|
||||
.trace-copy { min-width:0; flex:1; }
|
||||
.trace-copy strong { display:block; font-size:12px; }
|
||||
.trace-copy small { display:block; font-size:11px; line-height:1.7; color:var(--ws-muted); margin-top:4px; }
|
||||
.trace .status { font-size:10px; }
|
||||
@media(max-width:850px) {
|
||||
.node-code { display:none; }
|
||||
.param-card { flex-wrap:wrap; gap:10px; }
|
||||
.param-value { flex-basis:100%; order:3; }
|
||||
.context-cards,.run-options,.test-grid { grid-template-columns:1fr; }
|
||||
.panel { padding:18px 14px; }
|
||||
.flow-view-tools { flex-wrap:wrap; }
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
Tree canvas: every list is a rail, every step hangs off it with an
|
||||
elbow connector. Children start under their parent's symbol, branch
|
||||
lanes are colour-coded (✓ then / ✗ else / ! fallback) so the flow
|
||||
reads like a real tree instead of a flat stack of cards.
|
||||
------------------------------------------------------------------ */
|
||||
:host {
|
||||
--ws-rail: color-mix(in srgb, var(--ws-muted) 45%, var(--ws-paper));
|
||||
--ws-tint: color-mix(in srgb, var(--ws-accent) 12%, var(--ws-card));
|
||||
--ws-amber: #b08a3c;
|
||||
--ws-danger: #b3634d;
|
||||
--tree-indent: 26px; /* elbow length: rail → card edge */
|
||||
--tree-anchor: 24px; /* card padding-left 11px + symbol 26px / 2 */
|
||||
--tree-elbow: 26px; /* card padding-top 12px + symbol 26px / 2 +1 */
|
||||
--tree-gap: 12px; /* vertical gap between sibling items */
|
||||
--tree-lead: 10px; /* gap between a parent card and its children */
|
||||
}
|
||||
:host([data-dark]) { --ws-rail: color-mix(in srgb, var(--ws-muted) 52%, var(--ws-paper)); --ws-amber: #d4b060; --ws-danger: #d98a72; }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:host([data-auto-dark]) { --ws-rail: color-mix(in srgb, var(--ws-muted) 52%, var(--ws-paper)); --ws-amber: #d4b060; --ws-danger: #d98a72; }
|
||||
}
|
||||
.canvas { background-image: radial-gradient(color-mix(in srgb, var(--ws-line) 80%, transparent) 0.8px, transparent 0.8px); background-size: 18px 18px; }
|
||||
.tree { max-width: 820px; margin: 0 auto; padding: 2px 0 6px; }
|
||||
.sequence, .sequence.root { display: block; position: relative; min-width: 0; max-width: none; margin: 0; padding: 0 0 0 var(--tree-indent); }
|
||||
|
||||
/* Connectors ------------------------------------------------------ */
|
||||
.tree-item { position: relative; min-width: 0; }
|
||||
.tree-item::before, .tree-item::after { content: ""; position: absolute; left: calc(-1 * var(--tree-indent)); box-sizing: border-box; pointer-events: none; }
|
||||
.tree-item::before { top: var(--elbow, var(--tree-elbow)); bottom: 0; width: 2px; background: var(--lane, var(--ws-rail)); }
|
||||
.tree-item::after { top: calc(-1 * var(--lead, 0px)); width: var(--tree-indent); height: calc(var(--elbow, var(--tree-elbow)) + var(--lead, 0px)); border: 0 solid var(--lane, var(--ws-rail)); border-left-width: 2px; border-bottom-width: 2px; border-bottom-left-radius: 10px; }
|
||||
.tree-item:last-child::before { display: none; }
|
||||
.tree-item:has(> .node-row > .node.selected)::after { border-color: var(--ws-accent); }
|
||||
|
||||
/* Start / end of the main trunk */
|
||||
.endpoint.tree-item { --elbow: 11px; display: flex; align-items: center; gap: 10px; width: auto; min-height: 22px; margin: 0; padding: 0 0 10px; border: 0; border-radius: 0; background: none; font-size: 11px; font-weight: 600; letter-spacing: 1px; color: var(--ws-muted); text-align: left; }
|
||||
.endpoint .port { position: absolute; left: calc(-1 * var(--tree-indent) - 4px); top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--ws-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ws-accent) 22%, transparent); }
|
||||
.endpoint.start::after { display: none; }
|
||||
.endpoint.end { margin: 0; padding: 12px 0 0; }
|
||||
.endpoint.end .port { top: 18px; }
|
||||
.endpoint.end::before { display: none; }
|
||||
.endpoint.end::after { top: 0; width: 2px; height: 23px; border: 0; border-radius: 0; background: var(--ws-rail); }
|
||||
|
||||
/* Step cards ------------------------------------------------------ */
|
||||
.unit { margin: 0; padding: 0 0 var(--tree-gap); z-index: auto; }
|
||||
.node-row { position: relative; }
|
||||
.node { align-items: flex-start; gap: 11px; min-height: 0; padding: 12px 12px 11px 11px; border-radius: 11px; box-shadow: 0 1px 2px #0000000a; transition: border-color .15s ease, box-shadow .15s ease; }
|
||||
.node:hover:not(:disabled) { border-color: color-mix(in srgb, var(--ws-accent) 55%, var(--ws-line)); }
|
||||
.node.selected { border-color: var(--ws-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ws-accent) 18%, transparent); }
|
||||
.symbol { position: relative; width: 26px; height: 26px; border-radius: 7px; font-size: 14px; background: var(--ws-tint); color: var(--ws-accent); }
|
||||
.symbol b { position: relative; z-index: 1; font-weight: 500; font-style: normal; }
|
||||
.symbol.diamond { background: transparent; }
|
||||
.symbol.diamond::before, .symbol.diamond::after { content: ""; position: absolute; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
|
||||
.symbol.diamond::before { inset: -4px; background: var(--ws-accent); }
|
||||
.symbol.diamond::after { inset: -2px; background: var(--ws-tint); }
|
||||
.symbol.diamond b { font-weight: 700; font-size: 13px; }
|
||||
.node-info { display: block; min-width: 0; flex: 1; }
|
||||
.node-head { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
|
||||
.node-index { flex-shrink: 0; margin-top: 2px; padding: 2px 5px; border: 1px solid color-mix(in srgb, var(--ws-accent) 35%, transparent); border-radius: 5px; background: var(--ws-tint); color: var(--ws-accent); font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .5px; }
|
||||
.node-name { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 650; line-height: 1.5; overflow-wrap: anywhere; }
|
||||
.node-code { flex-shrink: 0; align-self: flex-start; margin-top: 1px; padding: 1px 8px; border: 1px solid var(--ws-line); border-radius: 20px; font: 10px/1.6 system-ui, sans-serif; color: var(--ws-muted); white-space: nowrap; }
|
||||
.node.control .node-code { border-color: color-mix(in srgb, var(--ws-accent) 40%, transparent); color: var(--ws-accent); }
|
||||
.node-description { display: block; margin-top: 3px; max-width: none; font-size: 11px; line-height: 1.65; color: var(--ws-muted); white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
|
||||
.node.control { border-left: 3px solid var(--ws-accent); }
|
||||
.node.control.selected { border-left-color: var(--ws-accent); }
|
||||
.node.failed { border-color: var(--ws-danger); }
|
||||
|
||||
/* Stages (GROUP / SWITCH / TRY) look like chapter headers */
|
||||
.stage > .node-row > .node { padding-right: 116px; background: color-mix(in srgb, var(--ws-accent) 7%, var(--ws-card)); border-color: color-mix(in srgb, var(--ws-accent) 32%, var(--ws-line)); }
|
||||
.stage > .node-row > .node .symbol { background: var(--ws-accent); color: var(--ws-card); }
|
||||
.stage > .node-row > .node.kind-SWITCH .symbol.diamond { background: transparent; color: var(--ws-accent); }
|
||||
.stage > .node-row > .node .node-name { font-size: 13px; }
|
||||
.stage .node-code { display: none; }
|
||||
.stage-toggle { position: absolute; right: 10px; top: 11px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border: 1px solid color-mix(in srgb, var(--ws-accent) 35%, var(--ws-line)); border-radius: 20px; background: var(--ws-card); color: var(--ws-accent); font-size: 11px; line-height: 1.4; white-space: nowrap; }
|
||||
.stage-toggle .chev { font-size: 12px; line-height: 1; }
|
||||
.stage-toggle:hover { background: var(--ws-tint); }
|
||||
|
||||
/* Notes */
|
||||
.note-card .node { align-items: flex-start; border-left: 3px solid var(--ws-accent); }
|
||||
.note-card .node-description { white-space: pre-wrap; margin-top: 4px; }
|
||||
.note-card .symbol { font-size: 14px; font-weight: 700; }
|
||||
.note-card.tone-warning .node { border-left-color: var(--ws-amber); }
|
||||
.note-card.tone-warning .symbol { background: color-mix(in srgb, var(--ws-amber) 16%, var(--ws-card)); color: var(--ws-amber); }
|
||||
.note-card.tone-danger .node { border-left-color: var(--ws-danger); }
|
||||
.note-card.tone-danger .symbol { background: color-mix(in srgb, var(--ws-danger) 16%, var(--ws-card)); color: var(--ws-danger); }
|
||||
.note-card.tone-success .node { border-left-color: var(--ws-accent); }
|
||||
|
||||
/* Children hang under the parent's symbol ------------------------- */
|
||||
.stage-content { --lane: initial; margin-left: var(--tree-anchor); padding-top: var(--tree-lead); }
|
||||
.branches, .branches.lanes, .branches.plain { display: block; margin: 0; padding: 0 0 0 var(--tree-indent); border: 0; border-radius: 0; background: none; }
|
||||
.branches.plain { padding-left: 0; }
|
||||
.branches.lanes > .tree-item:first-child, .branch.plain > .sequence > .tree-item:first-child { --lead: var(--tree-lead); }
|
||||
.branch { min-width: 0; margin: 0; padding: 0; border: 0; }
|
||||
.branch.plain > .sequence { padding-top: 0; }
|
||||
.branch.tree-item { --elbow: 12px; padding-bottom: var(--tree-gap); }
|
||||
.branch.kind-then, .branch.kind-steps, .branch.kind-case { --pill: var(--ws-accent); }
|
||||
.branch.kind-else, .branch.kind-default { --pill: var(--ws-amber); }
|
||||
.branch.kind-fallback { --pill: var(--ws-danger); }
|
||||
.branch-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-height: 24px; margin: 0; padding: 0; color: var(--ws-muted); font-size: 11px; letter-spacing: 0; text-align: left; justify-content: flex-start; }
|
||||
.branch-name .port { display: inline-grid; place-items: center; flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--pill); color: var(--ws-card); font: 700 11px/1 system-ui, sans-serif; font-style: normal; }
|
||||
.branch-name > span { padding: 3px 10px; border: 1px solid color-mix(in srgb, var(--pill) 55%, transparent); border-radius: 20px; background: color-mix(in srgb, var(--pill) 10%, var(--ws-card)); color: var(--pill); font-size: 11px; font-weight: 650; line-height: 1.4; }
|
||||
.branch-name small { font-size: 10.5px; color: var(--ws-muted); overflow-wrap: anywhere; }
|
||||
.branch.taken .branch-name > span { background: var(--pill); color: var(--ws-card); }
|
||||
.branch.taken .branch-name::after { content: "本次命中"; font-size: 10px; color: var(--pill); }
|
||||
.branch:not(.plain) > .sequence { --lane: color-mix(in srgb, var(--pill) 72%, var(--ws-rail)); margin-left: 10px; padding-top: 6px; }
|
||||
.branch:not(.plain) > .sequence > .tree-item:first-child { --lead: 6px; }
|
||||
.branch.empty { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
|
||||
.empty-route { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0; padding: 0; font-size: 11px; color: var(--ws-muted); }
|
||||
.empty-route .add { padding: 2px 8px; border: 1px dashed color-mix(in srgb, var(--ws-muted) 50%, transparent); border-radius: 20px; background: transparent; font-size: 10.5px; color: var(--ws-muted); }
|
||||
.empty-route .add:hover, .empty-route .add:focus-visible { color: var(--ws-accent); border-color: var(--ws-accent); background: var(--ws-card); }
|
||||
.decision-note.tree-item { --elbow: 10px; margin: 0; padding: 0 0 10px 6px; font-size: 11px; line-height: 20px; color: var(--ws-muted); }
|
||||
.merge.tree-item { --elbow: 10px; width: max-content; max-width: 100%; margin: 0; padding: 0 0 2px 6px; background: none; font-size: 10.5px; line-height: 20px; text-align: left; color: var(--ws-muted); }
|
||||
|
||||
/* Ghost leaf at the end of every list */
|
||||
.add.tree-item { --elbow: 13px; display: flex; align-items: center; width: max-content; max-width: 100%; min-height: 26px; margin: 0; padding: 3px 11px; border: 1px dashed color-mix(in srgb, var(--ws-muted) 50%, transparent); border-radius: 8px; background: transparent; font-size: 11px; color: var(--ws-muted); opacity: 1; z-index: auto; align-self: auto; }
|
||||
.add.tree-item:hover, .add.tree-item:focus-visible { color: var(--ws-accent); border-color: var(--ws-accent); background: var(--ws-card); }
|
||||
|
||||
/* Legend */
|
||||
.flow-view-tools { margin: -8px 0 22px; }
|
||||
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-width: 0; }
|
||||
.legend em { display: inline-flex; align-items: center; gap: 6px; font-style: normal; }
|
||||
.legend em:last-child { color: var(--ws-muted); opacity: .8; }
|
||||
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--ws-accent); }
|
||||
.lg.decide { border-radius: 0; transform: rotate(45deg) scale(.85); background: var(--ws-tint); box-shadow: 0 0 0 2px var(--ws-accent); }
|
||||
.lg.then { border-radius: 50%; }
|
||||
.lg.else { border-radius: 50%; background: var(--ws-amber); }
|
||||
|
||||
@media (max-width: 850px) {
|
||||
:host { --tree-indent: 12px; --tree-anchor: 21px; --tree-elbow: 23px; --tree-gap: 10px; --tree-lead: 8px; }
|
||||
.canvas { padding: 20px 14px; }
|
||||
.node { gap: 9px; padding: 10px 9px 9px 9px; }
|
||||
.symbol { width: 24px; height: 24px; font-size: 13px; }
|
||||
.node-code { display: none; }
|
||||
.node-index { display: none; }
|
||||
.stage > .node-row > .node { padding-right: 46px; }
|
||||
.stage-toggle .toggle-text { display: none; }
|
||||
.stage-toggle { padding: 4px 7px; top: 9px; right: 8px; }
|
||||
.branch-name .port { width: 18px; height: 18px; font-size: 10px; }
|
||||
.branch:not(.plain) > .sequence { margin-left: 8px; }
|
||||
.legend em:last-child { display: none; }
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 102 KiB |
@@ -0,0 +1,2 @@
|
||||
<svg width="640" height="640" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="m0 0h640v640h-640v-640z" fill="#EBF0F9"/><path d="m0 0h640v640h-640v-640zm320 5v2l-3 2v2c-0.66 0.186-1.32 0.371-2 0.562-5.087 2.438-9.779 6.051-12.38 11.13-0.206 0.763-0.413 1.526-0.625 2.312-0.33 0.599-0.66 1.199-1 1.816-1.165 2.544-1.405 4.652-1.625 7.434-0.125 1.583-0.25 3.167-0.375 4.75-0.664-0.015-1.329-0.029-2.013-0.044-6.83-0.084-13.41 0.394-20.18 1.294-1.015 0.131-2.031 0.261-3.078 0.396-11.29 1.492-22.52 3.387-33.73 5.354v2c-0.516 0.113-0.516 0.113-3.125 0.688-10.11 2.549-19.62 6.443-28.84 11.27-3.768 1.29-6.195 0.973-10.04 0.039l-2-2c-1.988-0.398-3.989-0.738-6-1l-1-3c-2.293-1.246-2.293-1.246-5.188-2.438-3.16-1.309-5.856-2.592-8.683-4.535-3.558-2.305-7.024-3.643-11-5.027-8.531-3.069-8.531-3.069-12.19-5.062-4.813-2.578-10.07-4.047-15.25-5.692-3.684-1.246-3.684-1.246-6.957-2.738-4.733-2.083-9.751-3.002-14.79-4.07-5.768-1.242-11.34-2.549-16.94-4.438-4.31-0.837-8.652-1.399-13-2-0.966-0.173-1.931-0.345-2.926-0.523-2.442-0.384-4.61-0.671-7.074-0.477-2.625 2.125-2.625 2.125-4 5-0.25 2.813-0.25 2.813 0 5h-2c-1.913 8.508-3.23 16.86-3.582 25.58-0.02 0.45-0.02 0.45-0.119 2.727-0.396 9.874-0.52 19.75-0.539 29.63-0.01 3.06-0.041 6.12-0.072 9.179-0.066 12.47 0.913 24.38 2.97 36.68 0.511 3.288 0.831 6.58 1.154 9.891 1.057 8.148 3.74 15.61 6.489 23.31 1.382 3.954 2.546 7.974 3.699 12l-2-1c-6.799-0.788-12.3 0.76-18.56 3.25-0.4 0.15-0.4 0.15-2.42 0.91-7.406 2.837-14.65 6.063-21.02 10.84v2c-0.274 0.032-0.274 0.032-1.66 0.191-6.953 2.403-13.26 10.95-16.59 17.31-1.908 4.025-1.908 4.025-0.75 7.5 2.957-2.645 4.797-4.354 6-8.188 1-2.812 1-2.812 3.188-3.874 0.928-0.31 1.856-0.619 2.812-0.938 2.416-1.569 4.688-3.277 7-5-0.655 3.39-1.989 5.858-3.75 8.812-2.966 5.27-4.879 10.56-6.601 16.32-0.499 1.637-1.069 3.253-1.649 4.864l-2 1v-7c-0.99 0.33-1.98 0.66-3 1 0.036 0.57 0.071 1.141 0.108 1.728 0.157 2.57 0.306 5.14 0.454 7.71 0.029 0.448 0.029 0.448 0.17 2.72 0.049 0.854 0.097 1.708 0.147 2.588 0.047 0.791 0.094 1.582 0.143 2.396-0.022 1.858-0.022 1.858-1.022 2.858-0.788 6.433 1.167 10.09 5 15 0.454 0.443 0.454 0.443 2.75 2.688 2.25 2.312 2.25 2.312 3.312 4.624-0.074 3.201-1.161 5.267-2.679 8.043-1.84 3.519-3.42 7.132-5.008 10.77-0.15 0.341-0.15 0.341-0.912 2.064-1.32 3.019-2.519 5.981-3.549 9.116-0.914 2.695-0.914 2.695-2.914 5.695-0.553 1.965-1.047 3.947-1.5 5.938-1.288 5.65-1.288 5.65-2.586 8.175-1.07 2.209-1.12 3.701-1.039 6.137 0.021 0.619 0.021 0.619 0.125 3.75h3c0.309-1.279 0.619-2.558 0.938-3.875 0.538-2.226 1.036-4.072 2.062-6.125 0.029 4.292 0.047 8.583 0.062 12.88 9e-3 1.223 0.017 2.447 0.026 3.707 3e-3 1.167 6e-3 2.333 0.01 3.535 5e-3 1.079 0.01 2.158 0.016 3.269-0.114 2.614-0.114 2.614-1.114 4.614-0.104 2.228-0.184 4.458-0.25 6.688-0.467 7.755-0.467 7.755-3.312 11.25-2.438 3.062-2.438 3.062-2.813 6.937 0.375 3.125 0.375 3.125 1.375 4.125 0.087 1.635 0.107 3.273 0.098 4.91-4e-3 0.99-7e-3 1.979-0.01 2.998-8e-3 1.041-0.017 2.082-0.026 3.154-4e-3 1.045-9e-3 2.09-0.013 3.167-0.012 2.59-0.028 5.181-0.049 7.771h2v5h2v2h2c0.165 0.701 0.33 1.402 0.5 2.125 2.194 4.206 5.437 6.512 9.5 8.875 3.5 0.875 3.5 0.875 6 1v2h10c-0.097 0.375-0.097 0.375-0.586 2.273-1.255 4.935-2.465 9.836-3.352 14.85-0.854 4.522-2.408 8.542-4.257 12.75-0.805 2.129-0.805 2.129-0.805 5.129h-2c-1.005 1.789-2.004 3.581-3 5.375-0.557 0.998-1.114 1.995-1.688 3.023-1.312 2.602-1.312 2.602-1.312 4.602h-2c-1.803 2.503-3.415 5.101-5.051 7.715-1.949 2.285-1.949 2.285-6.949 3.285v14c2.709 0.054 5.416 0.094 8.125 0.125 0.761 0.017 1.521 0.034 2.305 0.051 4.603 0.039 8.235-0.417 12.57-2.176-0.33 1.176-0.66 2.351-1 3.562-2.162 9.774-2.589 22.26 2 31.44-0.804-0.062-1.609-0.124-2.438-0.188-7.915 0.417-14.98 3.488-20.56 9.188-1 2.875-1 2.875-1 5l4-2v-2c7.186-3.799 14.93-5.529 23-6 0.365-0.026 0.365-0.026 2.211-0.16 10.01-0.404 17.4 3.153 25.54 8.734 2.25 1.426 2.25 1.426 4.25 1.426l1 3 4-1v-4c-0.743 0.103-1.485 0.206-2.25 0.312-2.75-0.312-2.75-0.312-4.75-2.624-0.66-0.887-1.32-1.774-2-2.688-8.437-5.929-16.97-7.176-27-7-2.454-6.075-3.301-11.76-3.312-18.25-6e-3 -0.673-0.011-1.346-0.016-2.039 0.072-5.216 0.533-9.916 4.328-13.71 0.413-1.072 0.825-2.145 1.25-3.25 2.012-4.867 5.233-8.685 10.13-10.76 0.863-0.327 1.727-0.655 2.617-0.992 2.517-1.262 5.009-2.567 7.5-3.879 14.5-6.5 39.37-3.505 54.09 1.817 0.711 0.288 1.423 0.577 2.156 0.874 3.25 1.188 3.25 1.188 5.625 0.626 1.625-1.438 1.625-1.438 2.625-3.5 1-1.938 1-1.938 3.125-2.688 0.619-0.082 1.238-0.165 1.875-0.25v-2c1.595-0.423 3.19-0.846 4.785-1.27 2.215-0.73 2.215-0.73 5.434-2.199 3.977-1.734 7.957-2.505 12.22-3.219 0.731-0.129 1.463-0.259 2.216-0.392 1.781-0.314 3.563-0.618 5.346-0.92v-2c4.868-2.109 9.905-3.556 15-5 0.665-0.21 1.33-0.42 2.016-0.637 13.92-3.863 29.91-1.111 43.98 0.637v2c1.238 0.351 2.475 0.701 3.75 1.062 4.066 1.316 7.248 3.16 10.81 5.5 6.204 3.78 11.59 4.436 18.65 5.043 4.867 0.507 9.182 1.833 13.79 3.395 1.33 0.346 2.663 0.684 4 1v2c1.793 1.332 1.793 1.332 4.188 2.812 3.753 2.401 6.66 5.036 9.812 8.188 1.324 0.368 2.6Line truncated
|
||||
|
||||
|
After Width: | Height: | Size: 513 KiB |
@@ -0,0 +1,45 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="960" height="200" viewBox="0 0 960 200" fill="none" role="img" aria-labelledby="wordmark-title wordmark-description">
|
||||
<title id="wordmark-title">Universal Web API</title>
|
||||
<desc id="wordmark-description">蓝灰色渐变的几何艺术字。字形由矢量路径绘制,使用透明背景,不依赖外部字体。</desc>
|
||||
|
||||
<defs>
|
||||
<linearGradient id="wordmark-ink" x1="0" y1="0" x2="649" y2="76" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#526D93"/>
|
||||
<stop offset="0.48" stop-color="#6F8EB6"/>
|
||||
<stop offset="1" stop-color="#536D92"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
<!-- UNIVERSAL: custom geometric letterforms, independent of installed fonts. -->
|
||||
<g transform="translate(155 36)" stroke="url(#wordmark-ink)" stroke-width="11" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="
|
||||
M0 0 V48 C0 66 11 76 29 76 C47 76 58 66 58 48 V0
|
||||
M84 76 V0 L142 76 V0
|
||||
M168 0 V76
|
||||
M196 0 L225 76 L254 0
|
||||
M328 0 H280 V76 H328 M280 37 H320
|
||||
M354 76 V0 H380 C398 0 408 10 408 24 C408 39 398 48 380 48 H354 M381 48 L411 76
|
||||
M488 8 C476 -4 452 -3 440 9 C429 22 436 37 453 40 L471 44 C494 49 496 67 481 76 C467 85 446 80 436 69
|
||||
M518 76 L546 0 H550 L578 76 M531 46 H565
|
||||
M604 0 V76 H649
|
||||
"/>
|
||||
</g>
|
||||
|
||||
<!-- WEB API: a quiet, widely spaced secondary wordmark. -->
|
||||
<g transform="translate(375 148)" stroke="#627C9F" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="
|
||||
M0 0 L5 20 L11 6 L17 20 L22 0
|
||||
M54 0 H38 V20 H54 M38 10 H51
|
||||
M70 0 V20 H80 C90 20 90 10 80 10 H70 M70 0 H79 C88 0 88 10 79 10
|
||||
M121 20 L131 0 L141 20 M125 12 H137
|
||||
M159 20 V0 H168 C179 0 179 11 168 11 H159
|
||||
M193 0 H209 M201 0 V20 M193 20 H209
|
||||
"/>
|
||||
</g>
|
||||
|
||||
<g stroke="#B6C6DC" stroke-width="1.5" stroke-linecap="round" aria-hidden="true">
|
||||
<path d="M282 158 H338 M622 158 H678"/>
|
||||
<circle cx="274" cy="158" r="2.5"/>
|
||||
<circle cx="686" cy="158" r="2.5"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,758 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Universal Web-to-API Dashboard</title>
|
||||
<link rel="icon" type="image/svg+xml" href="/static/images/logo.svg">
|
||||
<link rel="shortcut icon" href="/static/images/logo.svg">
|
||||
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#f7f3ea">
|
||||
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#141915">
|
||||
|
||||
<!-- 提前应用夜间模式,避免刷新时先闪一下亮色(FOUC) -->
|
||||
<script>
|
||||
(function () {
|
||||
try {
|
||||
var saved = localStorage.getItem('darkMode');
|
||||
var dark = saved === null
|
||||
? window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
: saved === 'true';
|
||||
if (dark) document.documentElement.classList.add('dark');
|
||||
} catch (e) { /* ignore */ }
|
||||
})();
|
||||
</script>
|
||||
|
||||
<!-- 外部依赖 -->
|
||||
|
||||
<!-- Tailwind 配置 -->
|
||||
|
||||
<!-- 自定义样式 -->
|
||||
<link rel="stylesheet" href="/static/css/dashboard.css?v=2.6.18">
|
||||
<link rel="stylesheet" href="/static/css/dashboard-migration.css?v=3.0.2">
|
||||
<link rel="stylesheet" href="/static/css/dashboard-reference.css?v=3.2.7">
|
||||
<link rel="stylesheet" href="/static/css/onboarding-guide.css?v=1.0.0">
|
||||
<link rel="stylesheet" href="/static/css/dashboard-dark.css?v=1.1.5">
|
||||
<link rel="stylesheet" href="/static/css/site-studio.css?v=3.1.1">
|
||||
<link rel="stylesheet" href="/static/css/operations-studio.css?v=1.0.1">
|
||||
<link rel="stylesheet" href="/static/css/adapter-panel.css?v=1.0.0">
|
||||
<!-- R2-8:预编译的 Tailwind(原运行时 JIT 脚本 407KB);放在所有样式表之后,与原先运行时把 <style> 追加到 head 末尾的层叠顺序一致 -->
|
||||
<link rel="stylesheet" href="/static/css/tailwind.css?v=3.4.17-1">
|
||||
|
||||
<!-- 图标定义 -->
|
||||
</head>
|
||||
<body class="bg-gray-50 dark:bg-gray-900 transition-colors duration-300 h-screen overflow-hidden">
|
||||
<div id="app-shell" class="app-shell">
|
||||
<div class="app-shell-card">
|
||||
<img src="/static/images/logo.svg" alt="Universal Web API logo" class="app-shell-logo">
|
||||
<div class="app-shell-title">控制面板加载中</div>
|
||||
<p class="app-shell-text">正在加载前端资源和配置。如果停留太久,通常是本地服务初始化或接口响应较慢。</p>
|
||||
<span class="app-shell-spinner" aria-hidden="true"></span>
|
||||
<button type="button" class="app-shell-button" onclick="window.location.reload()">重新加载</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="app" class="flex h-full overflow-hidden" v-cloak @click="closeAllMenus">
|
||||
|
||||
<!-- 隐藏的文件输入框 -->
|
||||
<input type="file" ref="importFileInput" accept=".json" class="hidden" @change="handleImportFile">
|
||||
<input type="file" ref="backupImportInput" accept=".json" class="hidden" @change="handleSettingsBackupImportFile">
|
||||
|
||||
<!-- Toast 通知 -->
|
||||
<div class="uwa-toast-stack" aria-live="polite">
|
||||
<div v-for="toast in toasts"
|
||||
:key="toast.id"
|
||||
:class="['uwa-toast', 'is-' + toast.type]"
|
||||
role="status"
|
||||
title="点击关闭"
|
||||
@click="removeToast(toast.id)">
|
||||
<i class="uwa-toast-dot" aria-hidden="true"></i>
|
||||
<span>{{ toast.message }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 左侧栏组件 -->
|
||||
<sidebar-component ref="sidebar"
|
||||
:sites="sites"
|
||||
:current-domain="currentDomain"
|
||||
:browser-status="browserStatus"
|
||||
:auth-enabled="authEnabled"
|
||||
:has-token="hasToken"
|
||||
:dark-mode="darkMode"
|
||||
:active-tab="activeTab"
|
||||
:update-available="updateAvailable"
|
||||
:system-stats="systemStats"
|
||||
@select-site="selectSite"
|
||||
@add-site="addNewSite"
|
||||
@delete-site="confirmDelete"
|
||||
@export-site="exportSingleSite"
|
||||
@toggle-dark="toggleDarkMode"
|
||||
@refresh-status="refreshStatus"
|
||||
@trigger-import="triggerImport"
|
||||
@export-all="exportConfig"
|
||||
@show-token-dialog="openTokenDialog"
|
||||
@open-guide="$refs.onboarding && $refs.onboarding.open(true)"
|
||||
@primary-action="handleSidebarPrimaryAction"
|
||||
@collapse-change="sidebarCollapsed = $event"
|
||||
@change-tab="changeTab">
|
||||
</sidebar-component>
|
||||
|
||||
<onboarding-guide ref="onboarding"
|
||||
@tour-start="$refs.sidebar && $refs.sidebar.beginTourNavigation()"
|
||||
@tour-end="$refs.sidebar && $refs.sidebar.endTourNavigation()">
|
||||
</onboarding-guide>
|
||||
|
||||
<!-- 主内容区 -->
|
||||
<main class="dashboard-main flex-1 flex flex-col overflow-x-hidden overflow-y-auto bg-gray-50 dark:bg-gray-900">
|
||||
<header class="mobile-app-header">
|
||||
<button type="button"
|
||||
@click="$refs.sidebar && $refs.sidebar.openMobileNav()"
|
||||
title="打开导航"
|
||||
aria-label="打开导航">
|
||||
<span class="mobile-menu-lines" aria-hidden="true"></span>
|
||||
</button>
|
||||
<div>
|
||||
<strong>Universal API</strong>
|
||||
</div>
|
||||
<button type="button"
|
||||
@click="refreshStatus"
|
||||
title="刷新状态"
|
||||
aria-label="刷新状态">
|
||||
<i :class="['mobile-service-dot', { 'is-online': browserStatus.connected }]"></i>
|
||||
<span class="mobile-service-text">{{ browserStatus.connected ? '在线' : '离线' }}</span>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<header v-if="activeTab === 'config' && currentDomain && currentConfig"
|
||||
class="workspace-header bg-white dark:bg-gray-800 border-b dark:border-gray-700 p-4">
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="flex items-center gap-4">
|
||||
<h2 class="text-xl font-bold dark:text-white">{{ currentDomain }}</h2>
|
||||
<label v-if="getActivePresetConfig()" class="flex items-center text-sm cursor-pointer dark:text-gray-300">
|
||||
<input type="checkbox"
|
||||
:checked="getActivePresetConfig().stealth"
|
||||
@change="getActivePresetConfig().stealth = $event.target.checked"
|
||||
class="mr-2">
|
||||
<span>低熵模式</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button @click="refreshStatus"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2 py-0.5 text-sm">
|
||||
<span v-html="$icons.arrowPath"></span> 刷新
|
||||
</button>
|
||||
<button @click="showJsonPreview = true"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2 py-0.5 text-sm">
|
||||
查看 JSON
|
||||
</button>
|
||||
<button @click="openMainCompareSummaryDialog"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2 py-0.5 text-sm">
|
||||
一键对比
|
||||
</button>
|
||||
<button @click="exportCurrentSite"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2 py-0.5 text-sm">
|
||||
<span v-html="$icons.arrowUpTray"></span> 导出站点
|
||||
</button>
|
||||
<button @click="reanalyzeCurrentSite"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2 py-0.5 text-sm">
|
||||
重新分析
|
||||
</button>
|
||||
<button @click="saveConfig"
|
||||
:disabled="isSaving"
|
||||
:class="['border rounded transition-colors px-2 py-0.5 text-sm',
|
||||
isSaving ? 'opacity-50 cursor-not-allowed px-3 py-1 hover:bg-gray-100 dark:text-gray-400'
|
||||
: 'bg-blue-500 text-white hover:bg-blue-600 border-blue-500']">
|
||||
<span v-if="!isSaving" v-html="$icons.arrowDownTray"></span>
|
||||
{{ isSaving ? '保存中...' : ' 保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 设置页头部 -->
|
||||
<header v-if="activeTab === 'settings'"
|
||||
class="workspace-header bg-white dark:bg-gray-800 border-b dark:border-gray-700 p-4">
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="flex items-center gap-3">
|
||||
<span v-html="$icons.cog" class="text-gray-600 dark:text-gray-400"></span>
|
||||
<h2 class="text-xl font-bold dark:text-white">系统设置</h2>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button @click="triggerSettingsBackupImport"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2 py-0.5 text-sm">
|
||||
<span v-html="$icons.documentArrowDown"></span> 完整导入
|
||||
</button>
|
||||
<button @click="exportSettingsBackup"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2 py-0.5 text-sm">
|
||||
<span v-html="$icons.arrowUpTray"></span> 完整导出
|
||||
</button>
|
||||
<button @click="loadEnvConfig(); loadBrowserConstants(); loadUpdatePreserveSettings(); loadSelectorDefinitions()"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2 py-0.5 text-sm">
|
||||
<span v-html="$icons.arrowPath"></span> 刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Tab 切换栏 -->
|
||||
<div class="dashboard-tab-strip bg-white dark:bg-gray-800 border-b dark:border-gray-700 px-4 flex flex-wrap items-center gap-2"
|
||||
aria-label="移动端主导航"
|
||||
:class="{ 'tab-pool-tab-strip': activeTab === 'tabpool' }">
|
||||
<button @click="activeTab = 'config'"
|
||||
:class="['px-4 py-2 text-sm font-medium border-b-2 transition-colors',
|
||||
activeTab === 'config'
|
||||
? 'border-blue-500 text-blue-600 dark:text-blue-400'
|
||||
: 'border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300']">
|
||||
<span v-html="$icons.clipboardList"></span> 配置
|
||||
</button>
|
||||
<button @click="activeTab = 'tabpool'"
|
||||
:class="['px-4 py-2 text-sm font-medium border-b-2 transition-colors',
|
||||
activeTab === 'tabpool'
|
||||
? 'border-blue-500 text-blue-600 dark:text-blue-400'
|
||||
: 'border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300']">
|
||||
🗂️ 标签页
|
||||
</button>
|
||||
<button @click="activeTab = 'logs'"
|
||||
:class="['px-4 py-2 text-sm font-medium border-b-2 transition-colors',
|
||||
activeTab === 'logs'
|
||||
? 'border-blue-500 text-blue-600 dark:text-blue-400'
|
||||
: 'border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300']">
|
||||
<span v-html="$icons.chartBar"></span> 日志
|
||||
<span v-if="logs.length > 0" class="ml-1 px-1.5 py-0.5 text-xs bg-blue-100 dark:bg-blue-900 text-blue-600 dark:text-blue-300 rounded-full">{{ logs.length }}</span>
|
||||
</button>
|
||||
<button @click="activeTab = 'monitor'"
|
||||
:class="['px-4 py-2 text-sm font-medium border-b-2 transition-colors',
|
||||
activeTab === 'monitor'
|
||||
? 'border-blue-500 text-blue-600 dark:text-blue-400'
|
||||
: 'border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300']">
|
||||
📊 请求监控
|
||||
</button>
|
||||
<button @click="activeTab = 'commands'"
|
||||
:class="['px-4 py-2 text-sm font-medium border-b-2 transition-colors',
|
||||
activeTab === 'commands'
|
||||
? 'border-blue-500 text-blue-600 dark:text-blue-400'
|
||||
: 'border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300']">
|
||||
⚡ 命令
|
||||
</button>
|
||||
<button @click="activeTab = 'settings'"
|
||||
:class="['px-4 py-2 text-sm font-medium border-b-2 transition-colors',
|
||||
activeTab === 'settings'
|
||||
? 'border-blue-500 text-blue-600 dark:text-blue-400'
|
||||
: 'border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300']">
|
||||
<span v-html="$icons.cog"></span> 设置
|
||||
<span v-if="envConfigChanged || browserConstantsChanged || updatePreserveChanged || selectorDefinitionsChanged"
|
||||
class="ml-1 w-2 h-2 bg-orange-500 rounded-full inline-block"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="dashboard-scroll-region flex-1 overflow-y-auto">
|
||||
<!-- Tab 内容区 -->
|
||||
<home-tab v-if="activeTab === 'home'"
|
||||
:sites="sites"
|
||||
:browser-status="browserStatus"
|
||||
:system-stats="systemStats"
|
||||
:records="requestHistory"
|
||||
@change-tab="changeTab"
|
||||
@add-site="addNewSite"
|
||||
@notify="notify($event.message, $event.type)">
|
||||
</home-tab>
|
||||
|
||||
<section v-if="activeTab === 'config'" class="uwa-page uwa-config-page">
|
||||
<header class="uwa-page-header" v-show="siteConfigView === 'library'">
|
||||
<div>
|
||||
<p class="uwa-eyebrow">SITES & CONNECTIONS</p>
|
||||
<h1>站点配置</h1>
|
||||
<p>从网页到接口,把每个站点配置得井井有条。</p>
|
||||
</div>
|
||||
<div class="uwa-page-actions">
|
||||
<!-- 导入二级下拉 -->
|
||||
<div class="uwa-dropdown" @click.stop>
|
||||
<button type="button" class="uwa-button" @click.stop="toggleImportMenu" :class="{ 'is-active': showImportMenu }">
|
||||
<span v-html="$icons.documentArrowDown"></span>导入<span class="uwa-dropdown-caret" v-html="$icons.chevronDown"></span>
|
||||
</button>
|
||||
<div v-if="showImportMenu" class="uwa-dropdown-menu">
|
||||
<button type="button" class="uwa-dropdown-item" @click="triggerImport(); closeAllMenus()">
|
||||
<span class="uwa-dropdown-icon" v-html="$icons.documentArrowDown"></span>
|
||||
<div class="uwa-dropdown-item-copy">
|
||||
<strong>按文件域名导入</strong>
|
||||
<small>按文件中的域名导入;支持一个或多个站点</small>
|
||||
</div>
|
||||
</button>
|
||||
<button type="button" class="uwa-dropdown-item" @click="triggerImportSingleSite(); closeAllMenus()">
|
||||
<span class="uwa-dropdown-icon" v-html="$icons.clipboardList"></span>
|
||||
<div class="uwa-dropdown-item-copy">
|
||||
<strong>导入到指定站点</strong>
|
||||
<small>手动选择目标域名,用于迁移单站点配置</small>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 导出二级下拉 -->
|
||||
<div class="uwa-dropdown" @click.stop>
|
||||
<button type="button" class="uwa-button" @click.stop="toggleExportMenu" :class="{ 'is-active': showExportMenu }">
|
||||
<span v-html="$icons.arrowUpTray"></span>导出<span class="uwa-dropdown-caret" v-html="$icons.chevronDown"></span>
|
||||
</button>
|
||||
<div v-if="showExportMenu" class="uwa-dropdown-menu">
|
||||
<button type="button" class="uwa-dropdown-item" @click="exportConfig(); closeAllMenus()">
|
||||
<span class="uwa-dropdown-icon" v-html="$icons.arrowUpTray"></span>
|
||||
<div class="uwa-dropdown-item-copy">
|
||||
<strong>导出所有站点</strong>
|
||||
<small>导出所有站点及预设({{ Object.keys(sites).length }} 个站点)</small>
|
||||
</div>
|
||||
</button>
|
||||
<button type="button" class="uwa-dropdown-item" :disabled="!currentDomain" @click="exportCurrentSite(); closeAllMenus()" :class="{ 'is-disabled': !currentDomain }">
|
||||
<span class="uwa-dropdown-icon" v-html="$icons.globe"></span>
|
||||
<div class="uwa-dropdown-item-copy">
|
||||
<strong>导出当前站点配置</strong>
|
||||
<small>{{ currentDomain ? ('导出 ' + currentDomain + ' 的完整预设配置') : '请先在下方选择一个站点' }}</small>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="uwa-button studio-add-site" @click="addNewSite"><span v-html="$icons.plusCircle"></span>新增站点</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section v-show="siteConfigView === 'library'" class="site-library" aria-label="站点总览">
|
||||
<div class="site-library-intro">
|
||||
<div class="site-library-intro-copy"><span class="site-library-kicker">你的站点连接库</span><h2>一个站点,一套连接方式。</h2><p>先选择站点,再配置元素、输入与响应。<br>每个站点支持多套预设,适配不同的使用场景。</p><button v-if="currentDomain" type="button" class="site-resume" @click="selectSite(currentDomain)">继续编辑 {{ siteDisplayName(currentDomain) }} <span v-html="$icons.arrowRight"></span></button></div>
|
||||
<div class="site-library-stats"><div><strong>{{ siteLibraryStats.sites }}</strong><span>已添加站点</span></div><div><strong>{{ siteLibraryStats.presets }}</strong><span>配置预设</span></div><div><strong>{{ siteLibraryStats.incomplete }}</strong><span>核心字段待补全<small>按默认预设统计</small></span></div></div>
|
||||
</div>
|
||||
<div class="site-library-toolbar">
|
||||
<div class="site-library-filters" aria-label="筛选站点"><button type="button" :class="{ 'is-active': siteLibraryFilter === 'all' }" :aria-pressed="siteLibraryFilter === 'all'" @click="siteLibraryFilter = 'all'">全部站点 <span>{{ Object.keys(sites).length }}</span></button><button type="button" :class="{ 'is-active': siteLibraryFilter === 'incomplete' }" :aria-pressed="siteLibraryFilter === 'incomplete'" @click="siteLibraryFilter = 'incomplete'">待补全 <span>{{ siteLibraryStats.incomplete }}</span></button></div>
|
||||
<label class="library-search"><span v-html="$icons.magnifyingGlass"></span><input v-model="searchQuery" type="search" aria-label="搜索站点" placeholder="搜索名称或域名" @keyup.escape="searchQuery = ''" @keyup.enter="librarySites.length && selectSite(librarySites[0])"><kbd>/</kbd></label>
|
||||
<button type="button" class="site-library-compare" @click="openMainCompareSummaryDialog"><span v-html="$icons.arrowPathRoundedSquare"></span>配置对比</button>
|
||||
<button type="button" class="uwa-icon-button" @click="refreshStatus" aria-label="刷新状态" title="刷新状态"><span v-html="$icons.arrowPath"></span></button>
|
||||
</div>
|
||||
<p class="site-discovery-note">仅自动收录识别成功的 AI 聊天页;搜索页、登录页和通用回退不会加入。自定义站点仍可手动添加。</p>
|
||||
<div class="site-library-grid">
|
||||
<article v-for="domain in librarySites" :key="domain" class="site-library-card">
|
||||
<details class="site-card-menu preset-more"><summary :aria-label="siteDisplayName(domain) + ' 站点操作'"><span v-html="$icons.ellipsisVertical"></span></summary><div class="preset-more-pop"><button type="button" @click="exportSingleSite(domain); $event.currentTarget.closest('details').open = false"><span v-html="$icons.arrowUpTray"></span>导出站点</button><button type="button" class="is-danger" @click="$event.currentTarget.closest('details').open = false; confirmDelete(domain)"><span v-html="$icons.trash"></span>删除站点</button></div></details>
|
||||
<button type="button" class="site-card-open" :aria-label="'编辑 ' + siteDisplayName(domain)" @click="selectSite(domain)">
|
||||
<span class="site-card-identity"><span class="site-card-mark">{{ siteStudioInitial(domain) }}</span><span><strong>{{ siteDisplayName(domain) }}</strong><small>{{ domain }}</small></span></span>
|
||||
<span class="site-card-preset"><span v-html="$icons.folderOpen"></span>默认预设 <strong>{{ siteLibrarySummary(domain).presetName }}</strong></span>
|
||||
<span class="site-card-readiness"><span>核心定位</span><strong>{{ siteLibrarySummary(domain).coreFilled }}<small> / 3 已填写</small></strong></span>
|
||||
<span class="site-card-progress" aria-hidden="true"><i v-for="(filled, index) in siteLibrarySummary(domain).coreChecks" :key="index" :class="{ 'is-filled': filled }"></i></span>
|
||||
<span class="site-card-footer"><span>{{ siteLibrarySummary(domain).presets }} 套预设 <i>·</i> {{ siteLibrarySummary(domain).selectors }} 个默认预设字段</span><b><span>编辑</span><span v-html="$icons.arrowRight"></span></b></span>
|
||||
</button>
|
||||
</article>
|
||||
<button v-if="!searchQuery.trim() && siteLibraryFilter === 'all'" type="button" class="site-add-card" @click="addNewSite"><span v-html="$icons.plusCircle"></span><strong>连接新的站点</strong><small>从一套空白配置开始</small></button>
|
||||
</div>
|
||||
<div v-if="!librarySites.length && (searchQuery || siteLibraryFilter !== 'all')" class="site-library-empty"><span v-html="$icons.magnifyingGlass"></span><h3>{{ siteLibraryFilter === 'incomplete' && !searchQuery ? '核心字段均已填写' : '没有找到匹配的站点' }}</h3><p>{{ siteLibraryFilter === 'incomplete' && !searchQuery ? '填写进度不等于验证结果,接下来可以进入站点逐项测试。' : '换个关键词,或清除筛选重新查看。' }}</p><button type="button" class="uwa-button" @click="searchQuery = ''; siteLibraryFilter = 'all'">查看全部站点</button></div>
|
||||
<p class="site-library-footnote"><span v-html="$icons.bookOpen"></span>填写进度仅用于整理配置,不代表站点在线或选择器已通过验证。</p>
|
||||
<div class="site-library-save"><span>站点新增、删除和编辑后,记得保存配置。</span><button type="button" class="uwa-button" @click="saveConfig" :disabled="isSaving">{{ isSaving ? '保存中…' : '保存全部配置' }}</button></div>
|
||||
</section>
|
||||
<div v-show="siteConfigView === 'editor'" class="site-editor-breadcrumb"><button type="button" @click="showSiteLibrary"><span v-html="$icons.arrowUp"></span>全部站点</button><span>/</span><span>{{ siteDisplayName(currentDomain) }}</span><small>正在编辑本地配置</small></div>
|
||||
<div v-show="siteConfigView === 'editor'" class="uwa-config-workspace">
|
||||
<section class="uwa-config-editor">
|
||||
<div v-if="currentDomain && currentConfig" class="uwa-editor-heading">
|
||||
<details class="uwa-site-switcher">
|
||||
<summary title="切换站点">
|
||||
<span class="uwa-editor-site-icon" >{{ siteStudioInitial(currentDomain) }}</span>
|
||||
<span class="uwa-site-switcher-current"><h2>{{ siteDisplayName(currentDomain) }}</h2><p>{{ currentDomain }}</p></span>
|
||||
<span class="uwa-site-switcher-chevron" v-html="$icons.chevronDown"></span>
|
||||
</summary>
|
||||
<div class="uwa-site-switcher-popover">
|
||||
<div class="uwa-site-switcher-top"><strong>切换站点</strong><span>{{ filteredSites.length }} / {{ Object.keys(sites).length }}</span></div>
|
||||
<label class="uwa-search-field"><span v-html="$icons.magnifyingGlass"></span><input v-model="searchQuery" type="search" autocomplete="off" placeholder="搜索名称或域名" aria-label="搜索站点"></label>
|
||||
<div class="uwa-site-switcher-list">
|
||||
<div v-for="domain in filteredSites" :key="domain" :class="['uwa-switcher-site', { 'is-active': currentDomain === domain }]">
|
||||
<button type="button" class="uwa-switcher-select" @click="selectSite(domain); $event.currentTarget.closest('details').open = false">
|
||||
<span class="uwa-site-mark">{{ domain.charAt(0).toUpperCase() }}</span>
|
||||
<span class="uwa-site-details"><strong>{{ siteDisplayName(domain) }}</strong><small>{{ domain }}</small></span>
|
||||
<i aria-hidden="true"></i>
|
||||
</button>
|
||||
<span class="uwa-switcher-actions">
|
||||
<button type="button" @click="exportSingleSite(domain)" title="导出站点" aria-label="导出站点" v-html="$icons.arrowUpTray"></button>
|
||||
<button type="button" @click="confirmDelete(domain)" title="删除站点" aria-label="删除站点" v-html="$icons.trash"></button>
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="filteredSites.length === 0" class="uwa-rail-empty">没有匹配的站点</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
<div class="uwa-editor-actions">
|
||||
<label v-if="getActivePresetConfig()" class="uwa-switch-label">
|
||||
<span>低熵模式</span>
|
||||
<input type="checkbox" :checked="getActivePresetConfig().stealth" @change="getActivePresetConfig().stealth = $event.target.checked">
|
||||
<i></i>
|
||||
</label>
|
||||
<i v-if="getActivePresetConfig()" class="uwa-actions-divider" aria-hidden="true"></i>
|
||||
<button type="button" class="uwa-button studio-tip" @click="flushConfigTabDrafts(); showJsonPreview = true" data-tip="查看当前站点的完整配置源码,包括全部预设。"><span v-html="$icons.clipboardList"></span>配置 JSON</button>
|
||||
<details class="preset-more site-tools"><summary class="uwa-button">站点工具<span v-html="$icons.chevronDown"></span></summary><div class="preset-more-pop"><button type="button" class="is-danger" title="删除本站点的所有预设,之后需重新访问站点进行识别。建议先导出备份。" @click="$event.currentTarget.closest('details').open=false; reanalyzeCurrentSite()"><span v-html="$icons.trash"></span>清除配置,重新识别…</button></div></details>
|
||||
<button type="button" class="uwa-button studio-save-button" @click="saveConfig" :disabled="isSaving" title="保存全部配置(Ctrl / ⌘ + S)"><span :class="{ 'studio-spin': isSaving }" v-html="isSaving ? $icons.arrowPath : $icons.arrowDownTray"></span>{{ isSaving ? '保存中…' : '保存配置' }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="currentDomain && currentConfig" class="studio-editor-caption"><span><span class="studio-caption-dot"></span> 配置在本地管理;填写后请保存并测试。</span><span class="studio-save-status" role="status" aria-live="polite">{{ isSaving ? '正在保存…' : (studioLastSavedAt ? '上次完整保存 ' + studioLastSavedAt : 'Ctrl / ⌘ + S 保存') }}</span></div>
|
||||
<config-tab ref="configTab"
|
||||
v-if="currentDomain && currentConfig"
|
||||
:current-domain="currentDomain"
|
||||
:current-config="currentConfig"
|
||||
@add-selector="addSelector"
|
||||
@remove-selector="removeSelector"
|
||||
@update-selector-key="updateSelectorKey"
|
||||
@test-selector="testSelector"
|
||||
@add-step="addStep"
|
||||
@remove-step="removeStep"
|
||||
@move-step="moveStep"
|
||||
@action-change="onActionChange"
|
||||
@show-templates="showTemplates"
|
||||
@update-image-config="updateImageConfig"
|
||||
@test-image-extraction="testImageExtraction"
|
||||
@reload-config="reloadConfig">
|
||||
</config-tab>
|
||||
<div v-else class="uwa-config-empty">
|
||||
<span v-html="$icons.globe"></span>
|
||||
<h2>选择一个站点开始配置</h2>
|
||||
<p>从左侧站点列表选择,或新建一个站点。</p>
|
||||
<button type="button" class="uwa-button is-primary" @click="addNewSite">新增站点</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 标签页池 Tab -->
|
||||
<tabpool-tab v-if="activeTab === 'tabpool'"
|
||||
:dark-mode="darkMode"
|
||||
@notify="notify($event.message, $event.type)">
|
||||
</tabpool-tab>
|
||||
|
||||
<!-- 命令 Tab -->
|
||||
<section v-if="shouldRenderTab('commands')" v-show="activeTab === 'commands'" class="uwa-component-page uwa-commands-page">
|
||||
<commands-tab ref="commandsTab" :dark-mode="darkMode" @notify="notify($event.message, $event.type)"></commands-tab>
|
||||
</section>
|
||||
<!-- 日志 Tab -->
|
||||
<section v-if="activeTab === 'logs'" class="uwa-page uwa-simple-page uwa-logs-page">
|
||||
<header class="uwa-page-header">
|
||||
<div><p class="uwa-eyebrow">RUNTIME</p><h1>运行日志</h1><p>检查服务、浏览器与请求执行过程中的实时事件。</p></div>
|
||||
</header>
|
||||
<logs-tab :logs="logs"
|
||||
:filter="logLevelFilter"
|
||||
:paused="pauseLogs"
|
||||
@clear="clearLogs"
|
||||
@change-filter="logLevelFilter = $event"
|
||||
@toggle-pause="pauseLogs = !pauseLogs">
|
||||
</logs-tab>
|
||||
</section>
|
||||
|
||||
<request-monitor-tab v-if="activeTab === 'monitor'"
|
||||
:records="requestHistory"
|
||||
:max-records="requestHistoryMaxRecords"
|
||||
:detail-loading="requestHistoryDetailLoading"
|
||||
:system-stats="systemStats"
|
||||
:system-stats-enabled="isSystemStatsPollingEnabled()"
|
||||
:loading="requestHistoryLoading"
|
||||
:error="requestHistoryError"
|
||||
@refresh="fetchRequestHistory({ silent: false, force: true }); fetchSystemStats({ timeoutMs: 5000 })"
|
||||
@load-detail="fetchRequestHistoryDetail">
|
||||
</request-monitor-tab>
|
||||
|
||||
<!-- 设置 Tab -->
|
||||
<section v-if="activeTab === 'settings'" class="uwa-page uwa-simple-page uwa-settings-page">
|
||||
<header class="uwa-page-header">
|
||||
<div><p class="uwa-eyebrow">PREFERENCES</p><h1>系统设置</h1><p>管理运行环境、浏览器常量、更新保留项与元素定义。</p></div>
|
||||
<div class="uwa-page-actions">
|
||||
<button type="button" class="uwa-button" @click="triggerSettingsBackupImport"><span v-html="$icons.documentArrowDown"></span>完整导入</button>
|
||||
<button type="button" class="uwa-button" @click="exportSettingsBackup"><span v-html="$icons.arrowUpTray"></span>完整导出</button>
|
||||
<button type="button" class="uwa-button" @click="loadEnvConfig(); loadBrowserConstants(); loadUpdatePreserveSettings(); loadSelectorDefinitions()"><span v-html="$icons.arrowPath"></span>刷新</button>
|
||||
</div>
|
||||
</header>
|
||||
<settings-tab
|
||||
:env-config="envConfig"
|
||||
:env-schema="envSchema"
|
||||
:env-collapsed="envCollapsed"
|
||||
:env-changed="envConfigChanged"
|
||||
:saving-env="isSavingEnv"
|
||||
:browser-constants="browserConstants"
|
||||
:browser-schema="browserConstantsSchema"
|
||||
:browser-collapsed="browserConstantsCollapsed"
|
||||
:browser-changed="browserConstantsChanged"
|
||||
:saving-browser="isSavingConstants"
|
||||
:update-preserve-options="updatePreserveOptions"
|
||||
:update-preserve-selected="updatePreserveSelected"
|
||||
:update-preserve-changed="updatePreserveChanged"
|
||||
:saving-update-preserve="isSavingUpdatePreserve"
|
||||
:selector-definitions="selectorDefinitions"
|
||||
:definitions-changed="selectorDefinitionsChanged"
|
||||
:saving-definitions="isSavingDefinitions"
|
||||
@save-env="saveEnvConfig"
|
||||
@reset-env="resetEnvConfig"
|
||||
@toggle-env-group="envCollapsed[$event] = !envCollapsed[$event]"
|
||||
@save-browser="saveBrowserConstants"
|
||||
@reset-browser="resetBrowserConstants"
|
||||
@toggle-browser-group="browserConstantsCollapsed[$event] = !browserConstantsCollapsed[$event]"
|
||||
@save-update-preserve="saveUpdatePreserveSettings"
|
||||
@reset-update-preserve="resetUpdatePreserveSettings"
|
||||
@toggle-update-preserve="toggleUpdatePreserve"
|
||||
@save-definitions="saveSelectorDefinitions"
|
||||
@reset-definitions="resetSelectorDefinitions"
|
||||
@add-definition="openAddDefinitionDialog"
|
||||
@edit-definition="openEditDefinitionDialog"
|
||||
@remove-definition="removeDefinition"
|
||||
@toggle-definition="toggleDefinitionEnabled"
|
||||
@move-definition="moveDefinition"
|
||||
:releases="releases"
|
||||
:releases-loading="releasesLoading"
|
||||
:releases-error="releasesError"
|
||||
:releases-current-version="releasesCurrentVersion"
|
||||
:switching-tag="switchingTag"
|
||||
:update-check-refreshing="updateCheckRefreshing"
|
||||
@load-releases="loadReleases"
|
||||
@refresh-update-check="refreshUpdateCheck"
|
||||
@switch-to-version="switchToVersion"
|
||||
@show-changelog="showChangelog">
|
||||
</settings-tab>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- 弹窗区域 -->
|
||||
<!-- v-if:getJsonPreviewData() 会先 flush 面板草稿再深拷贝整份预设,
|
||||
不加 v-if 的话每次根组件重渲染(日志 1s / 系统统计 3s 轮询)都会白跑一遍 -->
|
||||
<json-preview-dialog v-if="showJsonPreview"
|
||||
:show="showJsonPreview"
|
||||
:json-data="getJsonPreviewData()"
|
||||
:title="'配置 JSON · ' + getActivePresetName()"
|
||||
@close="showJsonPreview = false"
|
||||
@copy="copyJson"
|
||||
@save="saveJsonPreview">
|
||||
</json-preview-dialog>
|
||||
|
||||
<token-dialog :show="showTokenDialog"
|
||||
v-model="tempToken"
|
||||
@close="showTokenDialog = false"
|
||||
@save="saveToken">
|
||||
</token-dialog>
|
||||
|
||||
<step-templates-dialog :show="showStepTemplates"
|
||||
@close="showStepTemplates = false"
|
||||
@apply="applyTemplate($event); showStepTemplates = false">
|
||||
</step-templates-dialog>
|
||||
|
||||
<test-dialog :show="showTestDialog"
|
||||
:selector="testSelectorInput"
|
||||
:selector-key="currentTestingSelectorKey"
|
||||
:timeout-value="testTimeout"
|
||||
:highlight-enabled="testHighlight"
|
||||
:result="testResult"
|
||||
:testing="isTesting"
|
||||
@close="showTestDialog = false"
|
||||
@apply-selector="applyTestSelectorCandidate"
|
||||
@test="testSelectorInput = $event.selector; testTimeout = $event.timeout; testHighlight = $event.highlight; runTest()">
|
||||
</test-dialog>
|
||||
|
||||
<import-dialog :show="showImportDialog"
|
||||
:file-name="importFileName"
|
||||
:import-type="importType"
|
||||
:suggested-domain="singleSiteImportDomain"
|
||||
:imported-config="importedConfig"
|
||||
@close="cancelImport"
|
||||
@confirm="singleSiteImportDomain = $event.domain; importMode = $event.mode; executeImport()">
|
||||
</import-dialog>
|
||||
|
||||
<definition-dialog :show="showAddDefinitionDialog"
|
||||
:edit-index="editingDefinitionIndex"
|
||||
:definition="newDefinition"
|
||||
@close="showAddDefinitionDialog = false"
|
||||
@save="saveDefinition">
|
||||
</definition-dialog>
|
||||
|
||||
<div v-if="showMainCompareSummaryDialog"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/60 p-4 backdrop-blur-sm"
|
||||
@click.self="closeMainCompareSummaryDialog">
|
||||
<div class="flex h-[78vh] w-[72vw] min-w-[880px] max-w-[980px] flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-2xl dark:border-slate-700 dark:bg-slate-900">
|
||||
<div class="flex items-start justify-between gap-4 border-b border-slate-200 px-4 py-3 dark:border-slate-700">
|
||||
<div>
|
||||
<h3 class="text-base font-bold text-slate-900 dark:text-white">本地配置与官方预设差异清单</h3>
|
||||
<p class="mt-1 text-xs text-slate-500 dark:text-slate-400">
|
||||
对比当前配置与官方配置的差异。若需要深入看某一项,点“打开详细对比”进入对应站点。
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button @click="loadMainCompareSummary"
|
||||
:disabled="mainCompareSummaryLoading"
|
||||
class="rounded-xl border border-slate-200 px-3 py-1 text-xs font-medium text-slate-600 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800">
|
||||
{{ mainCompareSummaryLoading ? '对比中...' : '重新对比' }}
|
||||
</button>
|
||||
<button @click="closeMainCompareSummaryDialog"
|
||||
class="rounded-xl border border-slate-200 px-3 py-1 text-xs font-medium text-slate-600 transition hover:bg-slate-100 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800">
|
||||
关闭
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-3 overflow-auto px-4 py-3">
|
||||
<div class="flex flex-wrap items-center gap-2 text-xs">
|
||||
<span class="rounded-full border border-slate-200 bg-slate-50 px-2.5 py-1 text-slate-600 dark:border-slate-700 dark:bg-slate-800/80 dark:text-slate-300">
|
||||
官方来源: {{ mainCompareSummarySource.repository || '官方仓库' }}/{{ mainCompareSummarySource.branch || 'main' }} · {{ mainCompareSummaryPath }}
|
||||
</span>
|
||||
<span v-if="mainCompareSummarySource.status"
|
||||
:class="mainCompareSummarySource.stale
|
||||
? 'border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-200'
|
||||
: 'border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-900/20 dark:text-emerald-200'"
|
||||
class="rounded-full border px-2.5 py-1">
|
||||
{{ mainCompareSummarySource.stale
|
||||
? '缓存回退'
|
||||
: (mainCompareSummarySource.status === 'validated_cache' ? '已确认最新' : '刚刚获取') }}
|
||||
<template v-if="mainCompareSummarySource.stale ? mainCompareSummarySource.fetched_at : mainCompareSummarySource.checked_at">
|
||||
· {{ formatOfficialConfigSourceTime(mainCompareSummarySource.stale ? mainCompareSummarySource.fetched_at : mainCompareSummarySource.checked_at) }}
|
||||
</template>
|
||||
</span>
|
||||
<label class="inline-flex items-center gap-2 rounded-full border border-slate-200 bg-slate-50 px-2.5 py-1 text-slate-600 dark:border-slate-700 dark:bg-slate-800/80 dark:text-slate-300">
|
||||
<input v-model="mainCompareShowSame" type="checkbox" class="rounded">
|
||||
<span>显示一致项</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-if="mainCompareSummarySource.warning"
|
||||
class="border-l-2 border-amber-400 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:bg-amber-950/30 dark:text-amber-200">
|
||||
{{ mainCompareSummarySource.warning }}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-2 text-xs">
|
||||
<span class="rounded-full border border-amber-200 bg-amber-50 px-2.5 py-1 text-amber-700 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-200">有差异 {{ mainCompareDifferentTotal }}</span>
|
||||
<span class="rounded-full border border-emerald-200 bg-emerald-50 px-2.5 py-1 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-900/20 dark:text-emerald-200">一致 {{ mainCompareSummaryCounts.same || 0 }}</span>
|
||||
<span class="rounded-full border border-blue-200 bg-blue-50 px-2.5 py-1 text-blue-700 dark:border-blue-800 dark:bg-blue-900/20 dark:text-blue-200">本地预设 {{ mainCompareSummaryCounts.local_only_preset || 0 }}</span>
|
||||
<span class="rounded-full border border-rose-200 bg-rose-50 px-2.5 py-1 text-rose-700 dark:border-rose-800 dark:bg-rose-900/20 dark:text-rose-200">本地站点 {{ mainCompareSummaryCounts.local_only_site || 0 }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="(mainCompareSummaryCounts.main_only_preset || 0) > 0 || (mainCompareSummaryCounts.main_only_site || 0) > 0"
|
||||
class="rounded-2xl border border-slate-200 bg-slate-50 px-3 py-2 text-xs text-slate-600 dark:border-slate-700 dark:bg-slate-800/50 dark:text-slate-300">
|
||||
main 分支额外存在 {{ mainCompareSummaryCounts.main_only_preset || 0 }} 个你本地没有对应项的官方预设,
|
||||
以及 {{ mainCompareSummaryCounts.main_only_site || 0 }} 个你本地还没有的官方站点;这两类暂时不在下面列表里展开。
|
||||
</div>
|
||||
|
||||
<div v-if="mainCompareSummaryError"
|
||||
class="rounded-2xl border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700 dark:border-rose-800 dark:bg-rose-900/20 dark:text-rose-300">
|
||||
{{ mainCompareSummaryError }}
|
||||
</div>
|
||||
|
||||
<div v-else-if="mainCompareSummaryLoading"
|
||||
class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-6 text-center text-xs text-slate-500 dark:border-slate-700 dark:bg-slate-800/40 dark:text-slate-400">
|
||||
正在生成对比清单...
|
||||
</div>
|
||||
|
||||
<div v-else-if="mainCompareVisibleItems.length === 0"
|
||||
class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-6 text-center text-xs text-slate-500 dark:border-slate-700 dark:bg-slate-800/40 dark:text-slate-400">
|
||||
{{ mainCompareShowSame ? '当前没有可展示的对比项。' : '当前本地配置和官方预设没有差异。' }}
|
||||
</div>
|
||||
|
||||
<div v-else class="space-y-2">
|
||||
<article v-for="item in mainCompareVisibleItems"
|
||||
:key="item.domain + '::' + item.local_preset_name + '::' + item.status"
|
||||
class="rounded-2xl border border-slate-200 bg-white px-3 py-2.5 shadow-sm dark:border-slate-700 dark:bg-slate-900/50">
|
||||
<div class="flex flex-col gap-2 lg:flex-row lg:items-start lg:justify-between">
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span :class="['rounded-full border px-2.5 py-1 text-xs font-medium', getMainCompareStatusClass(item.status)]">
|
||||
{{ getMainCompareStatusText(item.status) }}
|
||||
</span>
|
||||
<span class="text-sm font-semibold text-slate-900 dark:text-white">{{ item.domain }}</span>
|
||||
<span class="text-xs text-slate-400 dark:text-slate-500">/</span>
|
||||
<span class="text-sm text-slate-600 dark:text-slate-300">{{ item.local_preset_name }}</span>
|
||||
<span v-if="item.main_preset_name && item.main_preset_name !== item.local_preset_name"
|
||||
class="rounded-full border border-slate-200 bg-slate-50 px-2 py-0.5 text-[11px] text-slate-500 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-400">
|
||||
官方对应 {{ item.main_preset_name }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-slate-500 dark:text-slate-400">{{ item.summary_text }}</p>
|
||||
<div v-if="Array.isArray(item.different_field_labels) && item.different_field_labels.length"
|
||||
class="mt-2 flex flex-wrap gap-1.5">
|
||||
<span v-for="label in item.different_field_labels"
|
||||
:key="item.domain + '-' + item.local_preset_name + '-' + label"
|
||||
class="rounded-full border border-amber-200 bg-amber-50 px-2.5 py-1 text-xs text-amber-700 dark:border-amber-800 dark:bg-amber-900/30 dark:text-amber-300">
|
||||
{{ label }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2 lg:pl-4">
|
||||
<button @click="openMainCompareDetail(item)"
|
||||
class="rounded-xl bg-blue-600 px-3 py-1.5 text-xs font-semibold text-white transition hover:bg-blue-700">
|
||||
打开详细对比
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Changelog 弹窗 -->
|
||||
<div v-if="showChangelogModal"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/60 p-4 backdrop-blur-sm"
|
||||
@click.self="showChangelogModal = false">
|
||||
<div class="flex max-h-[70vh] w-full max-w-lg flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-2xl dark:border-slate-700 dark:bg-slate-900">
|
||||
<div class="flex items-center justify-between border-b border-slate-200 px-6 py-4 dark:border-slate-700">
|
||||
<h3 class="text-base font-bold text-slate-900 dark:text-white flex items-center gap-2">
|
||||
📋 版本更新说明 ({{ changelogTag }})
|
||||
</h3>
|
||||
<button @click="showChangelogModal = false" class="text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 transition-colors">
|
||||
<svg class="w-6 h-6" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex-1 overflow-y-auto px-6 py-4 text-sm text-slate-700 dark:text-slate-300 whitespace-pre-wrap font-sans leading-relaxed">
|
||||
{{ changelogContent }}
|
||||
</div>
|
||||
<div class="border-t border-slate-200 bg-slate-50 px-6 py-3 text-right dark:border-slate-700 dark:bg-slate-800/40">
|
||||
<button @click="showChangelogModal = false"
|
||||
class="rounded-xl bg-blue-600 px-4 py-2 text-sm font-semibold text-white transition hover:bg-blue-700 shadow-sm active:scale-95">
|
||||
确定
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- 加载组件 JS(R2-8:除 Vue 全局构建外均以 ES 模块加载——严格模式、模块作用域、按文档顺序延迟执行) -->
|
||||
<script src="/static/vendor/vue.global.prod.js?v=2.6.7"></script>
|
||||
<script type="module" src="/static/js/icons.js?v=operations-2"></script>
|
||||
<script type="module" src="/static/js/components/Sidebar.js?v=studio-2.0.0"></script>
|
||||
<script type="module" src="/static/js/components/OnboardingGuide.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/components/HomeTab.js?v=3.1.1"></script>
|
||||
<!-- 子组件(在 ConfigTab 之前) -->
|
||||
<script type="module" src="static/js/components/panels/SelectorPanel.js?v=studio-2"></script>
|
||||
<script type="module" src="static/js/components/panels/ImageConfigPanel.js?v=gentle-2"></script>
|
||||
<script type="module" src="static/js/components/panels/StreamConfigPanel.js?v=gentle-2"></script>
|
||||
<script type="module" src="/static/js/workflow-studio.js?v=3.4.0"></script>
|
||||
<script type="module" src="/static/js/components/panels/WorkflowPanel.js?v=3.1.0"></script>
|
||||
<script type="module" src="static/js/components/panels/FilePastePanel.js?v=gentle-2"></script>
|
||||
<script type="module" src="static/js/components/panels/PromptPaddingPanel.js?v=gentle-2"></script>
|
||||
|
||||
<!-- 主组件 -->
|
||||
<script type="module" src="/static/js/components/panels/PresetTransfer.js?v=1.1.0"></script>
|
||||
<script type="module" src="static/js/components/panels/AdapterPanel.js?v=1.0.1"></script>
|
||||
<script type="module" src="static/js/components/ConfigTab.js?v=adapter-panel-1"></script>
|
||||
<script type="module" src="/static/js/components/LogsTab.js?v=3.0.1"></script>
|
||||
<script type="module" src="/static/js/components/RequestMonitorTab.js?v=operations-2"></script>
|
||||
<script type="module" src="/static/js/components/SettingsTab.js?v=3.0.1"></script>
|
||||
<script type="module" src="/static/js/components/Dialogs.js?v=2.6.9"></script>
|
||||
<script type="module" src="/static/js/components/TabPoolTab.js?v=operations-2"></script>
|
||||
<script type="module" src="/static/js/components/commands/CommandsTabComputed.js?v=2.6.9"></script>
|
||||
<script type="module" src="/static/js/components/commands/CommandsTabMethods.js?v=2.6.16"></script>
|
||||
<script type="module" src="/static/js/components/commands/CommandsTabTemplate.js?v=3.0.1"></script>
|
||||
<script type="module" src="/static/js/components/CommandsTab.js?v=2.6.14"></script>
|
||||
|
||||
<!-- 主应用逻辑 -->
|
||||
<script type="module" src="/static/js/dashboard-schema.js?v=attachments-1"></script>
|
||||
<script type="module" src="/static/js/dashboard-state.js?v=studio-2"></script>
|
||||
<!-- R2-8:dashboard-methods 按主题拆分;shared.js 与各分组须在组装器之前加载 -->
|
||||
<script type="module" src="/static/js/dashboard/shared.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard/methods-core.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard/methods-api.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard/methods-media.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard/methods-logs.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard/methods-transfer.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard/methods-settings.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard/methods-versions.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard/methods-selectors.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard/methods-editing.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard/methods-tools.js?v=1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard-methods.js?v=assembler-1.0.0"></script>
|
||||
<script type="module" src="/static/js/dashboard.js?v=3.1.0"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,194 @@
|
||||
// ==================== 命令管理组件 ====================
|
||||
window.CommandsTabComponent = {
|
||||
name: 'CommandsTabComponent',
|
||||
props: {
|
||||
darkMode: { type: Boolean, default: false }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
commands: [],
|
||||
loading: false,
|
||||
// action_id -> 上一次的动作类型;用于切换类型时判断 selector/timeout 等
|
||||
// 同名字段的语义分组是否变化(仅组件内部状态,不写入命令 JSON)
|
||||
actionTypeSnapshots: {},
|
||||
meta: { trigger_types: {}, action_types: {} },
|
||||
availableDomains: [],
|
||||
availableTabs: [],
|
||||
availablePresets: [],
|
||||
presetLoading: false,
|
||||
showHelpTip: false,
|
||||
currentPage: 1,
|
||||
pageSize: 16,
|
||||
pageSizeOptions: [8, 16, 24, 32, 48, 64],
|
||||
reordering: false,
|
||||
selectedCommandIds: [],
|
||||
pendingGroupName: '',
|
||||
selectedExistingGroupName: '',
|
||||
groupWorking: false,
|
||||
duplicatingCommandId: '',
|
||||
includeDisabledWhenRunGroup: false,
|
||||
runGroupAcquirePolicy: 'inherit_session',
|
||||
showGroupTools: false,
|
||||
collapsedGroups: {},
|
||||
bulkActionMenuOpen: false,
|
||||
groupActionMenuOpen: '',
|
||||
commandActionMenuOpen: '',
|
||||
draggingCommandId: '',
|
||||
dragOverGroupName: '',
|
||||
dragOverCommandId: '',
|
||||
dragOverCommandPosition: '',
|
||||
triggerTypePickerOpen: false,
|
||||
triggerTypeTooltipType: '',
|
||||
sourceCommandPickerOpen: false,
|
||||
sourceCommandSearch: '',
|
||||
sourcePickerExpandedGroups: {},
|
||||
sourcePickerShowUngrouped: false,
|
||||
pageProbeExpanded: false,
|
||||
|
||||
// 编辑弹窗
|
||||
showEditor: false,
|
||||
editingCommand: null,
|
||||
isNew: false,
|
||||
|
||||
// 高级模式编辑器高度
|
||||
scriptEditorHeight: '300px',
|
||||
advancedEditorMode: 'ui',
|
||||
commandResults: [],
|
||||
commandResultsLoading: false,
|
||||
commandResultsTimer: null,
|
||||
commandResultsRequestSeq: 0,
|
||||
selectedAdvancedRuleIndex: 0,
|
||||
|
||||
// 代理切换默认配置
|
||||
proxyDefaults: {
|
||||
clash_api: 'http://127.0.0.1:9090',
|
||||
clash_secret: '',
|
||||
selector: 'Proxy',
|
||||
mode: 'random',
|
||||
node_name: '',
|
||||
exclude_keywords: 'DIRECT,REJECT,GLOBAL,自动选择,故障转移',
|
||||
refresh_after: true
|
||||
},
|
||||
webhookDefaults: {
|
||||
method: 'POST',
|
||||
url: '',
|
||||
payload: '{"msg":"标签页#{{tab_index}} 在 {{domain}} 命中异常状态码 {{network_status}}"}',
|
||||
headers: '{"Content-Type":"application/json"}',
|
||||
timeout: 8,
|
||||
raise_for_status: false
|
||||
},
|
||||
napcatDefaults: {
|
||||
base_url: 'http://127.0.0.1:3000',
|
||||
target_type: 'private',
|
||||
user_id: '',
|
||||
group_id: '',
|
||||
message: '命令通知:{{source_command_name}}\\n{{command_result_summary}}',
|
||||
access_token: '',
|
||||
timeout: 8,
|
||||
raise_for_status: true
|
||||
},
|
||||
releaseLockDefaults: {
|
||||
reason: 'release_tab_lock_action',
|
||||
clear_page: true,
|
||||
stop_actions: true
|
||||
},
|
||||
automationWriteDefaults: {
|
||||
selector: '',
|
||||
write_mode: 'replace',
|
||||
clear_first: true,
|
||||
value_source: 'literal',
|
||||
text: '',
|
||||
template: '',
|
||||
variable_name: '',
|
||||
random_kind: 'alnum',
|
||||
random_length: 8,
|
||||
prefix: '',
|
||||
suffix: '',
|
||||
preset_name: 'name_cn',
|
||||
date_format: 'YYYY-MM-DD',
|
||||
min_age: 18,
|
||||
max_age: 35,
|
||||
save_as: '',
|
||||
timeout_sec: 6
|
||||
},
|
||||
automationReadDefaults: {
|
||||
selector: '',
|
||||
read_mode: 'auto',
|
||||
attr_name: '',
|
||||
trim: true,
|
||||
save_as: '',
|
||||
timeout_sec: 6
|
||||
},
|
||||
httpRequestDefaults: {
|
||||
method: 'GET',
|
||||
url: '',
|
||||
request_profile: '',
|
||||
headers: '{"Accept":"application/json"}',
|
||||
prompt: '',
|
||||
body: '',
|
||||
body_mode: 'json',
|
||||
response_mode: 'text',
|
||||
credentials: 'include',
|
||||
model_type: 'auto',
|
||||
search_enabled: 'auto',
|
||||
thinking_enabled: 'auto',
|
||||
client_version: '2.0.0',
|
||||
app_version: '2.0.0',
|
||||
timeout_sec: 15,
|
||||
fail_on_http_error: true,
|
||||
save_as: ''
|
||||
},
|
||||
appendFileDefaults: {
|
||||
file_path: '',
|
||||
content: '',
|
||||
append_newline: true,
|
||||
create_dirs: true,
|
||||
encoding: 'utf-8'
|
||||
},
|
||||
runJsFileDefaults: {
|
||||
file_path: 'js/arena-stream-hard-stop.user.js',
|
||||
encoding: 'utf-8-sig',
|
||||
inject_on_new_document: true,
|
||||
apply_now: true,
|
||||
fail_on_falsy: false
|
||||
},
|
||||
fetchCommandsSeq: 0,
|
||||
commandsResponseSignature: '',
|
||||
presetOptionsRequestSeq: 0
|
||||
};
|
||||
},
|
||||
computed: window.CommandsTabComputed,
|
||||
|
||||
methods: window.CommandsTabMethods,
|
||||
|
||||
watch: {
|
||||
'editingCommand.mode'(nextMode, prevMode) {
|
||||
if (nextMode === 'advanced' && prevMode !== 'advanced') {
|
||||
this.advancedEditorMode = 'ui';
|
||||
}
|
||||
},
|
||||
showEditor(nextValue) {
|
||||
if (!nextValue) {
|
||||
this.advancedEditorMode = 'ui';
|
||||
this.commandResultsRequestSeq += 1;
|
||||
this.commandResults = [];
|
||||
this.commandResultsLoading = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.fetchMeta();
|
||||
this.fetchCommands();
|
||||
this.fetchBindingMeta();
|
||||
this.commandResultsTimer = window.setInterval(() => {
|
||||
if (this.showEditor && this.editingCommand && this.advancedUiResultsEnabled) {
|
||||
this.loadCommandResults(true);
|
||||
}
|
||||
}, 5000);
|
||||
},
|
||||
beforeUnmount() {
|
||||
if (this.commandResultsTimer) window.clearInterval(this.commandResultsTimer);
|
||||
},
|
||||
template: window.CommandsTabTemplate
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,822 @@
|
||||
// ==================== 所有弹窗组件 ====================
|
||||
|
||||
// -------------------- JSON 预览弹窗 --------------------
|
||||
window.JsonPreviewDialog = {
|
||||
name: 'JsonPreviewDialog',
|
||||
props: {
|
||||
show: { type: Boolean, default: false },
|
||||
jsonData: { type: Object, default: () => ({}) },
|
||||
title: { type: String, default: '配置 JSON' }
|
||||
},
|
||||
emits: ['close', 'copy', 'save'],
|
||||
data() {
|
||||
return {
|
||||
draft: ''
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
show: {
|
||||
handler(value) {
|
||||
if (value) {
|
||||
this.draft = JSON.stringify(this.jsonData || {}, null, 2);
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
jsonData: {
|
||||
handler() {
|
||||
if (this.show) {
|
||||
this.draft = JSON.stringify(this.jsonData || {}, null, 2);
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div v-if="show"
|
||||
class="fixed inset-0 bg-black/50 flex items-center justify-center z-40"
|
||||
@click.self="$emit('close')">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg p-6 w-[96vw] max-w-[1600px] h-[90vh] flex flex-col shadow-2xl">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="font-semibold dark:text-white">{{ title }}</h3>
|
||||
<button @click="$emit('close')"
|
||||
class="text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300">
|
||||
<span v-html="$icons.xMark"></span>
|
||||
</button>
|
||||
</div>
|
||||
<textarea v-model="draft"
|
||||
spellcheck="false"
|
||||
class="flex-1 min-h-0 overflow-auto bg-gray-50 dark:bg-gray-900 p-4 rounded text-sm font-mono border dark:border-gray-700 dark:text-gray-300 resize-none focus:outline-none focus:ring-2 focus:ring-blue-400"></textarea>
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<button @click="$emit('copy', draft)"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2 py-0.5 text-sm">
|
||||
复制到剪贴板
|
||||
</button>
|
||||
<button @click="$emit('save', draft)"
|
||||
class="border rounded transition-colors bg-blue-500 text-white hover:bg-blue-600 border-blue-500 px-3 py-1 text-sm">
|
||||
保存修改
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
|
||||
// -------------------- 控制面板访问密钥弹窗 --------------------
|
||||
window.TokenDialog = {
|
||||
name: 'TokenDialog',
|
||||
props: {
|
||||
show: { type: Boolean, default: false },
|
||||
modelValue: { type: String, default: '' }
|
||||
},
|
||||
emits: ['close', 'save', 'update:modelValue'],
|
||||
computed: {
|
||||
tempToken: {
|
||||
get() { return this.modelValue; },
|
||||
set(val) { this.$emit('update:modelValue', val); }
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div v-if="show"
|
||||
class="fixed inset-0 bg-black/50 flex items-center justify-center z-40"
|
||||
@click.self="$emit('close')">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg p-6 w-96">
|
||||
<h3 class="font-semibold dark:text-white mb-4">配置控制面板访问密钥</h3>
|
||||
<div class="mb-4">
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400 mb-2 block">
|
||||
控制面板访问密钥(留空则清除)
|
||||
</label>
|
||||
<input v-model="tempToken"
|
||||
type="password"
|
||||
placeholder="dashboard-secret"
|
||||
class="border dark:border-gray-700 px-2 py-1 rounded focus:outline-none focus:border-blue-400 w-full bg-white dark:bg-gray-700 dark:text-white">
|
||||
</div>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400 mb-4">
|
||||
仅用于访问控制面板管理接口,不等同于对外服务 API Key
|
||||
</div>
|
||||
<div class="flex justify-end gap-2">
|
||||
<button @click="$emit('close')"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2 py-0.5 text-sm">
|
||||
取消
|
||||
</button>
|
||||
<button @click="$emit('save')"
|
||||
class="border rounded transition-colors bg-blue-500 text-white hover:bg-blue-600 border-blue-500 px-2 py-0.5 text-sm">
|
||||
保存
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
|
||||
// -------------------- 步骤模板弹窗 --------------------
|
||||
window.StepTemplatesDialog = {
|
||||
name: 'StepTemplatesDialog',
|
||||
props: {
|
||||
show: { type: Boolean, default: false }
|
||||
},
|
||||
emits: ['close', 'apply'],
|
||||
template: `
|
||||
<div v-if="show"
|
||||
class="fixed inset-0 bg-black/50 flex items-center justify-center z-40"
|
||||
@click.self="$emit('close')">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg p-6 w-[500px]">
|
||||
<h3 class="font-semibold dark:text-white mb-4">工作流模板</h3>
|
||||
<div class="space-y-2 mb-4">
|
||||
<button @click="$emit('apply', 'default')"
|
||||
class="w-full text-left p-3 border dark:border-gray-700 rounded hover:border-blue-400 dark:hover:border-blue-500 transition-colors">
|
||||
<div class="font-semibold text-sm dark:text-white">标准对话流程</div>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
||||
点击新建 → 填入 → 点击发送 → 等待 → 流式监听
|
||||
</div>
|
||||
</button>
|
||||
<button @click="$emit('apply', 'simple')"
|
||||
class="w-full text-left p-3 border dark:border-gray-700 rounded hover:border-blue-400 dark:hover:border-blue-500 transition-colors">
|
||||
<div class="font-semibold text-sm dark:text-white">简化流程</div>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
||||
填入 → 回车 → 流式监听
|
||||
</div>
|
||||
</button>
|
||||
<button @click="$emit('apply', 'battle_winner')"
|
||||
class="w-full text-left p-3 border dark:border-gray-700 rounded hover:border-amber-400 dark:hover:border-amber-500 transition-colors">
|
||||
<div class="font-semibold text-sm dark:text-white">Battle 赢家优先</div>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
||||
填入 → 点圆形重试 → 点方形发送 → 等待两侧结束,输出先完成的一侧
|
||||
</div>
|
||||
</button>
|
||||
<button @click="$emit('apply', 'battle_left')"
|
||||
class="w-full text-left p-3 border dark:border-gray-700 rounded hover:border-amber-400 dark:hover:border-amber-500 transition-colors">
|
||||
<div class="font-semibold text-sm dark:text-white">Battle 左侧</div>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
||||
填入 → 点圆形重试 → 点方形发送 → 流式输出左侧,等待两侧结束
|
||||
</div>
|
||||
</button>
|
||||
<button @click="$emit('apply', 'battle_right')"
|
||||
class="w-full text-left p-3 border dark:border-gray-700 rounded hover:border-amber-400 dark:hover:border-amber-500 transition-colors">
|
||||
<div class="font-semibold text-sm dark:text-white">Battle 右侧</div>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
||||
填入 → 点圆形重试 → 点方形发送 → 流式输出右侧,等待两侧结束
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button @click="$emit('close')"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2 py-0.5 text-sm">
|
||||
关闭
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
|
||||
// -------------------- 选择器测试弹窗 --------------------
|
||||
window.TestDialog = {
|
||||
name: 'TestDialog',
|
||||
props: {
|
||||
show: { type: Boolean, default: false },
|
||||
selector: { type: String, default: '' },
|
||||
selectorKey: { type: String, default: '' },
|
||||
timeoutValue: { type: Number, default: 2 },
|
||||
highlightEnabled: { type: Boolean, default: false },
|
||||
result: { type: Object, default: null },
|
||||
testing: { type: Boolean, default: false }
|
||||
},
|
||||
emits: ['close', 'test', 'apply-selector'],
|
||||
data() {
|
||||
return {
|
||||
selectorInput: '',
|
||||
timeout: 3,
|
||||
highlight: false,
|
||||
copyFeedback: ''
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
show: {
|
||||
handler(value) {
|
||||
if (value) {
|
||||
this.syncFromProps();
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
selector(value) {
|
||||
if (this.show) {
|
||||
this.selectorInput = value || '';
|
||||
}
|
||||
},
|
||||
timeoutValue(value) {
|
||||
if (this.show && Number.isFinite(value)) {
|
||||
this.timeout = value;
|
||||
}
|
||||
},
|
||||
highlightEnabled(value) {
|
||||
if (this.show) {
|
||||
this.highlight = !!value;
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
diagnosis() {
|
||||
return this.result && this.result.diagnosis ? this.result.diagnosis : null;
|
||||
},
|
||||
topCandidates() {
|
||||
return Array.isArray(this.result && this.result.top_candidates) ? this.result.top_candidates : [];
|
||||
},
|
||||
resultElements() {
|
||||
return Array.isArray(this.result && this.result.elements) ? this.result.elements : [];
|
||||
},
|
||||
selectorLabel() {
|
||||
const key = String(this.selectorKey || '').trim();
|
||||
const labelMap = {
|
||||
input_box: '输入框',
|
||||
send_btn: '发送按钮',
|
||||
result_container: '回复容器',
|
||||
new_chat_btn: '新建对话按钮',
|
||||
message_wrapper: '消息外层',
|
||||
generating_indicator: '生成中指示器',
|
||||
retry_send_btn: '重试/重新运行按钮',
|
||||
upload_btn: '上传按钮',
|
||||
file_input: '原生文件输入框',
|
||||
drop_zone: '拖拽区域'
|
||||
};
|
||||
return labelMap[key] || '当前字段';
|
||||
},
|
||||
canApplyCurrent() {
|
||||
return !!String(this.selectorInput || '').trim() && !!String(this.selectorKey || '').trim();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
syncFromProps() {
|
||||
this.selectorInput = this.selector || '';
|
||||
this.timeout = Number.isFinite(this.timeoutValue) ? this.timeoutValue : 3;
|
||||
this.highlight = !!this.highlightEnabled;
|
||||
this.copyFeedback = '';
|
||||
},
|
||||
async copyText(value) {
|
||||
const text = String(value || '').trim();
|
||||
if (!text) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
this.copyFeedback = '已复制到剪贴板';
|
||||
window.setTimeout(() => {
|
||||
if (this.copyFeedback === '已复制到剪贴板') {
|
||||
this.copyFeedback = '';
|
||||
}
|
||||
}, 1600);
|
||||
} catch (error) {
|
||||
this.copyFeedback = '复制失败';
|
||||
window.setTimeout(() => {
|
||||
if (this.copyFeedback === '复制失败') {
|
||||
this.copyFeedback = '';
|
||||
}
|
||||
}, 1600);
|
||||
}
|
||||
},
|
||||
useCandidate(selector) {
|
||||
this.selectorInput = String(selector || '').trim();
|
||||
},
|
||||
retestCandidate(selector) {
|
||||
this.selectorInput = String(selector || '').trim();
|
||||
if (!this.selectorInput) return;
|
||||
this.$emit('test', {
|
||||
selector: this.selectorInput,
|
||||
timeout: this.timeout,
|
||||
highlight: this.highlight
|
||||
});
|
||||
},
|
||||
applyCandidate(selector, rerun = false) {
|
||||
const value = String(selector || '').trim();
|
||||
if (!value) return;
|
||||
this.selectorInput = value;
|
||||
this.$emit('apply-selector', {
|
||||
selector: value,
|
||||
rerun
|
||||
});
|
||||
},
|
||||
applyCurrentSelector(rerun = false) {
|
||||
if (!this.canApplyCurrent) return;
|
||||
this.$emit('apply-selector', {
|
||||
selector: this.selectorInput,
|
||||
rerun
|
||||
});
|
||||
},
|
||||
resultToneClass() {
|
||||
const status = this.diagnosis && this.diagnosis.status;
|
||||
if (status === 'unique') {
|
||||
return 'bg-emerald-50 dark:bg-emerald-900/20 border-emerald-200 dark:border-emerald-800';
|
||||
}
|
||||
if (status === 'multiple') {
|
||||
return 'bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800';
|
||||
}
|
||||
return 'bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800';
|
||||
},
|
||||
uniqueBadgeClass(candidate) {
|
||||
return candidate && candidate.unique
|
||||
? 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300'
|
||||
: 'bg-slate-100 text-slate-600 dark:bg-slate-700 dark:text-slate-300';
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div v-if="show"
|
||||
class="fixed inset-0 bg-black/50 flex items-center justify-center z-40"
|
||||
@click.self="$emit('close')">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg p-6 w-[92vw] max-w-[980px] max-h-[88vh] overflow-hidden flex flex-col shadow-2xl">
|
||||
<div class="flex justify-between items-start gap-4 mb-4">
|
||||
<div>
|
||||
<h3 class="font-semibold dark:text-white text-lg">选择器测试工作台</h3>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
||||
不只是看“找到了没”,还会给出候选写法、风险提示和回填入口。
|
||||
</p>
|
||||
</div>
|
||||
<button @click="$emit('close')"
|
||||
class="text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300">
|
||||
<span v-html="$icons.xMark"></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)] gap-4 min-h-0 flex-1">
|
||||
<div class="min-h-0 overflow-auto pr-1 space-y-4">
|
||||
<div class="rounded-xl border border-slate-200 dark:border-slate-700 p-4 bg-slate-50/70 dark:bg-slate-900/30">
|
||||
<div class="flex flex-wrap items-center gap-2 mb-3">
|
||||
<span v-if="selectorKey"
|
||||
class="inline-flex items-center rounded-full bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-800 px-2.5 py-1 text-xs font-medium text-blue-700 dark:text-blue-300">
|
||||
当前字段:{{ selectorKey }} · {{ selectorLabel }}
|
||||
</span>
|
||||
<span v-if="copyFeedback"
|
||||
class="inline-flex items-center rounded-full bg-emerald-50 dark:bg-emerald-900/30 border border-emerald-200 dark:border-emerald-800 px-2.5 py-1 text-xs font-medium text-emerald-700 dark:text-emerald-300">
|
||||
{{ copyFeedback }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400 mb-2 block">测试选择器</label>
|
||||
<textarea v-model="selectorInput"
|
||||
rows="3"
|
||||
spellcheck="false"
|
||||
class="border dark:border-gray-700 px-3 py-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent w-full font-mono text-sm bg-white dark:bg-gray-700 dark:text-white resize-none"
|
||||
placeholder='例如: button[data-testid="send-button"]'></textarea>
|
||||
|
||||
<div class="mt-3 flex flex-wrap items-center gap-4">
|
||||
<label class="flex items-center gap-2 text-sm text-gray-600 dark:text-gray-300">
|
||||
<span>超时</span>
|
||||
<input v-model.number="timeout"
|
||||
type="number"
|
||||
min="1"
|
||||
max="10"
|
||||
class="border dark:border-gray-700 px-2 py-1 rounded w-20 bg-white dark:bg-gray-700 dark:text-white">
|
||||
<span class="text-xs text-gray-400">秒</span>
|
||||
</label>
|
||||
<label class="flex items-center text-sm cursor-pointer">
|
||||
<input type="checkbox" v-model="highlight" class="mr-2">
|
||||
<span class="dark:text-gray-300">🎨 高亮浏览器中的命中元素</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex flex-wrap gap-2">
|
||||
<button @click="$emit('test', { selector: selectorInput, timeout, highlight })"
|
||||
:disabled="!selectorInput.trim() || testing"
|
||||
class="border rounded-lg transition-colors bg-blue-500 text-white hover:bg-blue-600 border-blue-500 px-3 py-1.5 text-sm font-medium"
|
||||
:class="{'opacity-50 cursor-not-allowed': !selectorInput.trim() || testing}">
|
||||
{{ testing ? '测试中...' : '开始测试' }}
|
||||
</button>
|
||||
<button @click="applyCurrentSelector(false)"
|
||||
:disabled="!canApplyCurrent"
|
||||
class="border dark:border-gray-700 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-3 py-1.5 text-sm"
|
||||
:class="{'opacity-50 cursor-not-allowed': !canApplyCurrent}">
|
||||
回填当前字段
|
||||
</button>
|
||||
<button @click="applyCurrentSelector(true)"
|
||||
:disabled="!canApplyCurrent || testing"
|
||||
class="border dark:border-gray-700 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-3 py-1.5 text-sm"
|
||||
:class="{'opacity-50 cursor-not-allowed': !canApplyCurrent || testing}">
|
||||
回填并重测
|
||||
</button>
|
||||
<button @click="copyText(selectorInput)"
|
||||
:disabled="!selectorInput.trim()"
|
||||
class="border dark:border-gray-700 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-3 py-1.5 text-sm"
|
||||
:class="{'opacity-50 cursor-not-allowed': !selectorInput.trim()}">
|
||||
复制当前写法
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="result"
|
||||
class="rounded-xl border p-4"
|
||||
:class="resultToneClass()">
|
||||
<div class="flex flex-wrap items-center gap-2 mb-2">
|
||||
<span class="text-sm font-semibold dark:text-white">
|
||||
{{ result.success ? (result.count === 1 ? '✅ 唯一命中' : '⚠️ 命中多个元素') : '❌ 没有命中元素' }}
|
||||
</span>
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs bg-white/70 dark:bg-slate-800/70 text-slate-700 dark:text-slate-200">
|
||||
匹配数量:{{ result.count }}
|
||||
</span>
|
||||
<span v-if="result.locator_used"
|
||||
class="inline-flex items-center rounded-full px-2 py-0.5 text-xs bg-white/70 dark:bg-slate-800/70 text-slate-700 dark:text-slate-200">
|
||||
实际查询:{{ result.locator_used }}
|
||||
</span>
|
||||
<span v-if="result.tabs_tested"
|
||||
class="inline-flex items-center rounded-full px-2 py-0.5 text-xs bg-white/70 dark:bg-slate-800/70 text-slate-700 dark:text-slate-200">
|
||||
已测试 {{ result.tabs_tested }} 个页面,{{ result.matched_tabs }} 个页面命中
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p v-if="diagnosis" class="text-sm leading-6 text-slate-700 dark:text-slate-200">
|
||||
{{ diagnosis.summary }}
|
||||
</p>
|
||||
<p v-else-if="result.message" class="text-sm leading-6 text-slate-700 dark:text-slate-200">
|
||||
{{ result.message }}
|
||||
</p>
|
||||
|
||||
<div v-if="diagnosis && diagnosis.warnings && diagnosis.warnings.length" class="mt-3 space-y-2">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.14em] text-slate-500 dark:text-slate-400">风险提示</div>
|
||||
<div v-for="(warning, idx) in diagnosis.warnings" :key="'warn-' + idx"
|
||||
class="rounded-lg bg-white/70 dark:bg-slate-800/70 border border-white/80 dark:border-slate-700 px-3 py-2 text-sm text-amber-700 dark:text-amber-300">
|
||||
{{ warning }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="diagnosis && diagnosis.tips && diagnosis.tips.length" class="mt-3 space-y-2">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.14em] text-slate-500 dark:text-slate-400">下一步建议</div>
|
||||
<div v-for="(tip, idx) in diagnosis.tips" :key="'tip-' + idx"
|
||||
class="rounded-lg bg-white/70 dark:bg-slate-800/70 border border-white/80 dark:border-slate-700 px-3 py-2 text-sm text-slate-700 dark:text-slate-200">
|
||||
{{ tip }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="result.tabs && result.tabs.length" class="mt-3 space-y-2">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.14em] text-slate-500 dark:text-slate-400">逐页结果</div>
|
||||
<div v-for="tab in result.tabs"
|
||||
:key="tab.tab_id || tab.session_id || tab.url"
|
||||
class="rounded-lg bg-white/70 dark:bg-slate-800/70 border border-white/80 dark:border-slate-700 px-3 py-2 text-sm text-slate-700 dark:text-slate-200">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="font-medium">{{ tab.tab_index ? '页面 #' + tab.tab_index : '浏览器页面' }}</span>
|
||||
<span :class="tab.count > 0 ? 'text-emerald-600 dark:text-emerald-300' : 'text-red-600 dark:text-red-300'">
|
||||
{{ tab.count > 0 ? '命中 ' + tab.count + ' 个' : '未命中' }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="tab.url" class="mt-1 text-xs text-slate-500 dark:text-slate-400 truncate" :title="tab.url">{{ tab.url }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="result.skipped_busy_tabs"
|
||||
class="mt-3 rounded-lg bg-amber-50/80 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 px-3 py-2 text-sm text-amber-700 dark:text-amber-300">
|
||||
另有 {{ result.skipped_busy_tabs }} 个同站点页面正在执行任务,本次未打断它们。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="topCandidates.length"
|
||||
class="rounded-xl border border-slate-200 dark:border-slate-700 p-4 bg-white dark:bg-slate-900/20">
|
||||
<div class="flex items-center justify-between gap-3 mb-3">
|
||||
<div>
|
||||
<div class="text-sm font-semibold text-slate-900 dark:text-white">推荐候选选择器</div>
|
||||
<div class="text-xs text-slate-500 dark:text-slate-400">优先把更稳、更容易唯一命中的写法拿去复测。</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-3">
|
||||
<div v-for="(candidate, idx) in topCandidates"
|
||||
:key="candidate.selector + '-' + idx"
|
||||
class="rounded-xl border border-slate-200 dark:border-slate-700 p-3 bg-slate-50/70 dark:bg-slate-800/60">
|
||||
<div class="flex flex-wrap items-center gap-2 mb-2">
|
||||
<span class="text-xs font-semibold text-slate-400 dark:text-slate-500">候选 {{ idx + 1 }}</span>
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium"
|
||||
:class="uniqueBadgeClass(candidate)">
|
||||
{{ candidate.unique ? '唯一命中' : '匹配 ' + candidate.count + ' 个' }}
|
||||
</span>
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs bg-slate-100 text-slate-600 dark:bg-slate-700 dark:text-slate-300">
|
||||
{{ candidate.reason }}
|
||||
</span>
|
||||
</div>
|
||||
<code class="block whitespace-pre-wrap break-all rounded-lg bg-slate-950 px-3 py-2 text-xs leading-6 text-slate-100">{{ candidate.selector }}</code>
|
||||
<div class="mt-3 flex flex-wrap gap-2">
|
||||
<button @click="useCandidate(candidate.selector)"
|
||||
class="border dark:border-gray-700 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-3 py-1 text-xs">
|
||||
代入输入框
|
||||
</button>
|
||||
<button @click="retestCandidate(candidate.selector)"
|
||||
:disabled="testing"
|
||||
class="border dark:border-gray-700 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-3 py-1 text-xs"
|
||||
:class="{'opacity-50 cursor-not-allowed': testing}">
|
||||
代入并重测
|
||||
</button>
|
||||
<button v-if="selectorKey"
|
||||
@click="applyCandidate(candidate.selector, false)"
|
||||
class="border dark:border-gray-700 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-3 py-1 text-xs">
|
||||
回填字段
|
||||
</button>
|
||||
<button @click="copyText(candidate.selector)"
|
||||
class="border dark:border-gray-700 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-3 py-1 text-xs">
|
||||
复制
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="min-h-0 overflow-auto pl-1 space-y-4">
|
||||
<div class="rounded-xl border border-slate-200 dark:border-slate-700 p-4 bg-white dark:bg-slate-900/20">
|
||||
<div class="text-sm font-semibold text-slate-900 dark:text-white mb-2">命中详情</div>
|
||||
<div class="text-xs text-slate-500 dark:text-slate-400 mb-3">
|
||||
{{ result ? '已展开 ' + resultElements.length + ' 个元素详情' + (result.truncated ? '(其余命中已省略)' : '') : '先跑一次测试,这里会显示命中的元素摘要和属性。' }}
|
||||
</div>
|
||||
|
||||
<div v-if="!result" class="rounded-lg border border-dashed border-slate-300 dark:border-slate-700 px-3 py-6 text-sm text-slate-500 dark:text-slate-400 text-center">
|
||||
暂无测试结果
|
||||
</div>
|
||||
|
||||
<div v-else-if="!resultElements.length" class="rounded-lg border border-dashed border-slate-300 dark:border-slate-700 px-3 py-6 text-sm text-slate-500 dark:text-slate-400 text-center">
|
||||
这次没有拿到可展示的元素摘要
|
||||
</div>
|
||||
|
||||
<div v-else class="space-y-3">
|
||||
<div v-for="element in resultElements"
|
||||
:key="'element-' + element.index"
|
||||
class="rounded-xl border border-slate-200 dark:border-slate-700 p-3 bg-slate-50/70 dark:bg-slate-800/60">
|
||||
<div class="flex flex-wrap items-center gap-2 mb-2">
|
||||
<span class="text-xs font-semibold text-slate-400 dark:text-slate-500">#{{ element.index + 1 }}</span>
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs bg-slate-100 text-slate-700 dark:bg-slate-700 dark:text-slate-200">
|
||||
<{{ element.tag || 'unknown' }}>
|
||||
</span>
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs"
|
||||
:class="element.visible ? 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300' : 'bg-slate-100 text-slate-600 dark:bg-slate-700 dark:text-slate-300'">
|
||||
{{ element.visible ? '可见' : '不可见/尺寸为 0' }}
|
||||
</span>
|
||||
<span v-if="element.rect"
|
||||
class="inline-flex items-center rounded-full px-2 py-0.5 text-xs bg-slate-100 text-slate-600 dark:bg-slate-700 dark:text-slate-300">
|
||||
{{ element.rect.width }}×{{ element.rect.height }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-if="element.text"
|
||||
class="text-sm leading-6 text-slate-700 dark:text-slate-200 mb-2">
|
||||
{{ element.text }}
|
||||
</div>
|
||||
|
||||
<div v-if="element.attributes && Object.keys(element.attributes).length"
|
||||
class="flex flex-wrap gap-2 mb-2">
|
||||
<span v-for="(value, key) in element.attributes"
|
||||
:key="key"
|
||||
class="inline-flex max-w-full items-center rounded-full border border-slate-200 dark:border-slate-700 bg-white/80 dark:bg-slate-900/70 px-2.5 py-1 text-[11px] text-slate-600 dark:text-slate-300">
|
||||
<strong class="mr-1">{{ key }}</strong>
|
||||
<span class="truncate">{{ value }}</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<details v-if="element.html_preview" class="mb-2">
|
||||
<summary class="cursor-pointer text-xs font-medium text-blue-600 dark:text-blue-300">查看 HTML 摘要</summary>
|
||||
<pre class="mt-2 whitespace-pre-wrap break-all rounded-lg bg-slate-950 px-3 py-2 text-[11px] leading-5 text-slate-100">{{ element.html_preview }}</pre>
|
||||
</details>
|
||||
|
||||
<div v-if="element.warnings && element.warnings.length" class="space-y-1 mb-2">
|
||||
<div v-for="(warning, idx) in element.warnings"
|
||||
:key="'element-warning-' + element.index + '-' + idx"
|
||||
class="rounded-lg bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 px-3 py-2 text-xs text-amber-700 dark:text-amber-300">
|
||||
{{ warning }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="element.candidate_selectors && element.candidate_selectors.length" class="space-y-2">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.14em] text-slate-400 dark:text-slate-500">这个元素的候选</div>
|
||||
<div v-for="candidate in element.candidate_selectors"
|
||||
:key="candidate.selector"
|
||||
class="rounded-lg border border-slate-200 dark:border-slate-700 bg-white/80 dark:bg-slate-900/70 p-2">
|
||||
<div class="flex flex-wrap items-center gap-2 mb-1">
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium"
|
||||
:class="uniqueBadgeClass(candidate)">
|
||||
{{ candidate.unique ? '唯一命中' : '匹配 ' + candidate.count + ' 个' }}
|
||||
</span>
|
||||
<span class="text-[11px] text-slate-500 dark:text-slate-400">{{ candidate.reason }}</span>
|
||||
</div>
|
||||
<code class="block whitespace-pre-wrap break-all text-[11px] leading-5 text-slate-700 dark:text-slate-100">{{ candidate.selector }}</code>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<button @click="useCandidate(candidate.selector)"
|
||||
class="border dark:border-gray-700 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2.5 py-1 text-[11px]">
|
||||
代入
|
||||
</button>
|
||||
<button @click="copyText(candidate.selector)"
|
||||
class="border dark:border-gray-700 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-2.5 py-1 text-[11px]">
|
||||
复制
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<button @click="$emit('close')"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-3 py-1.5 text-sm">
|
||||
关闭
|
||||
</button>
|
||||
<button @click="$emit('test', { selector: selectorInput, timeout, highlight })"
|
||||
:disabled="!selectorInput.trim() || testing"
|
||||
class="border rounded transition-colors bg-blue-500 text-white hover:bg-blue-600 border-blue-500 px-3 py-1.5 text-sm font-medium"
|
||||
:class="{'opacity-50 cursor-not-allowed': !selectorInput.trim() || testing}">
|
||||
{{ testing ? '测试中...' : '重新测试' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
|
||||
// -------------------- 导入确认弹窗 --------------------
|
||||
window.ImportDialog = {
|
||||
name: 'ImportDialog',
|
||||
props: {
|
||||
show: { type: Boolean, default: false },
|
||||
fileName: { type: String, default: '' },
|
||||
importType: { type: String, default: 'full' },
|
||||
suggestedDomain: { type: String, default: '' },
|
||||
importedConfig: { type: Object, default: null }
|
||||
},
|
||||
emits: ['close', 'confirm'],
|
||||
data() {
|
||||
return {
|
||||
mode: 'merge',
|
||||
singleDomain: ''
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
show(val) {
|
||||
if (val) {
|
||||
this.mode = 'merge';
|
||||
this.singleDomain = this.suggestedDomain || '';
|
||||
}
|
||||
},
|
||||
suggestedDomain(val) {
|
||||
if (this.show && !this.singleDomain.trim()) {
|
||||
this.singleDomain = val || '';
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
singleImportHint() {
|
||||
if (this.suggestedDomain) {
|
||||
return '已从导入文件推断站点名,直接确认即可,也可以手动修改。';
|
||||
}
|
||||
return '未识别出站点名时,再手动补充即可。';
|
||||
},
|
||||
mergeDescription() {
|
||||
if (this.importType === 'single') {
|
||||
return '保留当前站点里未导入的预设;导入文件中的同名预设会被覆盖。';
|
||||
}
|
||||
return '只导入文件里的站点;同名站点整站覆盖,未出现在文件中的站点会保留。';
|
||||
},
|
||||
replaceDescription() {
|
||||
if (this.importType === 'single') {
|
||||
return '用导入文件完整替换这个站点,当前站点已有预设和设置都会被清掉。';
|
||||
}
|
||||
return '先清空当前全部站点配置,再写入导入文件中的站点。';
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div v-if="show"
|
||||
class="fixed inset-0 bg-black/50 flex items-center justify-center z-40"
|
||||
@click.self="$emit('close')">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg p-6 w-[450px]">
|
||||
<h3 class="font-semibold dark:text-white mb-4">导入配置</h3>
|
||||
|
||||
<div class="mb-4 p-3 bg-gray-50 dark:bg-gray-900 rounded border dark:border-gray-700">
|
||||
<div class="text-sm dark:text-gray-300">
|
||||
<span class="text-gray-600 dark:text-gray-400">文件:</span> {{ fileName }}
|
||||
</div>
|
||||
<div class="text-sm dark:text-gray-300 mt-1">
|
||||
<span class="text-gray-600 dark:text-gray-400">类型:</span>
|
||||
{{ importType === 'single' ? '单站点配置' : '全量配置 (' + Object.keys(importedConfig || {}).length + ' 个站点)' }}
|
||||
</div>
|
||||
<div v-if="importType === 'full' && importedConfig"
|
||||
class="text-xs text-gray-500 dark:text-gray-400 mt-2 max-h-24 overflow-auto">
|
||||
{{ Object.keys(importedConfig).join(', ') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 单站点导入时需要输入域名 -->
|
||||
<div v-if="importType === 'single'" class="mb-4">
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400 mb-2 block">站点名</label>
|
||||
<input v-model="singleDomain"
|
||||
placeholder="例如: chat.openai.com"
|
||||
class="border dark:border-gray-700 px-3 py-2 rounded w-full text-sm bg-white dark:bg-gray-700 dark:text-white">
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">{{ singleImportHint }}</p>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400 mb-2 block">导入模式</label>
|
||||
<div class="space-y-2">
|
||||
<label class="flex items-center cursor-pointer">
|
||||
<input type="radio" v-model="mode" value="merge" class="mr-2">
|
||||
<span class="dark:text-gray-300">合并导入</span>
|
||||
<span class="text-xs text-gray-500 dark:text-gray-400 ml-2">({{ mergeDescription }})</span>
|
||||
</label>
|
||||
<label class="flex items-center cursor-pointer">
|
||||
<input type="radio" v-model="mode" value="replace" class="mr-2">
|
||||
<span class="dark:text-gray-300">完全替换</span>
|
||||
<span class="text-xs text-gray-500 dark:text-gray-400 ml-2">({{ replaceDescription }})</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<button @click="$emit('close')"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-3 py-1 text-sm">
|
||||
取消
|
||||
</button>
|
||||
<button @click="$emit('confirm', { mode, domain: singleDomain })"
|
||||
:disabled="importType === 'single' && !singleDomain.trim()"
|
||||
:class="['border rounded transition-colors px-3 py-1 text-sm',
|
||||
importType === 'single' && !singleDomain.trim()
|
||||
? 'bg-blue-400 cursor-not-allowed opacity-70 text-white border-blue-400'
|
||||
: 'bg-blue-500 text-white hover:bg-blue-600 border-blue-500']">
|
||||
确认导入
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
|
||||
// -------------------- 新增/编辑元素定义弹窗 --------------------
|
||||
window.DefinitionDialog = {
|
||||
name: 'DefinitionDialog',
|
||||
props: {
|
||||
show: { type: Boolean, default: false },
|
||||
editIndex: { type: Number, default: null },
|
||||
definition: { type: Object, default: () => ({ key: '', description: '', enabled: true }) }
|
||||
},
|
||||
emits: ['close', 'save'],
|
||||
data() {
|
||||
return {
|
||||
form: { key: '', description: '', enabled: true }
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
show(val) {
|
||||
if (val) {
|
||||
this.form = { ...this.definition };
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isEdit() {
|
||||
return this.editIndex !== null;
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div v-if="show"
|
||||
class="fixed inset-0 bg-black/50 flex items-center justify-center z-40"
|
||||
@click.self="$emit('close')">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg p-6 w-[500px]">
|
||||
<h3 class="font-semibold dark:text-white mb-4">
|
||||
{{ isEdit ? '编辑元素定义' : '新增元素定义' }}
|
||||
</h3>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400 mb-2 block">关键词 (key)</label>
|
||||
<input v-model="form.key"
|
||||
:disabled="isEdit && definition.required"
|
||||
placeholder="例如: temp_chat_btn"
|
||||
class="border dark:border-gray-700 px-3 py-2 rounded w-full font-mono text-sm bg-white dark:bg-gray-700 dark:text-white disabled:opacity-50">
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
||||
用于工作流配置中引用此元素
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400 mb-2 block">描述 (发送给 AI)</label>
|
||||
<textarea v-model="form.description"
|
||||
placeholder="例如: 临时对话/隐私模式的切换按钮"
|
||||
rows="3"
|
||||
class="border dark:border-gray-700 px-3 py-2 rounded w-full text-sm bg-white dark:bg-gray-700 dark:text-white resize-none"></textarea>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
||||
AI 会根据这个描述在页面中查找对应的元素
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-sm dark:text-gray-300">默认启用</span>
|
||||
<label class="toggle-label">
|
||||
<input type="checkbox" v-model="form.enabled" class="sr-only peer">
|
||||
<div class="toggle-bg"></div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2 mt-6">
|
||||
<button @click="$emit('close')"
|
||||
class="border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white transition-colors px-4 py-2 text-sm">
|
||||
取消
|
||||
</button>
|
||||
<button @click="$emit('save', form)"
|
||||
class="border rounded transition-colors bg-blue-500 text-white hover:bg-blue-600 border-blue-500 px-4 py-2 text-sm">
|
||||
{{ isEdit ? '保存' : '添加' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
@@ -0,0 +1,276 @@
|
||||
// ==================== 提取器管理 Tab 组件 ====================
|
||||
window.ExtractorTab = {
|
||||
name: 'ExtractorTab',
|
||||
props: {
|
||||
extractors: { type: Array, default: () => [] },
|
||||
defaultExtractorId: { type: String, default: '' },
|
||||
sites: { type: Object, default: () => ({}) },
|
||||
isLoading: { type: Boolean, default: false }
|
||||
},
|
||||
emits: [
|
||||
'set-default',
|
||||
'export-config',
|
||||
'import-config',
|
||||
'set-site-extractor',
|
||||
'open-verify-dialog',
|
||||
'refresh'
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
activeSection: 'extractors', // 'extractors' | 'bindings'
|
||||
searchQuery: '',
|
||||
showImportDialog: false,
|
||||
importText: '',
|
||||
importError: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 过滤后的站点列表
|
||||
filteredSites() {
|
||||
const domains = Object.keys(this.sites);
|
||||
if (!this.searchQuery) return domains;
|
||||
const query = this.searchQuery.toLowerCase();
|
||||
return domains.filter(d => d.toLowerCase().includes(query));
|
||||
},
|
||||
|
||||
// 获取站点的提取器信息
|
||||
getSiteExtractorInfo() {
|
||||
return (domain) => {
|
||||
const site = this.sites[domain];
|
||||
const extractorId = site?.extractor_id || this.defaultExtractorId;
|
||||
const extractor = this.extractors.find(e => e.id === extractorId);
|
||||
return {
|
||||
id: extractorId,
|
||||
name: extractor?.name || extractorId,
|
||||
verified: site?.extractor_verified || false,
|
||||
isDefault: !site?.extractor_id
|
||||
};
|
||||
};
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleImport() {
|
||||
this.importError = '';
|
||||
try {
|
||||
const config = JSON.parse(this.importText);
|
||||
if (!config.extractors) {
|
||||
this.importError = '无效的配置格式:缺少 extractors 字段';
|
||||
return;
|
||||
}
|
||||
this.$emit('import-config', config);
|
||||
this.showImportDialog = false;
|
||||
this.importText = '';
|
||||
} catch (e) {
|
||||
this.importError = 'JSON 解析失败: ' + e.message;
|
||||
}
|
||||
},
|
||||
|
||||
openImportDialog() {
|
||||
this.importText = '';
|
||||
this.importError = '';
|
||||
this.showImportDialog = true;
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="h-full flex flex-col">
|
||||
<!-- 顶部标签切换 -->
|
||||
<div class="border-b dark:border-gray-700 bg-white dark:bg-gray-800 px-4">
|
||||
<div class="flex gap-4">
|
||||
<button @click="activeSection = 'extractors'"
|
||||
:class="['py-3 px-1 border-b-2 font-medium text-sm transition-colors',
|
||||
activeSection === 'extractors'
|
||||
? 'border-blue-500 text-blue-600 dark:text-blue-400'
|
||||
: 'border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200']">
|
||||
📦 提取器列表
|
||||
</button>
|
||||
<button @click="activeSection = 'bindings'"
|
||||
:class="['py-3 px-1 border-b-2 font-medium text-sm transition-colors',
|
||||
activeSection === 'bindings'
|
||||
? 'border-blue-500 text-blue-600 dark:text-blue-400'
|
||||
: 'border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200']">
|
||||
🔗 站点绑定
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<div class="flex-1 overflow-auto p-4">
|
||||
<!-- 加载状态 -->
|
||||
<div v-if="isLoading" class="flex items-center justify-center h-full">
|
||||
<div class="text-gray-500 dark:text-gray-400">
|
||||
<span class="animate-spin inline-block mr-2">⏳</span> 加载中...
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 提取器列表 -->
|
||||
<div v-else-if="activeSection === 'extractors'" class="space-y-4">
|
||||
<!-- 操作栏 -->
|
||||
<div class="flex justify-between items-center">
|
||||
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">
|
||||
可用提取器 ({{ extractors.length }})
|
||||
</h3>
|
||||
<div class="flex gap-2">
|
||||
<button @click="$emit('refresh')"
|
||||
class="px-3 py-1.5 text-sm border dark:border-gray-600 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 transition-colors">
|
||||
🔄 刷新
|
||||
</button>
|
||||
<button @click="openImportDialog"
|
||||
class="px-3 py-1.5 text-sm border dark:border-gray-600 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 transition-colors">
|
||||
📥 导入
|
||||
</button>
|
||||
<button @click="$emit('export-config')"
|
||||
class="px-3 py-1.5 text-sm border dark:border-gray-600 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 transition-colors">
|
||||
📤 导出
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 提取器卡片列表 -->
|
||||
<div class="grid gap-4">
|
||||
<div v-for="extractor in extractors" :key="extractor.id"
|
||||
class="bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg p-4 hover:shadow-md transition-shadow">
|
||||
<div class="flex justify-between items-start">
|
||||
<div class="flex-1">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="font-semibold text-gray-900 dark:text-white">
|
||||
{{ extractor.name }}
|
||||
</span>
|
||||
<span v-if="extractor.id === defaultExtractorId"
|
||||
class="px-2 py-0.5 text-xs bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 rounded-full">
|
||||
默认
|
||||
</span>
|
||||
<span v-if="!extractor.enabled"
|
||||
class="px-2 py-0.5 text-xs bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 rounded-full">
|
||||
已禁用
|
||||
</span>
|
||||
</div>
|
||||
<div class="text-sm text-gray-500 dark:text-gray-400 mt-1">
|
||||
ID: <code class="bg-gray-100 dark:bg-gray-700 px-1 rounded">{{ extractor.id }}</code>
|
||||
</div>
|
||||
<div class="text-sm text-gray-600 dark:text-gray-300 mt-2">
|
||||
{{ extractor.description || '暂无描述' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2 ml-4">
|
||||
<button v-if="extractor.id !== defaultExtractorId"
|
||||
@click="$emit('set-default', extractor.id)"
|
||||
class="px-3 py-1 text-sm text-blue-600 dark:text-blue-400 border border-blue-300 dark:border-blue-600 rounded hover:bg-blue-50 dark:hover:bg-blue-900/30 transition-colors">
|
||||
设为默认
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="extractors.length === 0"
|
||||
class="text-center py-12 text-gray-400 dark:text-gray-500">
|
||||
暂无可用的提取器
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 站点绑定 -->
|
||||
<div v-else-if="activeSection === 'bindings'" class="space-y-4">
|
||||
<!-- 搜索和说明 -->
|
||||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">站点提取器绑定</h3>
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400 mt-1">
|
||||
为每个站点指定使用的提取算法
|
||||
</p>
|
||||
</div>
|
||||
<input v-model="searchQuery"
|
||||
type="search"
|
||||
placeholder="搜索站点..."
|
||||
class="border dark:border-gray-600 px-3 py-1.5 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-400">
|
||||
</div>
|
||||
|
||||
<!-- 站点列表 -->
|
||||
<div class="space-y-2">
|
||||
<div v-for="domain in filteredSites" :key="domain"
|
||||
class="bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg p-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex-1">
|
||||
<div class="font-medium text-gray-900 dark:text-white">{{ domain }}</div>
|
||||
<div class="flex items-center gap-2 mt-1">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">
|
||||
当前: {{ getSiteExtractorInfo(domain).name }}
|
||||
</span>
|
||||
<span v-if="getSiteExtractorInfo(domain).isDefault"
|
||||
class="text-xs text-gray-400 dark:text-gray-500">
|
||||
(使用默认)
|
||||
</span>
|
||||
<span v-if="getSiteExtractorInfo(domain).verified"
|
||||
class="px-1.5 py-0.5 text-xs bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-300 rounded">
|
||||
✓ 已验证
|
||||
</span>
|
||||
<span v-else
|
||||
class="px-1.5 py-0.5 text-xs bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300 rounded">
|
||||
⚠ 未验证
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<select @change="$emit('set-site-extractor', domain, $event.target.value)"
|
||||
:value="getSiteExtractorInfo(domain).id"
|
||||
class="border dark:border-gray-600 px-2 py-1.5 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-400">
|
||||
<option v-for="ext in extractors" :key="ext.id" :value="ext.id">
|
||||
{{ ext.name }}
|
||||
</option>
|
||||
</select>
|
||||
<button @click="$emit('open-verify-dialog', domain)"
|
||||
class="px-3 py-1.5 text-sm text-blue-600 dark:text-blue-400 border border-blue-300 dark:border-blue-600 rounded hover:bg-blue-50 dark:hover:bg-blue-900/30 transition-colors">
|
||||
测试
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="filteredSites.length === 0"
|
||||
class="text-center py-12 text-gray-400 dark:text-gray-500">
|
||||
{{ searchQuery ? '无匹配结果' : '暂无站点配置' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<div v-if="showImportDialog"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"
|
||||
@click.self="showImportDialog = false">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg mx-4">
|
||||
<div class="px-4 py-3 border-b dark:border-gray-700 flex justify-between items-center">
|
||||
<h3 class="font-semibold text-gray-900 dark:text-white">导入提取器配置</h3>
|
||||
<button @click="showImportDialog = false"
|
||||
class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200">
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
<div class="p-4 space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
||||
粘贴 extractors.json 内容
|
||||
</label>
|
||||
<textarea v-model="importText"
|
||||
rows="10"
|
||||
class="w-full border dark:border-gray-600 rounded-md p-2 font-mono text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-400"
|
||||
placeholder='{"extractors": {...}, "default": "..."}'></textarea>
|
||||
</div>
|
||||
<div v-if="importError" class="text-sm text-red-500">
|
||||
{{ importError }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-4 py-3 border-t dark:border-gray-700 flex justify-end gap-2">
|
||||
<button @click="showImportDialog = false"
|
||||
class="px-4 py-2 text-sm text-gray-700 dark:text-gray-200 border dark:border-gray-600 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors">
|
||||
取消
|
||||
</button>
|
||||
<button @click="handleImport"
|
||||
class="px-4 py-2 text-sm text-white bg-blue-500 rounded-md hover:bg-blue-600 transition-colors">
|
||||
导入
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
@@ -0,0 +1,181 @@
|
||||
window.HomeTab = {
|
||||
name: 'HomeTab',
|
||||
props: {
|
||||
sites: { type: Object, default: () => ({}) },
|
||||
browserStatus: { type: Object, default: () => ({ connected: false }) },
|
||||
systemStats: { type: Object, default: () => ({}) },
|
||||
records: { type: Array, default: () => [] }
|
||||
},
|
||||
emits: ['change-tab', 'add-site', 'notify'],
|
||||
computed: {
|
||||
siteCount() {
|
||||
return Object.keys(this.sites || {}).length;
|
||||
},
|
||||
sortedRecords() {
|
||||
return (Array.isArray(this.records) ? this.records : []).slice().sort((a, b) => {
|
||||
return this.recordTimestamp(b) - this.recordTimestamp(a);
|
||||
});
|
||||
},
|
||||
recentRecords() {
|
||||
return this.sortedRecords.slice(0, 3);
|
||||
},
|
||||
totalRequests() {
|
||||
const reported = Number(this.systemStats && this.systemStats.total_requests || 0);
|
||||
return reported > 0 ? reported : this.sortedRecords.length;
|
||||
},
|
||||
averageDurationMs() {
|
||||
const completed = this.sortedRecords.filter(record => {
|
||||
return record && record.success && Number(record.duration_ms || 0) > 0;
|
||||
});
|
||||
if (!completed.length) return 0;
|
||||
return Math.round(completed.reduce((total, record) => total + Number(record.duration_ms || 0), 0) / completed.length);
|
||||
},
|
||||
baseUrl() {
|
||||
const origin = typeof window !== 'undefined' ? window.location.origin : 'http://127.0.0.1:8199';
|
||||
return origin + '/v1';
|
||||
},
|
||||
heroTitle() {
|
||||
return this.browserStatus && this.browserStatus.connected
|
||||
? '本地 API 已准备就绪'
|
||||
: '本地 API 正在等待浏览器';
|
||||
},
|
||||
browserLabel() {
|
||||
if (!(this.browserStatus && this.browserStatus.connected)) return '等待浏览器连接';
|
||||
// 修复:此前读的 tab_title / tab_url 后端从未返回(health_check 只产出
|
||||
// status/connected/port/tab_pool/error),导致这里恒为兜底文案。
|
||||
// 改用 health 里真实存在的 tab_pool 概览。
|
||||
const pool = this.browserStatus.tab_pool;
|
||||
if (pool && typeof pool === 'object') {
|
||||
const total = Number(pool.total || 0);
|
||||
const busy = Number(pool.busy || 0);
|
||||
const idle = Number(pool.idle || 0);
|
||||
if (total > 0) return `受控浏览器已连接 · ${total} 个标签页(忙碌 ${busy} / 空闲 ${idle})`;
|
||||
}
|
||||
return '受控浏览器已连接';
|
||||
},
|
||||
latestRecord() {
|
||||
return this.sortedRecords[0] || null;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
recordTimestamp(record) {
|
||||
return Number(record && (record.finished_at || record.started_at || record.created_at || record.timestamp) || 0);
|
||||
},
|
||||
recordDomain(record) {
|
||||
return String(record && (record.domain || record.site_domain || record.target_domain || record.model || record.route_group) || '未知站点');
|
||||
},
|
||||
recordStatus(record) {
|
||||
if (record && record.success) return '成功';
|
||||
if (record && record.status === 'cancelled') return '已取消';
|
||||
return '失败';
|
||||
},
|
||||
recordStatusClass(record) {
|
||||
if (record && record.success) return 'is-success';
|
||||
if (record && record.status === 'cancelled') return 'is-cancelled';
|
||||
return 'is-failed';
|
||||
},
|
||||
recordDuration(record) {
|
||||
const value = Number(record && record.duration_ms || 0);
|
||||
if (!value) return '-';
|
||||
return value >= 1000 ? (value / 1000).toFixed(value >= 10000 ? 1 : 2) + 's' : Math.round(value) + 'ms';
|
||||
},
|
||||
recordTime(record) {
|
||||
const timestamp = this.recordTimestamp(record);
|
||||
if (!timestamp) return '-';
|
||||
return new Date(timestamp * 1000).toLocaleTimeString('zh-CN', {
|
||||
hour: '2-digit', minute: '2-digit', second: '2-digit'
|
||||
});
|
||||
},
|
||||
averageDurationText() {
|
||||
if (!this.averageDurationMs) return '-';
|
||||
return this.recordDuration({ duration_ms: this.averageDurationMs });
|
||||
},
|
||||
async copyBaseUrl() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(this.baseUrl);
|
||||
this.$emit('notify', { message: 'API 地址已复制', type: 'success' });
|
||||
} catch (error) {
|
||||
this.$emit('notify', { message: '复制失败,请手动复制地址', type: 'error' });
|
||||
}
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<section class="uwa-home-view" aria-labelledby="home-title">
|
||||
<div class="uwa-hero-band">
|
||||
<div class="uwa-hero-copy">
|
||||
<div class="uwa-ready-label"><span v-html="$icons.activity"></span> Web to API, ready</div>
|
||||
<h1 id="home-title">{{ heroTitle }}</h1>
|
||||
<p>连接已登录的 AI 网页,把常用模型作为兼容 OpenAI / Anthropic 的本地接口使用。</p>
|
||||
</div>
|
||||
<div class="uwa-hero-art" aria-hidden="true">
|
||||
<i class="shape-a"></i><i class="shape-b"></i><i class="shape-c"></i>
|
||||
<i class="line-a"></i><i class="line-b"></i>
|
||||
<i class="node-a"></i><i class="node-b"></i><i class="node-c"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uwa-health-strip" aria-label="服务概览">
|
||||
<div class="uwa-health-item">
|
||||
<span class="uwa-health-icon is-service" v-html="$icons.activity"></span>
|
||||
<div><span>服务状态</span><strong>{{ browserStatus.connected ? '运行正常' : '等待浏览器' }}</strong></div>
|
||||
</div>
|
||||
<div class="uwa-health-item">
|
||||
<span class="uwa-health-icon is-sites" v-html="$icons.globe"></span>
|
||||
<div><span>可用站点</span><strong>{{ siteCount }} 个站点</strong></div>
|
||||
</div>
|
||||
<div class="uwa-health-item">
|
||||
<span class="uwa-health-icon is-requests" v-html="$icons.arrowPathRoundedSquare"></span>
|
||||
<div><span>累计请求</span><strong>{{ totalRequests.toLocaleString('zh-CN') }} 次</strong></div>
|
||||
</div>
|
||||
<div class="uwa-health-item">
|
||||
<span class="uwa-health-icon is-latency" v-html="$icons.timer"></span>
|
||||
<div><span>样本平均响应</span><strong>{{ averageDurationText() }}</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uwa-section-heading">
|
||||
<div><h2>开始使用</h2><p>选择当前最需要处理的任务。</p></div>
|
||||
<button type="button" class="uwa-text-button" @click="$emit('change-tab', 'monitor')">查看运行详情 <span v-html="$icons.arrowRight"></span></button>
|
||||
</div>
|
||||
|
||||
<div class="uwa-action-grid">
|
||||
<article class="uwa-action-card is-api">
|
||||
<div class="uwa-card-topline"><span class="uwa-feature-icon is-mint" v-html="$icons.arrowPathRoundedSquare"></span><span class="uwa-soft-tag">本机</span></div>
|
||||
<h3>连接 API 客户端</h3>
|
||||
<p>复制当前服务 Base URL,在兼容 OpenAI 的客户端中直接使用。</p>
|
||||
<div class="uwa-endpoint-box"><code>{{ baseUrl }}</code><button type="button" @click="copyBaseUrl" title="复制 API 地址" aria-label="复制 API 地址" v-html="$icons.copy"></button></div>
|
||||
<button type="button" class="uwa-primary-button" @click="copyBaseUrl">复制 API 地址 <span v-html="$icons.arrowRight"></span></button>
|
||||
</article>
|
||||
|
||||
<article class="uwa-action-card is-browser">
|
||||
<div class="uwa-card-topline"><span class="uwa-feature-icon is-olive" v-html="$icons.folderOpen"></span><span class="uwa-soft-tag">{{ browserStatus.connected ? '已连接' : '未连接' }}</span></div>
|
||||
<h3>管理受控浏览器</h3>
|
||||
<p>检查当前浏览器连接与标签页占用情况,快速定位失效会话。</p>
|
||||
<div class="uwa-browser-preview">
|
||||
<div><i></i><i></i><i></i><span>{{ browserStatus.connected ? '浏览器在线' : '浏览器离线' }}</span></div>
|
||||
<strong :title="browserLabel">{{ browserLabel }}</strong>
|
||||
</div>
|
||||
<button type="button" class="uwa-primary-button" @click="$emit('change-tab', 'tabpool')">查看标签页池 <span v-html="$icons.arrowRight"></span></button>
|
||||
</article>
|
||||
|
||||
<article class="uwa-action-card is-monitor">
|
||||
<div class="uwa-card-topline"><span class="uwa-feature-icon is-ochre" v-html="$icons.activity"></span><span class="uwa-soft-tag">实时</span></div>
|
||||
<h3>检查最近请求</h3>
|
||||
<p>查看模型路由、响应耗时与异常详情,定位客户端接入问题。</p>
|
||||
<div class="uwa-request-preview" v-if="recentRecords.length">
|
||||
<div v-for="record in recentRecords" :key="record.id || record.history_key || recordTimestamp(record)">
|
||||
<i :class="recordStatusClass(record)"></i><strong>{{ recordDomain(record) }}</strong><span>{{ recordStatus(record) }}</span><time>{{ recordDuration(record) }}</time>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uwa-empty-preview" v-else>暂无请求记录</div>
|
||||
<button type="button" class="uwa-primary-button" @click="$emit('change-tab', 'monitor')">打开请求监控 <span v-html="$icons.arrowRight"></span></button>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="uwa-activity-band" v-if="latestRecord">
|
||||
<div><span v-html="$icons.arrowPath"></span><div><strong>最近活动</strong><span>{{ recordDomain(latestRecord) }} · {{ recordStatus(latestRecord) }}</span></div></div>
|
||||
<div><span>{{ latestRecord.endpoint || latestRecord.request_type || 'API 请求' }}</span><strong>{{ recordDuration(latestRecord) }}</strong><time>{{ recordTime(latestRecord) }}</time></div>
|
||||
</div>
|
||||
</section>
|
||||
`
|
||||
};
|
||||
@@ -0,0 +1,476 @@
|
||||
// ==================== 日志 Tab 组件 ====================
|
||||
window.LogsTab = {
|
||||
name: 'LogsTab',
|
||||
props: {
|
||||
logs: { type: Array, required: true },
|
||||
filter: { type: String, default: 'ALL' },
|
||||
paused: { type: Boolean, default: false }
|
||||
},
|
||||
emits: ['clear', 'change-filter', 'toggle-pause'],
|
||||
data() {
|
||||
return {
|
||||
expandedRawLogs: {},
|
||||
collapsedRequestGroups: {},
|
||||
selectedRequestId: 'ALL',
|
||||
viewMode: 'requests',
|
||||
copiedLogId: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
filteredLogs() {
|
||||
if (this.filter === 'ALL') {
|
||||
return this.logs;
|
||||
}
|
||||
if (this.filter === 'INFO') {
|
||||
// 修复:normalizeLogLevel 会把带 [AI] / [OK] 标记的 INFO 日志重分类成 'AI' / 'OK',
|
||||
// 此前只按重分类后的 level 过滤,导致 INFO 档漏掉全部 [AI] 日志。
|
||||
// rawLevel 保留了服务端原始级别,用它兜底把 INFO 还原成超集。
|
||||
return this.logs.filter(log =>
|
||||
log.rawLevel === 'INFO' || log.level === 'INFO' || log.level === 'OK'
|
||||
);
|
||||
}
|
||||
return this.logs.filter(log => log.level === this.filter);
|
||||
},
|
||||
|
||||
requestOptions() {
|
||||
const requests = new Map();
|
||||
this.filteredLogs.forEach(log => {
|
||||
const requestId = this.getRequestId(log);
|
||||
const existing = requests.get(requestId);
|
||||
if (existing) {
|
||||
existing.count += 1;
|
||||
existing.lastSeq = Math.max(existing.lastSeq, Number(log.seq || 0));
|
||||
return;
|
||||
}
|
||||
requests.set(requestId, {
|
||||
requestId,
|
||||
requestTag: this.getRequestTag(log),
|
||||
count: 1,
|
||||
firstSeq: Number(log.seq || 0),
|
||||
lastSeq: Number(log.seq || 0)
|
||||
});
|
||||
});
|
||||
return Array.from(requests.values()).sort((left, right) => {
|
||||
if (left.requestId === 'SYSTEM') return 1;
|
||||
if (right.requestId === 'SYSTEM') return -1;
|
||||
return right.firstSeq - left.firstSeq;
|
||||
});
|
||||
},
|
||||
|
||||
requestFilteredLogs() {
|
||||
if (this.selectedRequestId === 'ALL') {
|
||||
return this.filteredLogs;
|
||||
}
|
||||
return this.filteredLogs.filter(log => this.getRequestId(log) === this.selectedRequestId);
|
||||
},
|
||||
|
||||
timelineLogs() {
|
||||
return this.requestFilteredLogs;
|
||||
},
|
||||
|
||||
requestGroups() {
|
||||
const groups = new Map();
|
||||
this.requestFilteredLogs.forEach(log => {
|
||||
const requestId = this.getRequestId(log);
|
||||
let group = groups.get(requestId);
|
||||
if (!group) {
|
||||
group = {
|
||||
requestId,
|
||||
requestTag: this.getRequestTag(log),
|
||||
logs: [],
|
||||
firstTimestamp: log.timestamp || '',
|
||||
lastTimestamp: log.timestamp || '',
|
||||
errorCount: 0,
|
||||
warningCount: 0
|
||||
};
|
||||
groups.set(requestId, group);
|
||||
}
|
||||
group.logs.push(log);
|
||||
group.lastTimestamp = log.timestamp || group.lastTimestamp;
|
||||
if (log.level === 'ERROR') group.errorCount += 1;
|
||||
if (log.level === 'WARN') group.warningCount += 1;
|
||||
});
|
||||
return Array.from(groups.values());
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
logs(nextLogs) {
|
||||
if (
|
||||
this.selectedRequestId !== 'ALL'
|
||||
&& !(nextLogs || []).some(log => this.getRequestId(log) === this.selectedRequestId)
|
||||
) {
|
||||
this.selectedRequestId = 'ALL';
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getRequestId(log) {
|
||||
return String(log && log.requestId || 'SYSTEM').trim() || 'SYSTEM';
|
||||
},
|
||||
|
||||
getRequestTag(log) {
|
||||
return String(log && (log.requestTag || log.requestId) || 'SYSTEM').trim() || 'SYSTEM';
|
||||
},
|
||||
|
||||
selectRequest(requestId) {
|
||||
this.selectedRequestId = String(requestId || 'ALL');
|
||||
},
|
||||
|
||||
isRequestGroupCollapsed(group) {
|
||||
const key = String(group.requestId);
|
||||
return Object.prototype.hasOwnProperty.call(this.collapsedRequestGroups, key)
|
||||
? Boolean(this.collapsedRequestGroups[key])
|
||||
: true;
|
||||
},
|
||||
|
||||
toggleRequestGroup(group) {
|
||||
const key = String(group.requestId);
|
||||
this.collapsedRequestGroups = {
|
||||
...this.collapsedRequestGroups,
|
||||
[key]: !this.isRequestGroupCollapsed(group)
|
||||
};
|
||||
},
|
||||
|
||||
getRequestGroupStatus(group) {
|
||||
if (group.errorCount > 0) return `${group.errorCount} 条错误`;
|
||||
if (group.warningCount > 0) return `${group.warningCount} 条警告`;
|
||||
return '无异常';
|
||||
},
|
||||
|
||||
getRequestGroupStatusClass(group) {
|
||||
if (group.errorCount > 0) return 'text-red-600 dark:text-red-400';
|
||||
if (group.warningCount > 0) return 'text-yellow-600 dark:text-yellow-400';
|
||||
return 'text-green-600 dark:text-green-400';
|
||||
},
|
||||
|
||||
getLogText(log) {
|
||||
return log.messageText || log.message || '';
|
||||
},
|
||||
|
||||
getRawLogText(log) {
|
||||
return log.originalMessageText || log.message || this.getLogText(log);
|
||||
},
|
||||
|
||||
formatRawLogText(log) {
|
||||
let raw = String(this.getRawLogText(log) || '');
|
||||
if (!raw) return '';
|
||||
|
||||
// 1. 反转义常见控制字符
|
||||
raw = raw.replace(/\\r\\n/g, '\n').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, ' ');
|
||||
|
||||
// 2. 尝试识别并格式化嵌入的 JSON 对象
|
||||
const jsonStartIdx = raw.search(/[\{\[]/);
|
||||
if (jsonStartIdx !== -1) {
|
||||
const prefix = raw.slice(0, jsonStartIdx);
|
||||
const candidate = raw.slice(jsonStartIdx).trim();
|
||||
try {
|
||||
const parsed = JSON.parse(candidate);
|
||||
const pretty = JSON.stringify(parsed, null, 2);
|
||||
return prefix ? `${prefix.trimEnd()}\n${pretty}` : pretty;
|
||||
} catch (e) {
|
||||
// 如果末尾有多余字符,尝试寻找匹配的大括号
|
||||
const lastBraceIdx = Math.max(raw.lastIndexOf('}'), raw.lastIndexOf(']'));
|
||||
if (lastBraceIdx > jsonStartIdx) {
|
||||
try {
|
||||
const subJson = raw.slice(jsonStartIdx, lastBraceIdx + 1);
|
||||
const parsed = JSON.parse(subJson);
|
||||
const pretty = JSON.stringify(parsed, null, 2);
|
||||
const suffix = raw.slice(lastBraceIdx + 1);
|
||||
return `${raw.slice(0, jsonStartIdx).trimEnd()}\n${pretty}${suffix ? '\n' + suffix.trim() : ''}`.trim();
|
||||
} catch (err) {
|
||||
// 降级使用基础反转义文本
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return raw.trim();
|
||||
},
|
||||
|
||||
async copyRawLog(log) {
|
||||
const text = this.formatRawLogText(log);
|
||||
if (!text) return;
|
||||
try {
|
||||
if (navigator && navigator.clipboard && navigator.clipboard.writeText) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} else {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = text;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
this.copiedLogId = String(log.id);
|
||||
setTimeout(() => {
|
||||
if (this.copiedLogId === String(log.id)) {
|
||||
this.copiedLogId = null;
|
||||
}
|
||||
}, 1800);
|
||||
} catch (err) {
|
||||
console.error('复制日志失败:', err);
|
||||
}
|
||||
},
|
||||
|
||||
isCopied(log) {
|
||||
return this.copiedLogId === String(log.id);
|
||||
},
|
||||
|
||||
hasRawLogText(log) {
|
||||
return Boolean(log && log.messageAlias && this.getRawLogText(log));
|
||||
},
|
||||
|
||||
isRawExpanded(log) {
|
||||
return Boolean(this.expandedRawLogs[String(log.id)]);
|
||||
},
|
||||
|
||||
toggleRawLog(log) {
|
||||
const key = String(log.id);
|
||||
this.expandedRawLogs = {
|
||||
...this.expandedRawLogs,
|
||||
[key]: !this.expandedRawLogs[key]
|
||||
};
|
||||
},
|
||||
|
||||
isKeyCmdLog(message) {
|
||||
if (!message || !message.includes('[CMD]')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const keyPatterns = [
|
||||
'[CMD] 执行:',
|
||||
'[CMD] 触发命令:',
|
||||
'[CMD] 链式触发:',
|
||||
'[CMD] 条件分支触发:',
|
||||
'[CMD] 结果事件触发:'
|
||||
];
|
||||
|
||||
return keyPatterns.some(pattern => message.includes(pattern));
|
||||
},
|
||||
|
||||
getLogTone(log) {
|
||||
if (log.level === 'ERROR') return 'ERROR';
|
||||
if (log.level === 'WARN') return 'WARN';
|
||||
if (log.level === 'AI') return 'AI';
|
||||
if (log.level === 'OK') return 'OK';
|
||||
if (log.level === 'DEBUG') return 'DEBUG';
|
||||
if (log.level === 'INFO' && this.isKeyCmdLog(this.getLogText(log))) return 'KEY';
|
||||
return 'INFO';
|
||||
},
|
||||
|
||||
getLogColorClass(log) {
|
||||
const tone = this.getLogTone(log);
|
||||
const colors = {
|
||||
'DEBUG': 'bg-slate-50 dark:bg-slate-900/30',
|
||||
'INFO': 'bg-green-50 dark:bg-green-900/20',
|
||||
'KEY': 'bg-sky-50 dark:bg-sky-900/20',
|
||||
'AI': 'bg-purple-50 dark:bg-purple-900/20',
|
||||
'OK': 'bg-green-50 dark:bg-green-900/20',
|
||||
'WARN': 'bg-yellow-50 dark:bg-yellow-900/20',
|
||||
'ERROR': 'bg-red-50 dark:bg-red-900/20'
|
||||
};
|
||||
return colors[tone] || colors['INFO'];
|
||||
},
|
||||
|
||||
getLogLevelClass(log) {
|
||||
const tone = this.getLogTone(log);
|
||||
const colors = {
|
||||
'DEBUG': 'text-slate-500 dark:text-slate-400',
|
||||
'INFO': 'text-green-600 dark:text-green-400',
|
||||
'KEY': 'text-sky-500 dark:text-sky-300',
|
||||
'AI': 'text-purple-600 dark:text-purple-400',
|
||||
'OK': 'text-green-600 dark:text-green-400',
|
||||
'WARN': 'text-yellow-600 dark:text-yellow-400',
|
||||
'ERROR': 'text-red-600 dark:text-red-400'
|
||||
};
|
||||
return colors[tone] || colors['INFO'];
|
||||
},
|
||||
|
||||
getLogTextClass(log) {
|
||||
// DEBUG 行正文做视觉降噪(灰色弱化),与控制台的暗灰 DEBUG 保持一致
|
||||
return this.getLogTone(log) === 'DEBUG'
|
||||
? 'text-gray-500 dark:text-gray-400'
|
||||
: 'dark:text-gray-200';
|
||||
}
|
||||
},
|
||||
updated() {
|
||||
this.$nextTick(() => {
|
||||
const container = this.$refs.logContainer;
|
||||
if (container) {
|
||||
container.scrollTop = container.scrollHeight;
|
||||
}
|
||||
});
|
||||
},
|
||||
template: `
|
||||
<div class="logs-workspace h-full flex flex-col bg-white dark:bg-gray-800">
|
||||
<div class="p-3 sm:p-4 border-b dark:border-gray-700 space-y-3">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="flex flex-wrap gap-2" aria-label="日志级别">
|
||||
<button @click="$emit('change-filter', 'DEBUG')"
|
||||
:class="['px-3 py-1 text-sm rounded',
|
||||
filter === 'DEBUG' ? 'bg-slate-500 text-white' : 'border dark:border-gray-700 dark:text-gray-300']">
|
||||
DEBUG
|
||||
</button>
|
||||
<button @click="$emit('change-filter', 'ALL')"
|
||||
:class="['px-3 py-1 text-sm rounded',
|
||||
filter === 'ALL' ? 'bg-blue-500 text-white' : 'border dark:border-gray-700 dark:text-gray-300']">
|
||||
全部
|
||||
</button>
|
||||
<button @click="$emit('change-filter', 'INFO')"
|
||||
:class="['px-3 py-1 text-sm rounded',
|
||||
filter === 'INFO' ? 'bg-green-500 text-white' : 'border dark:border-gray-700 dark:text-gray-300']">
|
||||
INFO
|
||||
</button>
|
||||
<button @click="$emit('change-filter', 'AI')"
|
||||
:class="['px-3 py-1 text-sm rounded',
|
||||
filter === 'AI' ? 'bg-purple-500 text-white' : 'border dark:border-gray-700 dark:text-gray-300']">
|
||||
AI
|
||||
</button>
|
||||
<button @click="$emit('change-filter', 'WARN')"
|
||||
:class="['px-3 py-1 text-sm rounded',
|
||||
filter === 'WARN' ? 'bg-yellow-500 text-white' : 'border dark:border-gray-700 dark:text-gray-300']">
|
||||
WARN
|
||||
</button>
|
||||
<button @click="$emit('change-filter', 'ERROR')"
|
||||
:class="['px-3 py-1 text-sm rounded',
|
||||
filter === 'ERROR' ? 'bg-red-500 text-white' : 'border dark:border-gray-700 dark:text-gray-300']">
|
||||
ERROR
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button @click="$emit('toggle-pause')"
|
||||
class="inline-flex h-9 items-center gap-1.5 border dark:border-gray-700 rounded px-3 text-sm dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
|
||||
<span v-html="paused ? $icons.play : $icons.pause"></span>
|
||||
{{ paused ? '继续' : '暂停' }}
|
||||
</button>
|
||||
<button @click="$emit('clear')"
|
||||
class="inline-flex h-9 items-center gap-1.5 border dark:border-gray-700 rounded px-3 text-sm dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
|
||||
<span v-html="$icons.trash"></span> 清除
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<label class="flex min-w-0 flex-1 items-center gap-2 text-sm text-gray-600 dark:text-gray-300">
|
||||
<span class="shrink-0">请求</span>
|
||||
<select v-model="selectedRequestId"
|
||||
class="h-9 min-w-0 w-full sm:w-72 rounded border border-gray-300 bg-white px-2 text-sm text-gray-800 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-100">
|
||||
<option value="ALL">全部请求({{ requestOptions.length }})</option>
|
||||
<option v-for="option in requestOptions" :key="option.requestId" :value="option.requestId">
|
||||
{{ option.requestTag }} · {{ option.count }} 条
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<div class="inline-flex h-9 shrink-0 rounded border border-gray-300 p-0.5 dark:border-gray-600" aria-label="日志排列方式">
|
||||
<button type="button"
|
||||
@click="viewMode = 'requests'"
|
||||
:class="['rounded px-3 text-sm', viewMode === 'requests' ? 'bg-gray-800 text-white dark:bg-gray-100 dark:text-gray-900' : 'text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700']">
|
||||
按请求
|
||||
</button>
|
||||
<button type="button"
|
||||
@click="viewMode = 'timeline'"
|
||||
:class="['rounded px-3 text-sm', viewMode === 'timeline' ? 'bg-gray-800 text-white dark:bg-gray-100 dark:text-gray-900' : 'text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700']">
|
||||
时间线
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ref="logContainer" class="flex-1 overflow-auto p-3 sm:p-4 font-mono text-sm">
|
||||
<div v-if="viewMode === 'requests' && requestGroups.length > 0" class="space-y-3">
|
||||
<section v-for="group in requestGroups" :key="group.requestId"
|
||||
class="overflow-hidden rounded border border-gray-200 dark:border-gray-700">
|
||||
<button type="button"
|
||||
@click="toggleRequestGroup(group)"
|
||||
:aria-expanded="!isRequestGroupCollapsed(group)"
|
||||
class="flex w-full flex-wrap items-center justify-between gap-2 bg-gray-50 px-3 py-2 text-left hover:bg-gray-100 dark:bg-gray-900/60 dark:hover:bg-gray-900">
|
||||
<span class="flex min-w-0 items-center gap-2">
|
||||
<span class="text-gray-400" v-html="isRequestGroupCollapsed(group) ? $icons.chevronDown : $icons.chevronUp"></span>
|
||||
<strong class="text-gray-900 dark:text-gray-100">{{ group.requestTag }}</strong>
|
||||
<span class="truncate text-xs text-gray-500 dark:text-gray-400">{{ group.requestId }}</span>
|
||||
</span>
|
||||
<span class="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
<span>{{ group.logs.length }} 条</span>
|
||||
<span>{{ group.firstTimestamp }}<template v-if="group.lastTimestamp && group.lastTimestamp !== group.firstTimestamp"> - {{ group.lastTimestamp }}</template></span>
|
||||
<span :class="getRequestGroupStatusClass(group)">{{ getRequestGroupStatus(group) }}</span>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<div v-show="!isRequestGroupCollapsed(group)" class="divide-y divide-gray-200 dark:divide-gray-700">
|
||||
<div v-for="log in group.logs" :key="log.id"
|
||||
:class="['px-3 py-2', getLogColorClass(log)]">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-gray-500 dark:text-gray-300">{{ log.timestamp }}</span>
|
||||
<span :class="['font-bold', getLogLevelClass(log)]">[{{ log.level }}]</span>
|
||||
<span v-if="log.logger" class="px-1.5 py-0.5 rounded bg-white/70 dark:bg-gray-900/40 text-gray-600 dark:text-gray-300">
|
||||
{{ log.logger }}
|
||||
</span>
|
||||
</div>
|
||||
<div :class="['mt-1 break-all whitespace-pre-wrap', getLogTextClass(log)]">
|
||||
<span>{{ getLogText(log) }}</span>
|
||||
<button v-if="hasRawLogText(log)"
|
||||
@click="toggleRawLog(log)"
|
||||
class="ml-2 inline-flex items-center rounded border border-gray-300 px-1.5 py-0.5 text-xs text-gray-600 hover:bg-white/70 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-900/50">
|
||||
{{ isRawExpanded(log) ? '收起原文' : '展开原文' }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="hasRawLogText(log) && isRawExpanded(log)"
|
||||
class="mt-2 overflow-hidden rounded-md border border-gray-700/80 bg-gray-950 text-gray-100 shadow-sm">
|
||||
<div class="flex items-center justify-between border-b border-gray-800 bg-gray-900/90 px-3 py-1.5 text-xs text-gray-400">
|
||||
<span class="font-mono font-medium text-gray-300">技术原文详情 (Raw Log)</span>
|
||||
<button type="button"
|
||||
@click.stop="copyRawLog(log)"
|
||||
class="inline-flex items-center gap-1 rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-200 hover:bg-gray-700 hover:text-white transition-colors">
|
||||
<span>{{ isCopied(log) ? '已复制 ✓' : '复制原文' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<pre class="max-h-72 overflow-auto p-2.5 text-xs font-mono whitespace-pre-wrap break-words select-all leading-relaxed">{{ formatRawLogText(log) }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div v-else-if="viewMode === 'timeline' && timelineLogs.length > 0" class="space-y-1">
|
||||
<div v-for="log in timelineLogs" :key="log.id"
|
||||
:class="['p-2 rounded', getLogColorClass(log)]">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-gray-500 dark:text-gray-300">{{ log.timestamp }}</span>
|
||||
<span :class="['font-bold', getLogLevelClass(log)]">[{{ log.level }}]</span>
|
||||
<span v-if="log.logger" class="px-1.5 py-0.5 rounded bg-white/70 dark:bg-gray-900/40 text-gray-600 dark:text-gray-300">
|
||||
{{ log.logger }}
|
||||
</span>
|
||||
<span v-if="log.requestTag || log.requestId" class="px-1.5 py-0.5 rounded bg-white/70 dark:bg-gray-900/40 text-gray-500 dark:text-gray-400">
|
||||
{{ log.requestTag || log.requestId }}
|
||||
</span>
|
||||
</div>
|
||||
<div :class="['mt-1 break-all whitespace-pre-wrap', getLogTextClass(log)]">
|
||||
<span>{{ getLogText(log) }}</span>
|
||||
<button v-if="hasRawLogText(log)"
|
||||
@click="toggleRawLog(log)"
|
||||
class="ml-2 inline-flex items-center rounded border border-gray-300 px-1.5 py-0.5 text-xs text-gray-600 hover:bg-white/70 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-900/50">
|
||||
{{ isRawExpanded(log) ? '收起原文' : '展开原文' }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="hasRawLogText(log) && isRawExpanded(log)"
|
||||
class="mt-2 overflow-hidden rounded-md border border-gray-700/80 bg-gray-950 text-gray-100 shadow-sm">
|
||||
<div class="flex items-center justify-between border-b border-gray-800 bg-gray-900/90 px-3 py-1.5 text-xs text-gray-400">
|
||||
<span class="font-mono font-medium text-gray-300">技术原文详情 (Raw Log)</span>
|
||||
<button type="button"
|
||||
@click.stop="copyRawLog(log)"
|
||||
class="inline-flex items-center gap-1 rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-200 hover:bg-gray-700 hover:text-white transition-colors">
|
||||
<span>{{ isCopied(log) ? '已复制 ✓' : '复制原文' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<pre class="max-h-72 overflow-auto p-2.5 text-xs font-mono whitespace-pre-wrap break-words select-all leading-relaxed">{{ formatRawLogText(log) }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else
|
||||
class="text-center text-gray-400 dark:text-gray-500 py-8">
|
||||
{{ selectedRequestId === 'ALL' ? '暂无日志' : '该请求暂无符合当前级别的日志' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
@@ -0,0 +1,503 @@
|
||||
// ==================== 首页首次访问引导 ====================
|
||||
(function () {
|
||||
const STORAGE_KEY = 'uwa_onboarding_v1';
|
||||
|
||||
const MODULE_STEPS = [
|
||||
{
|
||||
key: 'config',
|
||||
code: 'Config',
|
||||
title: '站点配置',
|
||||
summary: '定义一个网站如何被转换为稳定的 API。',
|
||||
detail: '在这里管理反代站点规则、CSS / XPath 选择器、数据提取器、响应拦截检测,以及输入与输出转换工作流。'
|
||||
},
|
||||
{
|
||||
key: 'tabpool',
|
||||
code: 'TabPool',
|
||||
title: '标签页池',
|
||||
summary: '掌握受控 Chrome 的实时工作状态。',
|
||||
detail: '查看多标签页并发池、网页匹配状态、会话隔离方式,以及每个 Tab 当前的线程占用情况。'
|
||||
},
|
||||
{
|
||||
key: 'monitor',
|
||||
code: 'Monitor',
|
||||
title: '请求监控',
|
||||
summary: '观察每一次真实请求如何流经系统。',
|
||||
detail: '抓取并检查 HTTP / WebSocket 请求流量,快速核对请求 Payload、目标站点响应与最终提取结果。'
|
||||
},
|
||||
{
|
||||
key: 'commands',
|
||||
code: 'Commands',
|
||||
title: '命令系统',
|
||||
summary: '把重复的浏览器操作编排成自动化流程。',
|
||||
detail: '配置和触发自动登录、点击交互、页面操作等动作序列,构建可重复执行的 UI 工作流。'
|
||||
},
|
||||
{
|
||||
key: 'logs',
|
||||
code: 'Logs',
|
||||
title: '运行日志',
|
||||
summary: '从底层运行信息中快速定位异常。',
|
||||
detail: '实时查看后端 Python 服务和控制台日志,用于追踪请求链路、脚本执行过程与错误原因。'
|
||||
},
|
||||
{
|
||||
key: 'settings',
|
||||
code: 'Settings',
|
||||
title: '设置',
|
||||
summary: '集中管理服务、安全与本地配置。',
|
||||
detail: '调整监听端口、面板 API Token、浏览器启动参数,并完成配置文件的导入导出、备份与恢复。'
|
||||
}
|
||||
];
|
||||
|
||||
const SOP_STEPS = [
|
||||
{
|
||||
key: 'principle',
|
||||
eyebrow: '核心原理',
|
||||
title: '网页交互,如何变成标准 API?',
|
||||
intro: 'Universal Web API 让受控 Chrome 保持真实网页的登录态和交互能力,再把网页会话桥接为 OpenAI 兼容接口。',
|
||||
note: '第三方客户端只需访问本地 API,无需直接理解每个网站的页面结构。'
|
||||
},
|
||||
{
|
||||
key: 'browser',
|
||||
eyebrow: '步骤 1',
|
||||
title: '在受控浏览器中打开目标网页',
|
||||
intro: '运行系统后,在自动弹出的受控 Chrome 中打开需要反代的 AI 网站,并完成正常登录。',
|
||||
note: '例如打开 gemini.google.com。请始终使用系统启动的受控浏览器,而不是另一个普通浏览器窗口。'
|
||||
},
|
||||
{
|
||||
key: 'interactive',
|
||||
eyebrow: '步骤 2 · 关键事项',
|
||||
title: '确保页面元素显性可交互',
|
||||
intro: '工作流要点击或提取的元素必须真实出现在页面中,不能处于折叠、遮挡或语言不匹配的状态。',
|
||||
note: '以 Gemini 为例,开始请求前请完成下面两项检查。'
|
||||
},
|
||||
{
|
||||
key: 'routing',
|
||||
eyebrow: '步骤 3',
|
||||
title: '在标签页池确认网页并选择路由',
|
||||
intro: '登录成功后,标签页池会显示已捕获网页。根据使用场景选择全局、域名路径或 Query 参数路由。',
|
||||
note: '多站点同时运行时,显式指定域名最容易保持请求边界清晰。'
|
||||
},
|
||||
{
|
||||
key: 'client',
|
||||
eyebrow: '步骤 4',
|
||||
title: '连接前端或第三方客户端',
|
||||
intro: '最后在 NextChat、LobeChat、LangChain 等客户端中填写 Base URL 与 API Key。',
|
||||
note: '未在设置中启用 Token 认证时,API Key 可以留空;若客户端强制要求,也可以填写任意值。'
|
||||
}
|
||||
];
|
||||
|
||||
window.OnboardingGuide = {
|
||||
name: 'OnboardingGuide',
|
||||
emits: ['tour-start', 'tour-end'],
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
view: 'welcome',
|
||||
phase: 'modules',
|
||||
moduleIndex: 0,
|
||||
sopIndex: 0,
|
||||
targetRect: null,
|
||||
cardStyle: {},
|
||||
initialTimer: null,
|
||||
resizeHandler: null,
|
||||
keyHandler: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
moduleSteps() {
|
||||
return MODULE_STEPS;
|
||||
},
|
||||
sopSteps() {
|
||||
return SOP_STEPS;
|
||||
},
|
||||
currentModule() {
|
||||
return this.moduleSteps[this.moduleIndex] || this.moduleSteps[0];
|
||||
},
|
||||
currentSop() {
|
||||
return this.sopSteps[this.sopIndex] || this.sopSteps[0];
|
||||
},
|
||||
totalTourSteps() {
|
||||
return this.moduleSteps.length + this.sopSteps.length;
|
||||
},
|
||||
completedTourSteps() {
|
||||
return this.phase === 'modules'
|
||||
? this.moduleIndex + 1
|
||||
: this.moduleSteps.length + this.sopIndex + 1;
|
||||
},
|
||||
progressPercent() {
|
||||
return Math.round((this.completedTourSteps / this.totalTourSteps) * 100);
|
||||
},
|
||||
spotlightStyle() {
|
||||
if (!this.targetRect) {
|
||||
return { display: 'none' };
|
||||
}
|
||||
return {
|
||||
left: this.targetRect.left + 'px',
|
||||
top: this.targetRect.top + 'px',
|
||||
width: this.targetRect.width + 'px',
|
||||
height: this.targetRect.height + 'px'
|
||||
};
|
||||
},
|
||||
shadeStyles() {
|
||||
if (!this.targetRect) {
|
||||
return [{ inset: '0' }];
|
||||
}
|
||||
const rect = this.targetRect;
|
||||
return [
|
||||
{ left: '0', top: '0', right: '0', height: rect.top + 'px' },
|
||||
{ left: '0', top: rect.top + 'px', width: rect.left + 'px', height: rect.height + 'px' },
|
||||
{ left: (rect.left + rect.width) + 'px', top: rect.top + 'px', right: '0', height: rect.height + 'px' },
|
||||
{ left: '0', top: (rect.top + rect.height) + 'px', right: '0', bottom: '0' }
|
||||
];
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.resizeHandler = () => this.schedulePositionUpdate();
|
||||
this.keyHandler = (event) => this.handleKeydown(event);
|
||||
window.addEventListener('resize', this.resizeHandler, { passive: true });
|
||||
window.addEventListener('scroll', this.resizeHandler, true);
|
||||
document.addEventListener('keydown', this.keyHandler);
|
||||
|
||||
this.initialTimer = window.setTimeout(() => {
|
||||
if (!this.hasSavedDecision()) {
|
||||
this.open(false);
|
||||
}
|
||||
}, 650);
|
||||
},
|
||||
beforeUnmount() {
|
||||
window.clearTimeout(this.initialTimer);
|
||||
window.removeEventListener('resize', this.resizeHandler);
|
||||
window.removeEventListener('scroll', this.resizeHandler, true);
|
||||
document.removeEventListener('keydown', this.keyHandler);
|
||||
},
|
||||
methods: {
|
||||
hasSavedDecision() {
|
||||
try {
|
||||
return !!localStorage.getItem(STORAGE_KEY);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
saveDecision(status) {
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify({
|
||||
version: 1,
|
||||
status: status,
|
||||
updatedAt: new Date().toISOString()
|
||||
}));
|
||||
} catch (error) {
|
||||
// Storage is optional; the guide remains usable for this session.
|
||||
}
|
||||
},
|
||||
open(startDirectly) {
|
||||
window.clearTimeout(this.initialTimer);
|
||||
this.visible = true;
|
||||
this.view = startDirectly ? 'tour' : 'welcome';
|
||||
this.phase = 'modules';
|
||||
this.moduleIndex = 0;
|
||||
this.sopIndex = 0;
|
||||
this.targetRect = null;
|
||||
if (startDirectly) {
|
||||
this.$emit('tour-start');
|
||||
this.$nextTick(() => this.updateSpotlight());
|
||||
}
|
||||
this.$nextTick(() => this.focusDialog());
|
||||
},
|
||||
startTour() {
|
||||
this.view = 'tour';
|
||||
this.phase = 'modules';
|
||||
this.moduleIndex = 0;
|
||||
this.$emit('tour-start');
|
||||
this.$nextTick(() => {
|
||||
this.updateSpotlight();
|
||||
this.focusDialog();
|
||||
});
|
||||
},
|
||||
dismissWelcome() {
|
||||
this.saveDecision('dismissed');
|
||||
this.close(false);
|
||||
},
|
||||
skipTour() {
|
||||
this.saveDecision('skipped');
|
||||
this.close(true);
|
||||
},
|
||||
finishTour() {
|
||||
this.saveDecision('completed');
|
||||
this.close(true);
|
||||
},
|
||||
close(wasTour) {
|
||||
this.visible = false;
|
||||
this.targetRect = null;
|
||||
if (wasTour || this.view === 'tour') {
|
||||
this.$emit('tour-end');
|
||||
}
|
||||
},
|
||||
previous() {
|
||||
if (this.phase === 'modules') {
|
||||
if (this.moduleIndex > 0) {
|
||||
this.moduleIndex -= 1;
|
||||
this.$nextTick(() => this.updateSpotlight());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.sopIndex > 0) {
|
||||
this.sopIndex -= 1;
|
||||
return;
|
||||
}
|
||||
this.phase = 'modules';
|
||||
this.moduleIndex = this.moduleSteps.length - 1;
|
||||
this.$nextTick(() => this.updateSpotlight());
|
||||
},
|
||||
next() {
|
||||
if (this.phase === 'modules') {
|
||||
if (this.moduleIndex < this.moduleSteps.length - 1) {
|
||||
this.moduleIndex += 1;
|
||||
this.$nextTick(() => this.updateSpotlight());
|
||||
return;
|
||||
}
|
||||
this.phase = 'sop';
|
||||
this.sopIndex = 0;
|
||||
this.targetRect = null;
|
||||
this.$nextTick(() => this.focusDialog());
|
||||
return;
|
||||
}
|
||||
if (this.sopIndex < this.sopSteps.length - 1) {
|
||||
this.sopIndex += 1;
|
||||
this.$nextTick(() => this.focusDialog());
|
||||
return;
|
||||
}
|
||||
this.finishTour();
|
||||
},
|
||||
goToSop(index) {
|
||||
this.sopIndex = index;
|
||||
this.$nextTick(() => this.focusDialog());
|
||||
},
|
||||
schedulePositionUpdate() {
|
||||
if (!this.visible || this.view !== 'tour' || this.phase !== 'modules') {
|
||||
return;
|
||||
}
|
||||
window.requestAnimationFrame(() => this.updateSpotlight());
|
||||
},
|
||||
updateSpotlight() {
|
||||
if (!this.visible || this.phase !== 'modules') {
|
||||
return;
|
||||
}
|
||||
const selector = '[data-tour-target="' + this.currentModule.key + '"]';
|
||||
const target = document.querySelector(selector);
|
||||
if (!target) {
|
||||
this.targetRect = null;
|
||||
this.cardStyle = {};
|
||||
return;
|
||||
}
|
||||
|
||||
target.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
||||
window.setTimeout(() => {
|
||||
const bounds = target.getBoundingClientRect();
|
||||
const gap = 7;
|
||||
const rect = {
|
||||
left: Math.max(0, bounds.left - gap),
|
||||
top: Math.max(0, bounds.top - gap),
|
||||
width: Math.min(window.innerWidth, bounds.width + gap * 2),
|
||||
height: Math.min(window.innerHeight, bounds.height + gap * 2)
|
||||
};
|
||||
this.targetRect = rect;
|
||||
this.cardStyle = this.getCardStyle(rect);
|
||||
}, 120);
|
||||
},
|
||||
getCardStyle(rect) {
|
||||
const viewportWidth = window.innerWidth;
|
||||
const viewportHeight = window.innerHeight;
|
||||
if (viewportWidth <= 700) {
|
||||
const estimatedHeight = 268;
|
||||
const placeAtTop = rect.top > viewportHeight * 0.48;
|
||||
return {
|
||||
left: '14px',
|
||||
right: '14px',
|
||||
top: placeAtTop ? '14px' : 'auto',
|
||||
bottom: placeAtTop ? 'auto' : '14px'
|
||||
};
|
||||
}
|
||||
|
||||
const cardWidth = 390;
|
||||
const preferredLeft = rect.left + rect.width + 20;
|
||||
const left = preferredLeft + cardWidth <= viewportWidth - 18
|
||||
? preferredLeft
|
||||
: Math.max(18, rect.left - cardWidth - 20);
|
||||
const top = Math.max(18, Math.min(rect.top - 22, viewportHeight - 340));
|
||||
return { left: left + 'px', top: top + 'px', width: cardWidth + 'px' };
|
||||
},
|
||||
focusDialog() {
|
||||
const dialog = this.$el && this.$el.querySelector('[role="dialog"]');
|
||||
if (dialog && typeof dialog.focus === 'function') {
|
||||
dialog.focus({ preventScroll: true });
|
||||
}
|
||||
},
|
||||
handleKeydown(event) {
|
||||
if (!this.visible) {
|
||||
return;
|
||||
}
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
this.view === 'welcome' ? this.dismissWelcome() : this.skipTour();
|
||||
return;
|
||||
}
|
||||
if (this.view !== 'tour') {
|
||||
return;
|
||||
}
|
||||
if (event.key === 'ArrowLeft') {
|
||||
event.preventDefault();
|
||||
this.previous();
|
||||
} else if (event.key === 'ArrowRight' || event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
this.next();
|
||||
}
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div v-if="visible" class="uwa-onboarding-root" @click.stop>
|
||||
<template v-if="view === 'welcome'">
|
||||
<div class="uwa-onboarding-backdrop"></div>
|
||||
<section class="uwa-welcome-dialog" role="dialog" aria-modal="true" aria-labelledby="uwa-welcome-title" tabindex="-1">
|
||||
<button type="button" class="uwa-tour-icon-button" @click="dismissWelcome" title="关闭" aria-label="关闭欢迎引导" v-html="$icons.xMark"></button>
|
||||
<div class="uwa-welcome-mark">
|
||||
<img src="/static/images/logo.svg" alt="">
|
||||
<span>首次使用</span>
|
||||
</div>
|
||||
<p class="uwa-tour-kicker">UNIVERSAL WEB API</p>
|
||||
<h2 id="uwa-welcome-title">欢迎来到控制面板</h2>
|
||||
<p class="uwa-welcome-copy">检测到这是您第一次使用。用大约 3 分钟认识核心模块,并完成第一次网页反代配置。</p>
|
||||
<div class="uwa-welcome-preview" aria-hidden="true">
|
||||
<span><i>1</i>认识控制台</span>
|
||||
<b></b>
|
||||
<span><i>2</i>连接目标网页</span>
|
||||
<b></b>
|
||||
<span><i>3</i>接入客户端</span>
|
||||
</div>
|
||||
<div class="uwa-welcome-actions">
|
||||
<button type="button" class="uwa-tour-button is-secondary" @click="dismissWelcome">暂不需要</button>
|
||||
<button type="button" class="uwa-tour-button is-primary" @click="startTour">
|
||||
<span>开始教程</span>
|
||||
<span v-html="$icons.arrowRight"></span>
|
||||
</button>
|
||||
</div>
|
||||
<p class="uwa-welcome-footnote">之后可随时从侧边栏底部的“新手指南”重新打开</p>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<template v-else-if="phase === 'modules'">
|
||||
<div v-for="(style, index) in shadeStyles" :key="index" class="uwa-tour-shade" :style="style"></div>
|
||||
<div class="uwa-tour-spotlight" :style="spotlightStyle" aria-hidden="true"></div>
|
||||
<section class="uwa-module-card" :style="cardStyle" role="dialog" aria-modal="true" :aria-label="currentModule.title + '介绍'" tabindex="-1">
|
||||
<header class="uwa-tour-card-header">
|
||||
<div>
|
||||
<span class="uwa-tour-stage">阶段 1 / 2</span>
|
||||
<span class="uwa-tour-step-count">模块 {{ moduleIndex + 1 }} / {{ moduleSteps.length }}</span>
|
||||
</div>
|
||||
<button type="button" class="uwa-tour-icon-button" @click="skipTour" title="退出教程" aria-label="退出教程" v-html="$icons.xMark"></button>
|
||||
</header>
|
||||
<div class="uwa-tour-progress" aria-hidden="true"><i :style="{ width: progressPercent + '%' }"></i></div>
|
||||
<div class="uwa-module-heading">
|
||||
<span class="uwa-module-number">{{ String(moduleIndex + 1).padStart(2, '0') }}</span>
|
||||
<div>
|
||||
<p>{{ currentModule.code }}</p>
|
||||
<h2>{{ currentModule.title }}</h2>
|
||||
</div>
|
||||
</div>
|
||||
<h3>{{ currentModule.summary }}</h3>
|
||||
<p class="uwa-module-detail">{{ currentModule.detail }}</p>
|
||||
<footer class="uwa-tour-footer">
|
||||
<button type="button" class="uwa-tour-skip" @click="skipTour">跳过教程</button>
|
||||
<div>
|
||||
<button type="button" class="uwa-tour-button is-secondary is-compact" @click="previous" :disabled="moduleIndex === 0">上一步</button>
|
||||
<button type="button" class="uwa-tour-button is-primary is-compact" @click="next">
|
||||
<span>{{ moduleIndex === moduleSteps.length - 1 ? '进入实操' : '下一步' }}</span>
|
||||
<span v-html="$icons.arrowRight"></span>
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="uwa-onboarding-backdrop is-strong"></div>
|
||||
<section class="uwa-sop-dialog" role="dialog" aria-modal="true" aria-labelledby="uwa-sop-title" tabindex="-1">
|
||||
<aside class="uwa-sop-rail">
|
||||
<div class="uwa-sop-rail-heading">
|
||||
<span class="uwa-tour-stage">阶段 2 / 2</span>
|
||||
<strong>反代实操</strong>
|
||||
<small>从网页到 API</small>
|
||||
</div>
|
||||
<nav aria-label="实操教程步骤">
|
||||
<button v-for="(step, index) in sopSteps" :key="step.key" type="button"
|
||||
:class="{ 'is-active': sopIndex === index, 'is-done': sopIndex > index }"
|
||||
@click="goToSop(index)" :aria-current="sopIndex === index ? 'step' : null">
|
||||
<i>{{ sopIndex > index ? '✓' : index }}</i>
|
||||
<span>{{ index === 0 ? '工作原理' : '步骤 ' + index }}</span>
|
||||
</button>
|
||||
</nav>
|
||||
<div class="uwa-sop-rail-progress">
|
||||
<span>整体进度</span><strong>{{ progressPercent }}%</strong>
|
||||
<div><i :style="{ width: progressPercent + '%' }"></i></div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div class="uwa-sop-content">
|
||||
<header class="uwa-sop-topbar">
|
||||
<span>{{ currentSop.eyebrow }}</span>
|
||||
<button type="button" class="uwa-tour-icon-button" @click="skipTour" title="退出教程" aria-label="退出教程" v-html="$icons.xMark"></button>
|
||||
</header>
|
||||
<div class="uwa-sop-scroll">
|
||||
<p class="uwa-tour-kicker">STEP-BY-STEP SOP</p>
|
||||
<h2 id="uwa-sop-title">{{ currentSop.title }}</h2>
|
||||
<p class="uwa-sop-intro">{{ currentSop.intro }}</p>
|
||||
|
||||
<div v-if="currentSop.key === 'principle'" class="uwa-bridge-flow">
|
||||
<div><span v-html="$icons.globe"></span><strong>真实 Web 界面</strong><small>登录态与页面交互</small></div>
|
||||
<i v-html="$icons.arrowRight"></i>
|
||||
<div><span v-html="$icons.server"></span><strong>受控 Chrome</strong><small>执行操作与提取响应</small></div>
|
||||
<i v-html="$icons.arrowRight"></i>
|
||||
<div class="is-accent"><span v-html="$icons.arrowPathRoundedSquare"></span><strong>OpenAI API</strong><small>统一请求与响应格式</small></div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="currentSop.key === 'browser'" class="uwa-browser-example">
|
||||
<div class="uwa-browser-bar"><i></i><i></i><i></i><span>gemini.google.com</span></div>
|
||||
<div class="uwa-browser-body">
|
||||
<span v-html="$icons.globe"></span>
|
||||
<div><strong>在受控浏览器完成登录</strong><small>保持目标网页打开,系统会自动捕获标签页</small></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="currentSop.key === 'interactive'" class="uwa-check-list">
|
||||
<div><i>1</i><span><strong>展开网页侧边栏</strong><small>避免对话切换等按钮因折叠而不可见</small></span></div>
|
||||
<div><i>2</i><span><strong>页面语言设为“汉语(中文)”</strong><small>防止选择器依赖的文案因语言不同而匹配失败</small></span></div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="currentSop.key === 'routing'" class="uwa-route-list">
|
||||
<article><span>全局路由</span><code>/v1/chat/completions</code><p>根据模型名或当前激活 Tab 自动路由。</p></article>
|
||||
<article class="is-recommended"><span>推荐 · 域名路由</span><code>/site/gemini.google.com/v1/chat/completions</code><p>在路径中固定目标域名,多站点运行互不干扰。</p></article>
|
||||
<article><span>Query 路由</span><code>/v1/chat/completions?domain=gemini.google.com</code><p>通过查询参数指定本次请求的目标站点。</p></article>
|
||||
</div>
|
||||
|
||||
<div v-else-if="currentSop.key === 'client'" class="uwa-client-fields">
|
||||
<label><span>Base URL</span><code>http://127.0.0.1:8199/v1</code></label>
|
||||
<label><span>API Key</span><code>留空或任意值</code><small>启用 Token 认证后,请改为设置中的真实 Token</small></label>
|
||||
</div>
|
||||
|
||||
<div class="uwa-sop-note"><span>提示</span><p>{{ currentSop.note }}</p></div>
|
||||
</div>
|
||||
<footer class="uwa-sop-footer">
|
||||
<button type="button" class="uwa-tour-skip" @click="skipTour">退出教程</button>
|
||||
<div>
|
||||
<button type="button" class="uwa-tour-button is-secondary is-compact" @click="previous">上一步</button>
|
||||
<button type="button" class="uwa-tour-button is-primary is-compact" @click="next">
|
||||
<span>{{ sopIndex === sopSteps.length - 1 ? '完成教程' : '下一步' }}</span>
|
||||
<span v-html="$icons.arrowRight"></span>
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
})();
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,600 @@
|
||||
// ==================== 设置 Tab 组件 (修复版) ====================
|
||||
window.SettingsTab = {
|
||||
name: 'SettingsTab',
|
||||
props: {
|
||||
envConfig: { type: Object, required: true },
|
||||
envSchema: { type: Object, required: true },
|
||||
envCollapsed: { type: Object, required: true },
|
||||
envChanged: { type: Boolean, default: false },
|
||||
savingEnv: { type: Boolean, default: false },
|
||||
|
||||
browserConstants: { type: Object, required: true },
|
||||
browserSchema: { type: Object, required: true },
|
||||
browserCollapsed: { type: Object, required: true },
|
||||
browserChanged: { type: Boolean, default: false },
|
||||
savingBrowser: { type: Boolean, default: false },
|
||||
|
||||
updatePreserveOptions: { type: Array, required: true },
|
||||
updatePreserveSelected: { type: Array, required: true },
|
||||
updatePreserveChanged: { type: Boolean, default: false },
|
||||
savingUpdatePreserve: { type: Boolean, default: false },
|
||||
|
||||
selectorDefinitions: { type: Array, required: true },
|
||||
definitionsChanged: { type: Boolean, default: false },
|
||||
savingDefinitions: { type: Boolean, default: false },
|
||||
|
||||
releases: { type: Array, required: true },
|
||||
releasesLoading: { type: Boolean, default: false },
|
||||
releasesError: { type: String, default: '' },
|
||||
releasesCurrentVersion: { type: String, default: '' },
|
||||
switchingTag: { type: String, default: null },
|
||||
updateCheckRefreshing: { type: Boolean, default: false }
|
||||
},
|
||||
emits: [
|
||||
'save-env', 'reset-env', 'toggle-env-group',
|
||||
'save-browser', 'reset-browser', 'toggle-browser-group',
|
||||
'save-update-preserve', 'reset-update-preserve', 'toggle-update-preserve',
|
||||
'save-definitions', 'reset-definitions',
|
||||
'add-definition', 'edit-definition', 'remove-definition',
|
||||
'toggle-definition', 'move-definition',
|
||||
'load-releases', 'switch-to-version', 'show-changelog',
|
||||
'refresh-update-check'
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
selectorDefsCollapsed: true,
|
||||
updatePreserveCollapsed: true,
|
||||
versionCollapsed: false,
|
||||
releasePage: 1,
|
||||
releasePageSize: 5
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
updatePreserveGroups() {
|
||||
const groups = {}
|
||||
for (const item of this.updatePreserveOptions || []) {
|
||||
const key = item.category || '其他'
|
||||
if (!groups[key]) groups[key] = []
|
||||
groups[key].push(item)
|
||||
}
|
||||
return groups
|
||||
},
|
||||
releaseTotalPages() {
|
||||
return Math.max(1, Math.ceil(this.releases.length / this.releasePageSize))
|
||||
},
|
||||
paginatedReleases() {
|
||||
const start = (this.releasePage - 1) * this.releasePageSize
|
||||
return this.releases.slice(start, start + this.releasePageSize)
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
releases() {
|
||||
if (this.releasePage > this.releaseTotalPages) {
|
||||
this.releasePage = this.releaseTotalPages
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getEnvApplyScope(field, group) {
|
||||
return field.apply || group.apply || 'service'
|
||||
},
|
||||
getEnvApplyLabel(field, group) {
|
||||
const scope = this.getEnvApplyScope(field, group)
|
||||
if (scope === 'launcher') return '需重启 start.bat'
|
||||
return '保存后服务重启生效'
|
||||
},
|
||||
getEnvApplyClass(field, group) {
|
||||
const scope = this.getEnvApplyScope(field, group)
|
||||
if (scope === 'launcher') {
|
||||
return 'bg-amber-50 text-amber-700 border border-amber-200 dark:bg-amber-900/20 dark:text-amber-300 dark:border-amber-800'
|
||||
}
|
||||
return 'bg-emerald-50 text-emerald-700 border border-emerald-200 dark:bg-emerald-900/20 dark:text-emerald-300 dark:border-emerald-800'
|
||||
},
|
||||
formatReleaseDate(isoStr) {
|
||||
if (!isoStr) return '—';
|
||||
try {
|
||||
var d = new Date(isoStr);
|
||||
var pad = function(n) { return String(n).padStart(2, '0'); };
|
||||
return d.getFullYear() + '/' + pad(d.getMonth()+1) + '/' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds());
|
||||
} catch (e) {
|
||||
return isoStr;
|
||||
}
|
||||
},
|
||||
goToReleasePage(page) {
|
||||
this.releasePage = Math.min(this.releaseTotalPages, Math.max(1, Number(page) || 1))
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="settings-workspace h-full overflow-auto p-4 md:p-6 bg-gray-50 dark:bg-gray-900">
|
||||
<div class="max-w-7xl mx-auto space-y-6">
|
||||
|
||||
<!-- ========== AI 元素识别 - 放在最上面 ========== -->
|
||||
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700">
|
||||
<div class="p-4 border-b border-gray-100 dark:border-gray-700 flex justify-between items-center cursor-pointer"
|
||||
@click="selectorDefsCollapsed = !selectorDefsCollapsed">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-gray-900 dark:text-white flex items-center gap-2">
|
||||
<span class="text-xl">🎯</span> AI 元素识别
|
||||
</h3>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">配置 AI 分析页面时需要查找的目标元素</p>
|
||||
</div>
|
||||
<div class="flex gap-2 items-center">
|
||||
<span class="text-xs px-2 py-1 bg-gray-100 dark:bg-gray-700 rounded-full text-gray-600 dark:text-gray-300">{{ selectorDefinitions.length }} 个定义</span>
|
||||
<div class="h-6 w-px bg-gray-200 dark:bg-gray-600 mx-2"></div>
|
||||
<button @click.stop="$emit('reset-definitions')" title="重置"
|
||||
class="p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors">
|
||||
<span v-html="$icons.arrowPath"></span>
|
||||
</button>
|
||||
<button @click.stop="$emit('save-definitions')"
|
||||
:disabled="savingDefinitions || !definitionsChanged"
|
||||
:class="['px-3 py-1.5 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-1 shadow-sm',
|
||||
savingDefinitions || !definitionsChanged
|
||||
? 'bg-blue-400 cursor-not-allowed opacity-60'
|
||||
: 'bg-blue-600 hover:bg-blue-700']">
|
||||
<span v-if="!savingDefinitions" v-html="$icons.arrowDownTray" class="w-4 h-4"></span>
|
||||
{{ savingDefinitions ? '...' : '保存' }}
|
||||
</button>
|
||||
<button class="p-1.5 ml-2 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors"
|
||||
v-html="selectorDefsCollapsed ? $icons.chevronDown : $icons.chevronUp">
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="!selectorDefsCollapsed" class="p-0">
|
||||
<!-- 表头 -->
|
||||
<div class="grid grid-cols-12 gap-4 px-6 py-3 bg-gray-50 dark:bg-gray-900/50 text-xs font-semibold text-gray-600 dark:text-gray-300 border-b border-gray-200 dark:border-gray-700">
|
||||
<div class="col-span-1 text-center">排序</div>
|
||||
<div class="col-span-3 md:col-span-2">关键词 (Key)</div>
|
||||
<div class="col-span-6 md:col-span-7">描述 (Description)</div>
|
||||
<div class="col-span-1 text-center">启用</div>
|
||||
<div class="col-span-1 text-center">操作</div>
|
||||
</div>
|
||||
|
||||
<!-- 列表 -->
|
||||
<div class="divide-y divide-gray-100 dark:divide-gray-700">
|
||||
<div v-for="(def, index) in selectorDefinitions" :key="def.key"
|
||||
class="grid grid-cols-12 gap-4 px-6 py-3 items-center hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors">
|
||||
|
||||
<!-- 排序按钮 - 优化日夜模式显示 -->
|
||||
<div class="col-span-1 flex flex-col items-center gap-0.5">
|
||||
<button @click.stop="$emit('move-definition', index, -1)"
|
||||
:disabled="index === 0"
|
||||
:class="['p-1 rounded-md transition-all duration-150',
|
||||
index === 0
|
||||
? 'text-gray-300 dark:text-gray-600 cursor-not-allowed'
|
||||
: 'text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-100 dark:hover:bg-blue-900/40 active:scale-95']"
|
||||
title="上移">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button @click.stop="$emit('move-definition', index, 1)"
|
||||
:disabled="index === selectorDefinitions.length - 1"
|
||||
:class="['p-1 rounded-md transition-all duration-150',
|
||||
index === selectorDefinitions.length - 1
|
||||
? 'text-gray-300 dark:text-gray-600 cursor-not-allowed'
|
||||
: 'text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-100 dark:hover:bg-blue-900/40 active:scale-95']"
|
||||
title="下移">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Key -->
|
||||
<div class="col-span-3 md:col-span-2 flex items-center gap-2 flex-wrap">
|
||||
<code class="px-2 py-1 bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-700 rounded text-xs font-mono text-blue-700 dark:text-blue-300">
|
||||
{{ def.key }}
|
||||
</code>
|
||||
<span v-if="def.required" class="text-[10px] text-red-600 dark:text-red-400 border border-red-300 dark:border-red-700 px-1.5 py-0.5 rounded bg-red-50 dark:bg-red-900/30 font-medium">必需</span>
|
||||
</div>
|
||||
|
||||
<!-- Description -->
|
||||
<div class="col-span-6 md:col-span-7 text-sm text-gray-700 dark:text-gray-200 truncate" :title="def.description">
|
||||
{{ def.description }}
|
||||
</div>
|
||||
|
||||
<!-- 启用开关 -->
|
||||
<div class="col-span-1 flex justify-center">
|
||||
<label class="toggle-label scale-90">
|
||||
<input type="checkbox" :checked="def.enabled"
|
||||
@change="$emit('toggle-definition', index)"
|
||||
:disabled="def.required" class="sr-only peer">
|
||||
<div class="toggle-bg" :class="{'opacity-50 cursor-not-allowed': def.required}"></div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- 操作按钮 - 优化删除按钮日夜模式显示 -->
|
||||
<div class="col-span-1 flex justify-center gap-1">
|
||||
<button @click.stop="$emit('edit-definition', index)"
|
||||
class="p-1.5 rounded-md transition-all duration-150 text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-100 dark:hover:bg-blue-900/40 active:scale-95"
|
||||
title="编辑">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button @click.stop="$emit('remove-definition', index)"
|
||||
:disabled="def.required"
|
||||
:class="['p-1.5 rounded-md transition-all duration-150',
|
||||
def.required
|
||||
? 'text-gray-300 dark:text-gray-600 cursor-not-allowed'
|
||||
: 'text-gray-600 dark:text-gray-300 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-100 dark:hover:bg-red-900/40 active:scale-95']"
|
||||
title="删除">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 添加按钮 -->
|
||||
<div class="p-4 bg-gray-50 dark:bg-gray-800/80 border-t border-gray-200 dark:border-gray-700 text-center">
|
||||
<button @click="$emit('add-definition')"
|
||||
class="text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium py-2 px-5 border-2 border-dashed border-blue-300 dark:border-blue-600 rounded-lg hover:bg-blue-50 dark:hover:bg-blue-900/30 transition-all duration-150 inline-flex items-center gap-2 active:scale-95">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||
</svg>
|
||||
添加新定义
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ========== 版本管理 ========== -->
|
||||
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700">
|
||||
<div class="p-4 border-b border-gray-100 dark:border-gray-700 flex justify-between items-center cursor-pointer"
|
||||
@click="versionCollapsed = !versionCollapsed">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-gray-900 dark:text-white flex items-center gap-2">
|
||||
<span class="text-xl">🔄</span> 版本管理
|
||||
</h3>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">手动选择 GitHub 发布的版本进行切换/更新</p>
|
||||
</div>
|
||||
<div class="flex gap-2 items-center">
|
||||
<span class="text-xs px-2 py-1 bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-700 rounded-full text-blue-700 dark:text-blue-300 font-mono font-medium">当前版本: v{{ releasesCurrentVersion || '加载中...' }}</span>
|
||||
<div class="h-6 w-px bg-gray-200 dark:bg-gray-600 mx-2"></div>
|
||||
<!-- 补齐入口:POST /api/update/check 会真正访问 GitHub 重查;GET 只读启动缓存 -->
|
||||
<button @click.stop="$emit('refresh-update-check')" title="立即联网检查最新版本"
|
||||
:disabled="updateCheckRefreshing"
|
||||
:class="['px-2.5 py-1.5 text-xs rounded-lg border transition-colors',
|
||||
updateCheckRefreshing
|
||||
? 'border-gray-200 dark:border-gray-600 text-gray-400 cursor-not-allowed'
|
||||
: 'border-blue-200 dark:border-blue-700 text-blue-700 dark:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/30']">
|
||||
{{ updateCheckRefreshing ? '检查中...' : '立即检查' }}
|
||||
</button>
|
||||
<button @click.stop="$emit('load-releases')" title="刷新版本列表"
|
||||
:disabled="releasesLoading"
|
||||
class="p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors flex items-center justify-center">
|
||||
<svg :class="['w-4 h-4', releasesLoading ? 'animate-spin' : '']" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button class="p-1.5 ml-2 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors"
|
||||
v-html="versionCollapsed ? $icons.chevronDown : $icons.chevronUp">
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="!versionCollapsed" class="p-0">
|
||||
<div v-if="releasesLoading && !releases.length" class="p-8 text-center text-gray-500 dark:text-gray-400">
|
||||
<div class="animate-spin inline-block w-6 h-6 border-[3px] border-current border-t-transparent text-blue-600 rounded-full mb-2" role="status" aria-label="loading"></div>
|
||||
<div>正在加载版本列表...</div>
|
||||
</div>
|
||||
<div v-else-if="releasesError" class="p-8 text-center text-red-500">
|
||||
{{ releasesError }}
|
||||
<button @click="$emit('load-releases')" class="mt-2 block mx-auto px-3 py-1 bg-red-100 hover:bg-red-200 text-red-700 rounded text-xs">重试</button>
|
||||
</div>
|
||||
<div v-else-if="!releases.length" class="p-8 text-center text-gray-500 dark:text-gray-400">
|
||||
暂无版本发布记录
|
||||
</div>
|
||||
<div v-else>
|
||||
<!-- 表头 -->
|
||||
<div class="grid grid-cols-12 gap-4 px-6 py-3 bg-gray-50 dark:bg-gray-900/50 text-xs font-semibold text-gray-600 dark:text-gray-300 border-b border-gray-200 dark:border-gray-700">
|
||||
<div class="col-span-3">版本 (Tag)</div>
|
||||
<div class="col-span-4">发布时间</div>
|
||||
<div class="col-span-2 text-center">更新说明</div>
|
||||
<div class="col-span-3 text-center">操作</div>
|
||||
</div>
|
||||
|
||||
<!-- 列表 -->
|
||||
<div class="divide-y divide-gray-100 dark:divide-gray-700">
|
||||
<div v-for="rel in paginatedReleases" :key="rel.tag"
|
||||
class="grid grid-cols-12 gap-4 px-6 py-3.5 items-center hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors">
|
||||
<div class="col-span-3 flex items-center gap-2">
|
||||
<span class="font-mono font-bold text-gray-900 dark:text-white">{{ rel.tag }}</span>
|
||||
<span v-if="rel.tag === 'v' + releasesCurrentVersion || rel.tag === releasesCurrentVersion || rel.is_current" class="px-2 py-0.5 text-[10px] text-green-700 bg-green-50 border border-green-200 rounded dark:bg-green-900/30 dark:text-green-300 dark:border-green-800">当前</span>
|
||||
</div>
|
||||
<div class="col-span-4 text-sm text-gray-500 dark:text-gray-400">
|
||||
{{ formatReleaseDate(rel.published_at) }}
|
||||
</div>
|
||||
<div class="col-span-2 text-center">
|
||||
<button @click="$emit('show-changelog', rel.tag, rel.body)"
|
||||
class="text-xs text-blue-600 dark:text-blue-400 hover:underline">
|
||||
查看说明
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-span-3 text-center">
|
||||
<span v-if="rel.tag === 'v' + releasesCurrentVersion || rel.tag === releasesCurrentVersion || rel.is_current"
|
||||
class="inline-block px-3 py-1 text-xs text-gray-400 bg-gray-100 dark:bg-gray-800 dark:text-gray-600 rounded-lg font-medium">
|
||||
已是当前版本
|
||||
</span>
|
||||
<button v-else-if="switchingTag === rel.tag" disabled
|
||||
class="px-3 py-1 text-xs text-white bg-blue-400 rounded-lg cursor-wait animate-pulse">
|
||||
切换中...
|
||||
</button>
|
||||
<button v-else @click="$emit('switch-to-version', rel.tag)"
|
||||
:disabled="!!switchingTag"
|
||||
:class="['px-3 py-1 text-xs font-medium rounded-lg transition-colors',
|
||||
switchingTag ? 'bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-600 cursor-not-allowed' : 'bg-blue-600 text-white hover:bg-blue-700 shadow-sm']">
|
||||
切换到此版本
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="releaseTotalPages > 1"
|
||||
class="flex flex-wrap items-center justify-between gap-3 border-t border-gray-200 px-6 py-3 text-xs text-gray-500 dark:border-gray-700 dark:text-gray-400">
|
||||
<span>共 {{ releases.length }} 条 · 第 {{ releasePage }} / {{ releaseTotalPages }} 页</span>
|
||||
<div class="flex items-center gap-1" aria-label="版本列表分页">
|
||||
<button type="button"
|
||||
@click="goToReleasePage(releasePage - 1)"
|
||||
:disabled="releasePage <= 1"
|
||||
title="上一页" aria-label="上一页"
|
||||
class="flex h-8 w-8 items-center justify-center rounded-lg border border-gray-200 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-700">
|
||||
<span class="h-4 w-4 rotate-180" v-html="$icons.arrowRight"></span>
|
||||
</button>
|
||||
<button v-for="page in releaseTotalPages" :key="page"
|
||||
type="button"
|
||||
@click="goToReleasePage(page)"
|
||||
:aria-current="page === releasePage ? 'page' : null"
|
||||
:class="['h-8 min-w-8 rounded-lg border px-2 text-xs font-medium transition-colors',
|
||||
page === releasePage
|
||||
? 'border-blue-600 bg-blue-600 text-white'
|
||||
: 'border-gray-200 text-gray-600 hover:bg-gray-100 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-700']">
|
||||
{{ page }}
|
||||
</button>
|
||||
<button type="button"
|
||||
@click="goToReleasePage(releasePage + 1)"
|
||||
:disabled="releasePage >= releaseTotalPages"
|
||||
title="下一页" aria-label="下一页"
|
||||
class="flex h-8 w-8 items-center justify-center rounded-lg border border-gray-200 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-700">
|
||||
<span class="h-4 w-4" v-html="$icons.arrowRight"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ========== 环境配置 和 浏览器常量 ========== -->
|
||||
<div class="grid grid-cols-1 xl:grid-cols-2 gap-6">
|
||||
|
||||
<!-- 环境配置 -->
|
||||
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 flex flex-col">
|
||||
<div class="p-4 border-b border-gray-100 dark:border-gray-700 flex justify-between items-start">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-gray-900 dark:text-white flex items-center gap-2">
|
||||
<span class="text-xl" v-html="$icons.folderOpen"></span> 环境配置
|
||||
</h3>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">每个字段都会标明是服务重启生效,还是需要重新运行 start.bat</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button @click="$emit('reset-env')" title="重置"
|
||||
class="p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors">
|
||||
<span v-html="$icons.arrowPath"></span>
|
||||
</button>
|
||||
<button @click="$emit('save-env')"
|
||||
:disabled="savingEnv || !envChanged"
|
||||
:class="['px-3 py-1.5 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-1 shadow-sm',
|
||||
savingEnv || !envChanged
|
||||
? 'bg-blue-400 cursor-not-allowed opacity-60'
|
||||
: 'bg-blue-600 hover:bg-blue-700']">
|
||||
<span v-if="!savingEnv" v-html="$icons.arrowDownTray" class="w-4 h-4"></span>
|
||||
{{ savingEnv ? '...' : '保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-2 space-y-2">
|
||||
<div v-for="(group, groupKey) in envSchema" :key="groupKey" class="rounded-lg border border-gray-100 dark:border-gray-700/50 overflow-hidden">
|
||||
<div class="px-4 py-2 bg-gray-50/50 dark:bg-gray-800/50 flex justify-between items-center cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700/50 transition-colors"
|
||||
@click="$emit('toggle-env-group', groupKey)">
|
||||
<div class="flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-200">
|
||||
<span class="opacity-70">{{ group.icon }}</span>
|
||||
<span>{{ group.label }}</span>
|
||||
</div>
|
||||
<span v-html="envCollapsed[groupKey] ? $icons.chevronDown : $icons.chevronUp" class="text-gray-400 w-4 h-4"></span>
|
||||
</div>
|
||||
|
||||
<div v-show="!envCollapsed[groupKey]" class="px-4 py-4 space-y-5 bg-white dark:bg-gray-800">
|
||||
<div v-for="(field, fieldKey) in group.items" :key="fieldKey" class="grid grid-cols-1 gap-1">
|
||||
<div class="flex justify-between items-start gap-3">
|
||||
<div class="min-w-0 space-y-1">
|
||||
<label class="text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||
{{ field.label }}
|
||||
</label>
|
||||
<span :class="['inline-flex rounded-full px-2 py-0.5 text-[10px] font-medium', getEnvApplyClass(field, group)]">
|
||||
{{ getEnvApplyLabel(field, group) }}
|
||||
</span>
|
||||
</div>
|
||||
<span v-if="field.unit" class="text-xs text-gray-400 dark:text-gray-500 font-mono">
|
||||
{{ field.unit }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div v-if="field.type === 'switch'" class="flex items-center h-9">
|
||||
<label class="toggle-label">
|
||||
<input type="checkbox" v-model="envConfig[fieldKey]" class="sr-only peer">
|
||||
<div class="toggle-bg"></div>
|
||||
</label>
|
||||
</div>
|
||||
<select v-else-if="field.type === 'select'" v-model="envConfig[fieldKey]"
|
||||
class="settings-input w-full">
|
||||
<option v-for="opt in field.options"
|
||||
:key="typeof opt === 'object' ? opt.value : opt"
|
||||
:value="typeof opt === 'object' ? opt.value : opt">
|
||||
{{ typeof opt === 'object' ? opt.label : opt }}
|
||||
</option>
|
||||
</select>
|
||||
<input v-else-if="field.type === 'number'" type="number"
|
||||
v-model.number="envConfig[fieldKey]"
|
||||
:min="field.min" :max="field.max" :step="field.step || 1"
|
||||
class="settings-input w-full">
|
||||
<input v-else :type="field.type === 'password' ? 'password' : 'text'"
|
||||
v-model="envConfig[fieldKey]"
|
||||
:placeholder="field.default"
|
||||
class="settings-input w-full">
|
||||
</div>
|
||||
|
||||
<div v-if="field.desc" class="text-xs text-gray-400 dark:text-gray-500 flex items-start gap-1 mt-0.5">
|
||||
<span class="mt-0.5 opacity-70">ℹ️</span>
|
||||
<span>{{ field.desc }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 浏览器常量 -->
|
||||
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 flex flex-col">
|
||||
<div class="p-4 border-b border-gray-100 dark:border-gray-700 flex justify-between items-start">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-gray-900 dark:text-white flex items-center gap-2">
|
||||
<span class="text-xl">🌐</span> 浏览器常量
|
||||
</h3>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">即时生效</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button @click="$emit('reset-browser')" title="重置"
|
||||
class="p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors">
|
||||
<span v-html="$icons.arrowPath"></span>
|
||||
</button>
|
||||
<button @click="$emit('save-browser')"
|
||||
:disabled="savingBrowser || !browserChanged"
|
||||
:class="['px-3 py-1.5 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-1 shadow-sm',
|
||||
savingBrowser || !browserChanged
|
||||
? 'bg-blue-400 cursor-not-allowed opacity-60'
|
||||
: 'bg-blue-600 hover:bg-blue-700']">
|
||||
<span v-if="!savingBrowser" v-html="$icons.arrowDownTray" class="w-4 h-4"></span>
|
||||
{{ savingBrowser ? '...' : '保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-2 space-y-2">
|
||||
<div v-for="(group, groupKey) in browserSchema" :key="groupKey" class="rounded-lg border border-gray-100 dark:border-gray-700/50 overflow-hidden">
|
||||
<div class="px-4 py-2 bg-gray-50/50 dark:bg-gray-800/50 flex justify-between items-center cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700/50 transition-colors"
|
||||
@click="$emit('toggle-browser-group', groupKey)">
|
||||
<div class="flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-200">
|
||||
<span class="opacity-70">{{ group.icon }}</span>
|
||||
<span>{{ group.label }}</span>
|
||||
</div>
|
||||
<span v-html="browserCollapsed[groupKey] ? $icons.chevronDown : $icons.chevronUp" class="text-gray-400 w-4 h-4"></span>
|
||||
</div>
|
||||
|
||||
<div v-show="!browserCollapsed[groupKey]" class="px-4 py-4 space-y-5 bg-white dark:bg-gray-800">
|
||||
<div v-for="(field, fieldKey) in group.items" :key="fieldKey" class="grid grid-cols-1 gap-1">
|
||||
<div class="flex justify-between">
|
||||
<label class="text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||
{{ field.label }}
|
||||
</label>
|
||||
<span v-if="field.unit" class="text-xs text-gray-400 dark:text-gray-500 font-mono">
|
||||
{{ field.unit }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div v-if="field.type === 'switch'" class="flex items-center h-9">
|
||||
<label class="toggle-label">
|
||||
<input type="checkbox" v-model="browserConstants[fieldKey]" class="sr-only peer">
|
||||
<div class="toggle-bg"></div>
|
||||
</label>
|
||||
</div>
|
||||
<select v-else-if="field.type === 'select'" v-model="browserConstants[fieldKey]"
|
||||
class="settings-input w-full">
|
||||
<option v-for="opt in field.options" :key="opt" :value="opt">{{ opt }}</option>
|
||||
</select>
|
||||
<input v-else-if="field.type === 'number'" type="number"
|
||||
v-model.number="browserConstants[fieldKey]"
|
||||
:min="field.min" :max="field.max" :step="field.step || 1"
|
||||
class="settings-input w-full">
|
||||
<input v-else :type="field.type === 'password' ? 'password' : 'text'"
|
||||
v-model="browserConstants[fieldKey]"
|
||||
:placeholder="field.default"
|
||||
class="settings-input w-full">
|
||||
</div>
|
||||
|
||||
<div v-if="field.desc" class="text-xs text-gray-400 dark:text-gray-500 flex items-start gap-1 mt-0.5">
|
||||
<span class="mt-0.5 opacity-70">ℹ️</span>
|
||||
<span>{{ field.desc }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700">
|
||||
<div class="p-4 border-b border-gray-100 dark:border-gray-700 flex justify-between items-center cursor-pointer"
|
||||
@click="updatePreserveCollapsed = !updatePreserveCollapsed">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-gray-900 dark:text-white flex items-center gap-2">
|
||||
<span class="text-xl">🛠️</span> 更新白名单
|
||||
</h3>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">勾选后,下次自动更新会原样保留对应文件或目录</p>
|
||||
</div>
|
||||
<div class="flex gap-2 items-center">
|
||||
<button @click.stop="$emit('reset-update-preserve')" title="重置"
|
||||
class="p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors">
|
||||
<span v-html="$icons.arrowPath"></span>
|
||||
</button>
|
||||
<button @click.stop="$emit('save-update-preserve')"
|
||||
:disabled="savingUpdatePreserve || !updatePreserveChanged"
|
||||
:class="['px-3 py-1.5 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-1 shadow-sm',
|
||||
savingUpdatePreserve || !updatePreserveChanged
|
||||
? 'bg-blue-400 cursor-not-allowed opacity-60'
|
||||
: 'bg-blue-600 hover:bg-blue-700']">
|
||||
<span v-if="!savingUpdatePreserve" v-html="$icons.arrowDownTray" class="w-4 h-4"></span>
|
||||
{{ savingUpdatePreserve ? '...' : '保存' }}
|
||||
</button>
|
||||
<button class="p-1.5 ml-2 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors"
|
||||
v-html="updatePreserveCollapsed ? $icons.chevronDown : $icons.chevronUp">
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="!updatePreserveCollapsed" class="p-4 space-y-4">
|
||||
<div class="rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:bg-amber-900/20 dark:text-amber-300">
|
||||
这里控制的是“更新时是否保留不变”,不是运行时是否启用。目录项会保留整个目录;未勾选的项目会在更新时按新版本内容覆盖或合并。
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div v-for="(items, category) in updatePreserveGroups" :key="category" class="space-y-2">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.14em] text-gray-400 dark:text-gray-500">{{ category }}</div>
|
||||
<div class="grid gap-2 md:grid-cols-2">
|
||||
<label v-for="item in items" :key="item.id"
|
||||
class="flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50/70 px-3 py-3 text-sm text-gray-700 transition hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-900/40 dark:text-gray-200 dark:hover:bg-gray-900/70">
|
||||
<input type="checkbox"
|
||||
:checked="updatePreserveSelected.includes(item.pattern)"
|
||||
@change="$emit('toggle-update-preserve', item.pattern)"
|
||||
class="mt-0.5 h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
|
||||
<span class="min-w-0">
|
||||
<span class="block font-medium">{{ item.label }}</span>
|
||||
<span class="mt-0.5 block text-xs text-gray-500 dark:text-gray-400">{{ item.description }}</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
@@ -0,0 +1,226 @@
|
||||
// ==================== 侧边栏组件 ====================
|
||||
window.getDashboardAuthToken = window.getDashboardAuthToken || function () {
|
||||
try {
|
||||
return String(
|
||||
localStorage.getItem('dashboard_token')
|
||||
|| localStorage.getItem('api_token')
|
||||
|| ''
|
||||
).trim();
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
window.SidebarComponent = {
|
||||
name: 'SidebarComponent',
|
||||
props: {
|
||||
sites: { type: Object, required: true },
|
||||
currentDomain: { type: String, default: '' },
|
||||
browserStatus: { type: Object, required: true },
|
||||
authEnabled: { type: Boolean, default: false },
|
||||
hasToken: { type: Boolean, default: false },
|
||||
darkMode: { type: Boolean, default: false },
|
||||
activeTab: { type: String, default: 'home' },
|
||||
updateAvailable: { type: Boolean, default: false },
|
||||
systemStats: { type: Object, default: () => ({ memory_mb: 0, disk_status: '未知', total_requests: 0 }) }
|
||||
},
|
||||
emits: [
|
||||
'select-site',
|
||||
'add-site',
|
||||
'delete-site',
|
||||
'export-site',
|
||||
'toggle-dark',
|
||||
'refresh-status',
|
||||
'trigger-import',
|
||||
'export-all',
|
||||
'show-token-dialog',
|
||||
'open-guide',
|
||||
'primary-action',
|
||||
'collapse-change',
|
||||
'change-tab' // ✨ 新增
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
navCollapsed: false,
|
||||
mobileOpen: false,
|
||||
tourNavigationSnapshot: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
primaryActionLabel() {
|
||||
return this.activeTab === 'commands' ? '新建命令' : '新增站点';
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
try {
|
||||
this.navCollapsed = localStorage.getItem('dashboard_nav_collapsed') === '1';
|
||||
} catch (e) {
|
||||
this.navCollapsed = false;
|
||||
}
|
||||
this.$emit('collapse-change', this.navCollapsed);
|
||||
},
|
||||
methods: {
|
||||
toggleNavCollapsed() {
|
||||
this.navCollapsed = !this.navCollapsed;
|
||||
this.$emit('collapse-change', this.navCollapsed);
|
||||
try {
|
||||
localStorage.setItem('dashboard_nav_collapsed', this.navCollapsed ? '1' : '0');
|
||||
} catch (e) {
|
||||
// Layout persistence is optional.
|
||||
}
|
||||
},
|
||||
openMobileNav() {
|
||||
this.mobileOpen = true;
|
||||
},
|
||||
closeMobileNav() {
|
||||
this.mobileOpen = false;
|
||||
},
|
||||
beginTourNavigation() {
|
||||
if (!this.tourNavigationSnapshot) {
|
||||
this.tourNavigationSnapshot = {
|
||||
navCollapsed: this.navCollapsed,
|
||||
mobileOpen: this.mobileOpen
|
||||
};
|
||||
}
|
||||
this.navCollapsed = false;
|
||||
this.mobileOpen = window.innerWidth <= 900;
|
||||
this.$emit('collapse-change', false);
|
||||
},
|
||||
endTourNavigation() {
|
||||
const snapshot = this.tourNavigationSnapshot;
|
||||
this.mobileOpen = false;
|
||||
if (snapshot) {
|
||||
this.navCollapsed = snapshot.navCollapsed;
|
||||
this.$emit('collapse-change', this.navCollapsed);
|
||||
}
|
||||
this.tourNavigationSnapshot = null;
|
||||
},
|
||||
selectTab(tab) {
|
||||
this.mobileOpen = false;
|
||||
this.$emit('change-tab', tab);
|
||||
},
|
||||
selectSite(domain) {
|
||||
this.mobileOpen = false;
|
||||
this.$emit('select-site', domain);
|
||||
},
|
||||
runPrimaryAction() {
|
||||
this.mobileOpen = false;
|
||||
this.$emit('primary-action', this.activeTab);
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div :class="['app-sidebar-layer', { 'is-mobile-open': mobileOpen }]">
|
||||
<button type="button" class="app-sidebar-scrim" @click="closeMobileNav" aria-label="关闭导航"></button>
|
||||
<aside :class="['app-sidebar', { 'is-collapsed': navCollapsed }]" aria-label="主导航">
|
||||
<div class="app-brand">
|
||||
<img src="/static/images/logo.svg" alt="Universal Web API logo" class="app-brand-logo">
|
||||
<div class="app-brand-copy">
|
||||
<strong>Universal API</strong>
|
||||
<span>Local AI bridge</span>
|
||||
</div>
|
||||
<button type="button" class="app-nav-collapse" @click="toggleNavCollapsed"
|
||||
:title="navCollapsed ? '展开导航' : '折叠导航'"
|
||||
:aria-label="navCollapsed ? '展开导航' : '折叠导航'">
|
||||
<span v-if="navCollapsed" class="app-collapse-lines" aria-hidden="true"></span>
|
||||
<span v-else v-html="$icons.xMark" aria-hidden="true"></span>
|
||||
</button>
|
||||
<button type="button" class="app-nav-mobile-close" @click="closeMobileNav" title="关闭导航" aria-label="关闭导航" v-html="$icons.xMark"></button>
|
||||
<button type="button" class="app-collapsed-status" @click="$emit('refresh-status')" title="刷新状态" aria-label="刷新服务状态">
|
||||
<i :class="['app-service-dot', { 'is-online': browserStatus.connected }]"></i>
|
||||
<span>{{ browserStatus.connected ? '在线' : '离线' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<nav class="app-primary-nav" aria-label="功能区">
|
||||
<button type="button" @click="selectTab('home')"
|
||||
:class="['app-nav-item', { 'is-active': activeTab === 'home' }]"
|
||||
title="首页" aria-label="首页"
|
||||
:aria-current="activeTab === 'home' ? 'page' : null">
|
||||
<span class="app-nav-icon" v-html="$icons.home"></span>
|
||||
<span>首页</span>
|
||||
</button>
|
||||
<button type="button" @click="selectTab('config')"
|
||||
data-tour-target="config"
|
||||
:class="['app-nav-item', { 'is-active': activeTab === 'config' }]"
|
||||
title="站点配置" aria-label="站点配置"
|
||||
:aria-current="activeTab === 'config' ? 'page' : null">
|
||||
<span class="app-nav-icon" v-html="$icons.clipboardList"></span>
|
||||
<span>站点配置</span>
|
||||
<span class="app-nav-count">{{ Object.keys(sites).length }}</span>
|
||||
</button>
|
||||
<button type="button" @click="selectTab('tabpool')"
|
||||
data-tour-target="tabpool"
|
||||
:class="['app-nav-item', { 'is-active': activeTab === 'tabpool' }]"
|
||||
title="标签页池" aria-label="标签页池"
|
||||
:aria-current="activeTab === 'tabpool' ? 'page' : null">
|
||||
<span class="app-nav-icon" v-html="$icons.folderOpen"></span>
|
||||
<span>标签页池</span>
|
||||
</button>
|
||||
<button type="button" @click="selectTab('monitor')"
|
||||
data-tour-target="monitor"
|
||||
:class="['app-nav-item', { 'is-active': activeTab === 'monitor' }]"
|
||||
title="请求监控" aria-label="请求监控"
|
||||
:aria-current="activeTab === 'monitor' ? 'page' : null">
|
||||
<span class="app-nav-icon" v-html="$icons.chartBar"></span>
|
||||
<span>请求监控</span>
|
||||
</button>
|
||||
<button type="button" @click="selectTab('commands')"
|
||||
data-tour-target="commands"
|
||||
:class="['app-nav-item', { 'is-active': activeTab === 'commands' }]"
|
||||
title="命令系统" aria-label="命令系统"
|
||||
:aria-current="activeTab === 'commands' ? 'page' : null">
|
||||
<span class="app-nav-icon" v-html="$icons.arrowPathRoundedSquare"></span>
|
||||
<span>命令系统</span>
|
||||
</button>
|
||||
<button type="button" @click="selectTab('logs')"
|
||||
data-tour-target="logs"
|
||||
:class="['app-nav-item', { 'is-active': activeTab === 'logs' }]"
|
||||
title="运行日志" aria-label="运行日志"
|
||||
:aria-current="activeTab === 'logs' ? 'page' : null">
|
||||
<span class="app-nav-icon" v-html="$icons.documentArrowDown"></span>
|
||||
<span>运行日志</span>
|
||||
</button>
|
||||
<button type="button" @click="selectTab('settings')"
|
||||
data-tour-target="settings"
|
||||
:class="['app-nav-item', { 'is-active': activeTab === 'settings' }]"
|
||||
title="设置" aria-label="设置"
|
||||
:aria-current="activeTab === 'settings' ? 'page' : null">
|
||||
<span class="app-nav-icon" v-html="$icons.cog"></span>
|
||||
<span>设置</span>
|
||||
<span v-if="updateAvailable" class="app-update-dot" title="发现新版本"></span>
|
||||
</button>
|
||||
</nav>
|
||||
<div class="app-sidebar-spacer"></div>
|
||||
|
||||
<div class="app-sidebar-footer">
|
||||
<button type="button" class="app-guide-link" @click="$emit('open-guide')" title="重新打开新手指南">
|
||||
<span class="app-footer-icon" v-html="$icons.bookOpen" aria-hidden="true"></span>
|
||||
<span>新手指南</span>
|
||||
</button>
|
||||
<button type="button" class="app-theme-toggle"
|
||||
@click.prevent.stop="$emit('toggle-dark')"
|
||||
:aria-pressed="darkMode"
|
||||
:title="darkMode ? '切换到日间模式' : '切换到夜间模式'">
|
||||
<span class="app-footer-icon" v-html="darkMode ? $icons.sun : $icons.moon" aria-hidden="true"></span>
|
||||
<span>{{ darkMode ? '日间模式' : '夜间模式' }}</span>
|
||||
<i aria-hidden="true"></i>
|
||||
</button>
|
||||
<div class="app-service-row">
|
||||
<span :class="['app-service-dot', { 'is-online': browserStatus.connected }]"></span>
|
||||
<span>{{ browserStatus.connected ? '浏览器已连接' : '浏览器未连接' }}</span>
|
||||
<button type="button" @click="$emit('refresh-status')" title="刷新状态" aria-label="刷新状态" v-html="$icons.arrowPath"></button>
|
||||
</div>
|
||||
<button v-if="authEnabled" type="button" class="app-auth-row" @click.stop="$emit('show-token-dialog')">
|
||||
<span>面板认证</span>
|
||||
<strong>{{ hasToken ? '已配置' : '待配置' }}</strong>
|
||||
</button>
|
||||
<button type="button" class="app-sidebar-primary" @click="runPrimaryAction" :title="primaryActionLabel" :aria-label="primaryActionLabel">
|
||||
<span v-html="$icons.plusCircle"></span>
|
||||
<span>{{ primaryActionLabel }}</span>
|
||||
</button>
|
||||
<div class="app-sidebar-version"><span>本地模式</span><strong>v2.9.5</strong></div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,357 @@
|
||||
// ==================== CommandsTab Computed ====================
|
||||
window.CommandsTriggerTypeBuiltinMeta = window.CommandsTriggerTypeBuiltinMeta || {
|
||||
request_count: {
|
||||
label: '请求计数',
|
||||
description: '当页面请求次数达到阈值时触发,适合每隔一段交互插入一次动作。'
|
||||
},
|
||||
error_count: {
|
||||
label: '错误计数',
|
||||
description: '当累计错误次数达到阈值时触发,适合自动恢复、告警或切换策略。'
|
||||
},
|
||||
idle_timeout: {
|
||||
label: '空闲超时',
|
||||
description: '当标签页持续空闲超过设定秒数时触发,适合长时间无响应后的兜底处理。'
|
||||
},
|
||||
page_check: {
|
||||
label: '页面特征探测',
|
||||
description: '通过文本检索或 JavaScript 注入自动检测页面状态(支持识别 Cloudflare 拦截、人机验证或 502 等异常)。'
|
||||
},
|
||||
command_check: {
|
||||
label: '命令检查',
|
||||
description: '先执行一条检查命令,再根据它某一步或最终返回值决定是否开始执行当前动作列表。'
|
||||
},
|
||||
command_triggered: {
|
||||
label: '命令已触发',
|
||||
description: '当指定命令刚刚被触发时联动执行,适合做后续补充动作。'
|
||||
},
|
||||
command_result_match: {
|
||||
label: '命令返回结果',
|
||||
description: '监听指定命令某一步或最终返回值,只有满足匹配条件时才触发。'
|
||||
},
|
||||
command_result_event: {
|
||||
label: '命令结果事件',
|
||||
description: '监听命令产生的结果事件,可按来源命令筛选,也可以只接收事件。'
|
||||
},
|
||||
network_request_error: {
|
||||
label: '网络异常',
|
||||
description: '按请求 URL 和状态码检查网络错误,命中后可立刻刷新、切代理或告警。'
|
||||
}
|
||||
};
|
||||
|
||||
window.CommandsTabComputed = {
|
||||
triggerTypeOptions() {
|
||||
const builtins = window.CommandsTriggerTypeBuiltinMeta || {};
|
||||
const backendLabels = this.meta.trigger_types || {};
|
||||
const orderedKeys = Array.from(new Set([
|
||||
...Object.keys(builtins),
|
||||
...Object.keys(backendLabels)
|
||||
]));
|
||||
|
||||
return orderedKeys.map(key => ({
|
||||
value: key,
|
||||
label: backendLabels[key] || builtins[key]?.label || key,
|
||||
description: builtins[key]?.description || '用于在满足指定条件后触发动作。'
|
||||
}));
|
||||
},
|
||||
actionTypeOptions() {
|
||||
return Object.entries(this.meta.action_types || {})
|
||||
.filter(([k]) => k !== 'switch_preset')
|
||||
.map(([k, v]) => ({ value: k, label: v }));
|
||||
},
|
||||
actionTypeGroups() {
|
||||
const categoryOrder = ['页面操作', '自动化', '预设与流程', '通知与集成', '任务控制'];
|
||||
const categoryMap = {
|
||||
clear_cookies: '页面操作',
|
||||
refresh_page: '页面操作',
|
||||
new_chat: '页面操作',
|
||||
run_js: '页面操作',
|
||||
run_js_file: '页面操作',
|
||||
wait: '页面操作',
|
||||
navigate: '页面操作',
|
||||
click_element: '页面操作',
|
||||
click_coordinates: '页面操作',
|
||||
// 补齐遗漏的分类映射,否则该动作会被 categoryMap[...] || '其他' 扔进“其他”分组
|
||||
click_captcha_challenge: '页面操作',
|
||||
write_element: '自动化',
|
||||
read_element: '自动化',
|
||||
http_request: '自动化',
|
||||
append_file: '自动化',
|
||||
execute_preset: '预设与流程',
|
||||
execute_workflow: '预设与流程',
|
||||
execute_command_group: '预设与流程',
|
||||
switch_proxy: '通知与集成',
|
||||
send_webhook: '通知与集成',
|
||||
send_napcat: '通知与集成',
|
||||
abort_task: '任务控制',
|
||||
release_tab_lock: '任务控制'
|
||||
};
|
||||
const grouped = new Map();
|
||||
for (const option of (this.actionTypeOptions || [])) {
|
||||
const category = categoryMap[option.value] || '其他';
|
||||
if (!grouped.has(category)) grouped.set(category, []);
|
||||
grouped.get(category).push(option);
|
||||
}
|
||||
const dynamicOrder = Array.from(grouped.keys()).filter(name => !categoryOrder.includes(name));
|
||||
return [...categoryOrder, ...dynamicOrder]
|
||||
.filter(name => grouped.has(name))
|
||||
.map(name => ({ label: name, options: grouped.get(name) }));
|
||||
},
|
||||
commandLogLevelOptions() {
|
||||
return [
|
||||
{ value: 'GLOBAL', label: '跟随全局' },
|
||||
{ value: 'DEBUG', label: '调试' },
|
||||
{ value: 'INFO', label: '信息' },
|
||||
{ value: 'WARNING', label: '警告' },
|
||||
{ value: 'ERROR', label: '错误' }
|
||||
];
|
||||
},
|
||||
sourceCommandOptions() {
|
||||
const currentId = this.editingCommand?.id;
|
||||
return (this.commands || [])
|
||||
.filter(cmd => cmd?.id && cmd.id !== currentId)
|
||||
.map(cmd => ({
|
||||
value: cmd.id,
|
||||
label: cmd.name || cmd.id,
|
||||
groupName: String(cmd.group_name || '').trim(),
|
||||
enabled: cmd.enabled !== false,
|
||||
searchText: [
|
||||
cmd.name || '',
|
||||
cmd.id || '',
|
||||
String(cmd.group_name || '').trim()
|
||||
].join(' ').toLowerCase()
|
||||
}))
|
||||
.sort((a, b) => {
|
||||
const aGrouped = a.groupName ? 0 : 1;
|
||||
const bGrouped = b.groupName ? 0 : 1;
|
||||
if (aGrouped !== bGrouped) return aGrouped - bGrouped;
|
||||
if (a.groupName !== b.groupName) {
|
||||
return a.groupName.localeCompare(b.groupName, 'zh-CN');
|
||||
}
|
||||
return a.label.localeCompare(b.label, 'zh-CN');
|
||||
});
|
||||
},
|
||||
selectedSourceCommandOptions() {
|
||||
const ids = new Set(
|
||||
Array.isArray(this.editingCommand?.trigger?.command_ids)
|
||||
? this.editingCommand.trigger.command_ids.map(id => String(id || '').trim()).filter(Boolean)
|
||||
: []
|
||||
);
|
||||
return (this.sourceCommandOptions || []).filter(opt => ids.has(opt.value));
|
||||
},
|
||||
selectedSourceCommandOption() {
|
||||
const selectedId = String(this.editingCommand?.trigger?.command_id || '').trim();
|
||||
if (!selectedId) return null;
|
||||
return this.sourceCommandOptions.find(opt => opt.value === selectedId) || null;
|
||||
},
|
||||
filteredSourceCommandSections() {
|
||||
const keyword = String(this.sourceCommandSearch || '').trim().toLowerCase();
|
||||
const groupedMap = new Map();
|
||||
const ungrouped = [];
|
||||
|
||||
for (const option of (this.sourceCommandOptions || [])) {
|
||||
if (keyword && !option.searchText.includes(keyword)) {
|
||||
continue;
|
||||
}
|
||||
if (option.groupName) {
|
||||
if (!groupedMap.has(option.groupName)) {
|
||||
groupedMap.set(option.groupName, []);
|
||||
}
|
||||
groupedMap.get(option.groupName).push(option);
|
||||
} else {
|
||||
ungrouped.push(option);
|
||||
}
|
||||
}
|
||||
|
||||
const groupedSections = Array.from(groupedMap.entries())
|
||||
.sort((a, b) => a[0].localeCompare(b[0], 'zh-CN'))
|
||||
.map(([name, commands]) => ({
|
||||
key: 'group:' + name,
|
||||
name,
|
||||
commands
|
||||
}));
|
||||
|
||||
if (ungrouped.length > 0) {
|
||||
groupedSections.push({
|
||||
key: 'group:__ungrouped__',
|
||||
name: '未分组命令',
|
||||
commands: ungrouped,
|
||||
isUngrouped: true
|
||||
});
|
||||
}
|
||||
|
||||
return groupedSections;
|
||||
},
|
||||
resultSourceActionOptions() {
|
||||
const sourceId = this.editingCommand?.trigger?.command_id;
|
||||
if (!sourceId) return [];
|
||||
return this.getCommandActionOptions(sourceId);
|
||||
},
|
||||
enabledCount() {
|
||||
return (this.commands || []).filter(cmd => cmd.enabled).length;
|
||||
},
|
||||
disabledCount() {
|
||||
return (this.commands || []).filter(cmd => !cmd.enabled).length;
|
||||
},
|
||||
displayRows() {
|
||||
const rows = [];
|
||||
const groupRowMap = {};
|
||||
for (const cmd of (this.commands || [])) {
|
||||
const groupName = String(cmd?.group_name || '').trim();
|
||||
if (!groupName) {
|
||||
rows.push({
|
||||
key: 'cmd_' + cmd.id,
|
||||
isGroup: false,
|
||||
groupName: '',
|
||||
commands: [cmd]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (!groupRowMap[groupName]) {
|
||||
const row = {
|
||||
key: 'group_' + groupName,
|
||||
isGroup: true,
|
||||
groupName,
|
||||
commands: []
|
||||
};
|
||||
groupRowMap[groupName] = row;
|
||||
rows.push(row);
|
||||
}
|
||||
groupRowMap[groupName].commands.push(cmd);
|
||||
}
|
||||
return rows;
|
||||
},
|
||||
totalPages() {
|
||||
return Math.max(1, Math.ceil((this.displayRows || []).length / this.pageSize));
|
||||
},
|
||||
pageStartIndex() {
|
||||
if (!this.displayRows.length) return 0;
|
||||
return (this.currentPage - 1) * this.pageSize + 1;
|
||||
},
|
||||
pageEndIndex() {
|
||||
return Math.min(this.currentPage * this.pageSize, this.displayRows.length);
|
||||
},
|
||||
visiblePageNumbers() {
|
||||
const total = this.totalPages;
|
||||
const current = this.currentPage;
|
||||
const start = Math.max(1, current - 2);
|
||||
const end = Math.min(total, start + 4);
|
||||
const adjustedStart = Math.max(1, end - 4);
|
||||
return Array.from({ length: end - adjustedStart + 1 }, (_, idx) => adjustedStart + idx);
|
||||
},
|
||||
selectedCommands() {
|
||||
if (!Array.isArray(this.selectedCommandIds) || this.selectedCommandIds.length === 0) return [];
|
||||
const selectedSet = new Set(this.selectedCommandIds);
|
||||
return (this.commands || []).filter(cmd => selectedSet.has(cmd.id));
|
||||
},
|
||||
hasSelection() {
|
||||
return this.selectedCommands.length > 0;
|
||||
},
|
||||
commandGroups() {
|
||||
const bucket = {};
|
||||
for (const cmd of (this.commands || [])) {
|
||||
const groupName = String(cmd?.group_name || '').trim();
|
||||
if (!groupName) continue;
|
||||
if (!bucket[groupName]) {
|
||||
bucket[groupName] = {
|
||||
name: groupName,
|
||||
count: 0,
|
||||
enabledCount: 0,
|
||||
commandIds: []
|
||||
};
|
||||
}
|
||||
bucket[groupName].count += 1;
|
||||
bucket[groupName].enabledCount += cmd.enabled ? 1 : 0;
|
||||
bucket[groupName].commandIds.push(cmd.id);
|
||||
}
|
||||
return Object.values(bucket).sort((a, b) => a.name.localeCompare(b.name, 'zh-CN'));
|
||||
},
|
||||
commandGroupOptions() {
|
||||
return this.commandGroups.map(group => ({ value: group.name, label: group.name }));
|
||||
},
|
||||
paginatedDisplayRows() {
|
||||
const start = (this.currentPage - 1) * this.pageSize;
|
||||
return (this.displayRows || []).slice(start, start + this.pageSize);
|
||||
},
|
||||
visiblePageCommandIds() {
|
||||
const ids = [];
|
||||
for (const row of (this.paginatedDisplayRows || [])) {
|
||||
if (row.isGroup && this.isGroupCollapsed(row.groupName)) continue;
|
||||
for (const cmd of (row.commands || [])) {
|
||||
ids.push(cmd.id);
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
},
|
||||
resolvedPresetDomain() {
|
||||
return this.getBoundDomain(this.editingCommand);
|
||||
},
|
||||
advancedUiConfig() {
|
||||
return this.editingCommand?.advanced_ui || {};
|
||||
},
|
||||
advancedUiFields() {
|
||||
const fields = this.advancedUiConfig.fields;
|
||||
return Array.isArray(fields) ? fields : [];
|
||||
},
|
||||
advancedUiRuleFields() {
|
||||
return this.advancedUiFields.filter(field => field.type === 'rule_list');
|
||||
},
|
||||
advancedUiGlobalFieldGroups() {
|
||||
const fields = this.advancedUiFields.filter(field => field.type !== 'rule_list');
|
||||
const definitions = [
|
||||
{ id: 'execution', label: '执行与内容', keys: ['total_runs', 'prompt_text', 'reference_image', 'random_insert_chars', 'wait_reply_timeout_sec'] },
|
||||
{ id: 'page', label: '页面交互', keys: ['message_selector', 'send_selector', 'new_chat_selector', 'agree_selector', 'redirect_url'] },
|
||||
{ id: 'retry', label: '重试与恢复', keys: ['new_chat_ready_timeout_sec', 'new_chat_retry_attempts', 'new_chat_retry_delay_sec'] },
|
||||
{ id: 'integration', label: '外部集成', keys: ['link_drawer_path', 'controlled_browser_api_url', 'detector_url'] },
|
||||
{ id: 'legacy', label: '兼容设置', keys: ['arena_detector_enabled', 'arena_detector_model_keyword'] },
|
||||
];
|
||||
const assigned = new Set();
|
||||
const groups = definitions.map(definition => {
|
||||
const groupedFields = definition.keys
|
||||
.map(key => fields.find(field => field.key === key))
|
||||
.filter(Boolean);
|
||||
groupedFields.forEach(field => assigned.add(field.key));
|
||||
return { ...definition, fields: groupedFields };
|
||||
}).filter(group => group.fields.length);
|
||||
const remaining = fields.filter(field => !assigned.has(field.key));
|
||||
if (remaining.length) groups.push({ id: 'other', label: '其他设置', fields: remaining });
|
||||
return groups;
|
||||
},
|
||||
hasAdvancedUiForm() {
|
||||
return String(this.advancedUiConfig.kind || '').trim().toLowerCase() === 'form'
|
||||
&& this.advancedUiFields.length > 0;
|
||||
},
|
||||
advancedUiTitle() {
|
||||
return String(this.advancedUiConfig.title || '').trim() || '高级命令配置';
|
||||
},
|
||||
advancedUiDescription() {
|
||||
if (this.advancedUiFields.some(field => field.type === 'rule_list')) {
|
||||
return '同一轮回复会交给所有模板独立筛选;命中 URL 持久化到结果区,并可按模板写入链接抽屉分组。';
|
||||
}
|
||||
return String(this.advancedUiConfig.description || '').trim();
|
||||
},
|
||||
advancedUiResultsEnabled() {
|
||||
return !!this.advancedUiConfig.results_enabled
|
||||
|| this.advancedUiFields.some(field => field.type === 'rule_list');
|
||||
},
|
||||
scriptPlaceholder() {
|
||||
if (!this.editingCommand) return '';
|
||||
if (this.editingCommand.script_lang === 'javascript') {
|
||||
return '// 在页面中执行的 JavaScript\n' +
|
||||
'// 清除 cookies 并刷新页面\n' +
|
||||
'document.cookie.split(";").forEach(c => {\n' +
|
||||
' document.cookie = c.trim().split("=")[0] + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/";\n' +
|
||||
'});\n' +
|
||||
'location.reload();';
|
||||
} else {
|
||||
return '# Python 脚本\n' +
|
||||
'# 默认使用受限沙箱;可用变量: tab, session, browser, config_engine, logger, time, json\n' +
|
||||
'# 默认允许导入: json, time, datetime, math, requests, urllib.parse\n\n' +
|
||||
'logger.info(f"当前 URL: {tab.url}")\n' +
|
||||
'logger.info(f"请求次数: {session.request_count}")\n\n' +
|
||||
'# 清除 cookies 并刷新\n' +
|
||||
'tab.run_js("document.cookie.split(\\";\\").forEach(c => document.cookie = c.trim().split(\\"=\\")[0] + \\"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/\\");")\n' +
|
||||
'time.sleep(0.5)\n' +
|
||||
'tab.refresh()';
|
||||
}
|
||||
}
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,212 @@
|
||||
// R2-8:站点适配器维护面板——健康巡检(R1-6)、选择器脆弱度(R1-7)、适配器在线更新(R1-3)。
|
||||
// 由 ConfigTab 以 <adapter-panel> 使用;request 为带鉴权与超时的请求函数(返回解析后的 JSON,出错抛异常)。
|
||||
window.AdapterPanel = {
|
||||
name: 'AdapterPanel',
|
||||
props: {
|
||||
domain: { type: String, default: '' },
|
||||
presetName: { type: String, default: '' },
|
||||
request: { type: Function, required: true }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
health: null, healthLoading: false, healthError: '',
|
||||
lint: null, lintLoading: false, lintError: '',
|
||||
updates: null, updatesLoading: false, updatesError: '',
|
||||
applyResult: null, applying: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
healthTab() {
|
||||
return (this.health && Array.isArray(this.health.tabs) && this.health.tabs[0]) || null;
|
||||
},
|
||||
lintRows() {
|
||||
const presets = (this.lint && this.lint.presets) || {};
|
||||
const rows = presets[this.presetName] || Object.values(presets)[0] || [];
|
||||
return rows.filter(row => row.score < 100 || (row.issues || []).length);
|
||||
},
|
||||
updateRows() {
|
||||
return ((this.updates && this.updates.sites) || []).filter(row => row.status !== 'up_to_date');
|
||||
},
|
||||
safeUpdateCount() {
|
||||
return this.updateRows.filter(row => row.status === 'update_available' || row.status === 'new_site').length;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
domain() {
|
||||
this.health = null; this.healthError = '';
|
||||
this.lint = null; this.lintError = '';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
statusLabel(status) {
|
||||
return ({
|
||||
healthy: '健康', degraded: '部分缺失', broken: '异常', unreachable: '无可用页面',
|
||||
ok: '命中', missing: '未命中', invalid: '语法无效',
|
||||
up_to_date: '已是最新', update_available: '可安全更新', conflict: '本地已修改',
|
||||
new_site: '新站点', local_only: '仅本地', requires_newer_app: '需要更新程序'
|
||||
})[status] || status;
|
||||
},
|
||||
statusClass(status) {
|
||||
if (['healthy', 'ok', 'up_to_date'].includes(status)) return 'adapter-badge is-good';
|
||||
if (['degraded', 'missing', 'update_available', 'new_site', 'conflict'].includes(status)) return 'adapter-badge is-warn';
|
||||
if (['broken', 'invalid', 'requires_newer_app'].includes(status)) return 'adapter-badge is-bad';
|
||||
return 'adapter-badge';
|
||||
},
|
||||
async runHealth() {
|
||||
if (!this.domain) return;
|
||||
this.healthLoading = true; this.healthError = '';
|
||||
try {
|
||||
const query = new URLSearchParams({ site: this.domain });
|
||||
if (this.presetName) query.set('preset', this.presetName);
|
||||
this.health = await this.request('/api/adapters/health?' + query.toString());
|
||||
} catch (error) {
|
||||
this.healthError = error.message || String(error);
|
||||
} finally {
|
||||
this.healthLoading = false;
|
||||
}
|
||||
},
|
||||
async runLint() {
|
||||
if (!this.domain) return;
|
||||
this.lintLoading = true; this.lintError = '';
|
||||
try {
|
||||
this.lint = await this.request('/api/adapters/lint?' + new URLSearchParams({ site: this.domain }).toString());
|
||||
} catch (error) {
|
||||
this.lintError = error.message || String(error);
|
||||
} finally {
|
||||
this.lintLoading = false;
|
||||
}
|
||||
},
|
||||
async checkUpdates(keepApplyResult = false) {
|
||||
// 应用更新后会自动刷新列表:这时要保留“已更新 N 个站点”的结果提示,不能被清掉
|
||||
this.updatesLoading = true; this.updatesError = '';
|
||||
if (!keepApplyResult) this.applyResult = null;
|
||||
try {
|
||||
this.updates = await this.request('/api/adapters/updates');
|
||||
} catch (error) {
|
||||
this.updatesError = error.message || String(error);
|
||||
} finally {
|
||||
this.updatesLoading = false;
|
||||
}
|
||||
},
|
||||
async applyUpdates(sites = null, includeConflicts = false) {
|
||||
if (includeConflicts && !window.confirm('该站点的本地配置改过:将按「本地优先」与官方新版合并(保留你的修改,补入新增字段)。继续?')) {
|
||||
return;
|
||||
}
|
||||
this.applying = true; this.updatesError = '';
|
||||
try {
|
||||
const body = { include_conflicts: includeConflicts };
|
||||
if (sites) body.sites = sites;
|
||||
this.applyResult = await this.request('/api/adapters/updates/apply', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body)
|
||||
});
|
||||
this.$emit('updated', this.applyResult);
|
||||
await this.checkUpdates(true);
|
||||
} catch (error) {
|
||||
this.updatesError = error.message || String(error);
|
||||
} finally {
|
||||
this.applying = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="adapter-panel">
|
||||
<section class="cap-card adapter-card" aria-label="健康巡检">
|
||||
<div class="adapter-card-header">
|
||||
<div>
|
||||
<h4>健康巡检</h4>
|
||||
<p>在浏览器里已打开的 {{ domain || '当前站点' }} 页面上检查各选择器能否命中。只读取页面,不会输入、点击或发送消息。</p>
|
||||
</div>
|
||||
<button type="button" class="adapter-btn" :disabled="!domain || healthLoading" @click="runHealth()">
|
||||
{{ healthLoading ? '巡检中…' : '开始巡检' }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="healthError" class="adapter-error">{{ healthError }}</p>
|
||||
<div v-if="health" class="adapter-result">
|
||||
<p>结果:<span :class="statusClass(health.status)">{{ statusLabel(health.status) }}</span>
|
||||
<span v-if="health.preset" class="adapter-muted">预设:{{ health.preset }}</span></p>
|
||||
<ul v-if="health.problems && health.problems.length" class="adapter-problems">
|
||||
<li v-for="problem in health.problems" :key="problem">{{ problem }}</li>
|
||||
</ul>
|
||||
<table v-if="healthTab" class="adapter-table">
|
||||
<thead><tr><th>元素</th><th>状态</th><th>命中数</th><th>稳健度</th><th>说明</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="row in healthTab.selectors" :key="row.key">
|
||||
<td><code>{{ row.key }}</code></td>
|
||||
<td><span :class="statusClass(row.status)">{{ statusLabel(row.status) }}</span></td>
|
||||
<td>{{ row.count }}</td>
|
||||
<td>{{ row.quality ? row.quality.score : '-' }}</td>
|
||||
<td>
|
||||
<span v-if="row.hint">{{ row.hint }}</span>
|
||||
<span v-if="row.suggestions && row.suggestions.length">可尝试:<code>{{ row.suggestions[0].selector }}</code></span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="cap-card adapter-card" aria-label="选择器稳健度">
|
||||
<div class="adapter-card-header">
|
||||
<div>
|
||||
<h4>选择器稳健度</h4>
|
||||
<p>静态检查当前预设的选择器:生成的哈希类名、依赖元素顺序或界面文字的写法,在站点改版时容易失效。</p>
|
||||
</div>
|
||||
<button type="button" class="adapter-btn" :disabled="!domain || lintLoading" @click="runLint()">
|
||||
{{ lintLoading ? '检查中…' : '检查' }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="lintError" class="adapter-error">{{ lintError }}</p>
|
||||
<div v-if="lint" class="adapter-result">
|
||||
<p v-if="!lintRows.length" class="adapter-good">当前预设的选择器没有发现明显问题。</p>
|
||||
<table v-else class="adapter-table">
|
||||
<thead><tr><th>元素</th><th>得分</th><th>问题</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="row in lintRows" :key="row.key">
|
||||
<td><code>{{ row.key }}</code></td>
|
||||
<td>{{ row.score }}</td>
|
||||
<td>{{ (row.issues || []).map(issue => issue.message).join(';') || '—' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="cap-card adapter-card" aria-label="适配器更新">
|
||||
<div class="adapter-card-header">
|
||||
<div>
|
||||
<h4>适配器更新(全部站点)</h4>
|
||||
<p>与官方仓库的站点配置比较。没改过的站点可以一键更新;改过的站点会单独标出,需要你确认后按「本地优先」合并。</p>
|
||||
</div>
|
||||
<button type="button" class="adapter-btn" :disabled="updatesLoading || applying" @click="checkUpdates()">
|
||||
{{ updatesLoading ? '检查中…' : '检查更新' }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="updatesError" class="adapter-error">{{ updatesError }}</p>
|
||||
<div v-if="updates" class="adapter-result">
|
||||
<p v-if="!updateRows.length" class="adapter-good">所有站点配置都是最新的。</p>
|
||||
<template v-else>
|
||||
<table class="adapter-table">
|
||||
<thead><tr><th>站点</th><th>状态</th><th>本地版本</th><th>官方版本</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="row in updateRows" :key="row.site">
|
||||
<td><code>{{ row.site }}</code></td>
|
||||
<td><span :class="statusClass(row.status)">{{ statusLabel(row.status) }}</span></td>
|
||||
<td>{{ row.local_version || '—' }}</td>
|
||||
<td>{{ row.official_version || '—' }}</td>
|
||||
<td>
|
||||
<button v-if="row.status === 'conflict'" type="button" class="adapter-btn is-small" :disabled="applying"
|
||||
@click="applyUpdates([row.site], true)">合并</button>
|
||||
<span v-else-if="row.status === 'requires_newer_app'" class="adapter-muted">需要 {{ row.min_app_version }}+</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="button" class="adapter-btn" :disabled="applying || !safeUpdateCount" @click="applyUpdates()">
|
||||
{{ applying ? '更新中…' : ('应用 ' + safeUpdateCount + ' 个安全更新') }}
|
||||
</button>
|
||||
</template>
|
||||
<p v-if="applyResult" class="adapter-good">已更新 {{ (applyResult.applied || []).length }} 个站点<span v-if="(applyResult.skipped || []).length">,跳过 {{ applyResult.skipped.length }} 个</span>。</p>
|
||||
</div>
|
||||
</section>
|
||||
</div>`
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
// ==================== 提取器显示面板 ====================
|
||||
|
||||
window.ExtractorPanel = {
|
||||
name: 'ExtractorPanel',
|
||||
props: {
|
||||
extractorId: { type: String, default: null },
|
||||
extractorVerified: { type: Boolean, default: false },
|
||||
collapsed: { type: Boolean, default: true }
|
||||
},
|
||||
emits: ['update:collapsed'],
|
||||
methods: {
|
||||
toggle() {
|
||||
this.$emit('update:collapsed', !this.collapsed);
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg shadow-sm">
|
||||
<div class="px-4 py-3 border-b dark:border-gray-700 flex justify-between items-center cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors"
|
||||
@click="toggle">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-4 inline-flex justify-center text-gray-500 dark:text-gray-400" v-html="collapsed ? $icons.chevronDown : $icons.chevronUp"></span>
|
||||
<h3 class="font-semibold text-gray-900 dark:text-white">🧩 提取器</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div v-show="!collapsed" class="p-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<div class="text-sm text-gray-600 dark:text-gray-300">
|
||||
当前: <span class="font-medium">{{ extractorId || '默认' }}</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2 mt-1">
|
||||
<span v-if="extractorVerified"
|
||||
class="px-2 py-0.5 text-xs bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-300 rounded">
|
||||
✓ 已验证
|
||||
</span>
|
||||
<span v-else
|
||||
class="px-2 py-0.5 text-xs bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300 rounded">
|
||||
⚠ 未验证
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-sm text-gray-500 dark:text-gray-400">
|
||||
前往「提取器」Tab 管理
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
|
||||
@@ -0,0 +1,812 @@
|
||||
// ==================== 文件粘贴 / 附件发送配置面板 ====================
|
||||
|
||||
window.FilePastePanel = {
|
||||
name: 'FilePastePanel',
|
||||
props: {
|
||||
filePasteConfig: { type: Object, required: true },
|
||||
currentDomain: { type: String, default: null },
|
||||
selectedPreset: { type: String, default: null },
|
||||
collapsed: { type: Boolean, default: true }
|
||||
},
|
||||
emits: ['update:collapsed'],
|
||||
data() {
|
||||
return {
|
||||
// 内部分区折叠状态:高级附件规则默认收起,其余默认展开
|
||||
sectionCollapsed: {
|
||||
attachments: false,
|
||||
pasteMode: false,
|
||||
sendConfirm: false,
|
||||
advancedRules: true
|
||||
},
|
||||
defaultAttachments: {
|
||||
enabled: true, max_count: 8, max_file_mb: 20, max_total_mb: 50,
|
||||
allowed_types: [], error_selectors: [], ready_timeout: 30,
|
||||
transport_order: ['file_input', 'cdp_drop', 'js_drop', 'file_clipboard']
|
||||
},
|
||||
transportOptions: [
|
||||
{ value: 'file_input', label: '文件输入框', description: '优先上传原文件;使用 file_input 选择器或自动查找。' },
|
||||
{ value: 'cdp_drop', label: '浏览器原生拖拽', description: '需要 drop_zone;不通过 base64 传输大文件。' },
|
||||
{ value: 'js_drop', label: '网页拖拽事件', description: '需要 drop_zone;仅用于不超过 4 MB 的文件。' },
|
||||
{ value: 'file_clipboard', label: '原生文件剪贴板', description: '需要系统支持与已确认的输入框焦点。' },
|
||||
{ value: 'image_clipboard', label: '图片像素剪贴板(有损)', description: '仅用于图片兼容;可能丢失透明度、动画帧和元数据。' }
|
||||
],
|
||||
defaultFilePaste: {
|
||||
enabled: false,
|
||||
threshold: 50000,
|
||||
temp_file_type: 'txt',
|
||||
hint_text: '完全专注于文件内容',
|
||||
txt_hint_text: '完全专注于文件内容',
|
||||
pdf_hint_text: '完全专注于文件内容',
|
||||
error_hint_text: '输入文本长度超过限制,已中止发送',
|
||||
reacquire_input_after_upload: false,
|
||||
post_upload_input_selector: '',
|
||||
post_upload_settle: 0.0,
|
||||
upload_signal_timeout: 2.5,
|
||||
upload_signal_grace: 3.0,
|
||||
state_probe: {
|
||||
enabled: false,
|
||||
code: ''
|
||||
}
|
||||
},
|
||||
tempFileTypeOptions: [
|
||||
{ value: 'txt', label: 'TXT' },
|
||||
{ value: 'pdf', label: 'PDF' },
|
||||
{ value: 'chunk', label: '分块' },
|
||||
{ value: 'error', label: 'ERROR' }
|
||||
],
|
||||
// 修复:补齐后端 get_default_send_confirmation_config() 的 7 个缺失键,
|
||||
// 否则未配过这些项的预设打开面板时对应输入框为空(如 pre_retry_probe_window)
|
||||
defaultSendConfirmation: {
|
||||
attachment_sensitivity: 'medium',
|
||||
post_click_observe_window: 1.8,
|
||||
pre_retry_probe_window: 0.12,
|
||||
retry_observe_window: 0.9,
|
||||
attachment_observe_window: 6.0,
|
||||
max_retry_count: 2,
|
||||
retry_interval: 0.6,
|
||||
retry_cooldown_window: 1.5,
|
||||
retry_action: 'click_send_btn',
|
||||
retry_key_combo: 'Enter',
|
||||
retry_on_unconfirmed_send: true,
|
||||
accept_attachment_change: false,
|
||||
accept_attachment_disappear: false,
|
||||
accept_probe_confirmation: true,
|
||||
retry_block_on_stop_button: true,
|
||||
retry_block_if_generating: true,
|
||||
trust_network_activity: true,
|
||||
trust_generating_indicator: true,
|
||||
trust_send_disabled_with_input_shrink: true
|
||||
},
|
||||
defaultAttachmentMonitor: {
|
||||
root_selectors: [],
|
||||
attachment_selectors: [],
|
||||
pending_selectors: [],
|
||||
status_selectors: [],
|
||||
content_exclusion_selectors: [],
|
||||
busy_text_markers: [],
|
||||
ignored_busy_text_markers: [],
|
||||
send_button_disabled_markers: [],
|
||||
require_attachment_present: false,
|
||||
require_upload_signal_before_ready: false,
|
||||
continue_once_on_unconfirmed_send: true,
|
||||
idle_timeout: 8.0,
|
||||
hard_max_wait: 90.0
|
||||
},
|
||||
attachmentSensitivityOptions: [
|
||||
{
|
||||
value: 'low',
|
||||
label: '低',
|
||||
description: '只认更强的发送信号,适合按钮状态经常乱跳的站点。'
|
||||
},
|
||||
{
|
||||
value: 'medium',
|
||||
label: '中',
|
||||
description: '平衡等待时间和识别速度,适合作为大多数站点的默认值。'
|
||||
},
|
||||
{
|
||||
value: 'high',
|
||||
label: '高',
|
||||
description: '更早接受附件发送成功信号,适合附件反馈慢、预览挂得晚的站点。'
|
||||
}
|
||||
],
|
||||
attachmentMonitorDrafts: {}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
filePasteConfig: {
|
||||
handler() {
|
||||
this.syncAttachmentMonitorDrafts();
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
},
|
||||
currentDomain() {
|
||||
this.syncAttachmentMonitorDrafts(true);
|
||||
},
|
||||
selectedPreset() {
|
||||
this.syncAttachmentMonitorDrafts(true);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.syncAttachmentMonitorDrafts(true);
|
||||
},
|
||||
computed: {
|
||||
resolvedAttachments() {
|
||||
return { ...this.defaultAttachments, ...((this.filePasteConfig || {}).attachments || {}) };
|
||||
},
|
||||
orderedTransports() {
|
||||
return (this.resolvedAttachments.transport_order || [])
|
||||
.map(value => this.transportOptions.find(option => option.value === value)).filter(Boolean);
|
||||
},
|
||||
longTextStrategy() {
|
||||
return ['chunk', 'error'].includes(this.resolvedFilePaste.temp_file_type)
|
||||
? this.resolvedFilePaste.temp_file_type : 'attachment';
|
||||
},
|
||||
resolvedFilePaste() {
|
||||
const raw = this.filePasteConfig || {};
|
||||
return {
|
||||
...this.defaultFilePaste,
|
||||
...raw,
|
||||
send_confirmation: {
|
||||
...this.defaultSendConfirmation,
|
||||
...((raw && raw.send_confirmation) || {})
|
||||
},
|
||||
attachment_monitor: {
|
||||
...this.defaultAttachmentMonitor,
|
||||
...((raw && raw.attachment_monitor) || {})
|
||||
},
|
||||
state_probe: {
|
||||
...(this.defaultFilePaste.state_probe || {}),
|
||||
...((raw && raw.state_probe) || {})
|
||||
},
|
||||
};
|
||||
},
|
||||
currentPresetLabel() {
|
||||
return String(this.selectedPreset || '').trim() || '主预设';
|
||||
},
|
||||
statusText() {
|
||||
return (this.resolvedAttachments.enabled ? '附件允许' : '附件禁止') + ' · ' + (this.resolvedFilePaste.enabled ? '长文本处理开启' : '长文本处理关闭');
|
||||
},
|
||||
attachmentSensitivityMeta() {
|
||||
const value = this.resolvedFilePaste.send_confirmation.attachment_sensitivity;
|
||||
return this.attachmentSensitivityOptions.find(option => option.value === value) || this.attachmentSensitivityOptions[1];
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateAttachmentField(key, value) {
|
||||
const config = this.getMutableFilePaste();
|
||||
config.attachments = { ...(config.attachments || {}), [key]: value };
|
||||
},
|
||||
updateAttachmentLimit(key, value, ceiling) {
|
||||
const number = Number(value);
|
||||
if (!Number.isFinite(number) || value === '') return;
|
||||
this.updateAttachmentField(key, Math.max(1, Math.min(ceiling, Math.trunc(number))));
|
||||
},
|
||||
updateAllowedTypes(value) {
|
||||
this.updateAttachmentField('allowed_types', [...new Set(String(value || '').toLowerCase().split(/[\s,;]+/).filter(Boolean))]);
|
||||
},
|
||||
toggleTransport(value) {
|
||||
const current = [...(this.resolvedAttachments.transport_order || [])];
|
||||
const next = current.includes(value) ? current.filter(item => item !== value) : [...current, value];
|
||||
this.updateAttachmentField('transport_order', next);
|
||||
},
|
||||
moveTransport(index, direction) {
|
||||
const current = [...(this.resolvedAttachments.transport_order || [])];
|
||||
const next = index + direction;
|
||||
if (next < 0 || next >= current.length) return;
|
||||
[current[index], current[next]] = [current[next], current[index]];
|
||||
this.updateAttachmentField('transport_order', current);
|
||||
},
|
||||
updateLongTextStrategy(value) {
|
||||
this.updateTempFileType(value === 'attachment' ? 'txt' : value);
|
||||
},
|
||||
toggle() {
|
||||
this.$emit('update:collapsed', !this.collapsed);
|
||||
},
|
||||
|
||||
toggleSection(key) {
|
||||
this.sectionCollapsed[key] = !this.sectionCollapsed[key];
|
||||
},
|
||||
|
||||
getMutableFilePaste() {
|
||||
return this.filePasteConfig || {};
|
||||
},
|
||||
|
||||
ensureSendConfirmation() {
|
||||
const fp = this.getMutableFilePaste();
|
||||
if (!fp.send_confirmation || typeof fp.send_confirmation !== 'object') {
|
||||
fp.send_confirmation = {};
|
||||
}
|
||||
return fp.send_confirmation;
|
||||
},
|
||||
|
||||
ensureAttachmentMonitor() {
|
||||
const fp = this.getMutableFilePaste();
|
||||
if (!fp.attachment_monitor || typeof fp.attachment_monitor !== 'object') {
|
||||
fp.attachment_monitor = {};
|
||||
}
|
||||
return fp.attachment_monitor;
|
||||
},
|
||||
|
||||
ensureStateProbe() {
|
||||
const fp = this.getMutableFilePaste();
|
||||
if (!fp.state_probe || typeof fp.state_probe !== 'object') {
|
||||
fp.state_probe = {};
|
||||
}
|
||||
return fp.state_probe;
|
||||
},
|
||||
|
||||
toggleEnabled() {
|
||||
const fp = this.getMutableFilePaste();
|
||||
fp.enabled = !this.resolvedFilePaste.enabled;
|
||||
},
|
||||
|
||||
updateThreshold(value) {
|
||||
// 修复:此前 <1000 直接丢弃,DOM 与模型脱节;改为与后端一致的夹取
|
||||
const num = parseInt(value);
|
||||
this.getMutableFilePaste().threshold = Number.isFinite(num)
|
||||
? Math.max(1000, Math.min(num, 10000000))
|
||||
: 50000;
|
||||
},
|
||||
|
||||
updateTempFileType(value) {
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
this.getMutableFilePaste().temp_file_type = ['txt', 'pdf', 'chunk', 'error'].includes(normalized) ? normalized : 'txt';
|
||||
},
|
||||
|
||||
updateHintText(value) {
|
||||
const fp = this.getMutableFilePaste();
|
||||
const type = this.resolvedFilePaste.temp_file_type;
|
||||
if (type === 'txt') {
|
||||
fp.txt_hint_text = value;
|
||||
} else if (type === 'pdf') {
|
||||
fp.pdf_hint_text = value;
|
||||
} else if (type === 'error') {
|
||||
fp.error_hint_text = value;
|
||||
}
|
||||
fp.hint_text = value;
|
||||
},
|
||||
|
||||
updateNumberField(field, value, fallback) {
|
||||
const parsed = parseFloat(value);
|
||||
this.getMutableFilePaste()[field] = Number.isFinite(parsed) ? parsed : fallback;
|
||||
},
|
||||
|
||||
updateBooleanField(field, value) {
|
||||
this.getMutableFilePaste()[field] = !!value;
|
||||
},
|
||||
|
||||
updateTextField(field, value) {
|
||||
this.getMutableFilePaste()[field] = value;
|
||||
},
|
||||
|
||||
updateSendConfirmationField(field, value) {
|
||||
this.ensureSendConfirmation()[field] = value;
|
||||
},
|
||||
|
||||
updateAttachmentMonitorField(field, value) {
|
||||
this.ensureAttachmentMonitor()[field] = value;
|
||||
},
|
||||
|
||||
updateStateProbeField(field, value) {
|
||||
this.ensureStateProbe()[field] = value;
|
||||
},
|
||||
|
||||
normalizeRuleList(value) {
|
||||
const lines = String(value || '')
|
||||
.split(/\r?\n/)
|
||||
.map(item => item.trim())
|
||||
.filter(Boolean);
|
||||
return [...new Set(lines)];
|
||||
},
|
||||
|
||||
syncAttachmentMonitorDrafts(force = false) {
|
||||
const monitor = this.resolvedFilePaste?.attachment_monitor || {};
|
||||
const listFields = [
|
||||
'attachment_selectors',
|
||||
'pending_selectors',
|
||||
'status_selectors',
|
||||
'content_exclusion_selectors',
|
||||
'busy_text_markers',
|
||||
'send_button_disabled_markers',
|
||||
'ignored_busy_text_markers',
|
||||
'root_selectors'
|
||||
];
|
||||
if (!this.attachmentMonitorDrafts) {
|
||||
this.attachmentMonitorDrafts = {};
|
||||
}
|
||||
const nextDrafts = { ...this.attachmentMonitorDrafts };
|
||||
let hasChange = false;
|
||||
for (const field of listFields) {
|
||||
const propArr = Array.isArray(monitor[field]) ? monitor[field] : [];
|
||||
const curDraftArr = this.normalizeRuleList(nextDrafts[field]);
|
||||
if (force || JSON.stringify(propArr) !== JSON.stringify(curDraftArr) || nextDrafts[field] === undefined || nextDrafts[field] === null) {
|
||||
nextDrafts[field] = propArr.join('\n');
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
if (hasChange) {
|
||||
this.attachmentMonitorDrafts = nextDrafts;
|
||||
}
|
||||
},
|
||||
|
||||
updateAttachmentMonitorListField(field, value) {
|
||||
if (!this.attachmentMonitorDrafts) {
|
||||
this.attachmentMonitorDrafts = {};
|
||||
}
|
||||
this.attachmentMonitorDrafts[field] = value;
|
||||
this.updateAttachmentMonitorField(field, this.normalizeRuleList(value));
|
||||
},
|
||||
|
||||
formatRuleList(value) {
|
||||
return Array.isArray(value) ? value.join('\n') : '';
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="cap-panel cap-input-panel bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg shadow-sm">
|
||||
<div class="px-4 py-3 border-b dark:border-gray-700 flex justify-between items-center cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors"
|
||||
@click="toggle">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-4 inline-flex justify-center text-gray-500 dark:text-gray-400" v-html="collapsed ? $icons.chevronDown : $icons.chevronUp"></span>
|
||||
<h3 class="font-semibold text-gray-900 dark:text-white">发送内容</h3>
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">({{ statusText }})</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="!collapsed" class="p-4 space-y-4">
|
||||
|
||||
|
||||
<section class="cap-card" :class="{ 'is-enabled': resolvedAttachments.enabled }" aria-label="发送附件"><div class="cap-card-header"><span class="cap-icon" v-html="$icons.arrowUpTray"></span><div class="cap-copy"><div class="cap-title-row"><h4>发送附件</h4><span class="cap-scope">当前预设</span></div><p>把图片、文档或音视频交给 AI。网站本身也需要支持这些文件。</p></div><label class="cap-switch"><span class="cap-state" :class="{ 'is-on': resolvedAttachments.enabled }">{{ resolvedAttachments.enabled ? '已开启' : '已关闭' }}</span><input role="switch" aria-label="发送附件" type="checkbox" :checked="resolvedAttachments.enabled" @change="updateAttachmentField('enabled', $event.target.checked)" class="cap-switch-input"><i aria-hidden="true"></i></label></div><p class="cap-facts">最多 {{ resolvedAttachments.max_count }} 个文件 <i>·</i> 单个 {{ resolvedAttachments.max_file_mb }} MB <i>·</i> 合计 {{ resolvedAttachments.max_total_mb }} MB</p><p v-if="!resolvedAttachments.enabled" class="cap-warning">已关闭附件上传;长文本也不能转为文件发送。普通文本仍可使用。</p><details class="cap-settings"><summary><span><strong>调整文件限制</strong><small>文件数量、大小与类型</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><div class="cap-form-grid">
|
||||
<label class="text-xs text-gray-700 dark:text-gray-300">一次最多几个文件
|
||||
<input type="number" min="1" max="32" :value="resolvedAttachments.max_count" @change="updateAttachmentLimit('max_count', $event.target.value, 32)" class="mt-1 w-full border dark:border-gray-600 rounded-md px-3 py-2 bg-white dark:bg-gray-700">
|
||||
</label>
|
||||
<label class="text-xs text-gray-700 dark:text-gray-300">单个文件大小(MB)
|
||||
<input type="number" min="1" max="100" :value="resolvedAttachments.max_file_mb" @change="updateAttachmentLimit('max_file_mb', $event.target.value, 100)" class="mt-1 w-full border dark:border-gray-600 rounded-md px-3 py-2 bg-white dark:bg-gray-700">
|
||||
</label>
|
||||
<label class="text-xs text-gray-700 dark:text-gray-300">全部文件总大小(MB)
|
||||
<input type="number" min="1" max="200" :value="resolvedAttachments.max_total_mb" @change="updateAttachmentLimit('max_total_mb', $event.target.value, 200)" class="mt-1 w-full border dark:border-gray-600 rounded-md px-3 py-2 bg-white dark:bg-gray-700">
|
||||
</label>
|
||||
|
||||
</div><label class="block text-sm text-gray-700 dark:text-gray-300">允许哪些文件(可选)
|
||||
<input type="text" :value="(resolvedAttachments.allowed_types || []).join(', ')" @change="updateAllowedTypes($event.target.value)" placeholder="例如 .pdf, .docx, image/*" class="mt-1 w-full border dark:border-gray-600 rounded-md px-3 py-2 text-sm font-mono bg-white dark:bg-gray-700">
|
||||
<span class="block mt-1 text-xs text-gray-500 dark:text-gray-400">用逗号分隔文件扩展名或 MIME 类型;留空不额外限制。网站本身仍需支持这些文件。</span>
|
||||
</label><details class="cap-technical"><summary><span><strong>上传兼容与错误识别</strong><small>只有上传失败、需要拖拽或网站提示错误时再调整。</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><label class="text-xs text-gray-700 dark:text-gray-300">单附件确认预算(秒)
|
||||
<input type="number" min="1" max="180" :value="resolvedAttachments.ready_timeout" @change="updateAttachmentLimit('ready_timeout', $event.target.value, 180)" class="mt-1 w-full border dark:border-gray-600 rounded-md px-3 py-2 bg-white dark:bg-gray-700">
|
||||
</label>
|
||||
<label class="block text-sm text-gray-700 dark:text-gray-300">网页上的上传错误提示(CSS 选择器)(可选,一行一个)
|
||||
<textarea :value="(resolvedAttachments.error_selectors || []).join('\\n')" @change="updateAttachmentField('error_selectors', $event.target.value.split(/\\n/).map(v => v.trim()).filter(Boolean))" placeholder=".upload-card[data-state=error]" rows="2" class="mt-1 w-full border dark:border-gray-600 rounded-md px-3 py-2 text-sm font-mono bg-white dark:bg-gray-700"></textarea>
|
||||
<span class="block text-xs text-gray-500 dark:text-gray-400">只匹配编辑区内可见的错误节点;命中后立即停止,不把错误预览视为上传成功。</span>
|
||||
</label>
|
||||
<div class="space-y-2">
|
||||
<div class="text-sm font-medium text-gray-800 dark:text-gray-200">尝试上传的顺序 <span class="text-xs font-normal text-gray-500">仅在确认尚未投递时回退</span></div>
|
||||
<div v-for="(transport, index) in orderedTransports" :key="transport.value" class="flex items-center gap-3 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-3">
|
||||
<span class="text-xs text-blue-600 dark:text-blue-400">{{ index + 1 }}</span>
|
||||
<div class="flex-1 min-w-0"><div class="text-sm text-gray-800 dark:text-gray-200">{{ transport.label }}</div><p class="text-xs text-gray-500 dark:text-gray-400 mt-1">{{ transport.description }}</p></div>
|
||||
<button type="button" :disabled="index === 0" @click="moveTransport(index, -1)" :aria-label="transport.label + '上移'" class="px-2 py-1 border rounded disabled:opacity-30">↑</button>
|
||||
<button type="button" :disabled="index === orderedTransports.length - 1" @click="moveTransport(index, 1)" :aria-label="transport.label + '下移'" class="px-2 py-1 border rounded disabled:opacity-30">↓</button>
|
||||
<button type="button" @click="toggleTransport(transport.value)" :aria-label="'停用' + transport.label" class="text-xs text-red-600 dark:text-red-400 px-2 py-1">停用</button>
|
||||
</div>
|
||||
<div v-if="!orderedTransports.length" class="text-xs text-red-600 dark:text-red-400">没有启用上传方式,附件将被明确拒绝,不会自动启用其他方式。</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<template v-for="option in transportOptions" :key="option.value">
|
||||
<button v-if="!resolvedAttachments.transport_order.includes(option.value)" type="button" @click="toggleTransport(option.value)" class="border border-dashed border-gray-400 rounded-md text-xs px-3 py-2 text-gray-600 dark:text-gray-300">+ {{ option.label }}</button>
|
||||
</template>
|
||||
</div>
|
||||
<p v-if="resolvedAttachments.transport_order.includes('image_clipboard')" class="text-xs text-amber-700 dark:text-amber-300">已启用有损图片剪贴板兼容。需要原文件保真时,请停用此方式。</p>
|
||||
</div>
|
||||
<details class="text-xs text-gray-600 dark:text-gray-400">
|
||||
<summary class="cursor-pointer font-medium">API 附件格式与兼容说明</summary>
|
||||
<div class="mt-2 space-y-2 leading-5">
|
||||
<p>支持 image_url、OpenAI file / Responses input_file、Anthropic document、input_audio 与音视频 URL。文件 ID、本地路径和 file:// 暂不支持;原始附件内容不会降级为提示词。</p>
|
||||
<pre class="overflow-x-auto p-3 rounded bg-gray-900 text-gray-100">{"type":"file","file":{"filename":"notes.txt","file_data":"data:text/plain;base64,aGVsbG8="}}</pre>
|
||||
<p>通用附件管线的配置存储在当前预设的 file_paste.attachments 中,旧配置无需手动迁移。选择器仍在「元素选择器」,就绪探针在下方「高级附件规则」。MB 按 1024² 字节计算。</p>
|
||||
</div>
|
||||
</details>
|
||||
</div></details></div></details></section>
|
||||
|
||||
<section class="cap-card" :class="{ 'is-enabled': resolvedFilePaste.enabled }" aria-label="长文本处理"><div class="cap-card-header"><span class="cap-icon" v-html="$icons.documentArrowDown"></span><div class="cap-copy"><div class="cap-title-row"><h4>长文本处理</h4><span class="cap-scope">当前预设</span></div><p>文字太长、网页放不下时,选择转成文件、分段发送或中止请求。</p></div><label class="cap-switch"><span class="cap-state" :class="{ 'is-on': resolvedFilePaste.enabled }">{{ resolvedFilePaste.enabled ? '已开启' : '已关闭' }}</span><input role="switch" aria-label="长文本处理" type="checkbox" :checked="resolvedFilePaste.enabled" @change="toggleEnabled" class="cap-switch-input"><i aria-hidden="true"></i></label></div><p class="cap-facts">{{ resolvedFilePaste.enabled ? '超过 ' + resolvedFilePaste.threshold + ' 字符时处理' : '当前不启用额外的长文本处理' }}<template v-if="resolvedFilePaste.enabled"> <i>·</i> {{ longTextStrategy === 'attachment' ? '转成文件' : longTextStrategy === 'chunk' ? '分段发送' : '中止并报错' }}</template></p><details class="cap-settings"><summary><span><strong>设置长文本处理方式</strong><small>长度阈值与超长后的行为</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><p class="cap-inline-help">转成文件需要先允许附件上传。分段发送会逐轮等待,只返回最后一轮回复。</p>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">超过多少字符开始处理</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="resolvedFilePaste.threshold"
|
||||
@input="updateThreshold($event.target.value)"
|
||||
min="1000"
|
||||
max="10000000"
|
||||
step="1000"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm text-right bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">字符</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">超长处理方式</label>
|
||||
<select :value="longTextStrategy"
|
||||
@change="updateLongTextStrategy($event.target.value)"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<option value="attachment">转为附件(共用上传管线)</option>
|
||||
<option value="chunk">分块连续发送</option>
|
||||
<option value="error">直接返回错误</option>
|
||||
</select>
|
||||
<label v-if="longTextStrategy === 'attachment'" class="mt-2 block text-xs text-gray-600 dark:text-gray-400">生成格式
|
||||
<select :value="resolvedFilePaste.temp_file_type" @change="updateTempFileType($event.target.value)" class="ml-2 border rounded px-2 py-1 bg-white dark:bg-gray-700">
|
||||
<option value="txt">TXT(推荐,保留原文)</option><option value="pdf">PDF</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label v-if="resolvedFilePaste.temp_file_type !== 'chunk'" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
||||
{{ resolvedFilePaste.temp_file_type === 'error' ? '错误信息' : '引导文本' }}
|
||||
</label>
|
||||
<input v-if="resolvedFilePaste.temp_file_type !== 'chunk'"
|
||||
type="text"
|
||||
:value="resolvedFilePaste.temp_file_type === 'txt' ? resolvedFilePaste.txt_hint_text : (resolvedFilePaste.temp_file_type === 'pdf' ? resolvedFilePaste.pdf_hint_text : resolvedFilePaste.error_hint_text)"
|
||||
@input="updateHintText($event.target.value)"
|
||||
:placeholder="resolvedFilePaste.temp_file_type === 'error' ? '超过阈值时返回给客户端的错误信息' : '粘贴文件后追加的文字,留空则不追加'"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<div v-else class="min-h-[38px] flex items-center rounded-md border border-blue-200 dark:border-blue-800 bg-blue-50/70 dark:bg-blue-900/20 px-3 py-2 text-xs leading-5 text-blue-700 dark:text-blue-300">
|
||||
自动使用最少块数,并把分块说明计入阈值。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
|
||||
</div>
|
||||
|
||||
<details class="cap-technical"><summary><span><strong>上传后的输入适配</strong><small>只有文件上传后输入框发生变化时再设置。</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">上传后稳定等待</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="resolvedFilePaste.post_upload_settle"
|
||||
@input="updateNumberField('post_upload_settle', $event.target.value, 0)"
|
||||
min="0"
|
||||
max="30"
|
||||
step="0.5"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">秒</span>
|
||||
</div>
|
||||
</div><label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="resolvedFilePaste.reacquire_input_after_upload"
|
||||
@change="updateBooleanField('reacquire_input_after_upload', $event.target.checked)">
|
||||
<span>上传完成后重新定位输入框</span>
|
||||
</label>
|
||||
|
||||
<div >
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">上传后输入框的位置(选择器)</label>
|
||||
<input type="text"
|
||||
:value="resolvedFilePaste.post_upload_input_selector"
|
||||
@input="updateTextField('post_upload_input_selector', $event.target.value)"
|
||||
placeholder=".composer textarea"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
</div>
|
||||
</div></details></div></details></section>
|
||||
|
||||
<details class="cap-troubleshoot"><summary><span><strong>附件上传了,但没有发出去?</strong><small>排查发送确认、重试和网页识别规则。正常发送时无需调整。</small></span><span class="cap-summary-value">敏感度:{{ attachmentSensitivityMeta.label }}</span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><p class="cap-inline-help">这些规则会影响所有附件。先确认网页上是否真的发出了消息,再调整等待或重试。</p>
|
||||
|
||||
<div class="mt-3 grid grid-cols-1 md:grid-cols-3 gap-3 items-start">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">敏感度</label>
|
||||
<select :value="resolvedFilePaste.send_confirmation.attachment_sensitivity"
|
||||
@change="updateSendConfirmationField('attachment_sensitivity', $event.target.value)"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<option v-for="option in attachmentSensitivityOptions"
|
||||
:key="option.value"
|
||||
:value="option.value">
|
||||
{{ option.label }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="md:col-span-2 text-xs leading-6 text-gray-600 dark:text-gray-300 bg-white/70 dark:bg-gray-900/40 rounded-lg border border-blue-100 dark:border-blue-900/60 px-3 py-2">
|
||||
{{ attachmentSensitivityMeta.description }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid grid-cols-1 md:grid-cols-4 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">最大重试次数</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="resolvedFilePaste.send_confirmation.max_retry_count"
|
||||
@input="updateSendConfirmationField('max_retry_count', parseInt($event.target.value) || 0)"
|
||||
min="0"
|
||||
max="10"
|
||||
step="1"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">次</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">重试间隔</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="resolvedFilePaste.send_confirmation.retry_interval"
|
||||
@input="updateSendConfirmationField('retry_interval', parseFloat($event.target.value) || 0)"
|
||||
min="0"
|
||||
max="30"
|
||||
step="0.1"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">秒</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">最小冷却窗</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="resolvedFilePaste.send_confirmation.retry_cooldown_window"
|
||||
@input="updateSendConfirmationField('retry_cooldown_window', parseFloat($event.target.value) || 0)"
|
||||
min="0"
|
||||
max="30"
|
||||
step="0.1"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">秒</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">重试前短探测</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="resolvedFilePaste.send_confirmation.pre_retry_probe_window"
|
||||
@input="updateSendConfirmationField('pre_retry_probe_window', parseFloat($event.target.value) || 0)"
|
||||
min="0"
|
||||
max="5"
|
||||
step="0.05"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">秒</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">自动重试动作</label>
|
||||
<select :value="resolvedFilePaste.send_confirmation.retry_action"
|
||||
@change="updateSendConfirmationField('retry_action', $event.target.value)"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<option value="click_send_btn">点击发送按钮</option>
|
||||
<option value="key_press">按键发送</option>
|
||||
</select>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
某些站点二次点击会把“发送”变成“停止”,这时更适合改成按键发送。
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">重试按键组合</label>
|
||||
<input type="text"
|
||||
:value="resolvedFilePaste.send_confirmation.retry_key_combo"
|
||||
@input="updateSendConfirmationField('retry_key_combo', $event.target.value)"
|
||||
placeholder="Enter / Ctrl+Enter"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
仅在“按键发送”时生效,支持 Enter、Ctrl+Enter、Shift+Enter 等组合。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 border-t border-blue-100 dark:border-blue-900/60 pt-4"
|
||||
:class="sectionCollapsed.advancedRules ? '' : 'space-y-4'">
|
||||
<div class="cursor-pointer select-none -m-2 p-2 rounded-md hover:bg-blue-100/50 dark:hover:bg-blue-900/30 transition-colors" role="button" tabindex="0" :aria-expanded="!sectionCollapsed.advancedRules" @keydown.enter.prevent="toggleSection('advancedRules')" @keydown.space.prevent="toggleSection('advancedRules')" @click="toggleSection('advancedRules')">
|
||||
<div class="flex items-center gap-2 text-sm font-medium text-gray-800 dark:text-gray-100">
|
||||
<span class="w-4 inline-flex justify-center text-gray-400 dark:text-gray-500" v-html="sectionCollapsed.advancedRules ? $icons.chevronDown : $icons.chevronUp"></span>
|
||||
<span>高级附件规则</span>
|
||||
<span v-show="sectionCollapsed.advancedRules" class="text-xs font-normal text-gray-400 dark:text-gray-500">(点击展开)</span>
|
||||
</div>
|
||||
<p v-show="!sectionCollapsed.advancedRules" class="mt-1 text-xs leading-5 text-gray-600 dark:text-gray-300">
|
||||
像 Gemini 这类站点,可以在这里补发送按钮灰态 token、附件预览 selector 和 pending 文案。即使文件粘贴没开,这块也会继续影响图片上传和发送前的附件 gate。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-show="!sectionCollapsed.advancedRules" class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="resolvedFilePaste.attachment_monitor.require_attachment_present"
|
||||
@change="updateAttachmentMonitorField('require_attachment_present', $event.target.checked)">
|
||||
<span>发送前必须看到附件已挂上页面</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="resolvedFilePaste.attachment_monitor.require_upload_signal_before_ready"
|
||||
@change="updateAttachmentMonitorField('require_upload_signal_before_ready', $event.target.checked)">
|
||||
<span>没有观察到上传启动前,不允许判定 ready</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="resolvedFilePaste.attachment_monitor.continue_once_on_unconfirmed_send"
|
||||
@change="updateAttachmentMonitorField('continue_once_on_unconfirmed_send', $event.target.checked)">
|
||||
<span>未确认时仍允许继续点一次发送</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="resolvedFilePaste.send_confirmation.retry_on_unconfirmed_send"
|
||||
@change="updateSendConfirmationField('retry_on_unconfirmed_send', $event.target.checked)">
|
||||
<span>发送未确认时允许自动重试</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="resolvedFilePaste.send_confirmation.retry_block_on_stop_button"
|
||||
@change="updateSendConfirmationField('retry_block_on_stop_button', $event.target.checked)">
|
||||
<span>发送按钮变成 stop 时禁止重试</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="resolvedFilePaste.send_confirmation.retry_block_if_generating"
|
||||
@change="updateSendConfirmationField('retry_block_if_generating', $event.target.checked)">
|
||||
<span>页面进入生成态时禁止重试</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="resolvedFilePaste.send_confirmation.accept_attachment_change"
|
||||
@change="updateSendConfirmationField('accept_attachment_change', $event.target.checked)">
|
||||
<span>发送后附件区发生变化时可视为已接受</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="resolvedFilePaste.send_confirmation.accept_attachment_disappear"
|
||||
@change="updateSendConfirmationField('accept_attachment_disappear', $event.target.checked)">
|
||||
<span>发送后附件区消失时可视为已接受</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="resolvedFilePaste.send_confirmation.accept_probe_confirmation"
|
||||
@change="updateSendConfirmationField('accept_probe_confirmation', $event.target.checked)">
|
||||
<span>允许 JS probe 直接确认发送成功</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-show="!sectionCollapsed.advancedRules" class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">空闲超时</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="resolvedFilePaste.attachment_monitor.idle_timeout"
|
||||
@input="updateAttachmentMonitorField('idle_timeout', parseFloat($event.target.value) || 8)"
|
||||
min="0.5"
|
||||
max="60"
|
||||
step="0.5"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">秒</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">附件最长等待</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="resolvedFilePaste.attachment_monitor.hard_max_wait"
|
||||
@input="updateAttachmentMonitorField('hard_max_wait', parseFloat($event.target.value) || 90)"
|
||||
min="1"
|
||||
max="300"
|
||||
step="1"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">秒</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="!sectionCollapsed.advancedRules" class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">附件预览 selector</label>
|
||||
<textarea
|
||||
:value="attachmentMonitorDrafts ? (attachmentMonitorDrafts.attachment_selectors ?? '') : ''"
|
||||
@input="updateAttachmentMonitorListField('attachment_selectors', $event.target.value)"
|
||||
rows="5"
|
||||
placeholder="[class*='attachment'] .upload-preview"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent"></textarea>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">每行一个 selector,选择独立附件卡片,不要选择包含输入框的大容器;嵌套图片不会重复计数。</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">上传中 selector</label>
|
||||
<textarea
|
||||
:value="attachmentMonitorDrafts ? (attachmentMonitorDrafts.pending_selectors ?? '') : ''"
|
||||
@input="updateAttachmentMonitorListField('pending_selectors', $event.target.value)"
|
||||
rows="5"
|
||||
placeholder="[aria-busy='true'] .uploading"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent"></textarea>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">每行一个 selector,命中后会继续等待,不会急着发送。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="!sectionCollapsed.advancedRules" class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">忙碌文本 / token</label>
|
||||
<textarea
|
||||
:value="attachmentMonitorDrafts ? (attachmentMonitorDrafts.busy_text_markers ?? '') : ''"
|
||||
@input="updateAttachmentMonitorListField('busy_text_markers', $event.target.value)"
|
||||
rows="5"
|
||||
placeholder="uploading 处理中 解析中"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent"></textarea>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">只匹配附件状态提示和发送按钮,不扫描提示词、文件名或文件预览正文。</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">发送按钮灰态 token</label>
|
||||
<textarea
|
||||
:value="attachmentMonitorDrafts ? (attachmentMonitorDrafts.send_button_disabled_markers ?? '') : ''"
|
||||
@input="updateAttachmentMonitorListField('send_button_disabled_markers', $event.target.value)"
|
||||
rows="5"
|
||||
placeholder="is-disabled cursor-not-allowed upload failed"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent"></textarea>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">填发送按钮 class / title / aria-label 里会出现的关键字,命中后视为按钮不可发。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="!sectionCollapsed.advancedRules" class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">附件状态提示区域(可选)
|
||||
<textarea :value="attachmentMonitorDrafts ? (attachmentMonitorDrafts.status_selectors ?? '') : ''"
|
||||
@input="updateAttachmentMonitorListField('status_selectors', $event.target.value)" rows="3" placeholder=".attachment-status"
|
||||
class="mt-1 w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700"></textarea>
|
||||
<span class="block mt-1 text-xs font-normal text-gray-500">只选择显示“读取中 / 上传中”等状态的小区域,不要选择整张卡片或输入框。</span>
|
||||
</label>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">不参与附件检测的内容区域(可选)
|
||||
<textarea :value="attachmentMonitorDrafts ? (attachmentMonitorDrafts.content_exclusion_selectors ?? '') : ''"
|
||||
@input="updateAttachmentMonitorListField('content_exclusion_selectors', $event.target.value)" rows="3" placeholder=".document-preview-content"
|
||||
class="mt-1 w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700"></textarea>
|
||||
<span class="block mt-1 text-xs font-normal text-gray-500">补充站点特有的正文镜像或文件内容预览区域;隐藏内容、输入框和常见文件名区域已自动排除。</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-show="!sectionCollapsed.advancedRules">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">忽略忙碌文本 / token</label>
|
||||
<textarea
|
||||
:value="attachmentMonitorDrafts ? (attachmentMonitorDrafts.ignored_busy_text_markers ?? '') : ''"
|
||||
@input="updateAttachmentMonitorListField('ignored_busy_text_markers', $event.target.value)"
|
||||
rows="3"
|
||||
placeholder="thinking"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent"></textarea>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">仅用于排除站点特有的状态词。正文与文件名会自动排除,不需要在这里逐个添加。</p>
|
||||
</div>
|
||||
|
||||
<div v-show="!sectionCollapsed.advancedRules">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">根容器 selector</label>
|
||||
<textarea
|
||||
:value="attachmentMonitorDrafts ? (attachmentMonitorDrafts.root_selectors ?? '') : ''"
|
||||
@input="updateAttachmentMonitorListField('root_selectors', $event.target.value)"
|
||||
rows="4"
|
||||
placeholder=".composer-shell .input-area"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent"></textarea>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">当通用根容器猜错时再填。这里会限制附件节点和 pending 节点的查找范围。</p>
|
||||
</div>
|
||||
|
||||
<div v-show="!sectionCollapsed.advancedRules" class="border-t border-blue-100 dark:border-blue-900/60 pt-4 space-y-3">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-800 dark:text-gray-100">JS 状态探针</div>
|
||||
<p class="mt-1 text-xs leading-5 text-gray-600 dark:text-gray-300">
|
||||
探针会收到一个参数对象,包含 stage 和 monitorState。返回结构建议包含 uploading、ready、accepted、confirmed、retry、shouldRetry、summary 这些字段。
|
||||
</p>
|
||||
</div>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="resolvedFilePaste.state_probe.enabled"
|
||||
@change="updateStateProbeField('enabled', $event.target.checked)">
|
||||
<span>启用</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">探针代码</label>
|
||||
<textarea
|
||||
:value="resolvedFilePaste.state_probe.code"
|
||||
@input="updateStateProbeField('code', $event.target.value)"
|
||||
rows="10"
|
||||
placeholder="return (() => { const { stage, monitorState } = arguments[0] || {}; return { accepted: false, shouldRetry: false, summary: stage }; })();"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div></details>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
@@ -0,0 +1,749 @@
|
||||
// ==================== 多模态提取配置面板 ====================
|
||||
|
||||
window.ImageConfigPanel = {
|
||||
name: 'ImageConfigPanel',
|
||||
props: {
|
||||
imageConfig: { type: Object, required: true },
|
||||
currentDomain: { type: String, default: null },
|
||||
collapsed: { type: Boolean, default: true }
|
||||
},
|
||||
emits: ['update:collapsed', 'update-image-config', 'reload-config'],
|
||||
data() {
|
||||
return {
|
||||
showPresetMenu: false,
|
||||
availablePresets: [],
|
||||
currentPreset: null,
|
||||
loadingPresets: false,
|
||||
imagePresetRequestSeq: 0,
|
||||
srcAllowPatternsDraft: '',
|
||||
audioNetworkUrlPatternsDraft: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
modalityPolicies() {
|
||||
return {
|
||||
image: this.normalizeModalityPolicy('image', (this.imageConfig.modalities || {}).image),
|
||||
audio: this.normalizeModalityPolicy('audio', (this.imageConfig.modalities || {}).audio),
|
||||
video: this.normalizeModalityPolicy('video', (this.imageConfig.modalities || {}).video)
|
||||
};
|
||||
},
|
||||
modalities() {
|
||||
return {
|
||||
image: !!this.modalityPolicies.image.enabled,
|
||||
audio: !!this.modalityPolicies.audio.enabled,
|
||||
video: !!this.modalityPolicies.video.enabled
|
||||
};
|
||||
},
|
||||
isEnabled() {
|
||||
return ['image', 'audio', 'video'].some(key => !!this.modalities[key]);
|
||||
},
|
||||
enabledLabels() {
|
||||
const labels = [];
|
||||
if (this.modalities.image) labels.push('图片');
|
||||
if (this.modalities.audio) labels.push('音频');
|
||||
if (this.modalities.video) labels.push('视频');
|
||||
return labels;
|
||||
},
|
||||
srcAllowPatternsText() {
|
||||
const patterns = Array.isArray(this.imageConfig.src_allow_patterns)
|
||||
? this.imageConfig.src_allow_patterns
|
||||
: [];
|
||||
return patterns.join('\n');
|
||||
},
|
||||
audioNetworkCapture() {
|
||||
return {
|
||||
enabled: false,
|
||||
timeout_seconds: 2.5,
|
||||
transport: 'page_websocket_probe',
|
||||
url_patterns: ['voicegenie', 'speech', 'audio', 'tts'],
|
||||
// 修复:默认值与后端 get_default_*(voicegenie_binary_stream)对齐
|
||||
extractor: 'voicegenie_binary_stream',
|
||||
settle_seconds: 0.35,
|
||||
max_payload_bytes: 10 * 1024 * 1024,
|
||||
...((this.imageConfig && this.imageConfig.audio_network_capture) || {})
|
||||
};
|
||||
},
|
||||
audioNetworkMaxPayloadMb() {
|
||||
const raw = Number(this.audioNetworkCapture.max_payload_bytes || 0);
|
||||
const fallback = Number(this.imageConfig.max_size_mb || 10);
|
||||
if (!Number.isFinite(raw) || raw <= 0) return fallback;
|
||||
return Math.round((raw / 1024 / 1024) * 10) / 10;
|
||||
},
|
||||
audioNetworkUrlPatternsText() {
|
||||
const patterns = Array.isArray(this.audioNetworkCapture.url_patterns)
|
||||
? this.audioNetworkCapture.url_patterns
|
||||
: [];
|
||||
return patterns.join('\n');
|
||||
},
|
||||
audioCaptureEnabled() {
|
||||
return this.imageConfig.audio_capture_enabled !== false;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
imageConfig: {
|
||||
handler() {
|
||||
this.syncDraftsFromProps();
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
},
|
||||
currentDomain(newVal) {
|
||||
this.imagePresetRequestSeq += 1;
|
||||
this.currentPreset = null;
|
||||
if (newVal) this.checkCurrentPreset();
|
||||
this.syncDraftsFromProps(true);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.loadPresets();
|
||||
if (this.currentDomain) this.checkCurrentPreset();
|
||||
this.syncDraftsFromProps(true);
|
||||
},
|
||||
methods: {
|
||||
mediaPolicyLabel(type) {
|
||||
const labels = { disabled: '不提取', generic_only: '读取现成媒体', on_signal: '发现媒体信号时提取', probe_if_trigger_found: '发现播放入口后探测', always_probe: '每次主动探测' };
|
||||
return labels[this.modalityPolicies[type].run_policy] || this.modalityPolicies[type].run_policy;
|
||||
},
|
||||
buildAuthHeaders(extraHeaders = {}) {
|
||||
const token = String(window.getDashboardAuthToken ? window.getDashboardAuthToken() : '').trim();
|
||||
const headers = { ...extraHeaders };
|
||||
if (token) {
|
||||
headers['Authorization'] = 'Bearer ' + token;
|
||||
}
|
||||
return headers;
|
||||
},
|
||||
|
||||
toggle() {
|
||||
this.$emit('update:collapsed', !this.collapsed);
|
||||
},
|
||||
|
||||
buildNextConfig(patch = {}) {
|
||||
const nextModalities = {
|
||||
...this.modalityPolicies
|
||||
};
|
||||
if (patch && patch.modalities && typeof patch.modalities === 'object') {
|
||||
for (const type of ['image', 'audio', 'video']) {
|
||||
if (Object.prototype.hasOwnProperty.call(patch.modalities, type)) {
|
||||
nextModalities[type] = this.normalizeModalityPolicy(
|
||||
type,
|
||||
patch.modalities[type],
|
||||
nextModalities[type]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
const next = {
|
||||
...this.imageConfig,
|
||||
...patch,
|
||||
modalities: nextModalities
|
||||
};
|
||||
next.enabled = ['image', 'audio', 'video'].some(key => !!(next.modalities[key] && next.modalities[key].enabled));
|
||||
return next;
|
||||
},
|
||||
|
||||
updateField(field, value) {
|
||||
const newConfig = this.buildNextConfig({ [field]: value });
|
||||
this.$emit('update-image-config', newConfig);
|
||||
},
|
||||
|
||||
numberOrFallback(value, fallback) {
|
||||
const parsed = Number(value);
|
||||
return Number.isFinite(parsed) ? parsed : fallback;
|
||||
},
|
||||
|
||||
defaultModalityPolicy(type, enabled = false) {
|
||||
const base = {
|
||||
enabled: !!enabled,
|
||||
run_policy: enabled ? 'on_signal' : 'disabled',
|
||||
quick_probe_timeout_seconds: 1.0
|
||||
};
|
||||
if (type === 'audio') {
|
||||
return {
|
||||
...base,
|
||||
run_policy: enabled ? 'probe_if_trigger_found' : 'disabled',
|
||||
capture_timeout_seconds: 12.0
|
||||
};
|
||||
}
|
||||
if (type === 'video') {
|
||||
return {
|
||||
...base,
|
||||
late_wait_timeout_seconds: 90.0
|
||||
};
|
||||
}
|
||||
return {
|
||||
...base,
|
||||
late_wait_timeout_seconds: 45.0,
|
||||
blind_wait_timeout_seconds: 1.0
|
||||
};
|
||||
},
|
||||
|
||||
normalizeModalityPolicy(type, value, fallback = null) {
|
||||
const current = fallback || this.defaultModalityPolicy(type, false);
|
||||
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
||||
const enabled = !!value.enabled;
|
||||
const allowedPolicies = ['disabled', 'generic_only', 'on_signal', 'probe_if_trigger_found', 'always_probe'];
|
||||
let runPolicy = String(value.run_policy || current.run_policy || '').trim();
|
||||
if (!allowedPolicies.includes(runPolicy)) {
|
||||
runPolicy = enabled ? this.defaultModalityPolicy(type, true).run_policy : 'disabled';
|
||||
}
|
||||
if (!enabled) {
|
||||
runPolicy = 'disabled';
|
||||
}
|
||||
return {
|
||||
...this.defaultModalityPolicy(type, enabled),
|
||||
...current,
|
||||
...value,
|
||||
enabled,
|
||||
run_policy: runPolicy
|
||||
};
|
||||
}
|
||||
return this.defaultModalityPolicy(type, !!value);
|
||||
},
|
||||
|
||||
updateModalityPolicy(type, patch = {}) {
|
||||
const current = this.modalityPolicies[type] || this.defaultModalityPolicy(type, false);
|
||||
const nextPolicy = this.normalizeModalityPolicy(type, { ...current, ...(patch || {}) }, current);
|
||||
this.updateField('modalities', {
|
||||
...this.modalityPolicies,
|
||||
[type]: nextPolicy
|
||||
});
|
||||
},
|
||||
|
||||
parsePatternLines(text) {
|
||||
return String(text || '')
|
||||
.split(/\r?\n/)
|
||||
.map(line => line.trim())
|
||||
.filter(Boolean);
|
||||
},
|
||||
|
||||
syncDraftsFromProps(force = false) {
|
||||
const srcArr = Array.isArray(this.imageConfig?.src_allow_patterns)
|
||||
? this.imageConfig.src_allow_patterns
|
||||
: [];
|
||||
const curSrcArr = this.parsePatternLines(this.srcAllowPatternsDraft);
|
||||
if (force || JSON.stringify(srcArr) !== JSON.stringify(curSrcArr) || this.srcAllowPatternsDraft === undefined || this.srcAllowPatternsDraft === null) {
|
||||
this.srcAllowPatternsDraft = srcArr.join('\n');
|
||||
}
|
||||
|
||||
const audioArr = Array.isArray(this.audioNetworkCapture?.url_patterns)
|
||||
? this.audioNetworkCapture.url_patterns
|
||||
: [];
|
||||
const curAudioArr = this.parsePatternLines(this.audioNetworkUrlPatternsDraft);
|
||||
if (force || JSON.stringify(audioArr) !== JSON.stringify(curAudioArr) || this.audioNetworkUrlPatternsDraft === undefined || this.audioNetworkUrlPatternsDraft === null) {
|
||||
this.audioNetworkUrlPatternsDraft = audioArr.join('\n');
|
||||
}
|
||||
},
|
||||
|
||||
updateSrcAllowPatterns(text) {
|
||||
this.srcAllowPatternsDraft = text;
|
||||
const patterns = this.parsePatternLines(text);
|
||||
this.updateField('src_allow_patterns', patterns);
|
||||
},
|
||||
|
||||
updateAudioNetworkCapture(patch = {}) {
|
||||
const nextConfig = {
|
||||
...this.audioNetworkCapture,
|
||||
...(patch || {})
|
||||
};
|
||||
this.updateField('audio_network_capture', nextConfig);
|
||||
},
|
||||
|
||||
updateAudioNetworkUrlPatterns(text) {
|
||||
this.audioNetworkUrlPatternsDraft = text;
|
||||
const patterns = this.parsePatternLines(text);
|
||||
this.updateAudioNetworkCapture({ url_patterns: patterns });
|
||||
},
|
||||
|
||||
toggleModality(type) {
|
||||
const enabled = !this.modalities[type];
|
||||
this.updateModalityPolicy(type, {
|
||||
enabled,
|
||||
run_policy: enabled ? this.defaultModalityPolicy(type, true).run_policy : 'disabled'
|
||||
});
|
||||
},
|
||||
|
||||
modalityCardClass(type) {
|
||||
return this.modalities[type]
|
||||
? 'border-blue-400 bg-blue-50 dark:bg-blue-900/20 dark:border-blue-500/50'
|
||||
: 'border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40';
|
||||
},
|
||||
|
||||
inputWrapClass(enabled) {
|
||||
return enabled ? '' : 'opacity-50';
|
||||
},
|
||||
|
||||
async loadPresets() {
|
||||
if (this.loadingPresets) return;
|
||||
this.loadingPresets = true;
|
||||
try {
|
||||
const response = await fetch('/api/image-presets', {
|
||||
headers: this.buildAuthHeaders()
|
||||
});
|
||||
if (!response.ok) {
|
||||
const err = await response.json().catch(() => ({}));
|
||||
throw new Error(err.detail || ('HTTP ' + response.status));
|
||||
}
|
||||
const data = await response.json();
|
||||
this.availablePresets = data.presets || [];
|
||||
} catch (e) {
|
||||
console.error('加载预设失败:', e);
|
||||
} finally {
|
||||
this.loadingPresets = false;
|
||||
}
|
||||
},
|
||||
|
||||
async checkCurrentPreset() {
|
||||
const domain = String(this.currentDomain || '').trim();
|
||||
const requestSeq = Number(this.imagePresetRequestSeq || 0) + 1;
|
||||
this.imagePresetRequestSeq = requestSeq;
|
||||
if (!domain) {
|
||||
this.currentPreset = null;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await fetch('/api/sites/' + encodeURIComponent(domain) + '/image-preset', {
|
||||
headers: this.buildAuthHeaders()
|
||||
});
|
||||
if (!response.ok) {
|
||||
const err = await response.json().catch(() => ({}));
|
||||
throw new Error(err.detail || ('HTTP ' + response.status));
|
||||
}
|
||||
const data = await response.json();
|
||||
if (requestSeq !== this.imagePresetRequestSeq || String(this.currentDomain || '').trim() !== domain) {
|
||||
return;
|
||||
}
|
||||
this.currentPreset = data.available ? data : null;
|
||||
} catch (e) {
|
||||
if (requestSeq !== this.imagePresetRequestSeq || String(this.currentDomain || '').trim() !== domain) {
|
||||
return;
|
||||
}
|
||||
console.error('读取当前图片预设失败:', e);
|
||||
this.currentPreset = null;
|
||||
}
|
||||
},
|
||||
|
||||
async applyPreset(presetDomain) {
|
||||
if (!this.currentDomain) return;
|
||||
try {
|
||||
const response = await fetch('/api/sites/' + encodeURIComponent(this.currentDomain) + '/apply-image-preset', {
|
||||
method: 'POST',
|
||||
headers: this.buildAuthHeaders({ 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify({ preset_domain: presetDomain })
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const err = await response.json().catch(() => ({}));
|
||||
throw new Error(err.detail || ('HTTP ' + response.status));
|
||||
}
|
||||
|
||||
this.showPresetMenu = false;
|
||||
this.$emit('reload-config');
|
||||
await this.checkCurrentPreset();
|
||||
} catch (e) {
|
||||
alert('应用预设失败: ' + e.message);
|
||||
}
|
||||
},
|
||||
|
||||
togglePresetMenu(e) {
|
||||
e.stopPropagation();
|
||||
this.showPresetMenu = !this.showPresetMenu;
|
||||
if (this.showPresetMenu && this.availablePresets.length === 0) {
|
||||
this.loadPresets();
|
||||
}
|
||||
},
|
||||
|
||||
closeMenu() {
|
||||
this.showPresetMenu = false;
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="cap-panel cap-media-panel bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg shadow-sm" @click="closeMenu">
|
||||
<div class="px-4 py-3 border-b dark:border-gray-700 flex justify-between items-center cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors"
|
||||
@click="toggle">
|
||||
<div class="flex items-center gap-2 flex-wrap">
|
||||
<span class="w-4 inline-flex justify-center text-gray-500 dark:text-gray-400" v-html="collapsed ? $icons.chevronDown : $icons.chevronUp"></span>
|
||||
<h3 class="font-semibold text-gray-900 dark:text-white">更改会自动保存</h3>
|
||||
<span v-if="isEnabled" class="px-2 py-0.5 text-xs bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-300 rounded font-medium">已启用</span>
|
||||
<span v-else class="px-2 py-0.5 text-xs bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 rounded">未启用</span>
|
||||
<span v-for="label in enabledLabels" :key="label"
|
||||
class="px-2 py-0.5 text-xs bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 rounded font-medium">
|
||||
{{ label }}
|
||||
</span>
|
||||
<span v-if="currentPreset && currentPreset.available"
|
||||
class="px-2 py-0.5 text-xs bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 rounded font-medium flex items-center gap-1">
|
||||
<svg class="w-3 h-3" fill="currentColor" viewBox="0 0 20 20"><path d="M10 2a6 6 0 00-6 6v3.586l-.707.707A1 1 0 004 14h12a1 1 0 00.707-1.707L16 11.586V8a6 6 0 00-6-6zM10 18a3 3 0 01-3-3h6a3 3 0 01-3 3z"/></svg>
|
||||
预设
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2" @click.stop>
|
||||
<div class="relative">
|
||||
<button @click="togglePresetMenu"
|
||||
class="px-3 py-1.5 text-sm font-medium text-gray-700 dark:text-gray-200 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors flex items-center gap-1">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
|
||||
</svg>
|
||||
站点规则模板
|
||||
</button>
|
||||
|
||||
<div v-if="showPresetMenu" class="absolute right-0 mt-1 w-80 max-h-96 overflow-y-auto bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg shadow-lg z-10">
|
||||
<div v-if="currentPreset && currentPreset.available" class="px-3 py-2 bg-blue-50 dark:bg-blue-900/30 border-b dark:border-gray-700 text-xs text-blue-700 dark:text-blue-300">
|
||||
<div class="font-medium">当前使用的媒体规则模板</div>
|
||||
<div class="mt-0.5">{{ currentPreset.name }}</div>
|
||||
</div>
|
||||
<div v-if="loadingPresets" class="px-3 py-6 text-center text-sm text-gray-400">加载中...</div>
|
||||
<div v-else-if="availablePresets.length > 0" class="divide-y dark:divide-gray-700">
|
||||
<div class="px-3 py-1.5 bg-gray-50 dark:bg-gray-900/50 text-xs font-medium text-gray-500">站点预设</div>
|
||||
<button v-for="preset in availablePresets" :key="preset.domain"
|
||||
@click="applyPreset(preset.domain)"
|
||||
class="w-full text-left px-3 py-2.5 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors">
|
||||
<div class="font-medium text-sm text-gray-900 dark:text-white truncate">{{ preset.name }}</div>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400 mt-0.5">{{ preset.domain }}</div>
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="px-3 py-6 text-center text-sm text-gray-400">暂无可用预设</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="!collapsed" class="p-4 space-y-4">
|
||||
<div>
|
||||
|
||||
<div class="cap-feature-stack">
|
||||
<section class="cap-card" :class="{ 'is-enabled': modalities.image }" aria-label="接收图片"><div class="cap-card-header"><span class="cap-icon" v-html="$icons.photo"></span><div class="cap-copy"><div class="cap-title-row"><h4>接收图片</h4><span class="cap-scope">当前预设</span></div><p>把 AI 回复里的图片带回客户端。</p></div><label class="cap-switch"><span class="cap-state" :class="{ 'is-on': modalities.image }">{{ modalities.image ? '已开启' : '已关闭' }}</span><input role="switch" aria-label="接收图片" type="checkbox" :checked="modalities.image" @change="toggleModality('image')" class="cap-switch-input"><i aria-hidden="true"></i></label></div><p v-if="modalities.image" class="cap-facts">{{ modalities.image ? '当前方式:' + mediaPolicyLabel('image') : '已关闭,不提取这类媒体' }}</p><details class="cap-settings"><summary><span><strong>配置图片提取</strong><small>识别位置与提取时机</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><p class="cap-inline-help">开启上方开关后,可调整识别位置与提取方式。关闭不会清空识别位置和等待参数。</p><div class="cap-form-grid"><div :class="inputWrapClass(modalities.image)">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">图片选择器</label>
|
||||
<input type="text" :value="imageConfig.selector" @input="updateField('selector', $event.target.value)" placeholder="img"
|
||||
:disabled="!modalities.image"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:cursor-not-allowed">
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">默认 <code>img</code></p>
|
||||
</div><div>
|
||||
<label class="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1">什么时候提取</label>
|
||||
<select :disabled="!modalities.image" :value="modalityPolicies.image.run_policy"
|
||||
@change="updateModalityPolicy('image', { run_policy: $event.target.value, enabled: $event.target.value !== 'disabled' })"
|
||||
class="w-full border dark:border-gray-600 px-2 py-1.5 rounded-md text-xs bg-white dark:bg-gray-700 text-gray-900 dark:text-white">
|
||||
<option value="disabled">不提取</option>
|
||||
<option value="generic_only">只读取现成的媒体</option>
|
||||
<option value="on_signal">发现媒体信号时提取</option>
|
||||
<!-- 修复:补齐后端 MODALITY_RUN_POLICY_VALUES 的第 5 个枚举 -->
|
||||
<option value="probe_if_trigger_found">发现播放入口后探测</option>
|
||||
<option value="always_probe">每次主动探测</option>
|
||||
</select>
|
||||
</div></div><details class="cap-technical"><summary><span><strong>提取不完整或等待太久?</strong><small>调整等待时间与特殊站点的兼容规则。</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><div class="cap-form-grid">
|
||||
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1">快速查找时长(秒)</label>
|
||||
<input type="number"
|
||||
:value="modalityPolicies.image.quick_probe_timeout_seconds"
|
||||
@input="updateModalityPolicy('image', { quick_probe_timeout_seconds: numberOrFallback($event.target.value, 1) })"
|
||||
min="0.1" max="10" step="0.1"
|
||||
:disabled="!modalities.image"
|
||||
class="w-full border dark:border-gray-600 px-2 py-1.5 rounded-md text-xs bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:opacity-50">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1">最长等待(秒)</label>
|
||||
<input type="number"
|
||||
:value="modalityPolicies.image.late_wait_timeout_seconds"
|
||||
@input="updateModalityPolicy('image', { late_wait_timeout_seconds: numberOrFallback($event.target.value, 45) })"
|
||||
min="0.2" max="300" step="1"
|
||||
:disabled="!modalities.image || modalityPolicies.image.run_policy === 'generic_only'"
|
||||
class="w-full border dark:border-gray-600 px-2 py-1.5 rounded-md text-xs bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:opacity-50">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<label class="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1">没有加载提示时等待(秒)</label>
|
||||
<input type="number"
|
||||
:value="modalityPolicies.image.blind_wait_timeout_seconds"
|
||||
@input="updateModalityPolicy('image', { blind_wait_timeout_seconds: numberOrFallback($event.target.value, 1) })"
|
||||
min="0" max="300" step="0.5"
|
||||
:disabled="!modalities.image || modalityPolicies.image.run_policy === 'generic_only'"
|
||||
class="w-full border dark:border-gray-600 px-2 py-1.5 rounded-md text-xs bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:opacity-50">
|
||||
</div>
|
||||
<div :class="inputWrapClass(modalities.image)">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">图片来源白名单 <span class="text-gray-400 font-normal">(可选)</span></label>
|
||||
<textarea :value="srcAllowPatternsDraft" @input="updateSrcAllowPatterns($event.target.value)" rows="5"
|
||||
placeholder="^data:image/ ^blob: ^https?://[^/]*oaiusercontent\.com/ ^https?://[^/]*oaistatic\.com/ ^https?://cdn\.openai\.com/"
|
||||
:disabled="!modalities.image"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:cursor-not-allowed"></textarea>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">每行一个正则,仅提取匹配这些 <code>src</code> 的图片。留空表示不过滤。</p>
|
||||
</div><div :class="inputWrapClass(modalities.image)" class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Canvas 导出格式</label>
|
||||
<select :value="imageConfig.canvas_export_mime || 'image/jpeg'"
|
||||
@change="updateField('canvas_export_mime', $event.target.value)"
|
||||
:disabled="!modalities.image"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:cursor-not-allowed">
|
||||
<option value="image/jpeg">JPEG</option>
|
||||
<option value="image/webp">WebP</option>
|
||||
<option value="image/png">PNG</option>
|
||||
</select>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">用于 blob 图片 Canvas 兜底导出。JPEG/WebP 体积更小。</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Canvas 导出质量</label>
|
||||
<input type="number"
|
||||
:value="imageConfig.canvas_export_quality === undefined ? 0.88 : imageConfig.canvas_export_quality"
|
||||
@input="updateField('canvas_export_quality', numberOrFallback($event.target.value, 0.88))"
|
||||
min="0.1" max="1" step="0.01"
|
||||
:disabled="!modalities.image || (imageConfig.canvas_export_mime || 'image/jpeg') === 'image/png'"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed">
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">仅 JPEG/WebP 生效,建议 0.80-0.92。</p>
|
||||
</div>
|
||||
</div></div></details></div></details></section>
|
||||
|
||||
<section class="cap-card" :class="{ 'is-enabled': modalities.audio }" aria-label="接收音频"><div class="cap-card-header"><span class="cap-icon" v-html="$icons.activity"></span><div class="cap-copy"><div class="cap-title-row"><h4>接收音频</h4><span class="cap-scope">当前预设</span></div><p>把 AI 回复里的声音文件带回客户端。</p></div><label class="cap-switch"><span class="cap-state" :class="{ 'is-on': modalities.audio }">{{ modalities.audio ? '已开启' : '已关闭' }}</span><input role="switch" aria-label="接收音频" type="checkbox" :checked="modalities.audio" @change="toggleModality('audio')" class="cap-switch-input"><i aria-hidden="true"></i></label></div><p v-if="modalities.audio" class="cap-facts">{{ modalities.audio ? '当前方式:' + mediaPolicyLabel('audio') : '已关闭,不提取这类媒体' }}</p><details class="cap-settings"><summary><span><strong>配置音频提取</strong><small>识别位置与提取时机</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><p class="cap-inline-help">开启上方开关后,可调整识别位置与提取方式。关闭不会清空识别位置和等待参数。</p><div class="cap-form-grid"><div :class="inputWrapClass(modalities.audio)">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">音频选择器</label>
|
||||
<input type="text" :value="imageConfig.audio_selector" @input="updateField('audio_selector', $event.target.value)" placeholder="audio, audio source"
|
||||
:disabled="!modalities.audio"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:cursor-not-allowed">
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">默认 <code>audio, audio source</code></p>
|
||||
</div><div>
|
||||
<label class="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1">什么时候提取</label>
|
||||
<select :disabled="!modalities.audio" :value="modalityPolicies.audio.run_policy"
|
||||
@change="updateModalityPolicy('audio', { run_policy: $event.target.value, enabled: $event.target.value !== 'disabled' })"
|
||||
class="w-full border dark:border-gray-600 px-2 py-1.5 rounded-md text-xs bg-white dark:bg-gray-700 text-gray-900 dark:text-white">
|
||||
<option value="disabled">不提取</option>
|
||||
<option value="generic_only">只读取现成的媒体</option>
|
||||
<option value="on_signal">发现媒体信号时提取</option>
|
||||
<option value="probe_if_trigger_found">发现播放入口后探测</option>
|
||||
<option value="always_probe">每次主动探测</option>
|
||||
</select>
|
||||
</div></div><details class="cap-technical"><summary><span><strong>提取不完整或等待太久?</strong><small>调整等待时间与特殊站点的兼容规则。</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><div class="cap-form-grid">
|
||||
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1">快速查找时长(秒)</label>
|
||||
<input type="number"
|
||||
:value="modalityPolicies.audio.quick_probe_timeout_seconds"
|
||||
@input="updateModalityPolicy('audio', { quick_probe_timeout_seconds: numberOrFallback($event.target.value, 1) })"
|
||||
min="0.1" max="10" step="0.1"
|
||||
:disabled="!modalities.audio"
|
||||
class="w-full border dark:border-gray-600 px-2 py-1.5 rounded-md text-xs bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:opacity-50">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1">最长录制时间(秒)</label>
|
||||
<input type="number"
|
||||
:value="modalityPolicies.audio.capture_timeout_seconds"
|
||||
@input="updateModalityPolicy('audio', { capture_timeout_seconds: numberOrFallback($event.target.value, 12) })"
|
||||
min="0.2" max="180" step="0.5"
|
||||
:disabled="!modalities.audio || !['probe_if_trigger_found', 'always_probe', 'on_signal'].includes(modalityPolicies.audio.run_policy)"
|
||||
class="w-full border dark:border-gray-600 px-2 py-1.5 rounded-md text-xs bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:opacity-50">
|
||||
</div>
|
||||
</div>
|
||||
<details class="cap-technical"><summary><span><strong>没有音频文件时,尝试捕获声音</strong><small>可能触发页面播放或录音;Gemini 直连提取预设应保持播放录音回退关闭。</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><div v-if="modalities.audio" class="border-t dark:border-gray-700 pt-4">
|
||||
<div class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-3">音频捕获</div>
|
||||
|
||||
<div class="flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg mb-3">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-700 dark:text-gray-300">页面播放音频捕获回退</div>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400">直接提取不到音频时,允许触发页面播放并录制音频。Gemini 直连提取预设应保持关闭。</div>
|
||||
</div>
|
||||
<label class="toggle-label scale-90">
|
||||
<input type="checkbox" aria-label="允许播放并录制音频" :checked="audioCaptureEnabled" @change="updateField('audio_capture_enabled', $event.target.checked)" class="sr-only peer">
|
||||
<div class="toggle-bg"></div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-700 dark:text-gray-300">启用网络音频捕获</div>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400">优先尝试从页面内 WebSocket / 网络流直接提取音频;是否继续回退到页面录音由上方开关控制。</div>
|
||||
</div>
|
||||
<label class="toggle-label scale-90">
|
||||
<input type="checkbox" aria-label="从网络捕获音频" :checked="audioNetworkCapture.enabled" @change="updateAudioNetworkCapture({ enabled: $event.target.checked })" class="sr-only peer">
|
||||
<div class="toggle-bg"></div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div :class="['mt-4 space-y-4', audioNetworkCapture.enabled ? '' : 'opacity-50']">
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">捕获超时 (秒)</label>
|
||||
<input type="number"
|
||||
:value="audioNetworkCapture.timeout_seconds"
|
||||
@input="updateAudioNetworkCapture({ timeout_seconds: numberOrFallback($event.target.value, 2.5) })"
|
||||
min="0.1" max="15" step="0.1"
|
||||
:disabled="!audioNetworkCapture.enabled"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:cursor-not-allowed">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">传输类型</label>
|
||||
<select :value="audioNetworkCapture.transport"
|
||||
@change="updateAudioNetworkCapture({ transport: $event.target.value })"
|
||||
:disabled="!audioNetworkCapture.enabled"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:cursor-not-allowed">
|
||||
<option value="page_websocket_probe">页面 WebSocket Probe</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">提取器</label>
|
||||
<select :value="audioNetworkCapture.extractor"
|
||||
@change="updateAudioNetworkCapture({ extractor: $event.target.value })"
|
||||
:disabled="!audioNetworkCapture.enabled"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:cursor-not-allowed">
|
||||
<option value="voicegenie_ogg_pages">voicegenie_ogg_pages</option>
|
||||
<!-- 修复:补齐后端合法枚举,否则已存该值的预设会渲染成空白 -->
|
||||
<option value="voicegenie_binary_stream">voicegenie_binary_stream</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">稳定等待窗口 (秒)</label>
|
||||
<input type="number"
|
||||
:value="audioNetworkCapture.settle_seconds"
|
||||
@input="updateAudioNetworkCapture({ settle_seconds: numberOrFallback($event.target.value, 0.35) })"
|
||||
min="0.05" max="5" step="0.05"
|
||||
:disabled="!audioNetworkCapture.enabled"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:cursor-not-allowed">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">单条载荷上限 (MB)</label>
|
||||
<input type="number"
|
||||
:value="audioNetworkMaxPayloadMb"
|
||||
@input="updateAudioNetworkCapture({ max_payload_bytes: Math.round(numberOrFallback($event.target.value, 10) * 1024 * 1024) })"
|
||||
min="0.1" max="100" step="0.5"
|
||||
:disabled="!audioNetworkCapture.enabled"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:cursor-not-allowed">
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">超过上限的二进制帧只记录摘要,不回传 Base64。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">URL 匹配关键字</label>
|
||||
<textarea :value="audioNetworkUrlPatternsDraft"
|
||||
@input="updateAudioNetworkUrlPatterns($event.target.value)"
|
||||
rows="4"
|
||||
:disabled="!audioNetworkCapture.enabled"
|
||||
placeholder="voicegenie speech audio tts"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:cursor-not-allowed"></textarea>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">每行一个关键字,命中对应 WebSocket / 网络请求 URL 时才会参与音频聚合。</p>
|
||||
</div>
|
||||
</div>
|
||||
</div></div></details></div></details></div></details></section>
|
||||
|
||||
<section class="cap-card" :class="{ 'is-enabled': modalities.video }" aria-label="接收视频"><div class="cap-card-header"><span class="cap-icon" v-html="$icons.play"></span><div class="cap-copy"><div class="cap-title-row"><h4>接收视频</h4><span class="cap-scope">当前预设</span></div><p>把 AI 回复里的视频文件带回客户端。</p></div><label class="cap-switch"><span class="cap-state" :class="{ 'is-on': modalities.video }">{{ modalities.video ? '已开启' : '已关闭' }}</span><input role="switch" aria-label="接收视频" type="checkbox" :checked="modalities.video" @change="toggleModality('video')" class="cap-switch-input"><i aria-hidden="true"></i></label></div><p v-if="modalities.video" class="cap-facts">{{ modalities.video ? '当前方式:' + mediaPolicyLabel('video') : '已关闭,不提取这类媒体' }}</p><details class="cap-settings"><summary><span><strong>配置视频提取</strong><small>识别位置与提取时机</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><p class="cap-inline-help">开启上方开关后,可调整识别位置与提取方式。关闭不会清空识别位置和等待参数。</p><div class="cap-form-grid"><div :class="inputWrapClass(modalities.video)">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">视频选择器</label>
|
||||
<input type="text" :value="imageConfig.video_selector" @input="updateField('video_selector', $event.target.value)" placeholder="video, video source"
|
||||
:disabled="!modalities.video"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent disabled:cursor-not-allowed">
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">默认 <code>video, video source</code></p>
|
||||
</div><div>
|
||||
<label class="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1">什么时候提取</label>
|
||||
<select :disabled="!modalities.video" :value="modalityPolicies.video.run_policy"
|
||||
@change="updateModalityPolicy('video', { run_policy: $event.target.value, enabled: $event.target.value !== 'disabled' })"
|
||||
class="w-full border dark:border-gray-600 px-2 py-1.5 rounded-md text-xs bg-white dark:bg-gray-700 text-gray-900 dark:text-white">
|
||||
<option value="disabled">不提取</option>
|
||||
<option value="generic_only">只读取现成的媒体</option>
|
||||
<option value="on_signal">发现媒体信号时提取</option>
|
||||
<!-- 修复:补齐后端 MODALITY_RUN_POLICY_VALUES 的第 5 个枚举 -->
|
||||
<option value="probe_if_trigger_found">发现播放入口后探测</option>
|
||||
<option value="always_probe">每次主动探测</option>
|
||||
</select>
|
||||
</div></div><details class="cap-technical"><summary><span><strong>提取不完整或等待太久?</strong><small>调整等待时间与特殊站点的兼容规则。</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><div class="cap-form-grid">
|
||||
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1">快速查找时长(秒)</label>
|
||||
<input type="number"
|
||||
:value="modalityPolicies.video.quick_probe_timeout_seconds"
|
||||
@input="updateModalityPolicy('video', { quick_probe_timeout_seconds: numberOrFallback($event.target.value, 1) })"
|
||||
min="0.1" max="10" step="0.1"
|
||||
:disabled="!modalities.video"
|
||||
class="w-full border dark:border-gray-600 px-2 py-1.5 rounded-md text-xs bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:opacity-50">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1">最长等待(秒)</label>
|
||||
<input type="number"
|
||||
:value="modalityPolicies.video.late_wait_timeout_seconds"
|
||||
@input="updateModalityPolicy('video', { late_wait_timeout_seconds: numberOrFallback($event.target.value, 90) })"
|
||||
min="0.2" max="300" step="1"
|
||||
:disabled="!modalities.video || modalityPolicies.video.run_policy === 'generic_only'"
|
||||
class="w-full border dark:border-gray-600 px-2 py-1.5 rounded-md text-xs bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:opacity-50">
|
||||
</div>
|
||||
</div>
|
||||
</div></details></div></details></section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!isEnabled" class="bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3 text-center">
|
||||
<div class="text-gray-500 dark:text-gray-400 text-sm">当前只处理文字回复;需要接收图片、声音或视频时,再开启对应能力。</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<details class="cap-troubleshoot"><summary><span><strong>通用识别与下载规则</strong><small>范围、文件大小和资源转换。现有提取正常时无需改动。</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">容器选择器 <span class="text-gray-400 font-normal">(可选)</span></label>
|
||||
<input type="text" :value="imageConfig.container_selector || ''" @input="updateField('container_selector', $event.target.value || null)" placeholder="留空则使用响应容器"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">统一限定媒体查找范围</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">提取模式</label>
|
||||
<select :value="imageConfig.mode" @change="updateField('mode', $event.target.value)"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<option value="all">全部提取</option>
|
||||
<option value="first">仅第一项</option>
|
||||
<option value="last">仅最后一项</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">最大大小 (MB)</label>
|
||||
<!-- 修复:后端取值域是连续区间 1..100,原下拉只有 5/10/20/50,存 100 的预设会渲染空白并被砍到 ≤50 -->
|
||||
<input type="number" :value="imageConfig.max_size_mb"
|
||||
@input="updateField('max_size_mb', numberOrFallback($event.target.value, 10))"
|
||||
min="1" max="100" step="1"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">防抖延迟 (秒)</label>
|
||||
<!-- 修复:parseFloat("0") || 2 恒为 2,用户输 0 关防抖会被写成 2 秒;后端下限是 0 -->
|
||||
<input type="number" :value="imageConfig.debounce_seconds" @input="updateField('debounce_seconds', numberOrFallback($event.target.value, 2))" min="0" max="30" step="0.5"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">加载超时时间 (秒)</label>
|
||||
<input type="number" :value="imageConfig.load_timeout_seconds" @input="updateField('load_timeout_seconds', parseFloat($event.target.value) || 5)"
|
||||
min="1" max="60" step="1" :disabled="!imageConfig.wait_for_load"
|
||||
:class="['w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent', !imageConfig.wait_for_load ? 'opacity-50 cursor-not-allowed' : '']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="border-t dark:border-gray-700 pt-4">
|
||||
<div class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-3">高级选项</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div class="flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-700 dark:text-gray-300">等待媒体加载</div>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400">等待音视频或图片完成加载后再提取</div>
|
||||
</div>
|
||||
<label class="toggle-label scale-90">
|
||||
<input type="checkbox" aria-label="等待媒体加载完成" :checked="imageConfig.wait_for_load" @change="updateField('wait_for_load', $event.target.checked)" class="sr-only peer">
|
||||
<div class="toggle-bg"></div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-700 dark:text-gray-300">转换 Blob 媒体</div>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400">将 blob: 资源转为可返回的数据 URI 或本地文件</div>
|
||||
</div>
|
||||
<label class="toggle-label scale-90">
|
||||
<input type="checkbox" aria-label="转换临时媒体资源" :checked="imageConfig.download_blobs" @change="updateField('download_blobs', $event.target.checked)" class="sr-only peer">
|
||||
<div class="toggle-bg"></div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div></details> </div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
@@ -0,0 +1,388 @@
|
||||
/* Scoped transfers: importing never writes the server or touches another site. */
|
||||
(() => {
|
||||
const copy = (x) => JSON.parse(JSON.stringify(x));
|
||||
const object = (x) => !!x && typeof x === "object" && !Array.isArray(x);
|
||||
const safeName = (x) =>
|
||||
typeof x === "string" &&
|
||||
!!x.trim() &&
|
||||
x.length <= 100 &&
|
||||
!["__proto__", "prototype", "constructor"].includes(x);
|
||||
function sources(data, fallbackDomain) {
|
||||
if (!object(data))
|
||||
throw Error("请选择站点或预设 JSON 文件,不是动作数组。");
|
||||
if (data.kind === "workflow")
|
||||
throw Error("这是工作流片段。请在「请求工作流 → 导入工作流」中使用它。");
|
||||
const result = [];
|
||||
const add = (domain, site) => {
|
||||
if (!object(site)) return;
|
||||
const presets = object(site.presets)
|
||||
? site.presets
|
||||
: "workflow" in site || "selectors" in site
|
||||
? { [site.preset_name || "主预设"]: site }
|
||||
: null;
|
||||
if (!presets) return;
|
||||
const clean = {};
|
||||
for (const [name, config] of Object.entries(presets)) {
|
||||
if (!safeName(name) || !object(config))
|
||||
throw Error("文件中存在无效的预设名称或配置对象。");
|
||||
if ("workflow" in config && !Array.isArray(config.workflow))
|
||||
throw Error(name + " 的 workflow 必须是数组。");
|
||||
if ("selectors" in config && !object(config.selectors))
|
||||
throw Error(name + " 的 selectors 必须是对象。");
|
||||
const value = copy(config);
|
||||
if (!object(site.presets)) {
|
||||
delete value.domain;
|
||||
delete value.preset_name;
|
||||
}
|
||||
Object.defineProperty(clean, name, {
|
||||
value,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
if (Object.keys(clean).length)
|
||||
result.push({
|
||||
domain: domain || fallbackDomain,
|
||||
presets: clean,
|
||||
settings: object(site.presets)
|
||||
? Object.fromEntries(
|
||||
Object.entries(site).filter(
|
||||
([k]) =>
|
||||
![
|
||||
"presets",
|
||||
"default_preset",
|
||||
"domain",
|
||||
"preset_name",
|
||||
"format",
|
||||
"version",
|
||||
].includes(k) &&
|
||||
!k.startsWith("_") &&
|
||||
safeName(k),
|
||||
),
|
||||
)
|
||||
: {},
|
||||
});
|
||||
};
|
||||
if (data.format === "universal-web-api/preset" && object(data.config))
|
||||
add(data.domain, {
|
||||
presets: { [data.preset_name || "主预设"]: data.config },
|
||||
});
|
||||
else if ("presets" in data || "workflow" in data || "selectors" in data)
|
||||
add(data.domain, data);
|
||||
else
|
||||
for (const [domain, site] of Object.entries(data))
|
||||
if (!domain.startsWith("_")) add(domain, site);
|
||||
if (!result.length)
|
||||
throw Error("没有找到可导入的站点预设。请选择站点配置或单预设文件。");
|
||||
return result;
|
||||
}
|
||||
window.PresetTransferSupport = { sources, safeName, copy };
|
||||
window.PresetTransfer = {
|
||||
name: "PresetTransfer",
|
||||
props: {
|
||||
domain: String,
|
||||
site: Object,
|
||||
preset: String,
|
||||
prepare: Function,
|
||||
disabled: Boolean,
|
||||
},
|
||||
emits: ["apply"],
|
||||
data: () => ({
|
||||
open: false,
|
||||
mode: "preset",
|
||||
fileName: "",
|
||||
sourceSites: [],
|
||||
sourceIndex: 0,
|
||||
sourcePreset: "",
|
||||
targetName: "",
|
||||
overwrite: false,
|
||||
includeSettings: false,
|
||||
busy: false,
|
||||
error: "",
|
||||
message: "",
|
||||
generation: 0,
|
||||
requestAbort: null,
|
||||
}),
|
||||
computed: {
|
||||
source() {
|
||||
return this.sourceSites[this.sourceIndex] || null;
|
||||
},
|
||||
names() {
|
||||
return Object.keys(this.source?.presets || {});
|
||||
},
|
||||
existing() {
|
||||
return this.site?.presets || { 主预设: this.site };
|
||||
},
|
||||
conflicts() {
|
||||
return this.names.filter((n) => Object.hasOwn(this.existing, n));
|
||||
},
|
||||
importCount() {
|
||||
return this.mode === "preset"
|
||||
? this.sourcePreset
|
||||
? 1
|
||||
: 0
|
||||
: this.names.filter(
|
||||
(n) => this.overwrite || !Object.hasOwn(this.existing, n),
|
||||
).length;
|
||||
},
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.requestAbort?.abort();
|
||||
this.generation++;
|
||||
},
|
||||
watch: {
|
||||
domain() {
|
||||
this.reset();
|
||||
this.open = false;
|
||||
this.message = "";
|
||||
},
|
||||
sourceIndex() {
|
||||
this.selectSource();
|
||||
},
|
||||
sourcePreset() {
|
||||
if (this.mode === "preset") this.suggestName();
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
trapFocus(e) {
|
||||
const items = [
|
||||
...e.currentTarget.querySelectorAll(
|
||||
"button:not(:disabled),input:not(:disabled),select:not(:disabled)",
|
||||
),
|
||||
].filter((n) => n.offsetParent !== null);
|
||||
if (e.shiftKey && document.activeElement === items[0]) {
|
||||
e.preventDefault();
|
||||
items.at(-1)?.focus();
|
||||
} else if (!e.shiftKey && document.activeElement === items.at(-1)) {
|
||||
e.preventDefault();
|
||||
items[0]?.focus();
|
||||
}
|
||||
},
|
||||
reset() {
|
||||
this.requestAbort?.abort();
|
||||
this.generation++;
|
||||
this.fileName = "";
|
||||
this.sourceSites = [];
|
||||
this.error = "";
|
||||
this.busy = false;
|
||||
this.sourcePreset = "";
|
||||
this.targetName = "";
|
||||
this.overwrite = false;
|
||||
this.includeSettings = false;
|
||||
},
|
||||
launch(mode) {
|
||||
this.reset();
|
||||
this.mode = mode;
|
||||
this.open = true;
|
||||
this.$refs.menu.open = false;
|
||||
this.$nextTick(() => this.$refs.choose.focus());
|
||||
},
|
||||
close() {
|
||||
this.requestAbort?.abort();
|
||||
this.generation++;
|
||||
this.open = false;
|
||||
this.busy = false;
|
||||
this.$nextTick(() => this.$refs.menu.querySelector("summary").focus());
|
||||
},
|
||||
suggestName() {
|
||||
let name = this.sourcePreset || "导入预设";
|
||||
if (Object.hasOwn(this.existing, name)) {
|
||||
const base = name.slice(0, 86) + " · 导入";
|
||||
name = base;
|
||||
let i = 2;
|
||||
while (Object.hasOwn(this.existing, name)) name = base + " " + i++;
|
||||
}
|
||||
this.targetName = name;
|
||||
},
|
||||
selectSource() {
|
||||
this.sourcePreset = this.names[0] || "";
|
||||
this.suggestName();
|
||||
},
|
||||
async read(event) {
|
||||
const file = event.target.files[0];
|
||||
event.target.value = "";
|
||||
if (!file) return;
|
||||
const generation = ++this.generation;
|
||||
this.error = "";
|
||||
try {
|
||||
if (file.size > 4 * 1024 * 1024)
|
||||
throw Error("配置文件不能超过 4 MiB。");
|
||||
const data = JSON.parse(await file.text());
|
||||
if (generation !== this.generation) return;
|
||||
this.sourceSites = sources(data, this.domain);
|
||||
this.sourceIndex = Math.max(
|
||||
0,
|
||||
this.sourceSites.findIndex((s) => s.domain === this.domain),
|
||||
);
|
||||
this.fileName = file.name;
|
||||
this.selectSource();
|
||||
} catch (e) {
|
||||
if (generation === this.generation) {
|
||||
this.sourceSites = [];
|
||||
this.fileName = "";
|
||||
this.error = e.message || "文件无法读取";
|
||||
}
|
||||
}
|
||||
},
|
||||
async validate(config) {
|
||||
const headers = { "Content-Type": "application/json" },
|
||||
token = window.getDashboardAuthToken?.();
|
||||
if (token) headers.Authorization = "Bearer " + token;
|
||||
const controller = new AbortController();
|
||||
this.requestAbort = controller;
|
||||
const timeout = setTimeout(() => controller.abort(), 30000);
|
||||
try {
|
||||
const response = await fetch("/api/workflow/validate", {
|
||||
method: "POST",
|
||||
headers,
|
||||
signal: controller.signal,
|
||||
body: JSON.stringify({ workflow: config.workflow || [] }),
|
||||
});
|
||||
const result = await response.json();
|
||||
if (!response.ok)
|
||||
throw Error(
|
||||
typeof result.detail === "string"
|
||||
? result.detail
|
||||
: "工作流校验失败",
|
||||
);
|
||||
} catch (e) {
|
||||
if (e.name === "AbortError")
|
||||
throw Error("校验已取消或超过 30 秒,请稍后再试。");
|
||||
throw e;
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
if (this.requestAbort === controller) this.requestAbort = null;
|
||||
}
|
||||
},
|
||||
async apply() {
|
||||
if (!this.source || this.busy) return;
|
||||
const domain = this.domain,
|
||||
generation = this.generation;
|
||||
this.error = "";
|
||||
try {
|
||||
const updates = {};
|
||||
if (this.mode === "preset") {
|
||||
const name = this.targetName.trim();
|
||||
if (!safeName(name)) throw Error("请输入 1–100 字的有效预设名称。");
|
||||
if (
|
||||
Object.hasOwn(this.existing, name) &&
|
||||
!confirm(
|
||||
"将替换当前站点的「" +
|
||||
name +
|
||||
"」预设。其他预设不变,是否继续?",
|
||||
)
|
||||
)
|
||||
return;
|
||||
updates[name] = copy(this.source.presets[this.sourcePreset]);
|
||||
} else {
|
||||
for (const n of this.names)
|
||||
if (this.overwrite || !Object.hasOwn(this.existing, n))
|
||||
updates[n] = copy(this.source.presets[n]);
|
||||
if (
|
||||
this.overwrite &&
|
||||
this.conflicts.length &&
|
||||
!confirm(
|
||||
"将覆盖 " +
|
||||
this.conflicts.length +
|
||||
" 个同名预设,其他预设保留。继续?",
|
||||
)
|
||||
)
|
||||
return;
|
||||
}
|
||||
if (!Object.keys(updates).length)
|
||||
throw Error(
|
||||
"没有可导入的预设。同名预设默认跳过,可选择覆盖或改为导入单个预设。",
|
||||
);
|
||||
this.busy = true;
|
||||
for (const config of Object.values(updates)) {
|
||||
if (domain !== this.domain || generation !== this.generation)
|
||||
return;
|
||||
await this.validate(config);
|
||||
}
|
||||
if (domain !== this.domain || generation !== this.generation) return;
|
||||
this.prepare?.();
|
||||
this.$emit("apply", {
|
||||
domain,
|
||||
presets: updates,
|
||||
settings:
|
||||
this.mode === "site" && this.includeSettings
|
||||
? copy(this.source.settings)
|
||||
: null,
|
||||
select: this.mode === "preset" ? this.targetName.trim() : null,
|
||||
});
|
||||
this.message =
|
||||
"已导入 " +
|
||||
Object.keys(updates).length +
|
||||
" 个预设为草稿,请点击「保存配置」。";
|
||||
this.close();
|
||||
} catch (e) {
|
||||
if (generation === this.generation) this.error = e.message;
|
||||
} finally {
|
||||
if (generation === this.generation) this.busy = false;
|
||||
}
|
||||
},
|
||||
download(scope) {
|
||||
this.prepare?.();
|
||||
const site = copy(this.site || {}),
|
||||
preset = this.preset;
|
||||
let payload, file;
|
||||
if (scope === "preset") {
|
||||
const config =
|
||||
site.presets?.[preset] || (!site.presets ? site : null);
|
||||
if (!config) {
|
||||
this.message = "当前预设不存在,请重新选择。";
|
||||
return;
|
||||
}
|
||||
payload = {
|
||||
domain: this.domain,
|
||||
default_preset: preset,
|
||||
presets: { [preset]: config },
|
||||
};
|
||||
file = this.domain + "__" + preset + "__preset.json";
|
||||
} else {
|
||||
payload = { ...site, domain: this.domain };
|
||||
file = this.domain + "__site.json";
|
||||
}
|
||||
const url = URL.createObjectURL(
|
||||
new Blob([JSON.stringify(payload, null, 2)], {
|
||||
type: "application/json",
|
||||
}),
|
||||
),
|
||||
a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = file.replace(/[\\/:*?"<>|]/g, "_");
|
||||
a.click();
|
||||
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
||||
this.$refs.menu.open = false;
|
||||
this.message =
|
||||
scope === "preset"
|
||||
? "已导出当前预设「" + preset + "」,不含其他预设和站点级设置。"
|
||||
: "已导出本站点全部预设与站点级设置。";
|
||||
},
|
||||
},
|
||||
template: `<div class="preset-transfer">
|
||||
<details ref="menu" class="preset-more transfer-menu"><summary class="preset-btn" :aria-disabled="disabled" @click="disabled && $event.preventDefault()"><span v-html="$icons.arrowUpTray"></span>导入 / 导出<span v-html="$icons.chevronDown"></span></summary>
|
||||
<div class="preset-more-pop"><div class="transfer-menu-caption">当前站点 · {{ domain }}</div>
|
||||
<button type="button" @click="launch('preset')"><span v-html="$icons.documentArrowDown"></span><span>导入一个预设<small>新建一份,或明确选择替换</small></span></button>
|
||||
<button type="button" @click="launch('site')"><span v-html="$icons.folderOpen"></span><span>合并站点配置<small>从文件导入本站点的多套预设</small></span></button>
|
||||
<hr class="preset-more-sep">
|
||||
<button type="button" @click="download('preset')"><span v-html="$icons.arrowUpTray"></span><span>导出当前预设<small>仅「{{ preset }}」,方便分享与迁移</small></span></button>
|
||||
<button type="button" @click="download('site')"><span v-html="$icons.globe"></span><span>导出整个站点<small>全部预设 + 站点级设置</small></span></button>
|
||||
</div>
|
||||
</details>
|
||||
<div v-if="message" class="transfer-feedback" role="status">{{ message }}<button type="button" @click="message=''" aria-label="关闭导入导出提示">×</button></div>
|
||||
<teleport to="body"><div v-if="open" class="preset-transfer-overlay" @click.self="close()" @keydown.esc.stop="close()">
|
||||
<section class="preset-transfer-dialog" role="dialog" aria-modal="true" aria-labelledby="preset-transfer-title" @keydown.tab="trapFocus">
|
||||
<header><div><span class="transfer-kicker">导入到当前站点</span><h3 id="preset-transfer-title">{{ mode==='preset'?'导入一个预设':'合并站点配置' }}</h3><p>{{ domain }} · 不会影响其他站点</p></div><button type="button" @click="close" aria-label="关闭导入对话框">×</button></header>
|
||||
<div class="transfer-body"><button ref="choose" type="button" class="transfer-file" @click="$refs.file.click()" :disabled="busy"><span v-html="$icons.documentArrowDown"></span><strong>{{ fileName || '选择配置 JSON 文件' }}</strong><small>支持单预设、单站点和多站点文件 · 最大 4 MiB</small></button><input ref="file" type="file" accept=".json,application/json" hidden @change="read">
|
||||
<template v-if="source"><label v-if="sourceSites.length>1">从文件选择来源站点<select v-model.number="sourceIndex" :disabled="busy"><option v-for="(s,i) in sourceSites" :value="i">{{ s.domain }} · {{ Object.keys(s.presets).length }} 个预设</option></select></label><p v-if="source.domain!==domain" class="transfer-note">来源 {{ source.domain }} → 导入到 {{ domain }}。请确认定位器适用于当前站点。</p>
|
||||
<template v-if="mode==='preset'"><label>文件中的预设<select v-model="sourcePreset" :disabled="busy"><option v-for="n in names" :value="n">{{ n }}</option></select></label><label>在本站点保存为<input v-model="targetName" maxlength="100" :disabled="busy"></label><p class="transfer-note">{{ Object.hasOwn(existing,targetName.trim())?'将替换同名预设;确认时会再次提醒。':'将新建预设;现有预设和默认选择均保持不变。' }}</p></template>
|
||||
<template v-else><div class="transfer-preview"><strong>{{ names.length }} 个来源预设 · {{ conflicts.length }} 个同名</strong><div v-for="n in names"><span>{{ n }}</span><small>{{ conflicts.includes(n)?(overwrite?'将覆盖':'保留已有,跳过'):'新增' }}</small></div></div><label class="transfer-check"><input type="checkbox" v-model="overwrite" :disabled="busy">覆盖同名预设(默认保留已有)</label><label v-if="Object.keys(source.settings).length" class="transfer-check"><input type="checkbox" v-model="includeSettings" :disabled="busy">同时导入站点级设置</label><p class="transfer-note">保留其他已有预设,不改变默认预设。{{ includeSettings?'文件中的站点级字段将替换当前同名字段。':'站点级设置保持不变。' }}</p></template>
|
||||
</template><p v-if="error" class="transfer-error" role="alert">{{ error }}</p>
|
||||
</div><footer><span>先校验并载入草稿,再由你保存。</span><button type="button" @click="close">取消</button><button type="button" class="transfer-primary" @click="apply" :disabled="busy||!source||!importCount">{{ busy?'校验中…':'导入为草稿' }}</button></footer>
|
||||
</section>
|
||||
</div></teleport>
|
||||
</div>`,
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,180 @@
|
||||
// ==================== 提示词开头注入面板 ====================
|
||||
|
||||
window.PromptPaddingPanel = {
|
||||
name: 'PromptPaddingPanel',
|
||||
props: {
|
||||
promptPaddingConfig: { type: Object, required: true },
|
||||
currentDomain: { type: String, default: null },
|
||||
selectedPreset: { type: String, default: null },
|
||||
collapsed: { type: Boolean, default: true }
|
||||
},
|
||||
emits: ['update:collapsed'],
|
||||
data() {
|
||||
return {
|
||||
defaultPromptPadding: {
|
||||
enabled: false,
|
||||
marker_text: '测试号,无实际意义',
|
||||
segments_per_side: 12,
|
||||
random_insert_enabled: false,
|
||||
random_insert_chars: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
resolvedPromptPadding() {
|
||||
const raw = this.promptPaddingConfig || {};
|
||||
return {
|
||||
...this.defaultPromptPadding,
|
||||
...raw
|
||||
};
|
||||
},
|
||||
currentPresetLabel() {
|
||||
return String(this.selectedPreset || '').trim() || '主预设';
|
||||
},
|
||||
statusText() {
|
||||
return (this.resolvedPromptPadding.enabled || this.resolvedPromptPadding.random_insert_enabled)
|
||||
? '已启用'
|
||||
: '未启用';
|
||||
},
|
||||
markerPreview() {
|
||||
const markerText = String(this.resolvedPromptPadding.marker_text || '').trim();
|
||||
const segmentCount = Math.max(0, parseInt(this.resolvedPromptPadding.segments_per_side, 10) || 0);
|
||||
if (segmentCount === 0) {
|
||||
return markerText || '不注入内容';
|
||||
}
|
||||
if (!markerText) {
|
||||
return '随机片段';
|
||||
}
|
||||
if (markerText.endsWith(':') || markerText.endsWith(':')) {
|
||||
return markerText + '随机片段';
|
||||
}
|
||||
return markerText + ':随机片段';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toggle() {
|
||||
this.$emit('update:collapsed', !this.collapsed);
|
||||
},
|
||||
|
||||
getMutablePromptPadding() {
|
||||
return this.promptPaddingConfig || {};
|
||||
},
|
||||
|
||||
toggleEnabled() {
|
||||
const cfg = this.getMutablePromptPadding();
|
||||
cfg.enabled = !this.resolvedPromptPadding.enabled;
|
||||
},
|
||||
|
||||
updateMarkerText(value) {
|
||||
this.getMutablePromptPadding().marker_text = String(value || '');
|
||||
},
|
||||
|
||||
updateSegmentsPerSide(value) {
|
||||
const parsed = parseInt(value, 10);
|
||||
if (!Number.isFinite(parsed)) {
|
||||
return;
|
||||
}
|
||||
this.getMutablePromptPadding().segments_per_side = Math.max(0, Math.min(parsed, 64));
|
||||
},
|
||||
|
||||
toggleRandomInsertEnabled() {
|
||||
const cfg = this.getMutablePromptPadding();
|
||||
cfg.random_insert_enabled = !this.resolvedPromptPadding.random_insert_enabled;
|
||||
},
|
||||
|
||||
updateRandomInsertChars(value) {
|
||||
this.getMutablePromptPadding().random_insert_chars = String(value || '');
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="cap-panel cap-padding-panel bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg shadow-sm">
|
||||
<div class="px-4 py-3 border-b dark:border-gray-700 flex justify-between items-center cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors"
|
||||
@click="toggle">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-4 inline-flex justify-center text-gray-500 dark:text-gray-400" v-html="collapsed ? $icons.chevronDown : $icons.chevronUp"></span>
|
||||
<h3 class="font-semibold text-gray-900 dark:text-white">特殊输入适配</h3>
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">({{ statusText }})</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="!collapsed" class="p-4"><details class="cap-troubleshoot"><summary><span><strong>特殊站点:调整提示词</strong><small>会在原消息中加入额外内容,普通对话通常无需修改。</small></span><span class="cap-summary-value">{{ resolvedPromptPadding.enabled || resolvedPromptPadding.random_insert_enabled ? '有功能已开启' : '未开启' }}</span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><p class="cap-warning">随机插入字符会改变原文。处理代码、结构化数据或需要精确措辞时请谨慎使用。</p>
|
||||
|
||||
|
||||
<div class="rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50/60 dark:bg-gray-900/30 p-4 space-y-4">
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-800 dark:text-gray-100">发送前在开头追加随机占位片段</div>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400 leading-5">
|
||||
开启后,只在提示词开头追加一段随机片段,不改动后面的原始消息主体。修改会跟随当前站点配置一起保存。
|
||||
</p>
|
||||
</div>
|
||||
<label class="toggle-label scale-90 flex-shrink-0">
|
||||
<input type="checkbox" aria-label="启用开头占位片段" :checked="resolvedPromptPadding.enabled" @change="toggleEnabled" class="sr-only peer">
|
||||
<div class="toggle-bg"></div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">开头片段数</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="resolvedPromptPadding.segments_per_side"
|
||||
@input="updateSegmentsPerSide($event.target.value)"
|
||||
min="0"
|
||||
max="64"
|
||||
step="1"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm text-right bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">个</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">说明文本</label>
|
||||
<input type="text"
|
||||
:value="resolvedPromptPadding.marker_text"
|
||||
@input="updateMarkerText($event.target.value)"
|
||||
placeholder="留空则只追加随机片段"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-lg border border-slate-200 dark:border-slate-700 bg-white/80 dark:bg-slate-900/40 px-4 py-3">
|
||||
<div class="text-sm font-medium text-gray-800 dark:text-gray-100">发送效果</div>
|
||||
<p class="mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400">
|
||||
实际发送时,会在提示词开头生成一段类似
|
||||
<code class="font-mono">{{ markerPreview }}</code>
|
||||
的文本。随机片段会混合数字和单字符字母,尽量贴近当前需求的样式。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-gray-200 dark:border-gray-700 pt-4 space-y-3">
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-800 dark:text-gray-100">提示词内随机插入一个字符</div>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400 leading-5">
|
||||
每次发送时,从候选字符中随机选择一个,并插入到用户提示词的随机位置。
|
||||
</p>
|
||||
</div>
|
||||
<label class="toggle-label scale-90 flex-shrink-0">
|
||||
<input type="checkbox"
|
||||
aria-label="在提示词中随机插入字符" :checked="resolvedPromptPadding.random_insert_enabled"
|
||||
@change="toggleRandomInsertEnabled"
|
||||
class="sr-only peer">
|
||||
<div class="toggle-bg"></div>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">候选字符</label>
|
||||
<input type="text"
|
||||
:value="resolvedPromptPadding.random_insert_chars"
|
||||
@input="updateRandomInsertChars($event.target.value)"
|
||||
placeholder="例如:abc123※☆"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">候选框中的每个字符都有机会被选中;留空时不会插入。</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div></details></div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
@@ -0,0 +1,508 @@
|
||||
// ==================== 选择器管理面板 ====================
|
||||
|
||||
window.SelectorPanel = {
|
||||
name: 'SelectorPanel',
|
||||
props: {
|
||||
selectors: { type: Object, required: true },
|
||||
collapsed: { type: Boolean, default: true }
|
||||
},
|
||||
emits: [
|
||||
'update:collapsed',
|
||||
'add-selector',
|
||||
'remove-selector',
|
||||
'update-selector-key',
|
||||
'update-selector-value',
|
||||
'test-selector'
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
showMenu: false,
|
||||
fieldQuery: '',
|
||||
fieldFilter: 'all',
|
||||
editingSelectorKey: '',
|
||||
expandedField: 'input_box',
|
||||
auxiliaryExpanded: false,
|
||||
guideExpanded: false,
|
||||
openRenameKey: '',
|
||||
renameDrafts: {},
|
||||
coreSelectorKeys: ['input_box', 'send_btn', 'result_container']
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
count() {
|
||||
return Object.keys(this.selectors || {}).length;
|
||||
},
|
||||
|
||||
selectorEntries() {
|
||||
const query = this.fieldQuery.trim().toLowerCase();
|
||||
return Object.entries(this.selectors || {}).filter(([key, value]) => {
|
||||
// Keep the active field mounted while typing, even when its value stops matching.
|
||||
if (key === this.editingSelectorKey) return true;
|
||||
if (this.fieldFilter === 'core' && !this.coreSelectorKeys.includes(key)) return false;
|
||||
if (this.fieldFilter === 'empty' && this.isSelectorFilled(key)) return false;
|
||||
const meta = this.getSelectorMeta(key);
|
||||
return !query || [key, value, meta.title, meta.description].join(' ').toLowerCase().includes(query);
|
||||
});
|
||||
},
|
||||
|
||||
selectorGroups() {
|
||||
return [
|
||||
{ id: 'core', title: '核心定位', note: '一次对话的三个关键位置', entries: this.selectorEntries.filter(([key]) => this.coreSelectorKeys.includes(key)) },
|
||||
{ id: 'auxiliary', title: '辅助与扩展', note: '对话管理、上传入口及自定义字段', entries: this.selectorEntries.filter(([key]) => !this.coreSelectorKeys.includes(key)) }
|
||||
];
|
||||
},
|
||||
coreChecklist() {
|
||||
return this.coreSelectorKeys.map(key => ({
|
||||
key,
|
||||
...this.getSelectorMeta(key),
|
||||
ready: this.isSelectorFilled(key)
|
||||
}));
|
||||
},
|
||||
|
||||
coreReadyCount() {
|
||||
return this.coreChecklist.filter(item => item.ready).length;
|
||||
},
|
||||
|
||||
missingQuickAdds() {
|
||||
return this.coreChecklist.filter(item => !Object.prototype.hasOwnProperty.call(this.selectors || {}, item.key));
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
selectors() {
|
||||
this.fieldQuery = '';
|
||||
this.fieldFilter = 'all';
|
||||
this.editingSelectorKey = '';
|
||||
this.expandedField = Object.prototype.hasOwnProperty.call(this.selectors || {}, 'input_box') ? 'input_box' : Object.keys(this.selectors || {})[0] || '';
|
||||
this.auxiliaryExpanded = false;
|
||||
this.closeRenameEditor();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openCoreField(key) {
|
||||
this.fieldFilter = 'all'; this.fieldQuery = '';
|
||||
if (!Object.prototype.hasOwnProperty.call(this.selectors || {}, key)) {
|
||||
this.addSelector(key);
|
||||
return;
|
||||
}
|
||||
this.expandedField = key;
|
||||
this.$nextTick(() => {
|
||||
const field = document.getElementById('selector-expression-' + key);
|
||||
if (field) { field.focus({ preventScroll: true }); field.scrollIntoView({ block: 'nearest' }); }
|
||||
});
|
||||
},
|
||||
toggle() {
|
||||
this.$emit('update:collapsed', !this.collapsed);
|
||||
},
|
||||
|
||||
toggleMenu(e) {
|
||||
e.stopPropagation();
|
||||
this.showMenu = !this.showMenu;
|
||||
},
|
||||
|
||||
addSelector(type) {
|
||||
this.showMenu = false;
|
||||
const previous = Object.keys(this.selectors || {});
|
||||
this.$emit('add-selector', type);
|
||||
this.$nextTick(() => {
|
||||
const key = Object.keys(this.selectors || {}).find(key => !previous.includes(key));
|
||||
if (!key) return;
|
||||
this.fieldFilter = 'all'; this.fieldQuery = '';
|
||||
this.expandedField = key;
|
||||
this.auxiliaryExpanded = !this.coreSelectorKeys.includes(key);
|
||||
});
|
||||
},
|
||||
|
||||
closeMenu() {
|
||||
this.showMenu = false;
|
||||
},
|
||||
|
||||
openInNewTab(url) {
|
||||
const target = String(url || '').trim();
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
window.open(target, '_blank', 'noopener,noreferrer');
|
||||
},
|
||||
|
||||
openTutorial(anchor = 'selector-basics') {
|
||||
this.openInNewTab('/static/tutorial/index.html#' + encodeURIComponent(anchor));
|
||||
},
|
||||
|
||||
openPracticeLab() {
|
||||
this.openInNewTab('/static/selector-practice.html');
|
||||
},
|
||||
|
||||
isSelectorFilled(key) {
|
||||
return String((this.selectors || {})[key] || '').trim().length > 0;
|
||||
},
|
||||
|
||||
isBuiltInSelectorKey(key) {
|
||||
return [
|
||||
'input_box',
|
||||
'send_btn',
|
||||
'result_container',
|
||||
'new_chat_btn',
|
||||
'message_wrapper',
|
||||
'generating_indicator',
|
||||
'retry_send_btn',
|
||||
'upload_btn',
|
||||
'file_input',
|
||||
'drop_zone',
|
||||
'composer_root'
|
||||
].includes(String(key || '').trim());
|
||||
},
|
||||
|
||||
canRenameSelectorKey(key) {
|
||||
return !this.isBuiltInSelectorKey(key);
|
||||
},
|
||||
|
||||
openRenameEditor(key) {
|
||||
this.openRenameKey = key;
|
||||
this.renameDrafts = {
|
||||
...this.renameDrafts,
|
||||
[key]: key
|
||||
};
|
||||
|
||||
this.$nextTick(() => {
|
||||
const ref = this.$refs['renameInput-' + key];
|
||||
const input = Array.isArray(ref) ? ref[0] : ref;
|
||||
if (input && typeof input.focus === 'function') {
|
||||
input.focus();
|
||||
if (typeof input.select === 'function') {
|
||||
input.select();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
closeRenameEditor() {
|
||||
this.openRenameKey = '';
|
||||
},
|
||||
|
||||
submitRenameKey(key) {
|
||||
const nextKey = String((this.renameDrafts || {})[key] || '').trim();
|
||||
this.openRenameKey = '';
|
||||
if (!nextKey || nextKey === key) {
|
||||
return;
|
||||
}
|
||||
this.$emit('update-selector-key', key, nextKey);
|
||||
this.$nextTick(() => {
|
||||
if (Object.prototype.hasOwnProperty.call(this.selectors || {}, nextKey) && !Object.prototype.hasOwnProperty.call(this.selectors || {}, key)) this.expandedField = nextKey;
|
||||
});
|
||||
},
|
||||
|
||||
getSelectorMeta(key) {
|
||||
const metaMap = {
|
||||
input_box: {
|
||||
title: '输入框',
|
||||
description: '用户真正打字的地方。常见是 textarea、contenteditable 或 role=textbox。',
|
||||
hint: '先右键输入区域点“检查”。看到 textarea,或者看到可编辑的 div,通常就离答案很近了。',
|
||||
required: true,
|
||||
chip: '必填',
|
||||
placeholder: '例如:textarea, div[contenteditable="true"]'
|
||||
},
|
||||
send_btn: {
|
||||
title: '发送按钮',
|
||||
description: '点一下就会把消息发出去的按钮,常见是纸飞机、箭头或“发送”字样。',
|
||||
hint: '优先找 button 上比较稳的属性,比如 type、aria-label、data-testid;只靠一串随机 class 往往不稳。',
|
||||
required: true,
|
||||
chip: '必填',
|
||||
placeholder: '例如:button[type="submit"], button[data-testid="send"]'
|
||||
},
|
||||
result_container: {
|
||||
title: '回复容器',
|
||||
description: '包住 AI 回复正文的区域。尽量选整段回复的外层,不要只选某个 p 或 span。',
|
||||
hint: '看到整条 AI 回复后,先选能完整包住这条内容的外层块。范围太小,后面很容易漏字、漏代码块。',
|
||||
required: true,
|
||||
chip: '必填',
|
||||
placeholder: '例如:main article .markdown-body'
|
||||
},
|
||||
new_chat_btn: {
|
||||
title: '新建对话按钮',
|
||||
description: '每次开始新会话前需要点的按钮,没有也可以先留空。',
|
||||
hint: '如果页面左上角有“新聊天”“新建对话”“清空上下文”之类的入口,这个字段通常就该填它。',
|
||||
required: false,
|
||||
chip: '选填',
|
||||
placeholder: '例如:button[aria-label*="新"], button.new-chat'
|
||||
},
|
||||
message_wrapper: {
|
||||
title: '消息外层容器',
|
||||
description: '一条消息最外层的盒子。长回复、分段节点、复杂样式场景里很有帮助。',
|
||||
hint: '如果一条回复里有很多段落、代码块、图片,给它补上最外层容器,提取结果通常会稳很多。',
|
||||
required: false,
|
||||
chip: '辅助',
|
||||
placeholder: '例如:article[data-role="assistant-message"]'
|
||||
},
|
||||
generating_indicator: {
|
||||
title: '生成中指示器',
|
||||
description: '能表明“模型还在继续输出”的元素,比如停止按钮、转圈、typing 提示。',
|
||||
hint: '有“停止生成”按钮时,这个字段通常很好找。它出现时代表还在生成,消失后通常代表结束。',
|
||||
required: false,
|
||||
chip: '辅助',
|
||||
placeholder: '例如:button[aria-label*="停止"], .typing-indicator'
|
||||
},
|
||||
retry_send_btn: {
|
||||
title: '重试/重新运行按钮',
|
||||
description: '用于重新运行当前回复或把停止后的回复重新拉起,常见是圆形箭头按钮。',
|
||||
hint: 'Battle 或双栏对比模式里,通常需要先点这个按钮,再点右下角发送/停止态按钮完成本轮发送。',
|
||||
required: false,
|
||||
chip: '辅助',
|
||||
placeholder: '例如:button[aria-label="Rerun stopped messages"]'
|
||||
},
|
||||
upload_btn: {
|
||||
title: '上传按钮',
|
||||
description: '点一下会弹出上传面板或系统文件选择窗口的按钮。',
|
||||
hint: '页面里有加号、回形针、图片图标时,先看那个按钮。很多站点把上传入口藏在工具栏里。',
|
||||
required: false,
|
||||
chip: '上传',
|
||||
placeholder: '例如:button[aria-label*="上传"], .toolbar-upload'
|
||||
},
|
||||
file_input: {
|
||||
title: '原生文件输入框',
|
||||
description: '真正的 input[type=file] 元素,适合直接写入文件。',
|
||||
hint: '很多站点会把它藏起来。开发者工具里搜索 type="file" 往往最快。',
|
||||
required: false,
|
||||
chip: '上传',
|
||||
placeholder: '例如:input[type="file"]'
|
||||
},
|
||||
composer_root: {
|
||||
title: '消息编辑区根节点',
|
||||
description: '限定自动查找文件输入框和附件观察的范围,避免匹配页面历史消息。',
|
||||
hint: '通常是包围输入框、附件预览和发送按钮的容器。配置 file_input 时仍优先使用指定入口。',
|
||||
required: false, chip: '上传', placeholder: '例如:.composer, form.chat-input'
|
||||
},
|
||||
drop_zone: {
|
||||
title: '拖拽上传区域',
|
||||
description: '支持把文件拖到页面里的区域,适合不吃粘贴的网站。',
|
||||
hint: '拖一张图到页面上时,哪个区域会高亮、变色、出现提示,那个区域通常就是它。',
|
||||
required: false,
|
||||
chip: '上传',
|
||||
placeholder: '例如:div[data-dropzone="true"]'
|
||||
}
|
||||
};
|
||||
|
||||
const presetMeta = metaMap[key];
|
||||
if (presetMeta) {
|
||||
return presetMeta;
|
||||
}
|
||||
|
||||
return {
|
||||
title: '自定义字段',
|
||||
description: '你自己补的额外选择器,常用于临时按钮、模式切换、弹窗确认之类的操作。',
|
||||
hint: '自定义字段也建议优先用稳定属性。页面每次刷新都会变的随机 class,后面维护起来会很痛苦。',
|
||||
required: false,
|
||||
chip: '自定义',
|
||||
placeholder: '例如:button[data-role="mode-switch"]'
|
||||
};
|
||||
},
|
||||
|
||||
getChipClass(key) {
|
||||
const chip = this.getSelectorMeta(key).chip;
|
||||
if (chip === '必填') {
|
||||
return 'dashboard-field-chip';
|
||||
}
|
||||
if (chip === '自定义') {
|
||||
return 'dashboard-field-chip dashboard-field-chip--custom';
|
||||
}
|
||||
return 'dashboard-field-chip dashboard-field-chip--optional';
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="studio-selector-panel bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg shadow-sm" @click="closeMenu">
|
||||
<!-- 标题栏 -->
|
||||
<div class="px-4 py-3 border-b dark:border-gray-700 flex justify-between items-center cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors"
|
||||
@click="toggle">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-4 inline-flex justify-center text-gray-500 dark:text-gray-400" v-html="collapsed ? $icons.chevronDown : $icons.chevronUp"></span>
|
||||
<h3 class="font-semibold text-gray-900 dark:text-white">字段配置</h3>
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">({{ count }})</span>
|
||||
</div>
|
||||
|
||||
<div class="relative" @click.stop>
|
||||
<button @click="toggleMenu"
|
||||
class="selector-add-btn">
|
||||
<span v-html="$icons.plusCircle"></span> 新增 <span v-html="$icons.chevronDown"></span>
|
||||
</button>
|
||||
|
||||
<div v-if="showMenu"
|
||||
class="absolute right-0 mt-1 w-56 bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg shadow-lg z-10 overflow-hidden">
|
||||
<button @click="addSelector('custom')"
|
||||
class="w-full text-left px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-900 dark:text-white text-sm border-b dark:border-gray-700 transition-colors">
|
||||
自定义字段
|
||||
</button>
|
||||
<div class="px-3 py-1.5 text-xs text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-900/50 font-medium">
|
||||
辅助字段
|
||||
</div>
|
||||
<button @click="addSelector('message_wrapper')"
|
||||
class="w-full text-left px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-700 text-xs transition-colors">
|
||||
<div class="font-semibold text-gray-900 dark:text-white">message_wrapper</div>
|
||||
<div class="text-gray-500 dark:text-gray-400">消息完整容器,适合多节点回复</div>
|
||||
</button>
|
||||
<button @click="addSelector('generating_indicator')"
|
||||
class="w-full text-left px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-700 text-xs transition-colors">
|
||||
<div class="font-semibold text-gray-900 dark:text-white">generating_indicator</div>
|
||||
<div class="text-gray-500 dark:text-gray-400">生成中提示,适合辅助判断结束</div>
|
||||
</button>
|
||||
<button @click="addSelector('retry_send_btn')"
|
||||
class="w-full text-left px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-700 text-xs transition-colors">
|
||||
<div class="font-semibold text-gray-900 dark:text-white">retry_send_btn</div>
|
||||
<div class="text-gray-500 dark:text-gray-400">重新运行或重试当前回复</div>
|
||||
</button>
|
||||
<button @click="addSelector('upload_btn')"
|
||||
class="w-full text-left px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-700 text-xs transition-colors">
|
||||
<div class="font-semibold text-gray-900 dark:text-white">upload_btn</div>
|
||||
<div class="text-gray-500 dark:text-gray-400">打开上传入口的按钮</div>
|
||||
</button>
|
||||
<button @click="addSelector('file_input')"
|
||||
class="w-full text-left px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-700 text-xs transition-colors">
|
||||
<div class="font-semibold text-gray-900 dark:text-white">file_input</div>
|
||||
<div class="text-gray-500 dark:text-gray-400">原生 input[type=file]</div>
|
||||
</button>
|
||||
<button @click="addSelector('composer_root')" class="w-full text-left px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-700 text-xs transition-colors">
|
||||
<div class="font-semibold text-gray-900 dark:text-white">composer_root</div>
|
||||
<div class="text-gray-500 dark:text-gray-400">限定附件操作的消息编辑区根节点</div>
|
||||
</button>
|
||||
<button @click="addSelector('drop_zone')"
|
||||
class="w-full text-left px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-700 text-xs transition-colors">
|
||||
<div class="font-semibold text-gray-900 dark:text-white">drop_zone</div>
|
||||
<div class="text-gray-500 dark:text-gray-400">支持拖拽上传的区域</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容 -->
|
||||
<div v-show="!collapsed" class="p-4 space-y-4 max-h-[44rem] overflow-auto">
|
||||
<div v-if="count === 0" class="dashboard-empty-state text-center text-sm text-slate-500 dark:text-slate-400">
|
||||
<div class="text-3xl mb-3">🧭</div>
|
||||
<p class="leading-6">
|
||||
现在还是空白很正常。先把 <code>input_box</code>、<code>send_btn</code>、<code>result_container</code> 加出来,再开始一项一项测试。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="site-core-path" aria-label="核心字段填写进度">
|
||||
<button type="button" v-for="(item, index) in coreChecklist" :key="item.key" :class="{ 'is-filled': item.ready }" :aria-label="'配置' + item.title" @click="openCoreField(item.key)"><span class="site-path-node" v-html="item.ready ? $icons.check : $icons.minus"></span><span><strong>{{ item.title }}</strong><small>{{ item.ready ? '已填写' : '待配置' }}</small></span><i v-if="index < 2" v-html="$icons.arrowRight"></i></button>
|
||||
</div>
|
||||
<div v-if="missingQuickAdds.length" class="site-missing-fields"><span>缺少核心字段</span><button v-for="item in missingQuickAdds" :key="item.key" type="button" @click="addSelector(item.key)"><span v-html="$icons.plusCircle"></span>添加{{ item.title }}</button></div>
|
||||
<div class="studio-field-toolbar">
|
||||
<div class="studio-field-filters" aria-label="筛选选择器">
|
||||
<button type="button" :class="{ 'is-active': fieldFilter === 'all' }" :aria-pressed="fieldFilter === 'all'" @click="fieldFilter = 'all'">全部字段 <span>{{ count }}</span></button>
|
||||
<button type="button" :class="{ 'is-active': fieldFilter === 'core' }" :aria-pressed="fieldFilter === 'core'" @click="fieldFilter = 'core'">核心字段</button>
|
||||
<button type="button" :class="{ 'is-active': fieldFilter === 'empty' }" :aria-pressed="fieldFilter === 'empty'" @click="fieldFilter = 'empty'">未填写</button>
|
||||
</div>
|
||||
<label class="studio-field-search"><span v-html="$icons.magnifyingGlass"></span><input v-model="fieldQuery" type="search" aria-label="搜索选择器字段" placeholder="搜索字段…" @keyup.escape="fieldQuery = ''"></label>
|
||||
</div>
|
||||
<div v-if="count > 0 && !selectorEntries.length" class="studio-fields-empty"><span v-html="$icons.magnifyingGlass"></span><strong>{{ fieldFilter === 'empty' && !fieldQuery ? '当前字段均已填写' : '没有匹配的字段' }}</strong><p>{{ fieldFilter === 'empty' && !fieldQuery ? '接下来可以逐项测试,确认网页元素能被正确定位。' : '试试其他关键词,或切换到全部字段。' }}</p><button type="button" @click="fieldQuery = ''; fieldFilter = 'all'">查看全部字段</button></div>
|
||||
<section v-for="group in selectorGroups" :key="group.id" v-show="group.entries.length" :class="['site-field-group', 'is-' + group.id]">
|
||||
<div class="site-field-group-heading"><div><h4>{{ group.title }} <span>{{ group.entries.length }}</span></h4><p>{{ group.note }}</p></div><button v-if="group.id === 'auxiliary'" type="button" :aria-expanded="auxiliaryExpanded || !!fieldQuery || fieldFilter !== 'all'" @click="auxiliaryExpanded = !auxiliaryExpanded; fieldQuery = ''; fieldFilter = 'all'">{{ auxiliaryExpanded || fieldQuery || fieldFilter !== 'all' ? '收起' : '展开' }}<span v-html="auxiliaryExpanded ? $icons.chevronUp : $icons.chevronDown"></span></button></div>
|
||||
<div v-show="group.id === 'core' || auxiliaryExpanded || fieldQuery || fieldFilter !== 'all'" class="site-field-group-list">
|
||||
<article v-for="([key, val], index) in group.entries" :key="key" :class="['studio-selector-card', { 'is-expanded': expandedField === key }]">
|
||||
<button type="button" class="site-field-toggle" :aria-label="'编辑字段 ' + key" :aria-expanded="expandedField === key" @click="expandedField = expandedField === key ? '' : key">
|
||||
<span class="site-field-index">{{ String(index + 1).padStart(2, '0') }}</span><span class="site-field-heading"><span><strong>{{ getSelectorMeta(key).title }}</strong><code>{{ key }}</code></span><small v-if="expandedField !== key">{{ val || '尚未填写定位表达式' }}</small></span><span :class="['site-field-state', { 'is-filled': isSelectorFilled(key) }]">{{ isSelectorFilled(key) ? '已填写' : '待填写' }}</span><span class="site-field-chevron" v-html="expandedField === key ? $icons.chevronUp : $icons.chevronDown"></span>
|
||||
</button>
|
||||
<div v-show="expandedField === key" class="site-field-expanded">
|
||||
<div v-if="openRenameKey === key"
|
||||
class="mb-2 flex flex-col md:flex-row gap-2 rounded-xl border border-blue-200/80 dark:border-blue-800/70 bg-blue-50/70 dark:bg-blue-900/20 p-2.5">
|
||||
<input :ref="'renameInput-' + key"
|
||||
v-model="renameDrafts[key]"
|
||||
@keyup.enter="submitRenameKey(key)"
|
||||
@keyup.esc="closeRenameEditor()"
|
||||
class="flex-1 border dark:border-gray-600 px-2.5 py-2 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent font-semibold text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white"
|
||||
placeholder="新的字段键名">
|
||||
<div class="flex items-center gap-2">
|
||||
<button @click="submitRenameKey(key)"
|
||||
type="button"
|
||||
class="px-3 py-1.5 rounded-md text-xs font-medium text-blue-600 dark:text-blue-300 border border-blue-300 dark:border-blue-700 hover:bg-blue-100/80 dark:hover:bg-blue-900/40 transition-colors">
|
||||
保存
|
||||
</button>
|
||||
<button @click="closeRenameEditor()"
|
||||
type="button"
|
||||
class="px-3 py-1.5 rounded-md text-xs font-medium text-slate-500 dark:text-slate-300 border border-slate-200 dark:border-slate-700 hover:bg-white/80 dark:hover:bg-slate-800/70 transition-colors">
|
||||
取消
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="site-field-edit-row"><div class="site-field-expression"><label :for="'selector-expression-' + key">定位表达式</label><textarea :id="'selector-expression-' + key" rows="3" :value="selectors[key]" :aria-label="getSelectorMeta(key).title + '选择器'" @focus="editingSelectorKey = key" @blur="editingSelectorKey = ''" @input="$emit('update-selector-value', key, $event.target.value)" :placeholder="getSelectorMeta(key).placeholder || '输入选择器'"></textarea></div><aside class="site-field-context"><span>如何定位</span><p>{{ getSelectorMeta(key).description }}</p><small>{{ getSelectorMeta(key).hint }}</small></aside></div>
|
||||
<div class="studio-field-actions"><span>填写后,请在目标网页上验证。</span><button v-if="canRenameSelectorKey(key)" type="button" @click="openRenameEditor(key)" class="site-rename-field"><span v-html="$icons.pencil"></span>改名</button><button type="button" class="site-delete-field" :aria-label="'删除选择器 ' + key" @click="$emit('remove-selector', key)"><span v-html="$icons.trash"></span></button><button type="button" class="site-test-field" @click="$emit('test-selector', key, val)"><span v-html="$icons.play"></span>测试选择器</button></div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
<div v-if="!guideExpanded" class="studio-guide-entry">
|
||||
<button @click="guideExpanded = true" type="button" class="dashboard-guide-toggle">
|
||||
<span v-html="$icons.bookOpen"></span><span>不知道怎么填写?查看选择器指南</span>
|
||||
<span v-html="$icons.chevronDown"></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-else class="dashboard-guide-card dashboard-guide-card--blue">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<span class="dashboard-guide-badge">零基础也能开始</span>
|
||||
<button @click="guideExpanded = false" type="button" class="dashboard-guide-toggle">
|
||||
<span>收起</span>
|
||||
<span v-html="$icons.chevronUp"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<div class="text-base font-semibold text-slate-900 dark:text-slate-50">
|
||||
先把 3 个核心字段补齐,页面就能有基础可用性
|
||||
</div>
|
||||
<p class="mt-1.5 text-sm leading-6 text-slate-600 dark:text-slate-300">
|
||||
先找输入框、发送按钮、AI 回复容器。上传按钮、消息外层、生成中提示这些字段可以后面再慢慢补。第一轮目标很简单:先让页面能发、能收、能测。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-guide-steps">
|
||||
<div class="dashboard-guide-step">
|
||||
<strong>第 1 步</strong>
|
||||
<span>打开教程章节,先看字段各自负责什么。</span>
|
||||
</div>
|
||||
<div class="dashboard-guide-step">
|
||||
<strong>第 2 步</strong>
|
||||
<span>打开本地选择器工作台,先在模拟页面里练一遍,再直接看候选写法和命中详情。</span>
|
||||
</div>
|
||||
<div class="dashboard-guide-step">
|
||||
<strong>第 3 步</strong>
|
||||
<span>回到真实站点,填一个测一个。测试工作台会直接告诉你命中了几个、为什么不稳、有没有更好的候选。</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-checklist">
|
||||
<div v-for="item in coreChecklist"
|
||||
:key="item.key"
|
||||
:class="['dashboard-checklist-item', item.ready ? 'is-ready' : 'is-missing']">
|
||||
<span>{{ item.ready ? '✓' : '•' }}</span>
|
||||
<span>{{ item.key }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-3 text-xs text-slate-500 dark:text-slate-400">
|
||||
当前核心字段进度:{{ coreReadyCount }}/3
|
||||
</p>
|
||||
|
||||
<div v-if="missingQuickAdds.length" class="mt-3 flex flex-wrap gap-2">
|
||||
<button v-for="item in missingQuickAdds"
|
||||
:key="item.key"
|
||||
@click="addSelector(item.key)"
|
||||
class="px-3 py-1.5 rounded-full text-xs font-medium border border-slate-300 dark:border-slate-600 text-slate-700 dark:text-slate-200 hover:bg-white/80 dark:hover:bg-slate-800/80 transition">
|
||||
新增 {{ item.key }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-guide-actions">
|
||||
<button @click="openTutorial('selector-basics')" class="dashboard-guide-btn">
|
||||
<span v-html="$icons.arrowTopRightOnSquare"></span>
|
||||
打开选择器教程
|
||||
</button>
|
||||
<button @click="openPracticeLab()" class="dashboard-guide-btn dashboard-guide-btn--secondary">
|
||||
<span v-html="$icons.folderOpen"></span>
|
||||
打开选择器工作台
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
@@ -0,0 +1,772 @@
|
||||
// ==================== 流式配置面板 ====================
|
||||
|
||||
window.StreamConfigPanel = {
|
||||
name: 'StreamConfigPanel',
|
||||
props: {
|
||||
streamConfig: { type: Object, required: true },
|
||||
currentDomain: { type: String, default: null },
|
||||
collapsed: { type: Boolean, default: true }
|
||||
},
|
||||
emits: ['update:collapsed', 'save-stream-config'],
|
||||
data() {
|
||||
return {
|
||||
availableParsers: [],
|
||||
loadingParsers: false,
|
||||
loadingTransportProfiles: false,
|
||||
guideExpanded: false,
|
||||
networkStepsExpanded: false,
|
||||
requestTransportMeta: {
|
||||
defaults: {
|
||||
mode: 'workflow',
|
||||
profile: '',
|
||||
options: {}
|
||||
},
|
||||
mode_options: ['workflow', 'page_fetch'],
|
||||
profiles: []
|
||||
},
|
||||
streamMatchModeOptions: [
|
||||
{
|
||||
value: 'keyword',
|
||||
label: '关键词',
|
||||
description: '直接判断 URL 是否包含指定文本,适合大多数站点。'
|
||||
},
|
||||
{
|
||||
value: 'regex',
|
||||
label: '正则',
|
||||
description: '用正则精确筛选目标 URL,适合需要排除 prepare 之类噪音请求的站点。'
|
||||
}
|
||||
],
|
||||
defaultNetworkConfig: {
|
||||
listen_pattern: '',
|
||||
stream_match_mode: 'keyword',
|
||||
stream_match_pattern: '',
|
||||
parser: '',
|
||||
silence_threshold: 3.0,
|
||||
response_interval: 0.5
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isNetworkMode() {
|
||||
return this.streamConfig.mode === 'network';
|
||||
},
|
||||
|
||||
requestTransportConfig() {
|
||||
const defaults = (this.requestTransportMeta && this.requestTransportMeta.defaults) || {
|
||||
mode: 'workflow',
|
||||
profile: '',
|
||||
options: {}
|
||||
};
|
||||
const current = (this.streamConfig && this.streamConfig.request_transport) || {};
|
||||
return {
|
||||
...defaults,
|
||||
...current,
|
||||
options: {
|
||||
...((defaults && defaults.options) || {}),
|
||||
...((current && current.options) || {})
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
requestTransportModeOptions() {
|
||||
const options = (this.requestTransportMeta && this.requestTransportMeta.mode_options) || ['workflow', 'page_fetch'];
|
||||
return options.map(value => ({
|
||||
value,
|
||||
label: value === 'page_fetch' ? '页面直发' : '工作流模拟'
|
||||
}));
|
||||
},
|
||||
|
||||
availableRequestTransportProfiles() {
|
||||
const profiles = (this.requestTransportMeta && this.requestTransportMeta.profiles) || [];
|
||||
const parserId = String(this.networkConfig.parser || '').trim().toLowerCase();
|
||||
const domain = String(this.currentDomain || '').trim().toLowerCase();
|
||||
return profiles.filter(profile => {
|
||||
const supportedParsers = Array.isArray(profile.supported_parsers) ? profile.supported_parsers : [];
|
||||
const supportedDomains = Array.isArray(profile.supported_domains) ? profile.supported_domains : [];
|
||||
const parserOkay = supportedParsers.length === 0 || supportedParsers.includes(parserId);
|
||||
const domainOkay = supportedDomains.length === 0 || supportedDomains.includes(domain);
|
||||
return parserOkay && domainOkay;
|
||||
});
|
||||
},
|
||||
|
||||
selectedRequestTransportProfileMeta() {
|
||||
const currentProfile = String(this.requestTransportConfig.profile || '').trim();
|
||||
return this.availableRequestTransportProfiles.find(profile => profile.id === currentProfile) || null;
|
||||
},
|
||||
|
||||
networkConfig() {
|
||||
return {
|
||||
...this.defaultNetworkConfig,
|
||||
...(this.streamConfig.network || {})
|
||||
};
|
||||
},
|
||||
|
||||
sendConfirmationConfig() {
|
||||
const defaults = {
|
||||
max_retry_count: 2,
|
||||
retry_interval: 0.6,
|
||||
retry_cooldown_window: 1.5,
|
||||
post_click_observe_window: 1.8,
|
||||
pre_retry_probe_window: 0.12,
|
||||
retry_observe_window: 0.9,
|
||||
retry_action: 'click_send_btn',
|
||||
retry_key_combo: 'Enter',
|
||||
retry_on_unconfirmed_send: true,
|
||||
retry_block_on_stop_button: true,
|
||||
retry_block_if_generating: true,
|
||||
trust_network_activity: true,
|
||||
trust_generating_indicator: true,
|
||||
trust_send_disabled_with_input_shrink: true,
|
||||
pre_send_interrupt_existing_generation: true
|
||||
};
|
||||
return {
|
||||
...defaults,
|
||||
...((this.streamConfig && this.streamConfig.send_confirmation) || {})
|
||||
};
|
||||
},
|
||||
|
||||
sendConfirmationSummary() {
|
||||
if (!this.sendConfirmationConfig.retry_on_unconfirmed_send || Number(this.sendConfirmationConfig.max_retry_count) <= 0) {
|
||||
return '不自动补点';
|
||||
}
|
||||
return '最多重试 ' + Number(this.sendConfirmationConfig.max_retry_count || 0) + ' 次';
|
||||
},
|
||||
|
||||
selectedParserMeta() {
|
||||
return this.findParserMeta(this.networkConfig.parser);
|
||||
},
|
||||
|
||||
preferredPattern() {
|
||||
const parserId = String(this.networkConfig.parser || '').trim();
|
||||
if (!parserId) {
|
||||
return '';
|
||||
}
|
||||
return this.getPreferredListenPattern(parserId);
|
||||
},
|
||||
|
||||
selectedStreamMatchModeMeta() {
|
||||
return this.streamMatchModeOptions.find(
|
||||
option => option.value === this.networkConfig.stream_match_mode
|
||||
) || this.streamMatchModeOptions[0];
|
||||
},
|
||||
|
||||
networkChecklist() {
|
||||
return [
|
||||
{
|
||||
label: 'listen_pattern',
|
||||
ready: String(this.networkConfig.listen_pattern || '').trim().length > 0
|
||||
},
|
||||
{
|
||||
label: 'parser',
|
||||
ready: String(this.networkConfig.parser || '').trim().length > 0
|
||||
},
|
||||
{
|
||||
label: '超时参数',
|
||||
ready: Number(this.streamConfig.hard_timeout) > 0 && Number(this.networkConfig.silence_threshold) > 0
|
||||
}
|
||||
];
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 修复:组件被 v-show 复用时不会重新 mounted,切到 network 模式的站点后
|
||||
// availableParsers 仍为空,导致已配置的解析器在下拉里匹配不到 option
|
||||
isNetworkMode: {
|
||||
immediate: true,
|
||||
handler(value) {
|
||||
if (value && !(this.availableParsers || []).length && !this.loadingParsers) {
|
||||
this.loadParsers();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.loadTransportProfiles();
|
||||
if (this.isNetworkMode) {
|
||||
this.loadParsers();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
buildAuthHeaders(extraHeaders = {}) {
|
||||
const token = String(window.getDashboardAuthToken ? window.getDashboardAuthToken() : '').trim();
|
||||
const headers = { ...extraHeaders };
|
||||
if (token) {
|
||||
headers['Authorization'] = 'Bearer ' + token;
|
||||
}
|
||||
return headers;
|
||||
},
|
||||
|
||||
toggle() {
|
||||
this.$emit('update:collapsed', !this.collapsed);
|
||||
},
|
||||
|
||||
updateField(field, value) {
|
||||
const newConfig = { ...this.streamConfig, [field]: value };
|
||||
this.$emit('save-stream-config', newConfig);
|
||||
},
|
||||
|
||||
updateRequestTransportField(field, value) {
|
||||
const request_transport = {
|
||||
...this.requestTransportConfig,
|
||||
[field]: value
|
||||
};
|
||||
if (field === 'mode' && value !== 'page_fetch') {
|
||||
request_transport.profile = '';
|
||||
request_transport.options = {};
|
||||
}
|
||||
if (field === 'profile') {
|
||||
const profile = this.availableRequestTransportProfiles.find(item => item.id === value);
|
||||
const nextOptions = {};
|
||||
(profile && Array.isArray(profile.options) ? profile.options : []).forEach(option => {
|
||||
nextOptions[option.key] = option.default;
|
||||
});
|
||||
request_transport.options = nextOptions;
|
||||
}
|
||||
const newConfig = { ...this.streamConfig, request_transport };
|
||||
this.$emit('save-stream-config', newConfig);
|
||||
},
|
||||
|
||||
updateRequestTransportOption(key, value) {
|
||||
const request_transport = {
|
||||
...this.requestTransportConfig,
|
||||
options: {
|
||||
...(this.requestTransportConfig.options || {}),
|
||||
[key]: value
|
||||
}
|
||||
};
|
||||
const newConfig = { ...this.streamConfig, request_transport };
|
||||
this.$emit('save-stream-config', newConfig);
|
||||
},
|
||||
|
||||
updateNetworkField(field, value) {
|
||||
const network = { ...this.networkConfig, [field]: value };
|
||||
const newConfig = { ...this.streamConfig, network };
|
||||
this.$emit('save-stream-config', newConfig);
|
||||
},
|
||||
|
||||
updateSendConfirmationField(field, value) {
|
||||
const send_confirmation = {
|
||||
...this.sendConfirmationConfig,
|
||||
[field]: value
|
||||
};
|
||||
const newConfig = { ...this.streamConfig, send_confirmation };
|
||||
this.$emit('save-stream-config', newConfig);
|
||||
},
|
||||
|
||||
openInNewTab(url) {
|
||||
const target = String(url || '').trim();
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
window.open(target, '_blank', 'noopener,noreferrer');
|
||||
},
|
||||
|
||||
openTutorial(anchor = 'non-stream-listener-basics') {
|
||||
this.openInNewTab('/static/tutorial/index.html#' + encodeURIComponent(anchor));
|
||||
},
|
||||
|
||||
findParserMeta(parserId) {
|
||||
return this.availableParsers.find(parser => parser.id === parserId) || null;
|
||||
},
|
||||
|
||||
getPreferredListenPattern(parserId) {
|
||||
const parser = this.findParserMeta(parserId);
|
||||
if (!parser || !Array.isArray(parser.patterns) || parser.patterns.length === 0) {
|
||||
return '';
|
||||
}
|
||||
return String(parser.patterns[0] || '').replace(/^\*\*\//, '');
|
||||
},
|
||||
|
||||
usePreferredPattern() {
|
||||
if (!this.preferredPattern) {
|
||||
return;
|
||||
}
|
||||
this.updateNetworkField('listen_pattern', this.preferredPattern);
|
||||
},
|
||||
|
||||
handleParserChange(parserId) {
|
||||
const currentPattern = (this.networkConfig.listen_pattern || '').trim();
|
||||
const nextPattern = currentPattern || this.getPreferredListenPattern(parserId);
|
||||
const network = {
|
||||
...this.networkConfig,
|
||||
parser: parserId,
|
||||
listen_pattern: nextPattern
|
||||
};
|
||||
const newConfig = { ...this.streamConfig, network };
|
||||
this.$emit('save-stream-config', newConfig);
|
||||
},
|
||||
|
||||
autofillListenPatternFromCurrentParser() {
|
||||
const parserId = (this.networkConfig.parser || '').trim();
|
||||
const currentPattern = (this.networkConfig.listen_pattern || '').trim();
|
||||
if (!parserId || currentPattern) {
|
||||
return;
|
||||
}
|
||||
|
||||
const suggestedPattern = this.getPreferredListenPattern(parserId);
|
||||
if (!suggestedPattern) {
|
||||
return;
|
||||
}
|
||||
|
||||
const network = {
|
||||
...this.networkConfig,
|
||||
listen_pattern: suggestedPattern
|
||||
};
|
||||
const newConfig = { ...this.streamConfig, network };
|
||||
this.$emit('save-stream-config', newConfig);
|
||||
},
|
||||
|
||||
toggleNetworkMode() {
|
||||
if (this.isNetworkMode) {
|
||||
this.updateField('mode', 'dom');
|
||||
} else {
|
||||
const newConfig = {
|
||||
...this.streamConfig,
|
||||
mode: 'network',
|
||||
network: this.streamConfig.network || { ...this.defaultNetworkConfig }
|
||||
};
|
||||
this.$emit('save-stream-config', newConfig);
|
||||
if (this.availableParsers.length === 0) {
|
||||
this.loadParsers();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async loadParsers() {
|
||||
if (this.loadingParsers) return;
|
||||
this.loadingParsers = true;
|
||||
try {
|
||||
const response = await fetch('/api/parsers', {
|
||||
headers: this.buildAuthHeaders()
|
||||
});
|
||||
if (!response.ok) {
|
||||
const err = await response.json().catch(() => ({}));
|
||||
throw new Error(err.detail || ('HTTP ' + response.status));
|
||||
}
|
||||
const data = await response.json();
|
||||
this.availableParsers = data.parsers || [];
|
||||
this.autofillListenPatternFromCurrentParser();
|
||||
} catch (e) {
|
||||
console.error('加载解析器失败:', e);
|
||||
} finally {
|
||||
this.loadingParsers = false;
|
||||
}
|
||||
},
|
||||
|
||||
async loadTransportProfiles() {
|
||||
if (this.loadingTransportProfiles) return;
|
||||
this.loadingTransportProfiles = true;
|
||||
try {
|
||||
const response = await fetch('/api/settings/stream-config-defaults', {
|
||||
headers: this.buildAuthHeaders()
|
||||
});
|
||||
if (!response.ok) {
|
||||
const err = await response.json().catch(() => ({}));
|
||||
throw new Error(err.detail || ('HTTP ' + response.status));
|
||||
}
|
||||
const data = await response.json();
|
||||
const requestTransport = data.request_transport || {};
|
||||
this.requestTransportMeta = {
|
||||
defaults: requestTransport.defaults || {
|
||||
mode: 'workflow',
|
||||
profile: '',
|
||||
options: {}
|
||||
},
|
||||
mode_options: requestTransport.mode_options || ['workflow', 'page_fetch'],
|
||||
profiles: requestTransport.profiles || []
|
||||
};
|
||||
} catch (e) {
|
||||
console.error('加载发送方式配置失败:', e);
|
||||
} finally {
|
||||
this.loadingTransportProfiles = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="cap-panel cap-response-panel bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg shadow-sm">
|
||||
<!-- 标题栏 -->
|
||||
<div class="px-4 py-3 border-b dark:border-gray-700 flex justify-between items-center cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors"
|
||||
@click="toggle">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-4 inline-flex justify-center text-gray-500 dark:text-gray-400" v-html="collapsed ? $icons.chevronDown : $icons.chevronUp"></span>
|
||||
<h3 class="font-semibold text-gray-900 dark:text-white">从哪里读取回复</h3>
|
||||
<span v-if="isNetworkMode" class="text-xs font-medium px-2 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-400">已启用</span>
|
||||
<span v-else class="text-xs font-medium px-2 py-0.5 rounded bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400">DOM 流式</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容 -->
|
||||
<div v-show="!collapsed" class="p-4 space-y-4"><div class="cap-response-explainer"><span class="cap-icon" v-html="$icons.documentArrowDown"></span><div><h4>{{ isNetworkMode ? '正在读取网络响应' : '正在读取网页上显示的回复' }}</h4><p>{{ isNetworkMode ? '适合保留代码、公式等原始内容,需要正确的请求匹配和解析器。' : '观察页面文字的变化来返回回复。首次适配站点时,可以先沿用这种方式。' }}</p><small>开启开关后读取网络响应,关闭则读取页面内容;切换可能影响现有回复解析。</small></div><label class="cap-switch"><span class="cap-state">{{ isNetworkMode ? '网络读取' : '网页读取' }}</span><input role="switch" type="checkbox" aria-label="从网络读取回复" :checked="isNetworkMode" @change="toggleNetworkMode" class="cap-switch-input"><i aria-hidden="true"></i></label></div>
|
||||
<div v-if="!guideExpanded">
|
||||
<button @click="guideExpanded = true" type="button" class="dashboard-guide-toggle dashboard-guide-toggle--violet">
|
||||
<span>网络模式引导</span>
|
||||
<span v-html="$icons.chevronDown"></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-else class="dashboard-guide-card dashboard-guide-card--violet">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<span class="dashboard-guide-badge">先判断场景,再动开关</span>
|
||||
<button @click="guideExpanded = false" type="button" class="dashboard-guide-toggle dashboard-guide-toggle--violet">
|
||||
<span>收起</span>
|
||||
<span v-html="$icons.chevronUp"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<div class="text-base font-semibold text-slate-900 dark:text-slate-50">
|
||||
DOM 模式与网络监听模式
|
||||
</div>
|
||||
<p class="mt-1.5 text-sm leading-6 text-slate-600 dark:text-slate-300">
|
||||
网络监听会优先读取底层请求响应;如果站点走的是 <strong>fetch/xhr 流式</strong>,现在可以直接增量输出;如果站点本身返回的是整包 JSON / 文本,那它看起来仍会像一次性完成。DOM 模式则是盯着页面展示内容变化来输出。遇到复杂 JSON、代码块或 LaTeX 数学公式时,网络监听通常更容易拿到干净原文。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-checklist">
|
||||
<div v-for="item in networkChecklist"
|
||||
:key="item.label"
|
||||
:class="['dashboard-checklist-item', item.ready ? 'is-ready' : 'is-missing']">
|
||||
<span>{{ item.ready ? '✓' : '•' }}</span>
|
||||
<span>{{ item.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-guide-actions">
|
||||
<button @click="openTutorial('non-stream-listener-basics')" class="dashboard-guide-btn">
|
||||
<span v-html="$icons.arrowTopRightOnSquare"></span>
|
||||
DOM 和网络监听区别
|
||||
</button>
|
||||
<button @click="openTutorial('non-stream-parser-guide')" class="dashboard-guide-btn dashboard-guide-btn--secondary">
|
||||
<span v-html="$icons.folderOpen"></span>
|
||||
网络解析器教程
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 网络模式配置 -->
|
||||
<details v-if="isNetworkMode" class="cap-settings"><summary><span><strong>配置网络响应识别</strong><small>先指定请求关键词,再选择解析器。</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body">
|
||||
<details class="cap-technical"><summary><span><strong>请求发送方式(高级)</strong><small>网页工作流或页面接口直发;仅在明确需要更换发送方式时设置。</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><div class="rounded-lg border border-slate-200/70 bg-slate-50/80 p-4 dark:border-slate-700 dark:bg-slate-900/40 space-y-4">
|
||||
<div class="text-sm font-medium text-gray-700 dark:text-gray-300 flex items-center gap-2">
|
||||
<span>🚀</span>
|
||||
<span>发送方式</span>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">发送模式</label>
|
||||
<select :value="requestTransportConfig.mode"
|
||||
@change="updateRequestTransportField('mode', $event.target.value)"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-purple-400 focus:border-transparent">
|
||||
<option v-for="option in requestTransportModeOptions" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="requestTransportConfig.mode === 'page_fetch'">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">发送 Profile</label>
|
||||
<select :value="requestTransportConfig.profile"
|
||||
@change="updateRequestTransportField('profile', $event.target.value)"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-purple-400 focus:border-transparent">
|
||||
<option value="" disabled>{{ loadingTransportProfiles ? '加载中...' : '选择发送 profile...' }}</option>
|
||||
<option v-for="profile in availableRequestTransportProfiles" :key="profile.id" :value="profile.id">{{ profile.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedRequestTransportProfileMeta" class="space-y-4">
|
||||
<p class="text-xs leading-5 text-slate-500 dark:text-slate-400">
|
||||
{{ selectedRequestTransportProfileMeta.description }}
|
||||
</p>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<template v-for="option in selectedRequestTransportProfileMeta.options" :key="option.key">
|
||||
<div v-if="option.type === 'enum'">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">{{ option.label }}</label>
|
||||
<select :value="requestTransportConfig.options[option.key]"
|
||||
@change="updateRequestTransportOption(option.key, $event.target.value)"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-purple-400 focus:border-transparent">
|
||||
<option v-for="choice in option.choices" :key="choice.value" :value="choice.value">{{ choice.label }}</option>
|
||||
</select>
|
||||
<p v-if="option.description" class="mt-1 text-xs text-gray-500 dark:text-gray-400">{{ option.description }}</p>
|
||||
</div>
|
||||
<div v-else-if="option.type === 'string'">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">{{ option.label }}</label>
|
||||
<input type="text"
|
||||
:value="requestTransportConfig.options[option.key]"
|
||||
@input="updateRequestTransportOption(option.key, $event.target.value)"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-purple-400 focus:border-transparent">
|
||||
<p v-if="option.description" class="mt-1 text-xs text-gray-500 dark:text-gray-400">{{ option.description }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div></div></details>
|
||||
|
||||
<div>
|
||||
<button v-if="!networkStepsExpanded"
|
||||
@click="networkStepsExpanded = true"
|
||||
type="button"
|
||||
class="dashboard-guide-toggle dashboard-guide-toggle--violet">
|
||||
<span>配置步骤</span>
|
||||
<span v-html="$icons.chevronDown"></span>
|
||||
</button>
|
||||
<div v-else class="space-y-3">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="text-xs font-medium uppercase tracking-[0.18em] text-slate-400 dark:text-slate-500">
|
||||
三步看完再填
|
||||
</div>
|
||||
<button @click="networkStepsExpanded = false"
|
||||
type="button"
|
||||
class="dashboard-guide-toggle dashboard-guide-toggle--violet">
|
||||
<span>收起</span>
|
||||
<span v-html="$icons.chevronUp"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-3">
|
||||
<div class="dashboard-mini-card">
|
||||
<div class="dashboard-mini-card-title">第 1 步:锁定请求关键词</div>
|
||||
<div class="dashboard-mini-card-copy">先找目标请求 URL 里最稳定的一小段路径,填进 <code>listen_pattern</code>。</div>
|
||||
</div>
|
||||
<div class="dashboard-mini-card">
|
||||
<div class="dashboard-mini-card-title">第 2 步:选对解析器</div>
|
||||
<div class="dashboard-mini-card-copy">有内置解析器就直接选;没有时先按教程导出请求,让 AI 帮你写 parser。</div>
|
||||
</div>
|
||||
<div class="dashboard-mini-card">
|
||||
<div class="dashboard-mini-card-title">第 3 步:补超时</div>
|
||||
<div class="dashboard-mini-card-copy">慢站点先把全局硬超时和静默超时调高;流式站点主要看静默超时,整包返回站点则更依赖整体等待窗口。</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-sm font-medium text-gray-700 dark:text-gray-300 flex items-center gap-2">
|
||||
<svg class="w-4 h-4 text-purple-500" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M8.288 15.038a5.25 5.25 0 017.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0M12.53 18.22l-.53.53-.53-.53a.75.75 0 011.06 0z"/>
|
||||
</svg>
|
||||
网络拦截配置
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<div class="flex items-center justify-between gap-3 mb-1">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">URL 匹配模式 <span class="text-red-500">*</span></label>
|
||||
<button v-if="preferredPattern"
|
||||
@click="usePreferredPattern"
|
||||
type="button"
|
||||
class="text-xs font-medium text-purple-600 dark:text-purple-300 hover:underline">
|
||||
一键填入推荐值
|
||||
</button>
|
||||
</div>
|
||||
<input type="text"
|
||||
:value="networkConfig.listen_pattern"
|
||||
@input="updateNetworkField('listen_pattern', $event.target.value)"
|
||||
placeholder="例如:GenerateContent"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-purple-400 focus:border-transparent">
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
只要 URL 里包含这段字符串,监听器就会尝试拦截。先写窄一点,调通后再看要不要放宽。
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">响应解析器 <span class="text-red-500">*</span></label>
|
||||
<select :value="networkConfig.parser"
|
||||
@change="handleParserChange($event.target.value)"
|
||||
@focus="loadParsers"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-purple-400 focus:border-transparent">
|
||||
<option value="" disabled>{{ loadingParsers ? '加载解析器中...' : '选择解析器...' }}</option>
|
||||
<option v-for="parser in availableParsers" :key="parser.id" :value="parser.id">{{ parser.name }}</option>
|
||||
</select>
|
||||
<p v-if="selectedParserMeta && Array.isArray(selectedParserMeta.patterns) && selectedParserMeta.patterns.length"
|
||||
class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
这个解析器常见监听关键词:<code>{{ preferredPattern }}</code>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<details class="cap-technical"><summary><span><strong>响应不完整、等待太久或重复发送?</strong><small>流匹配、超时与重试的排查参数。</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body"><div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">流目标匹配模式</label>
|
||||
<select :value="networkConfig.stream_match_mode"
|
||||
@change="updateNetworkField('stream_match_mode', $event.target.value)"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-purple-400 focus:border-transparent">
|
||||
<option v-for="option in streamMatchModeOptions" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||||
</select>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ selectedStreamMatchModeMeta.description }}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">流目标匹配表达式</label>
|
||||
<input type="text"
|
||||
:value="networkConfig.stream_match_pattern"
|
||||
@input="updateNetworkField('stream_match_pattern', $event.target.value)"
|
||||
placeholder="留空时默认沿用 listen_pattern"
|
||||
class="w-full border dark:border-gray-600 px-3 py-2 rounded-md text-sm font-mono bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-purple-400 focus:border-transparent">
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
<code>keyword</code> 模式下填 URL 子串,<code>regex</code> 模式下填正则;留空时回退到 <code>listen_pattern</code>。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">静默超时</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number" :value="networkConfig.silence_threshold" @input="updateNetworkField('silence_threshold', parseFloat($event.target.value) || 3)"
|
||||
min="0.5" max="30" step="0.5" class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-purple-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">秒</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">轮询间隔</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number" :value="networkConfig.response_interval" @input="updateNetworkField('response_interval', parseFloat($event.target.value) || 0.5)"
|
||||
min="0.1" max="5" step="0.1" class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-purple-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">秒</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-xl border border-amber-200/80 dark:border-amber-800/70 bg-amber-50/70 dark:bg-amber-900/20 p-4">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-800 dark:text-gray-100">发送确认与重试</div>
|
||||
<p class="mt-1 text-xs leading-5 text-gray-600 dark:text-gray-300">
|
||||
控制点击 <code>send_btn</code> 后,如果没有马上观察到输入框清空、网络活动或生成态,是否自动再点一次。Battle 模式里通常应关闭自动重试,避免第二次点击方形按钮变成中断输出。
|
||||
</p>
|
||||
</div>
|
||||
<span class="px-2 py-0.5 text-xs rounded-full bg-white/80 dark:bg-gray-800/80 text-amber-700 dark:text-amber-300 border border-amber-200 dark:border-amber-700">
|
||||
{{ sendConfirmationSummary }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">首次点击观察窗</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="sendConfirmationConfig.post_click_observe_window"
|
||||
@input="updateSendConfirmationField('post_click_observe_window', parseFloat($event.target.value) || 0)"
|
||||
min="0"
|
||||
max="15"
|
||||
step="0.1"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-amber-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">秒</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">最大重试次数</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="sendConfirmationConfig.max_retry_count"
|
||||
@input="updateSendConfirmationField('max_retry_count', parseInt($event.target.value) || 0)"
|
||||
min="0"
|
||||
max="10"
|
||||
step="1"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-amber-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">次</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">重试间隔</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number"
|
||||
:value="sendConfirmationConfig.retry_interval"
|
||||
@input="updateSendConfirmationField('retry_interval', parseFloat($event.target.value) || 0)"
|
||||
min="0"
|
||||
max="30"
|
||||
step="0.1"
|
||||
class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-amber-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">秒</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="sendConfirmationConfig.retry_on_unconfirmed_send"
|
||||
@change="updateSendConfirmationField('retry_on_unconfirmed_send', $event.target.checked)">
|
||||
<span>发送未确认时允许自动重试</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="sendConfirmationConfig.retry_block_on_stop_button"
|
||||
@change="updateSendConfirmationField('retry_block_on_stop_button', $event.target.checked)">
|
||||
<span>发送按钮变成 stop 时禁止重试</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="sendConfirmationConfig.retry_block_if_generating"
|
||||
@change="updateSendConfirmationField('retry_block_if_generating', $event.target.checked)">
|
||||
<span>页面进入生成态时禁止重试</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="sendConfirmationConfig.trust_generating_indicator"
|
||||
@change="updateSendConfirmationField('trust_generating_indicator', $event.target.checked)">
|
||||
<span>生成态可作为发送成功信号</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-3 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
|
||||
<input type="checkbox"
|
||||
class="rounded"
|
||||
:checked="sendConfirmationConfig.pre_send_interrupt_existing_generation"
|
||||
@change="updateSendConfirmationField('pre_send_interrupt_existing_generation', $event.target.checked)">
|
||||
<span>发送前主动打断旧生成态 (Arena)</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!networkConfig.listen_pattern || !networkConfig.parser"
|
||||
class="bg-yellow-50 dark:bg-yellow-900/30 border border-yellow-200 dark:border-yellow-800 rounded-xl p-3">
|
||||
<div class="flex items-start gap-2">
|
||||
<svg class="w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd"/>
|
||||
</svg>
|
||||
<div class="text-sm text-yellow-700 dark:text-yellow-300">
|
||||
<span class="font-medium">还差关键字段</span>
|
||||
<p class="mt-0.5 text-xs leading-5">
|
||||
先把 <code>listen_pattern</code> 和 <code>parser</code> 补齐,再开始调超时参数。当前直接测试,基本只会得到空结果或回退。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div></details></div></details>
|
||||
|
||||
<!-- DOM 模式说明 -->
|
||||
<div v-else class="dashboard-mini-card">
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<div class="dashboard-mini-card-title">DOM 轮询模式</div>
|
||||
<div class="dashboard-mini-card-copy">
|
||||
这个模式会盯着页面元素变化来判断回复是否结束。兼容性最好,第一次适配新站点时也更容易跑通。
|
||||
</div>
|
||||
</div>
|
||||
<button @click="openTutorial('response-detection')"
|
||||
type="button"
|
||||
class="text-xs font-medium text-blue-600 dark:text-blue-300 hover:underline shrink-0">
|
||||
打开章节
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 通用配置 -->
|
||||
<details class="cap-troubleshoot"><summary><span><strong>回复一直不结束?</strong><small>调整一次对话最多允许等待的时间。</small></span><span class="cap-chevron" v-html="$icons.chevronDown"></span></summary><div class="cap-settings-body">
|
||||
<div class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-3">通用配置</div>
|
||||
<div class="grid grid-cols-1 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">全局硬超时</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number" :value="streamConfig.hard_timeout" @input="updateField('hard_timeout', parseInt($event.target.value) || 300)"
|
||||
min="10" max="600" step="10" class="flex-1 border dark:border-gray-600 px-3 py-2 rounded-md text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-transparent">
|
||||
<span class="text-sm text-gray-500 dark:text-gray-400">秒</span>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
网络监听里,这就是一次完整对话允许等待的最长时间。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div></details>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,54 @@
|
||||
// ==================== 通用折叠面板组件 ====================
|
||||
|
||||
window.CollapsiblePanel = {
|
||||
name: 'CollapsiblePanel',
|
||||
props: {
|
||||
title: { type: String, required: true },
|
||||
icon: { type: String, default: '' },
|
||||
badge: { type: [String, Number], default: null },
|
||||
collapsed: { type: Boolean, default: true },
|
||||
headerClass: { type: String, default: '' }
|
||||
},
|
||||
emits: ['toggle'],
|
||||
methods: {
|
||||
toggle() {
|
||||
this.$emit('toggle');
|
||||
},
|
||||
|
||||
stopPropagation(event) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg shadow-sm">
|
||||
<!-- 标题栏 -->
|
||||
<div :class="[
|
||||
'px-4 py-3 border-b dark:border-gray-700 flex justify-between items-center cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors',
|
||||
headerClass
|
||||
]" @click="toggle">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-gray-500 dark:text-gray-400"
|
||||
v-html="collapsed ? $icons.chevronDown : $icons.chevronUp"></span>
|
||||
<h3 class="font-semibold text-gray-900 dark:text-white">
|
||||
{{ icon }} {{ title }}
|
||||
</h3>
|
||||
<span v-if="badge !== null" class="text-sm text-gray-500 dark:text-gray-400">
|
||||
({{ badge }})
|
||||
</span>
|
||||
<!-- 额外徽章插槽 -->
|
||||
<slot name="badges"></slot>
|
||||
</div>
|
||||
|
||||
<!-- 右侧操作区 -->
|
||||
<div @click.stop="stopPropagation">
|
||||
<slot name="actions"></slot>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容区 -->
|
||||
<div v-show="!collapsed">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
// Dashboard methods 组装器(R2-8 起拆分到 static/js/dashboard/:shared.js 为共享常量与辅助函数,
|
||||
// methods-*.js 为按主题分组的方法;index.html 需在本文件之前按顺序加载它们)。
|
||||
(() => {
|
||||
const parts = window.DashboardMethodParts || [];
|
||||
const merged = {};
|
||||
for (const part of parts) {
|
||||
for (const key of Object.keys(part)) {
|
||||
if (Object.prototype.hasOwnProperty.call(merged, key)) {
|
||||
console.warn('[dashboard] 方法重名,后加载的覆盖先加载的:' + key);
|
||||
}
|
||||
merged[key] = part[key];
|
||||
}
|
||||
}
|
||||
window.DashboardMethods = merged;
|
||||
})();
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,428 @@
|
||||
(() => {
|
||||
const DEFAULT_SELECTOR_DEFINITIONS = window.DEFAULT_SELECTOR_DEFINITIONS || []
|
||||
const BROWSER_CONSTANTS_SCHEMA = window.BROWSER_CONSTANTS_SCHEMA || {}
|
||||
const ENV_CONFIG_SCHEMA = window.ENV_CONFIG_SCHEMA || {}
|
||||
|
||||
const DASHBOARD_SITES_CACHE_STORAGE_KEY = 'dashboard_sites_cache_v1'
|
||||
const DASHBOARD_TOKEN_STORAGE_KEY = 'dashboard_token'
|
||||
const LEGACY_API_TOKEN_STORAGE_KEY = 'api_token'
|
||||
|
||||
function loadStoredDashboardToken() {
|
||||
try {
|
||||
return String(
|
||||
localStorage.getItem(DASHBOARD_TOKEN_STORAGE_KEY)
|
||||
|| localStorage.getItem(LEGACY_API_TOKEN_STORAGE_KEY)
|
||||
|| ''
|
||||
).trim()
|
||||
} catch (error) {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function loadStoredSitesCache() {
|
||||
try {
|
||||
const raw = localStorage.getItem(DASHBOARD_SITES_CACHE_STORAGE_KEY)
|
||||
if (!raw) {
|
||||
return null
|
||||
}
|
||||
const parsed = JSON.parse(raw)
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
return null
|
||||
}
|
||||
if (!parsed.sites || typeof parsed.sites !== 'object' || Array.isArray(parsed.sites)) {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
sites: parsed.sites,
|
||||
currentDomain: typeof parsed.currentDomain === 'string' ? parsed.currentDomain : null
|
||||
}
|
||||
} catch (error) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function saveStoredSitesCache(sites, currentDomain) {
|
||||
try {
|
||||
localStorage.setItem(DASHBOARD_SITES_CACHE_STORAGE_KEY, JSON.stringify({
|
||||
sites: sites && typeof sites === 'object' ? sites : {},
|
||||
currentDomain: typeof currentDomain === 'string' ? currentDomain : null,
|
||||
savedAt: Date.now()
|
||||
}))
|
||||
} catch (error) {
|
||||
// ignore storage failures and keep runtime data available
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 元素定义 Schema ==========
|
||||
|
||||
const DashboardState = {
|
||||
data() {
|
||||
return {
|
||||
// 数据
|
||||
sites: {},
|
||||
currentDomain: null,
|
||||
searchQuery: '',
|
||||
|
||||
// UI 状态
|
||||
toasts: [],
|
||||
toastCounter: 0,
|
||||
hasLoadedSettings: false,
|
||||
isSaving: false,
|
||||
studioLastSavedAt: '',
|
||||
isLoading: false,
|
||||
configLoadSeq: 0,
|
||||
imageConfigSaveSeq: 0,
|
||||
imageConfigSaveQueue: null,
|
||||
showJsonPreview: false,
|
||||
showTokenDialog: false,
|
||||
showStepTemplates: false,
|
||||
showTestDialog: false,
|
||||
showSelectorMenu: false,
|
||||
showImportMenu: false,
|
||||
showExportMenu: false,
|
||||
forceSingleSiteImport: false,
|
||||
singleSiteImportTargetDomain: '',
|
||||
darkMode: false,
|
||||
sidebarCollapsed: false,
|
||||
showMainCompareSummaryDialog: false,
|
||||
mainCompareSummaryLoading: false,
|
||||
mainCompareSummaryError: '',
|
||||
mainCompareSummaryItems: [],
|
||||
mainCompareSummaryCounts: {
|
||||
same: 0,
|
||||
different: 0,
|
||||
local_only_preset: 0,
|
||||
local_only_site: 0,
|
||||
main_only_preset: 0,
|
||||
main_only_site: 0
|
||||
},
|
||||
mainCompareSummaryPath: 'config/sites/index.json',
|
||||
mainCompareSummarySource: {
|
||||
repository: '',
|
||||
branch: 'main',
|
||||
status: '',
|
||||
stale: false,
|
||||
fetched_at: '',
|
||||
checked_at: '',
|
||||
warning: ''
|
||||
},
|
||||
mainCompareShowSame: false,
|
||||
|
||||
// Tab 切换(新增 settings)
|
||||
activeTab: 'home',
|
||||
siteConfigView: 'library',
|
||||
siteLibraryFilter: 'all',
|
||||
mountedTabs: {
|
||||
home: true,
|
||||
config: true
|
||||
},
|
||||
|
||||
// 折叠面板状态
|
||||
selectorCollapsed: true,
|
||||
workflowCollapsed: true,
|
||||
|
||||
// 浏览器状态
|
||||
browserStatus: {
|
||||
connected: false,
|
||||
// 后端 health_check 实际返回 status/connected/port/tab_pool/error
|
||||
// (此前这里声明的 tab_url / tab_title 后端从未产出,属假接口,已移除)
|
||||
tab_pool: null
|
||||
},
|
||||
|
||||
// 系统占用统计
|
||||
systemStats: {
|
||||
memory_mb: 0,
|
||||
disk_status: '加载中...',
|
||||
total_requests: 0,
|
||||
total_input_tokens: 0,
|
||||
total_output_tokens: 0,
|
||||
cpu_percent: 0,
|
||||
project_cpu: 0,
|
||||
memory_percent: 0,
|
||||
project_memory_percent: 0,
|
||||
// 实时请求计数(后端 /api/system/stats 提供,请求监控页「正在执行」KPI 使用)
|
||||
running_count: 0,
|
||||
queued_count: 0
|
||||
},
|
||||
|
||||
// 认证
|
||||
authEnabled: false,
|
||||
tempToken: '',
|
||||
hasTokenPresent: (() => {
|
||||
return !!loadStoredDashboardToken()
|
||||
})(),
|
||||
tokenStorageHandler: null,
|
||||
|
||||
// 选择器测试
|
||||
currentTestingSelectorKey: '',
|
||||
testSelectorInput: '',
|
||||
testTimeout: 2,
|
||||
testResult: null,
|
||||
isTesting: false,
|
||||
testHighlight: false,
|
||||
|
||||
// 日志相关
|
||||
logs: [],
|
||||
logLevelFilter: 'ALL',
|
||||
pauseLogs: false,
|
||||
lastLogTimestamp: 0,
|
||||
lastLogSeq: 0,
|
||||
lastBackgroundLogPollAt: 0,
|
||||
logGeneration: 0,
|
||||
logPollingTimer: null,
|
||||
logVisibilityHandler: null,
|
||||
isPollingLogs: false,
|
||||
logPollPending: false,
|
||||
systemStatsTimer: null,
|
||||
systemStatsVisibilityHandler: null,
|
||||
isFetchingSystemStats: false,
|
||||
systemStatsRequestPromise: null,
|
||||
|
||||
// 请求监控
|
||||
requestHistory: [],
|
||||
requestHistoryMaxRecords: 0,
|
||||
requestHistoryLoading: false,
|
||||
requestHistoryError: '',
|
||||
requestHistoryTimer: null,
|
||||
requestHistoryVisibilityHandler: null,
|
||||
requestHistoryRevision: '',
|
||||
requestHistoryFetchedAt: 0,
|
||||
requestHistoryRequestSeq: 0,
|
||||
requestHistoryPendingRefresh: null,
|
||||
requestHistoryDetailLoading: {},
|
||||
|
||||
// ========== 导入功能 ==========
|
||||
showImportDialog: false,
|
||||
importMode: 'merge', // 'merge' | 'replace'
|
||||
importType: 'full', // 'full' | 'single' (新增:导入类型)
|
||||
importedConfig: null,
|
||||
importFileName: '',
|
||||
singleSiteImportDomain: '', // 新增:单站点导入时的域名
|
||||
|
||||
// ========== 系统设置 ==========
|
||||
// 环境配置
|
||||
envConfig: {},
|
||||
envConfigOriginal: {},
|
||||
envCollapsed: {},
|
||||
isSavingEnv: false,
|
||||
isLoadingEnv: false,
|
||||
|
||||
// 浏览器常量
|
||||
browserConstants: {},
|
||||
browserConstantsOriginal: {},
|
||||
browserConstantsRaw: {},
|
||||
browserConstantsCollapsed: {},
|
||||
isSavingConstants: false,
|
||||
isLoadingConstants: false,
|
||||
|
||||
// 更新白名单
|
||||
updatePreserveOptions: [],
|
||||
updatePreserveSelected: [],
|
||||
updatePreserveSelectedOriginal: [],
|
||||
isSavingUpdatePreserve: false,
|
||||
isLoadingUpdatePreserve: false,
|
||||
|
||||
// Schema 引用
|
||||
envSchema: ENV_CONFIG_SCHEMA,
|
||||
browserConstantsSchema: BROWSER_CONSTANTS_SCHEMA,
|
||||
|
||||
// ========== 元素定义管理 ==========
|
||||
selectorDefinitions: [],
|
||||
selectorDefinitionsOriginal: [],
|
||||
isLoadingDefinitions: false,
|
||||
isSavingDefinitions: false,
|
||||
showAddDefinitionDialog: false,
|
||||
newDefinition: {
|
||||
key: '',
|
||||
description: '',
|
||||
enabled: true,
|
||||
required: false
|
||||
},
|
||||
editingDefinitionIndex: null,
|
||||
|
||||
// ========== 版本管理 ==========
|
||||
releases: [],
|
||||
releasesLoading: false,
|
||||
releasesError: '',
|
||||
releasesCurrentVersion: '',
|
||||
updateCheck: {
|
||||
checked: false,
|
||||
checking: false,
|
||||
available: false,
|
||||
current_version: '',
|
||||
latest_version: '',
|
||||
latest_tag: '',
|
||||
error: ''
|
||||
},
|
||||
updateCheckTimer: null,
|
||||
updateCheckRefreshing: false, // 「立即检查」按钮的进行中标记
|
||||
switchingTag: null, // 正在切换的 tag
|
||||
switchStatusPolling: null, // 轮询定时器
|
||||
switchStatusPollingActive: false,
|
||||
switchStatusPollingInFlight: false,
|
||||
showChangelogModal: false,
|
||||
changelogContent: '',
|
||||
changelogTag: '',
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
computed: {
|
||||
siteLibraryStats() {
|
||||
const summaries = Object.keys(this.sites).map(domain => this.siteLibrarySummary(domain))
|
||||
return { sites: summaries.length, presets: summaries.reduce((n, s) => n + s.presets, 0), incomplete: summaries.filter(s => s.coreFilled < 3).length }
|
||||
},
|
||||
librarySites() {
|
||||
return this.filteredSites.filter(domain => this.siteLibraryFilter !== 'incomplete' || this.siteLibrarySummary(domain).coreFilled < 3)
|
||||
},
|
||||
filteredSites() {
|
||||
const keys = Object.keys(this.sites).sort()
|
||||
const query = this.searchQuery.trim().toLowerCase()
|
||||
return query
|
||||
? keys.filter(d => (d + ' ' + this.siteDisplayName(d)).toLowerCase().includes(query))
|
||||
: keys
|
||||
},
|
||||
|
||||
currentConfig() {
|
||||
return this.currentDomain ? this.sites[this.currentDomain] : null
|
||||
},
|
||||
|
||||
hasToken() {
|
||||
return !!this.hasTokenPresent
|
||||
},
|
||||
|
||||
// 过滤后的日志
|
||||
filteredLogs() {
|
||||
if (this.logLevelFilter === 'ALL') {
|
||||
return this.logs;
|
||||
}
|
||||
if (this.logLevelFilter === 'INFO') {
|
||||
return this.logs.filter(log => log.level === 'INFO' || log.level === 'OK');
|
||||
}
|
||||
return this.logs.filter(log => log.level === this.logLevelFilter);
|
||||
},
|
||||
|
||||
// 检测环境配置是否有变更
|
||||
envConfigChanged() {
|
||||
return JSON.stringify(this.envConfig) !== JSON.stringify(this.envConfigOriginal);
|
||||
},
|
||||
|
||||
// 检测浏览器常量是否有变更
|
||||
browserConstantsChanged() {
|
||||
return JSON.stringify(this.browserConstants) !== JSON.stringify(this.browserConstantsOriginal);
|
||||
},
|
||||
|
||||
// 检测元素定义是否有变更
|
||||
selectorDefinitionsChanged() {
|
||||
return JSON.stringify(this.selectorDefinitions) !== JSON.stringify(this.selectorDefinitionsOriginal);
|
||||
},
|
||||
|
||||
// 检测更新白名单是否有变更
|
||||
updatePreserveChanged() {
|
||||
return JSON.stringify(this.updatePreserveSelected) !== JSON.stringify(this.updatePreserveSelectedOriginal);
|
||||
},
|
||||
|
||||
updateAvailable() {
|
||||
return !!(this.updateCheck && this.updateCheck.available);
|
||||
},
|
||||
|
||||
mainCompareVisibleItems() {
|
||||
const items = Array.isArray(this.mainCompareSummaryItems) ? this.mainCompareSummaryItems : [];
|
||||
if (this.mainCompareShowSame) {
|
||||
return items;
|
||||
}
|
||||
return items.filter(item => String(item && item.status || '') !== 'same');
|
||||
},
|
||||
|
||||
mainCompareDifferentTotal() {
|
||||
const counts = this.mainCompareSummaryCounts || {};
|
||||
return Number(counts.different || 0)
|
||||
+ Number(counts.local_only_preset || 0)
|
||||
+ Number(counts.local_only_site || 0);
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
sidebarCollapsed(collapsed) {
|
||||
const appRoot = document.getElementById('app')
|
||||
if (appRoot) {
|
||||
appRoot.classList.toggle('sidebar-is-collapsed', !!collapsed)
|
||||
}
|
||||
},
|
||||
activeTab(tab) {
|
||||
document.getElementById('app')?.classList.toggle('site-studio-active', tab === 'config')
|
||||
this.markTabAsVisited(tab)
|
||||
this.ensureTabDataLoaded(tab)
|
||||
if (tab === 'logs') {
|
||||
this.pollLogs()
|
||||
}
|
||||
},
|
||||
darkMode() {
|
||||
this.applyDarkMode()
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
document.addEventListener('keydown', this.handleStudioShortcut)
|
||||
document.getElementById('app')?.classList.toggle('site-studio-active', this.activeTab === 'config')
|
||||
// 读取夜间模式设置
|
||||
let savedDarkMode = null
|
||||
try {
|
||||
savedDarkMode = localStorage.getItem('darkMode')
|
||||
} catch (e) {
|
||||
savedDarkMode = null
|
||||
}
|
||||
if (savedDarkMode !== null) {
|
||||
this.darkMode = savedDarkMode === 'true'
|
||||
} else {
|
||||
this.darkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
}
|
||||
this.applyDarkMode()
|
||||
|
||||
// 初始化折叠状态
|
||||
this.initCollapsedStates()
|
||||
this.markTabAsVisited(this.activeTab)
|
||||
this.restoreSitesCache()
|
||||
this.syncTokenPresence()
|
||||
this.ensureTokenStorageHandler()
|
||||
|
||||
this.initializeDashboard()
|
||||
|
||||
this._globalClickCloser = (e) => {
|
||||
if (!e.target.closest('.uwa-dropdown')) {
|
||||
this.closeAllMenus();
|
||||
}
|
||||
};
|
||||
document.addEventListener('click', this._globalClickCloser);
|
||||
|
||||
// 启动日志轮询(每 1 秒)
|
||||
|
||||
// 加载系统设置
|
||||
|
||||
// 加载元素定义
|
||||
|
||||
// 加载提取器列表
|
||||
},
|
||||
|
||||
beforeUnmount() {
|
||||
document.removeEventListener('keydown', this.handleStudioShortcut)
|
||||
this.stopLogPolling()
|
||||
this.stopRequestHistoryPolling()
|
||||
this.stopSystemStatsPolling()
|
||||
if (this.updateCheckTimer) {
|
||||
clearTimeout(this.updateCheckTimer)
|
||||
this.updateCheckTimer = null
|
||||
}
|
||||
this.stopSwitchStatusPolling()
|
||||
this.stopTokenStorageHandler()
|
||||
if (this._globalClickCloser) {
|
||||
document.removeEventListener('click', this._globalClickCloser);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
window.DashboardState = DashboardState
|
||||
window.loadStoredSitesCache = loadStoredSitesCache
|
||||
window.saveStoredSitesCache = saveStoredSitesCache
|
||||
})();
|
||||
@@ -0,0 +1,48 @@
|
||||
const { createApp } = Vue
|
||||
const dashboardState = window.DashboardState || {}
|
||||
|
||||
// ========== Vue App ==========
|
||||
|
||||
const app = createApp({
|
||||
data: dashboardState.data || function () { return {} },
|
||||
computed: dashboardState.computed || {},
|
||||
watch: dashboardState.watch || {},
|
||||
mounted: dashboardState.mounted || function () {},
|
||||
beforeUnmount: dashboardState.beforeUnmount || function () {},
|
||||
|
||||
methods: window.DashboardMethods || {}
|
||||
});
|
||||
|
||||
// ========== 组件注册 ==========
|
||||
app.component('sidebar-component', window.SidebarComponent);
|
||||
app.component('onboarding-guide', window.OnboardingGuide);
|
||||
app.component('home-tab', window.HomeTab);
|
||||
app.component('config-tab', window.ConfigTab);
|
||||
app.component('request-monitor-tab', window.RequestMonitorTab);
|
||||
app.component('tabpool-tab', window.TabPoolTabComponent);
|
||||
app.component('commands-tab', window.CommandsTabComponent); // 🆕 命令系统
|
||||
app.component('logs-tab', window.LogsTab);
|
||||
app.component('settings-tab', window.SettingsTab);
|
||||
app.component('json-preview-dialog', window.JsonPreviewDialog);
|
||||
app.component('token-dialog', window.TokenDialog);
|
||||
app.component('step-templates-dialog', window.StepTemplatesDialog);
|
||||
app.component('test-dialog', window.TestDialog);
|
||||
app.component('import-dialog', window.ImportDialog);
|
||||
app.component('definition-dialog', window.DefinitionDialog);
|
||||
|
||||
// ========== 全局 Mixin (修复图标访问问题) ==========
|
||||
app.mixin({
|
||||
computed: {
|
||||
$icons() {
|
||||
return window.$icons || window.icons || {};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ========== 启动应用 ==========
|
||||
app.mount('#app');
|
||||
document.body.classList.add('app-mounted');
|
||||
const appShell = document.getElementById('app-shell');
|
||||
if (appShell) {
|
||||
appShell.style.display = 'none';
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
// R2-8:由 dashboard-methods.js 拆分——API 调用与配置读写。方法原样迁出,由 dashboard-methods.js 统一组装。
|
||||
(() => {
|
||||
const {
|
||||
DEFAULT_SELECTOR_DEFINITIONS,
|
||||
BROWSER_CONSTANTS_SCHEMA,
|
||||
ENV_CONFIG_SCHEMA,
|
||||
DASHBOARD_TOKEN_STORAGE_KEY,
|
||||
LEGACY_API_TOKEN_STORAGE_KEY,
|
||||
SITE_CONFIG_IMPORT_MAX_BYTES,
|
||||
SETTINGS_BACKUP_IMPORT_MAX_BYTES,
|
||||
importFileSizeError,
|
||||
formatGitCompareErrorText,
|
||||
getStoredDashboardToken,
|
||||
setStoredDashboardToken,
|
||||
SITE_FRIENDLY_NAMES,
|
||||
GENERIC_DOMAIN_LABELS,
|
||||
siteDisplayName,
|
||||
} = window.DashboardShared;
|
||||
(window.DashboardMethodParts = window.DashboardMethodParts || []).push({
|
||||
// ========== API 调用 ==========
|
||||
|
||||
openTokenDialog() {
|
||||
if (this.showTokenDialog) {
|
||||
return
|
||||
}
|
||||
this.tempToken = getStoredDashboardToken()
|
||||
this.showTokenDialog = true
|
||||
},
|
||||
|
||||
async apiRequest(url, options = {}) {
|
||||
const token = getStoredDashboardToken()
|
||||
const timeoutMs = Number(options.timeoutMs || 0)
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
...options.headers
|
||||
}
|
||||
|
||||
if (token) {
|
||||
headers['Authorization'] = 'Bearer ' + token
|
||||
}
|
||||
|
||||
const fetchOptions = { ...options }
|
||||
delete fetchOptions.timeoutMs
|
||||
|
||||
let timeoutId = null
|
||||
let controller = null
|
||||
if (timeoutMs > 0 && typeof AbortController !== 'undefined') {
|
||||
controller = new AbortController()
|
||||
fetchOptions.signal = controller.signal
|
||||
timeoutId = setTimeout(() => {
|
||||
controller.abort()
|
||||
}, timeoutMs)
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
...fetchOptions,
|
||||
headers
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status === 401) {
|
||||
this.notify('控制面板认证失败,请检查访问密钥', 'error')
|
||||
this.openTokenDialog()
|
||||
throw new Error('UNAUTHORIZED')
|
||||
}
|
||||
|
||||
const errorData = await response.json().catch(() => ({}))
|
||||
throw new Error(errorData.detail || '请求失败 (' + response.status + ')')
|
||||
}
|
||||
|
||||
return await response.json()
|
||||
} catch (error) {
|
||||
if (error && error.name === 'AbortError') {
|
||||
throw new Error('REQUEST_TIMEOUT')
|
||||
}
|
||||
if (error.message !== 'UNAUTHORIZED') {
|
||||
console.error('API 请求错误:', error)
|
||||
}
|
||||
throw error
|
||||
} finally {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async loadConfig(silent) {
|
||||
// 防御:@click="loadConfig" 会传入 Event 对象,需要过滤
|
||||
if (typeof silent !== 'boolean') {
|
||||
silent = false
|
||||
}
|
||||
|
||||
const requestSeq = Number(this.configLoadSeq || 0) + 1
|
||||
this.configLoadSeq = requestSeq
|
||||
this.isLoading = true
|
||||
try {
|
||||
const data = await this.apiRequest('/api/config', { timeoutMs: 5000 })
|
||||
if (requestSeq !== this.configLoadSeq) {
|
||||
return false
|
||||
}
|
||||
|
||||
this.sites = this.normalizeConfig(data)
|
||||
if (!this.currentDomain && Object.keys(this.sites).length > 0) {
|
||||
this.currentDomain = Object.keys(this.sites)[0]
|
||||
}
|
||||
window.saveStoredSitesCache(this.sites, this.currentDomain)
|
||||
|
||||
if (!silent) {
|
||||
this.notify('配置已刷新 (' + Object.keys(this.sites).length + ' 个站点)', 'success')
|
||||
}
|
||||
return true
|
||||
} catch (error) {
|
||||
if (requestSeq !== this.configLoadSeq) {
|
||||
return false
|
||||
}
|
||||
this.notify('加载配置失败: ' + error.message, 'error')
|
||||
if (Object.keys(this.sites || {}).length === 0) {
|
||||
this.sites = {}
|
||||
}
|
||||
return false
|
||||
} finally {
|
||||
if (requestSeq === this.configLoadSeq) {
|
||||
this.isLoading = false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 修复:FilePastePanel / PromptPaddingPanel 编辑的是独立草稿,必须 flush 才会回写到
|
||||
// presetConfig。原先只有 saveConfig 调用,导致 JSON 预览既显示旧值也保存旧值。
|
||||
// 抽成方法后在读取/保存配置的各处统一调用。
|
||||
flushConfigTabDrafts() {
|
||||
if (this.$refs && this.$refs.configTab && typeof this.$refs.configTab.flushMutableSectionDrafts === 'function') {
|
||||
this.$refs.configTab.flushMutableSectionDrafts()
|
||||
}
|
||||
},
|
||||
|
||||
async saveConfig() {
|
||||
if (!this.validateConfig()) {
|
||||
return
|
||||
}
|
||||
|
||||
this.isSaving = true
|
||||
try {
|
||||
this.flushConfigTabDrafts()
|
||||
const tab = this.$refs?.configTab, configRef = tab?.currentConfig, transferRevision = tab?.pendingPresetTransfer
|
||||
await this.apiRequest('/api/config', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ config: this.sites })
|
||||
})
|
||||
if (tab && tab.currentConfig === configRef && tab.pendingPresetTransfer === transferRevision) tab.pendingPresetTransfer = 0
|
||||
this.studioLastSavedAt = new Date().toLocaleTimeString('zh-CN', { hour12: false })
|
||||
this.notify('配置已保存', 'success')
|
||||
} catch (error) {
|
||||
this.notify('保存失败: ' + error.message, 'error')
|
||||
} finally {
|
||||
this.isSaving = false
|
||||
}
|
||||
},
|
||||
|
||||
async checkAuth() {
|
||||
return this.loadHealthStatus({ silent: true })
|
||||
},
|
||||
|
||||
async testSelector(key, selector) {
|
||||
this.currentTestingSelectorKey = key || ''
|
||||
this.testSelectorInput = selector || ''
|
||||
this.showTestDialog = true
|
||||
this.testResult = null
|
||||
|
||||
if (!String(this.testSelectorInput || '').trim()) {
|
||||
this.notify('当前字段还没填,先在测试工作台里输入一个选择器再测。', 'info')
|
||||
return
|
||||
}
|
||||
|
||||
await this.runTest()
|
||||
},
|
||||
|
||||
async runTest() {
|
||||
if (!this.testSelectorInput) return
|
||||
|
||||
this.isTesting = true
|
||||
this.testResult = null
|
||||
|
||||
try {
|
||||
const result = await this.apiRequest('/api/debug/test-selector', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
selector: this.testSelectorInput,
|
||||
timeout: this.testTimeout,
|
||||
highlight: this.testHighlight,
|
||||
route_domain: this.currentDomain || ''
|
||||
})
|
||||
})
|
||||
|
||||
this.testResult = result
|
||||
|
||||
if (result.success) {
|
||||
if (result.count > 1) {
|
||||
this.notify('✅ 找到 ' + result.count + ' 个元素' + (this.testHighlight ? ',已全部高亮' : ''), 'success')
|
||||
} else {
|
||||
this.notify('✅ 选择器有效' + (this.testHighlight ? ',已高亮显示' : ''), 'success')
|
||||
}
|
||||
} else {
|
||||
this.notify('❌ 选择器无效', 'error')
|
||||
}
|
||||
} catch (error) {
|
||||
this.testResult = {
|
||||
success: false,
|
||||
message: error.message
|
||||
}
|
||||
this.notify('测试失败: ' + error.message, 'error')
|
||||
} finally {
|
||||
this.isTesting = false
|
||||
}
|
||||
},
|
||||
|
||||
async applyTestSelectorCandidate(payload) {
|
||||
const selector = String(payload && payload.selector || '').trim()
|
||||
if (!selector) {
|
||||
return
|
||||
}
|
||||
|
||||
this.testSelectorInput = selector
|
||||
|
||||
const key = String(this.currentTestingSelectorKey || '').trim()
|
||||
const preset = this.getActivePresetConfig()
|
||||
if (key && preset && preset.selectors) {
|
||||
preset.selectors[key] = selector
|
||||
this.notify('候选选择器已回填到当前字段', 'success')
|
||||
} else {
|
||||
this.notify('已代入当前测试输入框', 'info')
|
||||
}
|
||||
|
||||
if (payload && payload.rerun) {
|
||||
await this.runTest()
|
||||
}
|
||||
},
|
||||
|
||||
async testCurrentSite() {
|
||||
if (!this.currentConfig || Object.keys(this.currentConfig.selectors).length === 0) {
|
||||
this.notify('当前站点没有选择器', 'warning')
|
||||
return
|
||||
}
|
||||
|
||||
this.notify('开始批量测试...', 'info')
|
||||
|
||||
let successCount = 0
|
||||
let failCount = 0
|
||||
|
||||
for (const [key, selector] of Object.entries(this.currentConfig.selectors)) {
|
||||
if (!selector) continue
|
||||
|
||||
try {
|
||||
const result = await this.apiRequest('/api/debug/test-selector', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
selector: selector,
|
||||
timeout: 2,
|
||||
route_domain: this.currentDomain || ''
|
||||
})
|
||||
})
|
||||
|
||||
if (result.success) {
|
||||
successCount++
|
||||
console.log('✅ ' + key + ': ' + selector)
|
||||
} else {
|
||||
failCount++
|
||||
console.warn('❌ ' + key + ': ' + selector)
|
||||
}
|
||||
} catch (error) {
|
||||
failCount++
|
||||
console.error('❌ ' + key + ': ' + error.message)
|
||||
}
|
||||
}
|
||||
|
||||
this.notify('测试完成: ' + successCount + ' 成功, ' + failCount + ' 失败',
|
||||
failCount > 0 ? 'warning' : 'success')
|
||||
},
|
||||
|
||||
async reanalyzeCurrentSite() {
|
||||
if (!this.currentDomain) return
|
||||
|
||||
if (!confirm('确定要删除 ' + this.currentDomain + ' 的配置并重新分析吗?\n\n重新分析需要浏览器当前正在访问该站点。')) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await this.apiRequest('/api/config/' + this.currentDomain, {
|
||||
method: 'DELETE'
|
||||
})
|
||||
|
||||
this.notify('配置已删除,请刷新页面让 AI 重新分析', 'info')
|
||||
|
||||
delete this.sites[this.currentDomain]
|
||||
this.currentDomain = null
|
||||
} catch (error) {
|
||||
this.notify('删除失败: ' + error.message, 'error')
|
||||
}
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,482 @@
|
||||
// R2-8:由 dashboard-methods.js 拆分——基础:站点显示、初始化、夜间模式、菜单。方法原样迁出,由 dashboard-methods.js 统一组装。
|
||||
(() => {
|
||||
const {
|
||||
DEFAULT_SELECTOR_DEFINITIONS,
|
||||
BROWSER_CONSTANTS_SCHEMA,
|
||||
ENV_CONFIG_SCHEMA,
|
||||
DASHBOARD_TOKEN_STORAGE_KEY,
|
||||
LEGACY_API_TOKEN_STORAGE_KEY,
|
||||
SITE_CONFIG_IMPORT_MAX_BYTES,
|
||||
SETTINGS_BACKUP_IMPORT_MAX_BYTES,
|
||||
importFileSizeError,
|
||||
formatGitCompareErrorText,
|
||||
getStoredDashboardToken,
|
||||
setStoredDashboardToken,
|
||||
SITE_FRIENDLY_NAMES,
|
||||
GENERIC_DOMAIN_LABELS,
|
||||
siteDisplayName,
|
||||
} = window.DashboardShared;
|
||||
(window.DashboardMethodParts = window.DashboardMethodParts || []).push({
|
||||
siteDisplayName,
|
||||
siteStudioInitial(domain) {
|
||||
const name = this.siteDisplayName(domain)
|
||||
const initials = { 'aistudio.google.com': 'G', 'aistudio.xiaomimimo.com': 'M', 'chat.qwen.ai': 'Q', 'www.doubao.com': '豆', 'chatglm.cn': '智' }
|
||||
return initials[domain] || Array.from(name || '?')[0].toUpperCase()
|
||||
},
|
||||
siteLibrarySummary(domain) {
|
||||
const site = this.sites[domain] || {}
|
||||
const presets = site.presets || null
|
||||
const names = presets ? Object.keys(presets) : []
|
||||
const presetName = presets ? (names.includes(site.default_preset) ? site.default_preset : names.includes('主预设') ? '主预设' : names[0] || '无预设') : '主预设'
|
||||
const config = presets ? presets[presetName] || {} : site
|
||||
const selectors = config.selectors || {}
|
||||
const coreChecks = ['input_box', 'send_btn', 'result_container'].map(key => !!String(selectors[key] || '').trim())
|
||||
return { presetName, presets: presets ? names.length : 1, selectors: Object.keys(selectors).length, coreChecks, coreFilled: coreChecks.filter(Boolean).length }
|
||||
},
|
||||
showSiteLibrary() {
|
||||
this.flushConfigTabDrafts()
|
||||
this.siteConfigView = 'library'
|
||||
this.$nextTick(() => document.querySelector('.dashboard-scroll-region')?.scrollTo({ top: 0 }))
|
||||
},
|
||||
handleStudioShortcut(event) {
|
||||
if (this.activeTab !== 'config' || event.defaultPrevented) return
|
||||
const editing = event.target && (event.target.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(event.target.tagName))
|
||||
const visibleDialog = Array.from(document.querySelectorAll('[role="dialog"]')).some(el => el.getClientRects().length)
|
||||
const editingDialog = Object.entries(this.$data || {}).some(([key, value]) => /^show.*(Dialog|Modal|Preview)$/.test(key) && value === true)
|
||||
if (visibleDialog || editingDialog) return
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 's') {
|
||||
event.preventDefault()
|
||||
if (!this.isSaving && this.currentConfig && !this.showJsonPreview) this.saveConfig()
|
||||
} else if (event.key === '/' && !editing && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
||||
const field = document.querySelector('.library-search input')
|
||||
if (field && field.getClientRects().length) {
|
||||
event.preventDefault()
|
||||
field.focus()
|
||||
}
|
||||
}
|
||||
},
|
||||
async initializeDashboard() {
|
||||
await this.loadConfig(true)
|
||||
await this.loadBrowserConstants().catch(() => {})
|
||||
|
||||
this.startLogPolling()
|
||||
await this.loadHealthStatus({ silent: true, timeoutMs: 2500 }).catch(() => false)
|
||||
this.loadUpdateCheck({ silent: true })
|
||||
.then((status) => this.scheduleUpdateCheckStatusRefresh(status))
|
||||
.catch(() => {})
|
||||
this.startRequestHistoryPolling()
|
||||
this.ensureTabDataLoaded(this.activeTab)
|
||||
|
||||
this.startSystemStatsPolling()
|
||||
},
|
||||
|
||||
startLogPolling() {
|
||||
this.ensureLogPollingVisibilityHandler()
|
||||
const interval = this.getDashboardPollInterval('DASHBOARD_LOG_POLL_INTERVAL_MS', 1000)
|
||||
if (
|
||||
interval <= 0
|
||||
|| !this.getBrowserConstantBool('LOG_WEB_COLLECTOR_ENABLED', true)
|
||||
|| this.getBrowserConstantNumber('LOG_WEB_MAX_RECORDS', 5000) <= 0
|
||||
) {
|
||||
this.stopLogPollingTimer()
|
||||
this.logs = []
|
||||
return
|
||||
}
|
||||
if (this.logPollingTimer || this.isDocumentHidden()) {
|
||||
return
|
||||
}
|
||||
|
||||
this.pollLogs()
|
||||
this.logPollingTimer = setInterval(() => {
|
||||
this.pollLogs({ background: this.activeTab !== 'logs' })
|
||||
}, interval)
|
||||
},
|
||||
|
||||
stopLogPolling() {
|
||||
this.stopLogPollingTimer()
|
||||
if (
|
||||
this.logVisibilityHandler
|
||||
&& typeof document !== 'undefined'
|
||||
&& typeof document.removeEventListener === 'function'
|
||||
) {
|
||||
document.removeEventListener('visibilitychange', this.logVisibilityHandler)
|
||||
}
|
||||
this.logVisibilityHandler = null
|
||||
},
|
||||
|
||||
stopLogPollingTimer() {
|
||||
if (!this.logPollingTimer) {
|
||||
return
|
||||
}
|
||||
|
||||
clearInterval(this.logPollingTimer)
|
||||
this.logPollingTimer = null
|
||||
},
|
||||
|
||||
ensureLogPollingVisibilityHandler() {
|
||||
if (
|
||||
this.logVisibilityHandler
|
||||
|| typeof document === 'undefined'
|
||||
|| typeof document.addEventListener !== 'function'
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
this.logVisibilityHandler = () => {
|
||||
if (this.isDocumentHidden()) {
|
||||
this.stopLogPollingTimer()
|
||||
return
|
||||
}
|
||||
this.startLogPolling()
|
||||
}
|
||||
document.addEventListener('visibilitychange', this.logVisibilityHandler)
|
||||
},
|
||||
|
||||
markTabAsVisited(tab) {
|
||||
const key = String(tab || '').trim()
|
||||
if (!key || this.mountedTabs[key]) {
|
||||
return
|
||||
}
|
||||
this.mountedTabs = {
|
||||
...this.mountedTabs,
|
||||
[key]: true
|
||||
}
|
||||
},
|
||||
|
||||
shouldRenderTab(tab) {
|
||||
return this.activeTab === tab || !!this.mountedTabs[tab]
|
||||
},
|
||||
|
||||
syncTokenPresence() {
|
||||
try {
|
||||
this.hasTokenPresent = !!getStoredDashboardToken()
|
||||
} catch (e) {
|
||||
this.hasTokenPresent = false
|
||||
}
|
||||
},
|
||||
|
||||
ensureTokenStorageHandler() {
|
||||
if (
|
||||
this.tokenStorageHandler
|
||||
|| typeof window === 'undefined'
|
||||
|| typeof window.addEventListener !== 'function'
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
this.tokenStorageHandler = (event) => {
|
||||
if (
|
||||
!event
|
||||
|| event.key === DASHBOARD_TOKEN_STORAGE_KEY
|
||||
|| event.key === LEGACY_API_TOKEN_STORAGE_KEY
|
||||
) {
|
||||
this.hasTokenPresent = !!getStoredDashboardToken()
|
||||
}
|
||||
}
|
||||
window.addEventListener('storage', this.tokenStorageHandler)
|
||||
},
|
||||
|
||||
stopTokenStorageHandler() {
|
||||
if (
|
||||
this.tokenStorageHandler
|
||||
&& typeof window !== 'undefined'
|
||||
&& typeof window.removeEventListener === 'function'
|
||||
) {
|
||||
window.removeEventListener('storage', this.tokenStorageHandler)
|
||||
}
|
||||
this.tokenStorageHandler = null
|
||||
},
|
||||
|
||||
startRequestHistoryPolling() {
|
||||
this.ensureRequestHistoryVisibilityHandler()
|
||||
const interval = this.getDashboardPollInterval('DASHBOARD_REQUEST_HISTORY_POLL_INTERVAL_MS', 3000)
|
||||
if (!this.isRequestMonitorEnabled() || interval <= 0) {
|
||||
this.stopRequestHistoryPollingTimer()
|
||||
if (!this.isRequestMonitorEnabled()) {
|
||||
this.requestHistory = []
|
||||
this.requestHistoryRevision = ''
|
||||
this.requestHistoryError = ''
|
||||
}
|
||||
return
|
||||
}
|
||||
if (this.requestHistoryTimer || this.isDocumentHidden()) {
|
||||
return
|
||||
}
|
||||
this.requestHistoryTimer = setInterval(() => {
|
||||
if (this.activeTab === 'monitor' && document.visibilityState !== 'hidden') {
|
||||
this.fetchRequestHistory({ silent: true, ifChanged: true }).catch(() => {})
|
||||
}
|
||||
}, interval)
|
||||
},
|
||||
|
||||
stopRequestHistoryPolling() {
|
||||
this.stopRequestHistoryPollingTimer()
|
||||
if (
|
||||
this.requestHistoryVisibilityHandler
|
||||
&& typeof document !== 'undefined'
|
||||
&& typeof document.removeEventListener === 'function'
|
||||
) {
|
||||
document.removeEventListener('visibilitychange', this.requestHistoryVisibilityHandler)
|
||||
}
|
||||
this.requestHistoryVisibilityHandler = null
|
||||
},
|
||||
|
||||
stopRequestHistoryPollingTimer() {
|
||||
if (!this.requestHistoryTimer) {
|
||||
return
|
||||
}
|
||||
clearInterval(this.requestHistoryTimer)
|
||||
this.requestHistoryTimer = null
|
||||
},
|
||||
|
||||
ensureRequestHistoryVisibilityHandler() {
|
||||
if (
|
||||
this.requestHistoryVisibilityHandler
|
||||
|| typeof document === 'undefined'
|
||||
|| typeof document.addEventListener !== 'function'
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
this.requestHistoryVisibilityHandler = () => {
|
||||
if (this.isDocumentHidden()) {
|
||||
this.stopRequestHistoryPollingTimer()
|
||||
return
|
||||
}
|
||||
this.startRequestHistoryPolling()
|
||||
if (this.activeTab === 'monitor' && this.isRequestMonitorEnabled()) {
|
||||
this.fetchRequestHistory({ silent: true, ifChanged: true }).catch(() => {})
|
||||
}
|
||||
}
|
||||
document.addEventListener('visibilitychange', this.requestHistoryVisibilityHandler)
|
||||
},
|
||||
|
||||
isDocumentHidden() {
|
||||
return typeof document !== 'undefined' && document.visibilityState === 'hidden'
|
||||
},
|
||||
|
||||
getBrowserConstantDefault(key, fallback = null) {
|
||||
const targetKey = String(key || '')
|
||||
for (const group of Object.values(BROWSER_CONSTANTS_SCHEMA || {})) {
|
||||
const items = group && group.items ? group.items : {}
|
||||
if (Object.prototype.hasOwnProperty.call(items, targetKey)) {
|
||||
const field = items[targetKey] || {}
|
||||
return Object.prototype.hasOwnProperty.call(field, 'default') ? field.default : fallback
|
||||
}
|
||||
}
|
||||
return fallback
|
||||
},
|
||||
|
||||
getBrowserConstantValue(key, fallback = null) {
|
||||
const targetKey = String(key || '')
|
||||
const constants = this.browserConstants && typeof this.browserConstants === 'object' ? this.browserConstants : {}
|
||||
if (Object.prototype.hasOwnProperty.call(constants, targetKey)) {
|
||||
return constants[targetKey]
|
||||
}
|
||||
return this.getBrowserConstantDefault(targetKey, fallback)
|
||||
},
|
||||
|
||||
getBrowserConstantNumber(key, fallback = 0, { min = null, max = null } = {}) {
|
||||
const value = Number(this.getBrowserConstantValue(key, fallback))
|
||||
if (!Number.isFinite(value)) {
|
||||
return fallback
|
||||
}
|
||||
let normalized = value
|
||||
if (Number.isFinite(min)) {
|
||||
normalized = Math.max(min, normalized)
|
||||
}
|
||||
if (Number.isFinite(max)) {
|
||||
normalized = Math.min(max, normalized)
|
||||
}
|
||||
return normalized
|
||||
},
|
||||
|
||||
getBrowserConstantBool(key, fallback = true) {
|
||||
const value = this.getBrowserConstantValue(key, fallback)
|
||||
if (typeof value === 'boolean') {
|
||||
return value
|
||||
}
|
||||
if (typeof value === 'number') {
|
||||
return value !== 0
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
const normalized = value.trim().toLowerCase()
|
||||
if (['0', 'false', 'no', 'off'].includes(normalized)) {
|
||||
return false
|
||||
}
|
||||
if (['1', 'true', 'yes', 'on'].includes(normalized)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return Boolean(fallback)
|
||||
},
|
||||
|
||||
getDashboardPollInterval(key, fallback) {
|
||||
const value = this.getBrowserConstantNumber(key, fallback, { min: 0 })
|
||||
return Number.isFinite(value) ? Math.floor(value) : fallback
|
||||
},
|
||||
|
||||
isRequestMonitorEnabled() {
|
||||
return this.getBrowserConstantBool('REQUEST_MONITOR_ENABLED', true)
|
||||
&& this.getBrowserConstantNumber('REQUEST_MONITOR_MAX_RECORDS', 200, { min: 0 }) > 0
|
||||
},
|
||||
|
||||
isSystemStatsPollingEnabled() {
|
||||
return this.getBrowserConstantBool('DASHBOARD_SYSTEM_STATS_ENABLED', true)
|
||||
&& this.getDashboardPollInterval('DASHBOARD_SYSTEM_STATS_POLL_INTERVAL_MS', 3000) > 0
|
||||
},
|
||||
|
||||
applyDashboardRuntimeSettings() {
|
||||
this.stopLogPollingTimer()
|
||||
this.stopRequestHistoryPollingTimer()
|
||||
this.stopSystemStatsPollingTimer()
|
||||
|
||||
if (
|
||||
!this.getBrowserConstantBool('LOG_WEB_COLLECTOR_ENABLED', true)
|
||||
|| this.getBrowserConstantNumber('LOG_WEB_MAX_RECORDS', 5000, { min: 0 }) <= 0
|
||||
|| this.getDashboardPollInterval('DASHBOARD_LOG_POLL_INTERVAL_MS', 1000) <= 0
|
||||
) {
|
||||
this.logs = []
|
||||
this.lastLogSeq = 0
|
||||
this.lastLogTimestamp = 0
|
||||
this.logPollPending = false
|
||||
}
|
||||
|
||||
if (!this.isRequestMonitorEnabled()) {
|
||||
this.requestHistory = []
|
||||
this.requestHistoryRevision = ''
|
||||
this.requestHistoryError = ''
|
||||
this.requestHistoryPendingRefresh = null
|
||||
}
|
||||
|
||||
this.startLogPolling()
|
||||
this.startRequestHistoryPolling()
|
||||
this.startSystemStatsPolling()
|
||||
|
||||
if (this.activeTab === 'monitor' && this.isRequestMonitorEnabled()) {
|
||||
this.fetchRequestHistory({ silent: true, ifChanged: false, force: true }).catch(() => {})
|
||||
}
|
||||
},
|
||||
|
||||
startSystemStatsPolling() {
|
||||
this.ensureSystemStatsVisibilityHandler()
|
||||
const interval = this.getDashboardPollInterval('DASHBOARD_SYSTEM_STATS_POLL_INTERVAL_MS', 3000)
|
||||
if (!this.getBrowserConstantBool('DASHBOARD_SYSTEM_STATS_ENABLED', true) || interval <= 0) {
|
||||
this.stopSystemStatsPollingTimer()
|
||||
return
|
||||
}
|
||||
if (this.systemStatsTimer || this.isDocumentHidden()) {
|
||||
return
|
||||
}
|
||||
|
||||
this.fetchSystemStats({ timeoutMs: 2500 }).catch(() => {})
|
||||
|
||||
this.systemStatsTimer = setInterval(() => {
|
||||
this.fetchSystemStats({ timeoutMs: 2500 }).catch(() => {})
|
||||
}, interval)
|
||||
},
|
||||
|
||||
stopSystemStatsPollingTimer() {
|
||||
if (!this.systemStatsTimer) {
|
||||
return
|
||||
}
|
||||
|
||||
clearInterval(this.systemStatsTimer)
|
||||
this.systemStatsTimer = null
|
||||
},
|
||||
|
||||
ensureSystemStatsVisibilityHandler() {
|
||||
if (
|
||||
this.systemStatsVisibilityHandler
|
||||
|| typeof document === 'undefined'
|
||||
|| typeof document.addEventListener !== 'function'
|
||||
) {
|
||||
return
|
||||
}
|
||||
this.systemStatsVisibilityHandler = () => {
|
||||
if (this.isDocumentHidden()) {
|
||||
this.stopSystemStatsPollingTimer()
|
||||
return
|
||||
}
|
||||
this.startSystemStatsPolling()
|
||||
}
|
||||
document.addEventListener('visibilitychange', this.systemStatsVisibilityHandler)
|
||||
},
|
||||
|
||||
stopSystemStatsPolling() {
|
||||
this.stopSystemStatsPollingTimer()
|
||||
if (
|
||||
this.systemStatsVisibilityHandler
|
||||
&& typeof document !== 'undefined'
|
||||
&& typeof document.removeEventListener === 'function'
|
||||
) {
|
||||
document.removeEventListener('visibilitychange', this.systemStatsVisibilityHandler)
|
||||
}
|
||||
this.systemStatsVisibilityHandler = null
|
||||
},
|
||||
// ========== 初始化 ==========
|
||||
|
||||
initCollapsedStates() {
|
||||
// 环境配置分组默认折叠
|
||||
for (const key of Object.keys(ENV_CONFIG_SCHEMA)) {
|
||||
this.envCollapsed[key] = true;
|
||||
}
|
||||
// 浏览器常量分组默认折叠
|
||||
for (const [key] of Object.entries(BROWSER_CONSTANTS_SCHEMA)) {
|
||||
this.browserConstantsCollapsed[key] = true;
|
||||
}
|
||||
},
|
||||
|
||||
// ========== 夜间模式 ==========
|
||||
|
||||
applyDarkMode() {
|
||||
const isDark = !!this.darkMode
|
||||
const targets = [
|
||||
document.documentElement,
|
||||
document.body,
|
||||
document.getElementById('app')
|
||||
].filter(Boolean)
|
||||
for (const el of targets) {
|
||||
el.classList.remove('dark', 'light')
|
||||
el.classList.add(isDark ? 'dark' : 'light')
|
||||
el.setAttribute('data-theme', isDark ? 'dark' : 'light')
|
||||
}
|
||||
document.documentElement.style.colorScheme = isDark ? 'dark' : 'light'
|
||||
},
|
||||
|
||||
toggleDarkMode() {
|
||||
this.darkMode = !this.darkMode
|
||||
this.applyDarkMode()
|
||||
try {
|
||||
localStorage.setItem('darkMode', this.darkMode.toString())
|
||||
} catch (e) {
|
||||
// ignore storage failures and keep runtime theme switch available
|
||||
}
|
||||
this.notify('已切换到' + (this.darkMode ? '夜间' : '日间') + '模式', 'success')
|
||||
},
|
||||
|
||||
// ========== 菜单控制 ==========
|
||||
|
||||
toggleSelectorMenu() {
|
||||
this.showSelectorMenu = !this.showSelectorMenu
|
||||
},
|
||||
|
||||
toggleImportMenu(e) {
|
||||
if (e && typeof e.stopPropagation === 'function') e.stopPropagation();
|
||||
this.showImportMenu = !this.showImportMenu;
|
||||
this.showExportMenu = false;
|
||||
},
|
||||
|
||||
toggleExportMenu(e) {
|
||||
if (e && typeof e.stopPropagation === 'function') e.stopPropagation();
|
||||
this.showExportMenu = !this.showExportMenu;
|
||||
this.showImportMenu = false;
|
||||
},
|
||||
|
||||
closeAllMenus() {
|
||||
this.showSelectorMenu = false;
|
||||
this.showImportMenu = false;
|
||||
this.showExportMenu = false;
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,468 @@
|
||||
// R2-8:由 dashboard-methods.js 拆分——数据、选择器与工作流操作。方法原样迁出,由 dashboard-methods.js 统一组装。
|
||||
(() => {
|
||||
const {
|
||||
DEFAULT_SELECTOR_DEFINITIONS,
|
||||
BROWSER_CONSTANTS_SCHEMA,
|
||||
ENV_CONFIG_SCHEMA,
|
||||
DASHBOARD_TOKEN_STORAGE_KEY,
|
||||
LEGACY_API_TOKEN_STORAGE_KEY,
|
||||
SITE_CONFIG_IMPORT_MAX_BYTES,
|
||||
SETTINGS_BACKUP_IMPORT_MAX_BYTES,
|
||||
importFileSizeError,
|
||||
formatGitCompareErrorText,
|
||||
getStoredDashboardToken,
|
||||
setStoredDashboardToken,
|
||||
SITE_FRIENDLY_NAMES,
|
||||
GENERIC_DOMAIN_LABELS,
|
||||
siteDisplayName,
|
||||
} = window.DashboardShared;
|
||||
(window.DashboardMethodParts = window.DashboardMethodParts || []).push({
|
||||
// ========== 数据操作 ==========
|
||||
|
||||
normalizeConfig(raw) {
|
||||
const norm = {}
|
||||
// 预设内的字段列表(用于清理顶层残留)
|
||||
const PRESET_FIELDS = [
|
||||
'selectors', 'workflow', 'stealth', 'stream_config',
|
||||
'image_extraction', 'file_paste', 'prompt_padding',
|
||||
'extractor_id', 'extractor_verified', 'model_catalog'
|
||||
]
|
||||
for (const [k, v] of Object.entries(raw || {})) {
|
||||
if (v.presets) {
|
||||
// 新格式:保留 presets 结构,确保每个预设有基本字段
|
||||
const normalizedPresets = {}
|
||||
for (const [presetName, presetData] of Object.entries(v.presets)) {
|
||||
normalizedPresets[presetName] = {
|
||||
...presetData,
|
||||
selectors: presetData.selectors || {},
|
||||
workflow: presetData.workflow || [],
|
||||
stealth: !!presetData.stealth
|
||||
}
|
||||
}
|
||||
const presetKeys = Object.keys(normalizedPresets)
|
||||
const configuredDefault = typeof v.default_preset === 'string'
|
||||
? v.default_preset
|
||||
: null
|
||||
const resolvedDefault = (configuredDefault && normalizedPresets[configuredDefault])
|
||||
? configuredDefault
|
||||
: (normalizedPresets['主预设'] ? '主预设' : (presetKeys[0] || '主预设'))
|
||||
// 构建站点对象,只保留 presets,清理预设外的残留字段
|
||||
const siteObj = {
|
||||
presets: normalizedPresets,
|
||||
default_preset: resolvedDefault
|
||||
}
|
||||
// 保留非预设字段(如未来可能的站点级元数据)
|
||||
for (const [field, value] of Object.entries(v)) {
|
||||
if (field !== 'presets' && field !== 'default_preset' && !PRESET_FIELDS.includes(field)) {
|
||||
siteObj[field] = value
|
||||
}
|
||||
}
|
||||
if (siteObj.domain) {
|
||||
siteObj.domain = k
|
||||
}
|
||||
norm[k] = siteObj
|
||||
} else {
|
||||
// 旧格式兼容:包装为预设(后端迁移后不应再出现,但做兜底)
|
||||
norm[k] = {
|
||||
default_preset: '主预设',
|
||||
presets: {
|
||||
'主预设': {
|
||||
...v,
|
||||
selectors: v.selectors || {},
|
||||
workflow: v.workflow || [],
|
||||
stealth: !!v.stealth
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return norm
|
||||
},
|
||||
|
||||
validateConfig() {
|
||||
if (!this.currentDomain || !this.currentConfig) {
|
||||
this.notify('请选择站点', 'warning')
|
||||
return false
|
||||
}
|
||||
|
||||
// 获取当前活跃预设的配置
|
||||
const presetConfig = this.getActivePresetConfig()
|
||||
if (!presetConfig) {
|
||||
this.notify('无法获取预设配置', 'error')
|
||||
return false
|
||||
}
|
||||
|
||||
const selectors = presetConfig.selectors || {}
|
||||
const workflow = presetConfig.workflow || []
|
||||
const hasSelectorActions = workflow.some(step => ['FILL_INPUT', 'SELECT_MODEL', 'CLICK', 'STREAM_WAIT'].includes(step.action))
|
||||
if (hasSelectorActions && Object.keys(selectors).length === 0) {
|
||||
this.notify('至少需要一个选择器', 'warning')
|
||||
return false
|
||||
}
|
||||
|
||||
for (let i = 0; i < workflow.length; i++) {
|
||||
const step = workflow[i]
|
||||
|
||||
if (!step.action) {
|
||||
this.notify('步骤 ' + (i + 1) + ': 缺少动作类型', 'error')
|
||||
return false
|
||||
}
|
||||
|
||||
if (['FILL_INPUT', 'SELECT_MODEL', 'CLICK', 'STREAM_WAIT'].includes(step.action)) {
|
||||
if (!step.target) {
|
||||
this.notify('步骤 ' + (i + 1) + ': 请选择目标选择器', 'error')
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (step.action === 'COORD_CLICK') {
|
||||
const x = Number(step.value?.x)
|
||||
const y = Number(step.value?.y)
|
||||
if (!Number.isFinite(x) || !Number.isFinite(y)) {
|
||||
this.notify('步骤 ' + (i + 1) + ': 请输入有效的 X/Y 坐标', 'error')
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (step.action === 'COORD_SCROLL') {
|
||||
const startX = Number(step.value?.start_x)
|
||||
const startY = Number(step.value?.start_y)
|
||||
const endX = Number(step.value?.end_x)
|
||||
const endY = Number(step.value?.end_y)
|
||||
if (![startX, startY, endX, endY].every(Number.isFinite)) {
|
||||
this.notify('步骤 ' + (i + 1) + ': 请输入完整的起点/终点坐标', 'error')
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (step.action === 'KEY_PRESS' && !step.target) {
|
||||
this.notify('步骤 ' + (i + 1) + ': 请输入按键名称', 'error')
|
||||
return false
|
||||
}
|
||||
|
||||
if (step.action === 'WAIT' && (!step.value || step.value <= 0)) {
|
||||
this.notify('步骤 ' + (i + 1) + ': 等待时间必须大于 0', 'error')
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < workflow.length; i++) {
|
||||
const step = workflow[i]
|
||||
if (step.action === 'JS_EXEC' && !String(step.value || '').trim()) {
|
||||
this.notify('步骤 ' + (i + 1) + ': 请输入 JavaScript 代码', 'error')
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
|
||||
selectSite(domain) {
|
||||
if (!domain || !this.sites[domain]) return
|
||||
this.flushConfigTabDrafts()
|
||||
this.currentDomain = domain
|
||||
this.siteConfigView = 'editor'
|
||||
this.searchQuery = ''
|
||||
this.$nextTick(() => document.querySelector('.dashboard-scroll-region')?.scrollTo({ top: 0 }))
|
||||
},
|
||||
|
||||
selectSiteFromSearch(domain) {
|
||||
if (!domain) return
|
||||
this.selectSite(domain)
|
||||
this.searchQuery = ''
|
||||
},
|
||||
|
||||
addNewSite() {
|
||||
const domain = prompt('请输入域名(例如: chat.example.com):')
|
||||
if (!domain) return
|
||||
this.siteConfigView = 'editor'
|
||||
|
||||
if (this.sites[domain]) {
|
||||
this.notify('该站点已存在', 'warning')
|
||||
this.currentDomain = domain
|
||||
return
|
||||
}
|
||||
|
||||
this.sites[domain] = {
|
||||
default_preset: '主预设',
|
||||
presets: {
|
||||
'主预设': {
|
||||
selectors: {},
|
||||
workflow: [],
|
||||
stealth: false
|
||||
}
|
||||
}
|
||||
}
|
||||
this.currentDomain = domain
|
||||
this.notify('已创建站点: ' + domain, 'success')
|
||||
},
|
||||
|
||||
confirmDelete(domain) {
|
||||
if (!confirm('确定要删除 ' + domain + ' 的配置吗?')) {
|
||||
return
|
||||
}
|
||||
|
||||
delete this.sites[domain]
|
||||
|
||||
if (this.currentDomain === domain) {
|
||||
this.currentDomain = Object.keys(this.sites)[0] || null
|
||||
}
|
||||
|
||||
this.notify('已删除: ' + domain, 'info')
|
||||
},
|
||||
|
||||
// ========== 选择器操作 ==========
|
||||
|
||||
addSelector(preset) {
|
||||
this.showSelectorMenu = false
|
||||
const pc = this.getActivePresetConfig()
|
||||
if (!pc) return
|
||||
|
||||
let key
|
||||
if (preset === 'custom') {
|
||||
key = prompt('请输入选择器名称(例如: input_box)')
|
||||
if (!key) return
|
||||
} else {
|
||||
key = preset
|
||||
}
|
||||
|
||||
if (pc.selectors[key]) {
|
||||
this.notify('选择器 "' + key + '" 已存在', 'warning')
|
||||
return
|
||||
}
|
||||
|
||||
pc.selectors[key] = ''
|
||||
this.notify('已添加选择器: ' + key, 'success')
|
||||
},
|
||||
|
||||
removeSelector(key) {
|
||||
if (!confirm('确定删除选择器 ' + key + ' 吗?')) {
|
||||
return
|
||||
}
|
||||
|
||||
const pc = this.getActivePresetConfig()
|
||||
if (!pc) return
|
||||
|
||||
delete pc.selectors[key]
|
||||
|
||||
; (pc.workflow || []).forEach(function (step) {
|
||||
if (step.target === key) {
|
||||
step.target = ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
updateSelectorKey(oldKey, newKey) {
|
||||
if (!newKey || oldKey === newKey) return
|
||||
|
||||
newKey = newKey.trim()
|
||||
|
||||
const pc = this.getActivePresetConfig()
|
||||
if (!pc) return
|
||||
|
||||
if (pc.selectors[newKey]) {
|
||||
this.notify('该键名已存在', 'error')
|
||||
return
|
||||
}
|
||||
|
||||
pc.selectors[newKey] = pc.selectors[oldKey]
|
||||
delete pc.selectors[oldKey]
|
||||
|
||||
; (pc.workflow || []).forEach(function (step) {
|
||||
if (step.target === oldKey) {
|
||||
step.target = newKey
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// ========== 工作流操作 ==========
|
||||
|
||||
addStep() {
|
||||
const pc = this.getActivePresetConfig()
|
||||
if (!pc) return
|
||||
|
||||
const defaultStep = {
|
||||
action: 'CLICK',
|
||||
target: '',
|
||||
optional: false,
|
||||
value: null
|
||||
}
|
||||
|
||||
if (!pc.workflow) pc.workflow = []
|
||||
pc.workflow.push(defaultStep)
|
||||
},
|
||||
|
||||
removeStep(index) {
|
||||
const pc = this.getActivePresetConfig()
|
||||
if (!pc || !pc.workflow) return
|
||||
|
||||
pc.workflow.splice(index, 1)
|
||||
},
|
||||
|
||||
moveStep(index, direction) {
|
||||
const pc = this.getActivePresetConfig()
|
||||
if (!pc || !pc.workflow) return
|
||||
|
||||
const arr = pc.workflow
|
||||
const newIndex = index + direction
|
||||
|
||||
if (newIndex < 0 || newIndex >= arr.length) return
|
||||
|
||||
const temp = arr[index]
|
||||
arr[index] = arr[newIndex]
|
||||
arr[newIndex] = temp
|
||||
},
|
||||
|
||||
onActionChange(step) {
|
||||
if (step.action === 'SELECT_MODEL') {
|
||||
if (!step.target) step.target = 'model_select_btn'
|
||||
step.value = { timeout: Number(step.value?.timeout ?? 3) }
|
||||
} else if (['FILL_INPUT', 'CLICK', 'STREAM_WAIT'].includes(step.action)) {
|
||||
step.value = null
|
||||
if (!step.target) step.target = ''
|
||||
} else if (step.action === 'PAGE_FETCH') {
|
||||
step.target = ''
|
||||
step.optional = true
|
||||
step.value = null
|
||||
} else if (step.action === 'READONLY_HINT') {
|
||||
step.target = ''
|
||||
const current = (step.value && typeof step.value === 'object' && !Array.isArray(step.value))
|
||||
? step.value
|
||||
: {}
|
||||
step.value = {
|
||||
title: String(current.title || '提示'),
|
||||
text: String(current.text || '这是一条只读提示,不会在执行时触发页面操作。'),
|
||||
tone: ['info', 'success', 'warning', 'danger'].includes(String(current.tone || '').trim().toLowerCase())
|
||||
? String(current.tone || '').trim().toLowerCase()
|
||||
: 'info'
|
||||
}
|
||||
} else if (step.action === 'COORD_CLICK') {
|
||||
step.target = ''
|
||||
step.value = {
|
||||
x: Number(step.value?.x ?? 0),
|
||||
y: Number(step.value?.y ?? 0),
|
||||
random_radius: Number(step.value?.random_radius ?? 10)
|
||||
}
|
||||
} else if (step.action === 'COORD_SCROLL') {
|
||||
step.target = ''
|
||||
step.value = {
|
||||
start_x: Number(step.value?.start_x ?? 0),
|
||||
start_y: Number(step.value?.start_y ?? 0),
|
||||
end_x: Number(step.value?.end_x ?? 0),
|
||||
end_y: Number(step.value?.end_y ?? 300)
|
||||
}
|
||||
} else if (step.action === 'KEY_PRESS') {
|
||||
step.value = null
|
||||
if (!step.target) step.target = 'Enter'
|
||||
} else if (step.action === 'JS_EXEC') {
|
||||
step.target = ''
|
||||
if (!String(step.value || '').trim()) step.value = 'return document.title;'
|
||||
} else if (step.action === 'WAIT') {
|
||||
step.target = ''
|
||||
if (!step.value) step.value = '1.0'
|
||||
}
|
||||
},
|
||||
|
||||
showTemplates() {
|
||||
this.showStepTemplates = true
|
||||
},
|
||||
|
||||
applyTemplate(type) {
|
||||
const templates = {
|
||||
'default': [
|
||||
{ action: 'CLICK', target: 'new_chat_btn', optional: true, value: null },
|
||||
{ action: 'WAIT', target: '', optional: false, value: '0.5' },
|
||||
{ action: 'FILL_INPUT', target: 'input_box', optional: false, value: null },
|
||||
{ action: 'CLICK', target: 'send_btn', optional: true, value: null },
|
||||
{ action: 'KEY_PRESS', target: 'Enter', optional: true, value: null },
|
||||
{ action: 'STREAM_WAIT', target: 'result_container', optional: false, value: null }
|
||||
],
|
||||
'simple': [
|
||||
{ action: 'FILL_INPUT', target: 'input_box', optional: false, value: null },
|
||||
{ action: 'KEY_PRESS', target: 'Enter', optional: false, value: null },
|
||||
{ action: 'STREAM_WAIT', target: 'result_container', optional: false, value: null }
|
||||
],
|
||||
'experimental_hint': [
|
||||
{ action: 'READONLY_HINT', target: '', optional: false, value: { title: '提示', text: '这是一条只读提示,不会影响执行,只用于说明当前工作流中的特殊行为。', tone: 'info' } },
|
||||
{ action: 'PAGE_FETCH', target: '', optional: true, value: null },
|
||||
{ action: 'FILL_INPUT', target: 'input_box', optional: false, value: null },
|
||||
{ action: 'KEY_PRESS', target: 'Enter', optional: false, value: null },
|
||||
{ action: 'STREAM_WAIT', target: 'result_container', optional: false, value: null }
|
||||
],
|
||||
'battle_winner': [
|
||||
{ action: 'WAIT', target: '', optional: false, value: 2 },
|
||||
{ action: 'FILL_INPUT', target: 'input_box', optional: false, value: null },
|
||||
{ action: 'WAIT', target: '', optional: false, value: 0.5 },
|
||||
{ action: 'CLICK', target: 'retry_send_btn', optional: true, value: null },
|
||||
{ action: 'WAIT', target: '', optional: false, value: 0.2 },
|
||||
{ action: 'CLICK', target: 'send_btn', optional: false, value: null },
|
||||
{ action: 'STREAM_WAIT', target: 'result_container', optional: false, value: null }
|
||||
],
|
||||
'battle_left': [
|
||||
{ action: 'WAIT', target: '', optional: false, value: 1 },
|
||||
{ action: 'FILL_INPUT', target: 'input_box', optional: false, value: null },
|
||||
{ action: 'CLICK', target: 'retry_send_btn', optional: true, value: null },
|
||||
{ action: 'WAIT', target: '', optional: false, value: 0.8 },
|
||||
{ action: 'CLICK', target: 'send_btn', optional: true, value: null },
|
||||
{ action: 'STREAM_WAIT', target: 'result_container', optional: false, value: null }
|
||||
],
|
||||
'battle_right': [
|
||||
{ action: 'WAIT', target: '', optional: false, value: 2 },
|
||||
{ action: 'FILL_INPUT', target: 'input_box', optional: false, value: null },
|
||||
{ action: 'WAIT', target: '', optional: false, value: 0.5 },
|
||||
{ action: 'CLICK', target: 'retry_send_btn', optional: true, value: null },
|
||||
{ action: 'WAIT', target: '', optional: false, value: 0.2 },
|
||||
{ action: 'CLICK', target: 'send_btn', optional: false, value: null },
|
||||
{ action: 'STREAM_WAIT', target: 'result_container', optional: false, value: null }
|
||||
]
|
||||
}
|
||||
|
||||
if (!confirm('这将覆盖当前的工作流配置,确定继续吗?')) {
|
||||
return
|
||||
}
|
||||
|
||||
const pc = this.getActivePresetConfig()
|
||||
if (!pc) return
|
||||
pc.workflow = JSON.parse(JSON.stringify(templates[type]))
|
||||
|
||||
const battleParserMap = {
|
||||
battle_winner: 'lmarena_battle_winner',
|
||||
battle_left: 'lmarena_battle_side_left',
|
||||
battle_right: 'lmarena_battle_side_right'
|
||||
}
|
||||
if (battleParserMap[type]) {
|
||||
pc.selectors = {
|
||||
...(pc.selectors || {}),
|
||||
retry_send_btn: pc.selectors?.retry_send_btn || 'button[aria-label="Rerun stopped messages"], button[data-slot="tooltip-trigger"]:has(svg path[d*="21.8883"])',
|
||||
send_btn: pc.selectors?.send_btn || 'button[aria-label="Send message"][type="submit"]:not(:disabled):not([aria-disabled="true"]), button[aria-label="Stop generation"]',
|
||||
generating_indicator: pc.selectors?.generating_indicator || 'button[aria-label="Stop generation"]'
|
||||
}
|
||||
pc.stream_config = {
|
||||
...((pc && pc.stream_config) || {}),
|
||||
mode: 'network',
|
||||
send_confirmation: {
|
||||
...(((pc && pc.stream_config) || {}).send_confirmation || {}),
|
||||
max_retry_count: 0,
|
||||
retry_on_unconfirmed_send: false,
|
||||
post_click_observe_window: 0.5,
|
||||
pre_retry_probe_window: 0,
|
||||
retry_observe_window: 0,
|
||||
trust_generating_indicator: true,
|
||||
trust_network_activity: true
|
||||
},
|
||||
network: {
|
||||
...(((pc && pc.stream_config) || {}).network || {}),
|
||||
parser: battleParserMap[type],
|
||||
url_pattern: '**/nextjs-api/stream/create-evaluation**',
|
||||
method: 'POST',
|
||||
listen_pattern: '/nextjs-api/stream/create-evaluation',
|
||||
silence_threshold: 10,
|
||||
response_interval: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
this.showStepTemplates = false
|
||||
this.notify('模板已应用', 'success')
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,177 @@
|
||||
// R2-8:由 dashboard-methods.js 拆分——日志。方法原样迁出,由 dashboard-methods.js 统一组装。
|
||||
(() => {
|
||||
const {
|
||||
DEFAULT_SELECTOR_DEFINITIONS,
|
||||
BROWSER_CONSTANTS_SCHEMA,
|
||||
ENV_CONFIG_SCHEMA,
|
||||
DASHBOARD_TOKEN_STORAGE_KEY,
|
||||
LEGACY_API_TOKEN_STORAGE_KEY,
|
||||
SITE_CONFIG_IMPORT_MAX_BYTES,
|
||||
SETTINGS_BACKUP_IMPORT_MAX_BYTES,
|
||||
importFileSizeError,
|
||||
formatGitCompareErrorText,
|
||||
getStoredDashboardToken,
|
||||
setStoredDashboardToken,
|
||||
SITE_FRIENDLY_NAMES,
|
||||
GENERIC_DOMAIN_LABELS,
|
||||
siteDisplayName,
|
||||
} = window.DashboardShared;
|
||||
(window.DashboardMethodParts = window.DashboardMethodParts || []).push({
|
||||
// ========== 日志相关 ==========
|
||||
|
||||
async pollLogs(options = {}) {
|
||||
if (this.pauseLogs || document.visibilityState === 'hidden') return;
|
||||
if (
|
||||
!this.getBrowserConstantBool('LOG_WEB_COLLECTOR_ENABLED', true)
|
||||
|| this.getBrowserConstantNumber('LOG_WEB_MAX_RECORDS', 5000, { min: 0 }) <= 0
|
||||
) {
|
||||
this.logs = [];
|
||||
this.lastLogSeq = 0;
|
||||
this.lastLogTimestamp = 0;
|
||||
this.logPollPending = false;
|
||||
return;
|
||||
}
|
||||
if (this.isPollingLogs) {
|
||||
this.logPollPending = true;
|
||||
return;
|
||||
}
|
||||
if (options && options.background) {
|
||||
const now = Date.now();
|
||||
const backgroundInterval = this.getDashboardPollInterval('DASHBOARD_LOG_BACKGROUND_POLL_INTERVAL_MS', 5000)
|
||||
|| this.getDashboardPollInterval('DASHBOARD_LOG_POLL_INTERVAL_MS', 1000);
|
||||
if (this.lastBackgroundLogPollAt && backgroundInterval > 0 && now - this.lastBackgroundLogPollAt < backgroundInterval) {
|
||||
return;
|
||||
}
|
||||
this.lastBackgroundLogPollAt = now;
|
||||
}
|
||||
|
||||
this.isPollingLogs = true;
|
||||
const generation = Number(this.logGeneration || 0);
|
||||
try {
|
||||
const result = await this.apiRequest('/api/logs?after_seq=' + this.lastLogSeq);
|
||||
if (generation !== Number(this.logGeneration || 0)) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!this.getBrowserConstantBool('LOG_WEB_COLLECTOR_ENABLED', true)
|
||||
|| this.getBrowserConstantNumber('LOG_WEB_MAX_RECORDS', 5000, { min: 0 }) <= 0
|
||||
) {
|
||||
this.logs = [];
|
||||
this.lastLogSeq = 0;
|
||||
this.lastLogTimestamp = 0;
|
||||
this.logPollPending = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.cleared) {
|
||||
this.logs = [];
|
||||
this.lastLogSeq = 0;
|
||||
this.lastLogTimestamp = 0;
|
||||
}
|
||||
|
||||
if (result.logs && result.logs.length > 0) {
|
||||
const nextLogs = result.logs.map(log => {
|
||||
const messageText = log.message_text || log.display_message || log.message || '';
|
||||
const kind = log.kind || log.level;
|
||||
return {
|
||||
id: log.seq || (Date.now() + Math.random()),
|
||||
seq: log.seq || 0,
|
||||
timestamp: new Date(log.timestamp * 1000).toLocaleTimeString() + '.' +
|
||||
String(Math.floor((log.timestamp % 1) * 1000)).padStart(3, '0'),
|
||||
level: this.normalizeLogLevel(kind, messageText),
|
||||
rawLevel: String(log.level || '').toUpperCase(),
|
||||
kind: String(kind || '').toUpperCase(),
|
||||
logger: log.logger || '',
|
||||
requestId: log.request_id || 'SYSTEM',
|
||||
requestTag: log.request_tag || log.request_id || 'SYSTEM',
|
||||
message: log.display_message || log.message || messageText,
|
||||
messageText,
|
||||
originalMessageText: log.original_message_text || messageText,
|
||||
messageAlias: log.message_alias || ''
|
||||
}
|
||||
});
|
||||
const maxLogs = Math.floor(this.getBrowserConstantNumber('LOG_WEB_MAX_RECORDS', 5000, { min: 0, max: 10000 }));
|
||||
this.logs = maxLogs > 0 ? this.logs.concat(nextLogs).slice(-maxLogs) : [];
|
||||
}
|
||||
this.lastLogSeq = Number(result.next_seq || this.lastLogSeq || 0);
|
||||
this.lastLogTimestamp = Number(result.timestamp || this.lastLogTimestamp || 0);
|
||||
} catch (error) {
|
||||
if (generation === Number(this.logGeneration || 0)) {
|
||||
console.debug('日志轮询失败:', error.message);
|
||||
}
|
||||
} finally {
|
||||
if (generation === Number(this.logGeneration || 0)) {
|
||||
this.isPollingLogs = false;
|
||||
if (this.logPollPending && !this.pauseLogs && document.visibilityState !== 'hidden') {
|
||||
this.logPollPending = false;
|
||||
this.pollLogs({ ...(options || {}), background: false }).catch(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
normalizeLogLevel(level, message) {
|
||||
const normalized = String(level || '').toUpperCase();
|
||||
if (normalized === 'WARNING') return 'WARN';
|
||||
if (normalized === 'CRITICAL') return 'ERROR';
|
||||
if (normalized === 'SUCCESS') return 'OK';
|
||||
if (normalized === 'DEBUG' || normalized === 'WARN' || normalized === 'ERROR') {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
if (normalized === 'INFO') {
|
||||
if (message.includes('[AI]')) return 'AI';
|
||||
if (message.includes('[OK]') || message.includes('[SUCCESS]') || message.includes('✅')) return 'OK';
|
||||
return 'INFO';
|
||||
}
|
||||
|
||||
if (message.includes('[AI]')) return 'AI';
|
||||
if (message.includes('[ERROR]')) return 'ERROR';
|
||||
if (message.includes('[WARN]') || message.includes('[WARNING]')) return 'WARN';
|
||||
if (message.includes('[OK]') || message.includes('[SUCCESS]') || message.includes('✅')) return 'OK';
|
||||
return 'INFO';
|
||||
},
|
||||
|
||||
getLogColorClass(level) {
|
||||
const colors = {
|
||||
'DEBUG': 'bg-slate-50 dark:bg-slate-900/30',
|
||||
'INFO': 'bg-green-50 dark:bg-green-900/20',
|
||||
'AI': 'bg-purple-50 dark:bg-purple-900/20',
|
||||
'OK': 'bg-green-50 dark:bg-green-900/20',
|
||||
'WARN': 'bg-yellow-50 dark:bg-yellow-900/20',
|
||||
'ERROR': 'bg-red-50 dark:bg-red-900/20',
|
||||
'KEY': 'bg-sky-50 dark:bg-sky-900/20'
|
||||
};
|
||||
return colors[level] || colors['INFO'];
|
||||
},
|
||||
|
||||
getLogLevelClass(level) {
|
||||
const colors = {
|
||||
'DEBUG': 'text-slate-500 dark:text-slate-400',
|
||||
'INFO': 'text-green-600 dark:text-green-400',
|
||||
'AI': 'text-purple-600 dark:text-purple-400',
|
||||
'OK': 'text-green-600 dark:text-green-400',
|
||||
'WARN': 'text-yellow-600 dark:text-yellow-400',
|
||||
'ERROR': 'text-red-600 dark:text-red-400',
|
||||
'KEY': 'text-sky-500 dark:text-sky-300'
|
||||
};
|
||||
return colors[level] || colors['INFO'];
|
||||
},
|
||||
|
||||
clearLogs() {
|
||||
if (confirm('确定清除所有日志吗?')) {
|
||||
this.logGeneration = Number(this.logGeneration || 0) + 1;
|
||||
this.logs = [];
|
||||
this.lastLogSeq = 0;
|
||||
this.lastLogTimestamp = 0;
|
||||
this.isPollingLogs = false;
|
||||
this.logPollPending = false;
|
||||
|
||||
this.apiRequest('/api/logs', { method: 'DELETE' })
|
||||
.catch(() => { });
|
||||
|
||||
this.notify('日志已清除', 'success');
|
||||
}
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,206 @@
|
||||
// R2-8:由 dashboard-methods.js 拆分——图片配置。方法原样迁出,由 dashboard-methods.js 统一组装。
|
||||
(() => {
|
||||
const {
|
||||
DEFAULT_SELECTOR_DEFINITIONS,
|
||||
BROWSER_CONSTANTS_SCHEMA,
|
||||
ENV_CONFIG_SCHEMA,
|
||||
DASHBOARD_TOKEN_STORAGE_KEY,
|
||||
LEGACY_API_TOKEN_STORAGE_KEY,
|
||||
SITE_CONFIG_IMPORT_MAX_BYTES,
|
||||
SETTINGS_BACKUP_IMPORT_MAX_BYTES,
|
||||
importFileSizeError,
|
||||
formatGitCompareErrorText,
|
||||
getStoredDashboardToken,
|
||||
setStoredDashboardToken,
|
||||
SITE_FRIENDLY_NAMES,
|
||||
GENERIC_DOMAIN_LABELS,
|
||||
siteDisplayName,
|
||||
} = window.DashboardShared;
|
||||
(window.DashboardMethodParts = window.DashboardMethodParts || []).push({
|
||||
// ========== 图片配置 (新增) ==========
|
||||
|
||||
// 🆕 更新图片配置
|
||||
async updateImageConfig(newConfig) {
|
||||
if (!this.currentDomain || !this.currentConfig) return;
|
||||
|
||||
const domain = this.currentDomain
|
||||
const pc = this.getActivePresetConfig()
|
||||
const presetName = this.getActivePresetName()
|
||||
const nextConfig = JSON.parse(JSON.stringify(newConfig || {}))
|
||||
const saveSeq = Number(this.imageConfigSaveSeq || 0) + 1
|
||||
this.imageConfigSaveSeq = saveSeq
|
||||
|
||||
if (pc) pc.image_extraction = nextConfig;
|
||||
|
||||
const previousSave = this.imageConfigSaveQueue || Promise.resolve()
|
||||
const saveRequest = previousSave
|
||||
.catch(() => undefined)
|
||||
.then(() => {
|
||||
const payload = { ...nextConfig, preset_name: presetName }
|
||||
return this.apiRequest(`/api/sites/${encodeURIComponent(domain)}/image-config`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(payload)
|
||||
})
|
||||
})
|
||||
this.imageConfigSaveQueue = saveRequest
|
||||
|
||||
try {
|
||||
await saveRequest
|
||||
if (
|
||||
saveSeq === this.imageConfigSaveSeq
|
||||
&& domain === this.currentDomain
|
||||
&& presetName === this.getActivePresetName()
|
||||
) {
|
||||
this.notify('多模态提取配置已保存', 'success')
|
||||
}
|
||||
} catch (error) {
|
||||
if (
|
||||
saveSeq === this.imageConfigSaveSeq
|
||||
&& domain === this.currentDomain
|
||||
&& presetName === this.getActivePresetName()
|
||||
) {
|
||||
console.error('保存图片配置失败:', error)
|
||||
this.notify('保存多模态提取配置失败: ' + error.message, 'error')
|
||||
await this.reloadConfig()
|
||||
}
|
||||
} finally {
|
||||
if (this.imageConfigSaveQueue === saveRequest) {
|
||||
this.imageConfigSaveQueue = null
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 🆕 重新加载当前站点配置(应用预设后调用)
|
||||
async reloadConfig() {
|
||||
if (!this.currentDomain) return;
|
||||
|
||||
try {
|
||||
const data = await this.apiRequest('/api/config/' + encodeURIComponent(this.currentDomain));
|
||||
// 返回的数据已经是预设格式 { presets: { ... } }
|
||||
// 对其进行规范化确保结构完整
|
||||
const normalized = this.normalizeConfig({ [this.currentDomain]: data })
|
||||
if (normalized[this.currentDomain]) {
|
||||
this.sites[this.currentDomain] = normalized[this.currentDomain]
|
||||
}
|
||||
this.notify('配置已重新加载', 'success');
|
||||
} catch (error) {
|
||||
console.error('重新加载配置失败:', error);
|
||||
this.notify('加载失败: ' + error.message, 'error');
|
||||
}
|
||||
},
|
||||
|
||||
async openMainCompareSummaryDialog() {
|
||||
this.showMainCompareSummaryDialog = true;
|
||||
await this.loadMainCompareSummary();
|
||||
},
|
||||
|
||||
closeMainCompareSummaryDialog() {
|
||||
this.showMainCompareSummaryDialog = false;
|
||||
},
|
||||
|
||||
formatOfficialConfigSourceTime(value) {
|
||||
const raw = String(value || '').trim();
|
||||
if (!raw) return '';
|
||||
const timestamp = new Date(raw);
|
||||
if (Number.isNaN(timestamp.getTime())) return raw;
|
||||
return timestamp.toLocaleString('zh-CN', { hour12: false });
|
||||
},
|
||||
|
||||
async loadMainCompareSummary() {
|
||||
this.mainCompareSummaryLoading = true;
|
||||
this.mainCompareSummaryError = '';
|
||||
try {
|
||||
const data = await this.apiRequest('/api/config/compare-main-summary');
|
||||
this.mainCompareSummaryItems = Array.isArray(data.items) ? data.items : [];
|
||||
this.mainCompareSummaryCounts = {
|
||||
same: 0,
|
||||
different: 0,
|
||||
local_only_preset: 0,
|
||||
local_only_site: 0,
|
||||
main_only_preset: 0,
|
||||
main_only_site: 0,
|
||||
...(data.counts || {})
|
||||
};
|
||||
this.mainCompareSummaryPath = String(data.path || 'config/sites/index.json').trim() || 'config/sites/index.json';
|
||||
this.mainCompareSummarySource = {
|
||||
repository: '',
|
||||
branch: 'main',
|
||||
status: '',
|
||||
stale: false,
|
||||
fetched_at: '',
|
||||
checked_at: '',
|
||||
warning: '',
|
||||
...(data.source || {})
|
||||
};
|
||||
return true;
|
||||
} catch (error) {
|
||||
this.mainCompareSummaryItems = [];
|
||||
this.mainCompareSummarySource = {
|
||||
repository: '',
|
||||
branch: 'main',
|
||||
status: '',
|
||||
stale: false,
|
||||
fetched_at: '',
|
||||
checked_at: '',
|
||||
warning: ''
|
||||
};
|
||||
this.mainCompareSummaryError = formatGitCompareErrorText(error);
|
||||
return false;
|
||||
} finally {
|
||||
this.mainCompareSummaryLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
getMainCompareStatusClass(status) {
|
||||
if (status === 'different') {
|
||||
return 'border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-900/30 dark:text-amber-300';
|
||||
}
|
||||
if (status === 'local_only_preset') {
|
||||
return 'border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-800 dark:bg-blue-900/30 dark:text-blue-300';
|
||||
}
|
||||
if (status === 'local_only_site') {
|
||||
return 'border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-800 dark:bg-rose-900/30 dark:text-rose-300';
|
||||
}
|
||||
return 'border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-300';
|
||||
},
|
||||
|
||||
getMainCompareStatusText(status) {
|
||||
if (status === 'different') return '字段不同';
|
||||
if (status === 'local_only_preset') return '本地自定义预设';
|
||||
if (status === 'local_only_site') return '本地自定义站点';
|
||||
return '与官方一致';
|
||||
},
|
||||
|
||||
async waitForConfigTabRef() {
|
||||
for (let attempt = 0; attempt < 30; attempt++) {
|
||||
await this.$nextTick();
|
||||
const ref = this.$refs.configTab;
|
||||
if (ref && typeof ref.openConfigCompareForPreset === 'function') {
|
||||
return ref;
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, 60));
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
async openMainCompareDetail(item) {
|
||||
if (!item || !item.domain) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.showMainCompareSummaryDialog = false;
|
||||
this.activeTab = 'config';
|
||||
this.currentDomain = item.domain;
|
||||
this.siteConfigView = 'editor';
|
||||
|
||||
const configTab = await this.waitForConfigTabRef();
|
||||
if (!configTab) {
|
||||
this.notify('配置面板尚未准备好', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const targetPreset = String(item.local_preset_name || '').trim();
|
||||
await configTab.openConfigCompareForPreset(targetPreset);
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,479 @@
|
||||
// R2-8:由 dashboard-methods.js 拆分——元素定义与预设辅助。方法原样迁出,由 dashboard-methods.js 统一组装。
|
||||
(() => {
|
||||
const {
|
||||
DEFAULT_SELECTOR_DEFINITIONS,
|
||||
BROWSER_CONSTANTS_SCHEMA,
|
||||
ENV_CONFIG_SCHEMA,
|
||||
DASHBOARD_TOKEN_STORAGE_KEY,
|
||||
LEGACY_API_TOKEN_STORAGE_KEY,
|
||||
SITE_CONFIG_IMPORT_MAX_BYTES,
|
||||
SETTINGS_BACKUP_IMPORT_MAX_BYTES,
|
||||
importFileSizeError,
|
||||
formatGitCompareErrorText,
|
||||
getStoredDashboardToken,
|
||||
setStoredDashboardToken,
|
||||
SITE_FRIENDLY_NAMES,
|
||||
GENERIC_DOMAIN_LABELS,
|
||||
siteDisplayName,
|
||||
} = window.DashboardShared;
|
||||
(window.DashboardMethodParts = window.DashboardMethodParts || []).push({
|
||||
// ========== 元素定义管理方法 ==========
|
||||
|
||||
async loadSelectorDefinitions() {
|
||||
this.isLoadingDefinitions = true;
|
||||
try {
|
||||
const data = await this.apiRequest('/api/settings/selector-definitions');
|
||||
this.selectorDefinitions = data.definitions || DEFAULT_SELECTOR_DEFINITIONS;
|
||||
this.selectorDefinitionsOriginal = JSON.parse(JSON.stringify(this.selectorDefinitions));
|
||||
} catch (error) {
|
||||
console.error('加载元素定义失败:', error);
|
||||
this.selectorDefinitions = JSON.parse(JSON.stringify(DEFAULT_SELECTOR_DEFINITIONS));
|
||||
this.selectorDefinitionsOriginal = JSON.parse(JSON.stringify(this.selectorDefinitions));
|
||||
} finally {
|
||||
this.isLoadingDefinitions = false;
|
||||
}
|
||||
},
|
||||
|
||||
async saveSelectorDefinitions() {
|
||||
this.isSavingDefinitions = true;
|
||||
try {
|
||||
await this.apiRequest('/api/settings/selector-definitions', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ definitions: this.selectorDefinitions })
|
||||
});
|
||||
|
||||
this.selectorDefinitionsOriginal = JSON.parse(JSON.stringify(this.selectorDefinitions));
|
||||
this.notify('元素定义已保存', 'success');
|
||||
} catch (error) {
|
||||
this.notify('保存失败: ' + error.message, 'error');
|
||||
} finally {
|
||||
this.isSavingDefinitions = false;
|
||||
}
|
||||
},
|
||||
|
||||
async resetSelectorDefinitions() {
|
||||
if (!confirm('确定要重置元素定义为默认值吗?')) return;
|
||||
|
||||
try {
|
||||
const data = await this.apiRequest('/api/settings/selector-definitions/reset', {
|
||||
method: 'POST'
|
||||
});
|
||||
|
||||
this.selectorDefinitions = data.definitions;
|
||||
this.selectorDefinitionsOriginal = JSON.parse(JSON.stringify(this.selectorDefinitions));
|
||||
this.notify('已重置为默认值', 'success');
|
||||
} catch (error) {
|
||||
this.notify('重置失败: ' + error.message, 'error');
|
||||
}
|
||||
},
|
||||
|
||||
toggleDefinitionEnabled(index) {
|
||||
const def = this.selectorDefinitions[index];
|
||||
|
||||
if (def.required) {
|
||||
this.notify('必需字段不能禁用', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
def.enabled = !def.enabled;
|
||||
},
|
||||
|
||||
openAddDefinitionDialog() {
|
||||
this.newDefinition = {
|
||||
key: '',
|
||||
description: '',
|
||||
enabled: true,
|
||||
required: false
|
||||
};
|
||||
this.editingDefinitionIndex = null;
|
||||
this.showAddDefinitionDialog = true;
|
||||
},
|
||||
|
||||
openEditDefinitionDialog(index) {
|
||||
const def = this.selectorDefinitions[index];
|
||||
this.newDefinition = { ...def };
|
||||
this.editingDefinitionIndex = index;
|
||||
this.showAddDefinitionDialog = true;
|
||||
},
|
||||
|
||||
saveDefinition() {
|
||||
if (!this.newDefinition.key.trim()) {
|
||||
this.notify('请输入关键词', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.newDefinition.description.trim()) {
|
||||
this.notify('请输入描述', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
const key = this.newDefinition.key.trim();
|
||||
const existingIndex = this.selectorDefinitions.findIndex(d => d.key === key);
|
||||
|
||||
if (this.editingDefinitionIndex === null) {
|
||||
// 新增模式
|
||||
if (existingIndex !== -1) {
|
||||
this.notify('关键词已存在', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
this.selectorDefinitions.push({
|
||||
key: key,
|
||||
description: this.newDefinition.description.trim(),
|
||||
enabled: this.newDefinition.enabled,
|
||||
required: false
|
||||
});
|
||||
} else {
|
||||
// 编辑模式
|
||||
if (existingIndex !== -1 && existingIndex !== this.editingDefinitionIndex) {
|
||||
this.notify('关键词已存在', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
this.selectorDefinitions[this.editingDefinitionIndex] = {
|
||||
...this.selectorDefinitions[this.editingDefinitionIndex],
|
||||
key: key,
|
||||
description: this.newDefinition.description.trim(),
|
||||
enabled: this.newDefinition.enabled
|
||||
};
|
||||
}
|
||||
|
||||
this.showAddDefinitionDialog = false;
|
||||
this.notify('已添加,请点击保存以应用', 'info');
|
||||
},
|
||||
|
||||
removeDefinition(index) {
|
||||
const def = this.selectorDefinitions[index];
|
||||
|
||||
if (def.required) {
|
||||
this.notify('必需字段不能删除', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm('确定要删除 "' + def.key + '" 吗?')) return;
|
||||
|
||||
this.selectorDefinitions.splice(index, 1);
|
||||
this.notify('已删除,请点击保存以应用', 'info');
|
||||
},
|
||||
|
||||
moveDefinition(index, direction) {
|
||||
const newIndex = index + direction;
|
||||
if (newIndex < 0 || newIndex >= this.selectorDefinitions.length) return;
|
||||
|
||||
const temp = this.selectorDefinitions[index];
|
||||
this.selectorDefinitions[index] = this.selectorDefinitions[newIndex];
|
||||
this.selectorDefinitions[newIndex] = temp;
|
||||
},
|
||||
|
||||
changeTab(tab) {
|
||||
this.markTabAsVisited(tab)
|
||||
this.activeTab = tab;
|
||||
},
|
||||
|
||||
handleSidebarPrimaryAction(tab) {
|
||||
if (tab === 'commands') {
|
||||
this.changeTab('commands')
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.commandsTab && typeof this.$refs.commandsTab.openNewCommand === 'function') {
|
||||
this.$refs.commandsTab.openNewCommand()
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
this.addNewSite()
|
||||
},
|
||||
|
||||
async ensureTabDataLoaded(tab) {
|
||||
if (tab === 'monitor') {
|
||||
const now = Date.now()
|
||||
const stale = now - Number(this.requestHistoryFetchedAt || 0) > 2000
|
||||
const loaders = [];
|
||||
if (this.isRequestMonitorEnabled()) {
|
||||
loaders.push(this.fetchRequestHistory({ silent: true, ifChanged: !stale }));
|
||||
} else {
|
||||
this.requestHistory = [];
|
||||
this.requestHistoryRevision = '';
|
||||
this.requestHistoryError = '';
|
||||
}
|
||||
if (this.isSystemStatsPollingEnabled()) {
|
||||
loaders.push(this.fetchSystemStats({ timeoutMs: 2500 }));
|
||||
}
|
||||
await Promise.all(loaders);
|
||||
return;
|
||||
}
|
||||
if (tab === 'settings' && !this.hasLoadedSettings) {
|
||||
this.hasLoadedSettings = true;
|
||||
await Promise.all([
|
||||
this.loadEnvConfig(),
|
||||
this.loadBrowserConstants(),
|
||||
this.loadUpdatePreserveSettings(),
|
||||
this.loadSelectorDefinitions(),
|
||||
this.loadReleases()
|
||||
]);
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
async fetchRequestHistory({ silent = false, ifChanged = false, force = false } = {}) {
|
||||
if (!this.isRequestMonitorEnabled()) {
|
||||
this.requestHistory = [];
|
||||
this.requestHistoryMaxRecords = 0;
|
||||
this.requestHistoryRevision = '';
|
||||
this.requestHistoryError = '';
|
||||
this.requestHistoryPendingRefresh = null;
|
||||
return this.requestHistory;
|
||||
}
|
||||
if (this.requestHistoryLoading) {
|
||||
this.requestHistoryPendingRefresh = {
|
||||
silent: this.requestHistoryPendingRefresh
|
||||
? (this.requestHistoryPendingRefresh.silent && silent)
|
||||
: silent,
|
||||
ifChanged: this.requestHistoryPendingRefresh
|
||||
? (this.requestHistoryPendingRefresh.ifChanged && ifChanged)
|
||||
: ifChanged,
|
||||
force: Boolean(force || (this.requestHistoryPendingRefresh && this.requestHistoryPendingRefresh.force))
|
||||
};
|
||||
return this.requestHistory;
|
||||
}
|
||||
const now = Date.now();
|
||||
if (!force && ifChanged && now - Number(this.requestHistoryFetchedAt || 0) < 1200) {
|
||||
return this.requestHistory;
|
||||
}
|
||||
this.requestHistoryLoading = true;
|
||||
if (!silent) {
|
||||
this.requestHistoryError = '';
|
||||
}
|
||||
const requestSeq = Number(this.requestHistoryRequestSeq || 0) + 1;
|
||||
this.requestHistoryRequestSeq = requestSeq;
|
||||
try {
|
||||
const maxRecords = this.getBrowserConstantNumber('REQUEST_MONITOR_MAX_RECORDS', 200, { min: 0, max: 2000 });
|
||||
if (maxRecords <= 0) {
|
||||
this.requestHistory = [];
|
||||
this.requestHistoryMaxRecords = 0;
|
||||
this.requestHistoryRevision = '';
|
||||
this.requestHistoryError = '';
|
||||
return this.requestHistory;
|
||||
}
|
||||
const params = new URLSearchParams({ limit: String(Math.max(1, Math.floor(maxRecords))) });
|
||||
if (ifChanged && !force && this.requestHistoryRevision) {
|
||||
params.set('if_revision', String(this.requestHistoryRevision));
|
||||
}
|
||||
const data = await this.apiRequest('/api/system/request-history?' + params.toString(), {
|
||||
timeoutMs: 5000
|
||||
});
|
||||
if (!this.isRequestMonitorEnabled()) {
|
||||
this.requestHistory = [];
|
||||
this.requestHistoryRevision = '';
|
||||
this.requestHistoryFetchedAt = Date.now();
|
||||
this.requestHistoryError = '';
|
||||
return this.requestHistory;
|
||||
}
|
||||
if (requestSeq !== this.requestHistoryRequestSeq) {
|
||||
return this.requestHistory;
|
||||
}
|
||||
if (data && data.enabled === false) {
|
||||
this.requestHistory = [];
|
||||
this.requestHistoryMaxRecords = 0;
|
||||
this.requestHistoryRevision = '';
|
||||
this.requestHistoryFetchedAt = Date.now();
|
||||
this.requestHistoryError = '';
|
||||
return this.requestHistory;
|
||||
}
|
||||
const revision = String(data.revision || '');
|
||||
this.requestHistoryMaxRecords = Math.max(
|
||||
0,
|
||||
Number(data && data.max_records || maxRecords || 0)
|
||||
);
|
||||
if (data.not_modified && revision && revision === this.requestHistoryRevision) {
|
||||
this.requestHistoryFetchedAt = Date.now();
|
||||
this.requestHistoryError = '';
|
||||
return this.requestHistory;
|
||||
}
|
||||
if (!ifChanged || force || !this.requestHistoryRevision || revision !== this.requestHistoryRevision) {
|
||||
const detailCache = new Map(
|
||||
this.requestHistory
|
||||
.filter(item => item && item.detail_loaded && item.id)
|
||||
.map(item => [String(item.history_key || item.id), {
|
||||
prompt: item.prompt,
|
||||
response: item.response,
|
||||
error_stack: item.error_stack,
|
||||
// 修复:这里原本缓存 payload / response_payload,但后端从未产出这两个键,
|
||||
// 每次轮询都会把两个 undefined 键塞进每条记录,已删除。
|
||||
// 同时补上 error_message / summary:不缓存的话,下一次轮询会用列表里的
|
||||
// 截断版本覆盖掉已加载的完整详情。
|
||||
error_message: item.error_message,
|
||||
summary: item.summary,
|
||||
detail_loaded: true,
|
||||
has_detail: true
|
||||
}])
|
||||
);
|
||||
const records = Array.isArray(data.records) ? data.records : [];
|
||||
this.requestHistory = records.map(item => {
|
||||
const cached = detailCache.get(String(item && (item.history_key || item.id) || ''));
|
||||
return cached ? { ...item, ...cached, detail_loaded: true, has_detail: true } : item;
|
||||
});
|
||||
this.requestHistoryRevision = revision;
|
||||
}
|
||||
this.requestHistoryFetchedAt = Date.now();
|
||||
this.requestHistoryError = '';
|
||||
return this.requestHistory;
|
||||
} catch (error) {
|
||||
if (!silent) {
|
||||
this.requestHistoryError = error.message || '请求历史加载失败';
|
||||
}
|
||||
return this.requestHistory;
|
||||
} finally {
|
||||
if (requestSeq === this.requestHistoryRequestSeq) {
|
||||
this.requestHistoryLoading = false;
|
||||
const pending = this.requestHistoryPendingRefresh;
|
||||
this.requestHistoryPendingRefresh = null;
|
||||
if (pending) {
|
||||
this.fetchRequestHistory(pending).catch(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async fetchRequestHistoryDetail(requestId) {
|
||||
const id = String(requestId || '').trim();
|
||||
if (!id || this.requestHistoryDetailLoading[id]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const matchesRequestHistoryId = (item) => {
|
||||
if (!item) return false;
|
||||
return String(item.history_key || '').trim() === id || String(item.id || '').trim() === id;
|
||||
};
|
||||
const existingIndex = this.requestHistory.findIndex(matchesRequestHistoryId);
|
||||
if (existingIndex >= 0 && this.requestHistory[existingIndex].detail_loaded) {
|
||||
return this.requestHistory[existingIndex];
|
||||
}
|
||||
|
||||
this.requestHistoryDetailLoading = {
|
||||
...this.requestHistoryDetailLoading,
|
||||
[id]: true
|
||||
};
|
||||
try {
|
||||
const detail = await this.apiRequest('/api/system/request-history/' + encodeURIComponent(id), {
|
||||
timeoutMs: 5000
|
||||
});
|
||||
const detailKey = String(detail && detail.history_key || '').trim();
|
||||
const detailId = String(detail && detail.id || '').trim();
|
||||
const index = this.requestHistory.findIndex(item => {
|
||||
if (!item) return false;
|
||||
return String(item.history_key || '').trim() === (detailKey || id)
|
||||
|| String(item.history_key || '').trim() === id
|
||||
|| (
|
||||
!detailKey
|
||||
&& detailId
|
||||
&& String(item.id || '').trim() === detailId
|
||||
)
|
||||
|| String(item.id || '').trim() === id;
|
||||
});
|
||||
if (index >= 0) {
|
||||
const current = this.requestHistory[index];
|
||||
const detailPayload = detail && typeof detail === 'object' ? detail : {};
|
||||
const updated = {
|
||||
...current,
|
||||
prompt: detailPayload.prompt ?? current.prompt,
|
||||
response: detailPayload.response ?? current.response,
|
||||
error_stack: detailPayload.error_stack ?? current.error_stack,
|
||||
// 修复:列表投影会把 error_message 截到 800 字、summary 截到 240 字,
|
||||
// 详情接口返回的才是完整原文;此前白名单漏掉这两个键,详情抽屉永远显示截断版本。
|
||||
error_message: detailPayload.error_message ?? current.error_message,
|
||||
summary: detailPayload.summary ?? current.summary,
|
||||
// 修复:这里原本还合并 payload / response_payload,但后端从未产出这两个键,只会
|
||||
// 给记录塞进两个 undefined 字段,已删除。
|
||||
token_estimate: detailPayload.token_estimate ?? current.token_estimate,
|
||||
detail_text_lengths: detailPayload.detail_text_lengths ?? current.detail_text_lengths,
|
||||
detail_loaded: true,
|
||||
has_detail: true
|
||||
};
|
||||
const nextHistory = this.requestHistory.slice();
|
||||
nextHistory[index] = updated;
|
||||
this.requestHistory = nextHistory;
|
||||
return updated;
|
||||
}
|
||||
return detail || null;
|
||||
} catch (error) {
|
||||
this.notify('加载请求详情失败: ' + error.message, 'error');
|
||||
return null;
|
||||
} finally {
|
||||
const nextLoading = { ...this.requestHistoryDetailLoading };
|
||||
delete nextLoading[id];
|
||||
this.requestHistoryDetailLoading = nextLoading;
|
||||
}
|
||||
},
|
||||
|
||||
downloadDataAsJson(filename, payloadText) {
|
||||
const blob = new Blob([payloadText], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
},
|
||||
|
||||
// ========== 预设辅助方法 ==========
|
||||
|
||||
getActivePresetName() {
|
||||
try {
|
||||
if (this.$refs.configTab && this.$refs.configTab.selectedPreset) {
|
||||
return this.$refs.configTab.selectedPreset
|
||||
}
|
||||
} catch (e) { }
|
||||
const presets = this.currentConfig && this.currentConfig.presets
|
||||
if (presets && typeof presets === 'object') {
|
||||
const configuredDefault = this.currentConfig.default_preset
|
||||
if (configuredDefault && presets[configuredDefault]) {
|
||||
return configuredDefault
|
||||
}
|
||||
if (presets['主预设']) {
|
||||
return '主预设'
|
||||
}
|
||||
const keys = Object.keys(presets)
|
||||
if (keys.length > 0) {
|
||||
return keys[0]
|
||||
}
|
||||
}
|
||||
return '主预设'
|
||||
},
|
||||
|
||||
getActivePresetConfig() {
|
||||
if (!this.currentConfig) return null
|
||||
const presets = this.currentConfig.presets
|
||||
if (!presets) return this.currentConfig
|
||||
const name = this.resolveExistingPresetName(this.currentConfig, this.getActivePresetName())
|
||||
const configuredDefault = this.currentConfig.default_preset
|
||||
return presets[name]
|
||||
|| (configuredDefault ? presets[configuredDefault] : null)
|
||||
|| presets['主预设']
|
||||
|| Object.values(presets)[0]
|
||||
|| null
|
||||
},
|
||||
|
||||
resolveExistingPresetName(site, presetName) {
|
||||
const presets = site && site.presets
|
||||
const normalized = String(presetName || '').trim()
|
||||
if (!presets || typeof presets !== 'object' || !normalized) {
|
||||
return normalized
|
||||
}
|
||||
if (presets[normalized]) {
|
||||
return normalized
|
||||
}
|
||||
if (normalized.startsWith('预设_')) {
|
||||
const stripped = normalized.slice(3).trim()
|
||||
if (stripped && presets[stripped]) {
|
||||
return stripped
|
||||
}
|
||||
} else {
|
||||
const prefixed = '预设_' + normalized
|
||||
if (presets[prefixed]) {
|
||||
return prefixed
|
||||
}
|
||||
}
|
||||
return normalized
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,331 @@
|
||||
// R2-8:由 dashboard-methods.js 拆分——环境配置、浏览器常量与更新白名单。方法原样迁出,由 dashboard-methods.js 统一组装。
|
||||
(() => {
|
||||
const {
|
||||
DEFAULT_SELECTOR_DEFINITIONS,
|
||||
BROWSER_CONSTANTS_SCHEMA,
|
||||
ENV_CONFIG_SCHEMA,
|
||||
DASHBOARD_TOKEN_STORAGE_KEY,
|
||||
LEGACY_API_TOKEN_STORAGE_KEY,
|
||||
SITE_CONFIG_IMPORT_MAX_BYTES,
|
||||
SETTINGS_BACKUP_IMPORT_MAX_BYTES,
|
||||
importFileSizeError,
|
||||
formatGitCompareErrorText,
|
||||
getStoredDashboardToken,
|
||||
setStoredDashboardToken,
|
||||
SITE_FRIENDLY_NAMES,
|
||||
GENERIC_DOMAIN_LABELS,
|
||||
siteDisplayName,
|
||||
} = window.DashboardShared;
|
||||
(window.DashboardMethodParts = window.DashboardMethodParts || []).push({
|
||||
// ========== 环境配置 ==========
|
||||
|
||||
async loadEnvConfig() {
|
||||
this.isLoadingEnv = true;
|
||||
try {
|
||||
const data = await this.apiRequest('/api/settings/env');
|
||||
const fileConfig = data.config || {};
|
||||
// 修复:DASHBOARD_AUTH_ENABLED 未写进 .env 时,后端运行时语义是「沿用 AUTH_ENABLED」。
|
||||
// 若这里直接用 schema 默认值 false 填充,用户保存任意一项都会把
|
||||
// DASHBOARD_AUTH_ENABLED=false 写进 .env,静默关掉控制面板认证。
|
||||
// 后端在 effective 里给出真实生效值,仅在 .env 确实缺该键时采纳。
|
||||
const effective = (data.effective && typeof data.effective === 'object') ? data.effective : {};
|
||||
const inherited = {};
|
||||
if (!Object.prototype.hasOwnProperty.call(fileConfig, 'DASHBOARD_AUTH_ENABLED')
|
||||
&& Object.prototype.hasOwnProperty.call(effective, 'DASHBOARD_AUTH_ENABLED')) {
|
||||
inherited.DASHBOARD_AUTH_ENABLED = !!effective.DASHBOARD_AUTH_ENABLED;
|
||||
}
|
||||
this.envConfig = {
|
||||
...this.getEnvDefaults(),
|
||||
...inherited,
|
||||
...fileConfig
|
||||
};
|
||||
this.envConfigOriginal = JSON.parse(JSON.stringify(this.envConfig));
|
||||
} catch (error) {
|
||||
console.error('加载环境配置失败:', error);
|
||||
this.envConfig = this.getEnvDefaults();
|
||||
this.envConfigOriginal = JSON.parse(JSON.stringify(this.envConfig));
|
||||
} finally {
|
||||
this.isLoadingEnv = false;
|
||||
}
|
||||
},
|
||||
|
||||
getEnvDefaults() {
|
||||
const defaults = {};
|
||||
for (const group of Object.values(ENV_CONFIG_SCHEMA)) {
|
||||
for (const [key, field] of Object.entries(group.items)) {
|
||||
defaults[key] = field.default;
|
||||
}
|
||||
}
|
||||
return defaults;
|
||||
},
|
||||
|
||||
normalizeEnvCompareValue(value) {
|
||||
if (value === undefined || value === null) return '';
|
||||
if (typeof value === 'boolean') return value ? 'true' : 'false';
|
||||
return String(value);
|
||||
},
|
||||
|
||||
getEnvFieldMeta(fieldKey) {
|
||||
for (const group of Object.values(ENV_CONFIG_SCHEMA)) {
|
||||
if (!group || !group.items || !Object.prototype.hasOwnProperty.call(group.items, fieldKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const field = group.items[fieldKey] || {};
|
||||
return {
|
||||
...field,
|
||||
apply: field.apply || group.apply || 'service'
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
getEnvChangedKeys() {
|
||||
const current = this.envConfig || {};
|
||||
const original = this.envConfigOriginal || {};
|
||||
const keys = new Set([
|
||||
...Object.keys(current),
|
||||
...Object.keys(original)
|
||||
]);
|
||||
|
||||
return Array.from(keys).filter((key) => {
|
||||
return this.normalizeEnvCompareValue(current[key]) !== this.normalizeEnvCompareValue(original[key]);
|
||||
});
|
||||
},
|
||||
|
||||
async saveEnvConfig() {
|
||||
this.isSavingEnv = true;
|
||||
try {
|
||||
const changedKeys = this.getEnvChangedKeys();
|
||||
await this.apiRequest('/api/settings/env', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ config: this.envConfig })
|
||||
});
|
||||
|
||||
this.envConfigOriginal = JSON.parse(JSON.stringify(this.envConfig));
|
||||
const launcherKeys = changedKeys.filter((key) => {
|
||||
return (this.getEnvFieldMeta(key)?.apply || 'service') === 'launcher';
|
||||
});
|
||||
const scheduledRestartKeys = launcherKeys.filter((key) => String(key || '').startsWith('SCHEDULED_RESTART_'));
|
||||
const browserRestartKeys = launcherKeys.filter((key) => !String(key || '').startsWith('SCHEDULED_RESTART_'));
|
||||
|
||||
if (browserRestartKeys.length > 0) {
|
||||
const launcherLabels = browserRestartKeys.map((key) => {
|
||||
return this.getEnvFieldMeta(key)?.label || key;
|
||||
}).join(', ');
|
||||
|
||||
this.notify(
|
||||
'环境配置已保存。服务会自动重启,但以下启动型配置要完全生效,请关闭当前浏览器和脚本后重新运行 start.bat:' + launcherLabels,
|
||||
'warning'
|
||||
);
|
||||
} else if (scheduledRestartKeys.length > 0) {
|
||||
this.notify('服务守护配置已保存,后端会自动重启;浏览器和现有标签页保持不变', 'success');
|
||||
} else {
|
||||
this.notify('环境配置已保存,服务将自动重启后生效', 'success');
|
||||
}
|
||||
} catch (error) {
|
||||
this.notify('保存失败: ' + error.message, 'error');
|
||||
} finally {
|
||||
this.isSavingEnv = false;
|
||||
}
|
||||
},
|
||||
|
||||
resetEnvConfig() {
|
||||
if (!confirm('确定要重置环境配置为默认值吗?')) return;
|
||||
|
||||
this.envConfig = this.getEnvDefaults();
|
||||
this.notify('已重置为默认值,请点击保存以应用', 'info');
|
||||
},
|
||||
|
||||
// ========== 浏览器常量 ==========
|
||||
|
||||
normalizeBrowserConstantsForEditor(rawConfig = {}) {
|
||||
const raw = rawConfig && typeof rawConfig === 'object' ? rawConfig : {};
|
||||
const normalized = {};
|
||||
|
||||
for (const group of Object.values(BROWSER_CONSTANTS_SCHEMA)) {
|
||||
for (const [key, field] of Object.entries(group.items || {})) {
|
||||
normalized[key] = field.default;
|
||||
}
|
||||
}
|
||||
|
||||
for (const key of Object.keys(normalized)) {
|
||||
if (key.startsWith('TAB_POOL_')) {
|
||||
continue;
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(raw, key)) {
|
||||
normalized[key] = raw[key];
|
||||
}
|
||||
}
|
||||
|
||||
const tabPool = raw.tab_pool && typeof raw.tab_pool === 'object' ? raw.tab_pool : {};
|
||||
normalized.TAB_POOL_MAX_TABS = raw.TAB_POOL_MAX_TABS ?? tabPool.max_tabs ?? normalized.TAB_POOL_MAX_TABS;
|
||||
normalized.TAB_POOL_MIN_TABS = raw.TAB_POOL_MIN_TABS ?? tabPool.min_tabs ?? normalized.TAB_POOL_MIN_TABS;
|
||||
normalized.TAB_POOL_IDLE_TIMEOUT = raw.TAB_POOL_IDLE_TIMEOUT ?? tabPool.idle_timeout ?? normalized.TAB_POOL_IDLE_TIMEOUT;
|
||||
normalized.TAB_POOL_ACQUIRE_TIMEOUT = raw.TAB_POOL_ACQUIRE_TIMEOUT ?? tabPool.acquire_timeout ?? normalized.TAB_POOL_ACQUIRE_TIMEOUT;
|
||||
normalized.TAB_POOL_STUCK_TIMEOUT = raw.TAB_POOL_STUCK_TIMEOUT ?? tabPool.stuck_timeout ?? normalized.TAB_POOL_STUCK_TIMEOUT;
|
||||
|
||||
return normalized;
|
||||
},
|
||||
|
||||
serializeBrowserConstants(editorConfig = {}, rawBase = {}) {
|
||||
const base = rawBase && typeof rawBase === 'object'
|
||||
? JSON.parse(JSON.stringify(rawBase))
|
||||
: {};
|
||||
const merged = this.normalizeBrowserConstantsForEditor(editorConfig);
|
||||
const obsoleteKeys = [
|
||||
'DEFAULT_PORT',
|
||||
'STREAM_RERENDER_WAIT',
|
||||
'STREAM_MIN_VALID_LENGTH',
|
||||
'STREAM_INITIAL_ELEMENT_WAIT',
|
||||
'STREAM_MAX_ABNORMAL_COUNT',
|
||||
'STREAM_MAX_ELEMENT_MISSING',
|
||||
'STREAM_CONTENT_SHRINK_THRESHOLD'
|
||||
];
|
||||
|
||||
for (const key of obsoleteKeys) {
|
||||
delete base[key];
|
||||
}
|
||||
|
||||
for (const key of Object.keys(merged)) {
|
||||
if (key.startsWith('TAB_POOL_')) {
|
||||
continue;
|
||||
}
|
||||
base[key] = merged[key];
|
||||
}
|
||||
|
||||
const existingTabPool = base.tab_pool && typeof base.tab_pool === 'object' ? base.tab_pool : {};
|
||||
base.tab_pool = {
|
||||
...existingTabPool,
|
||||
max_tabs: merged.TAB_POOL_MAX_TABS,
|
||||
min_tabs: merged.TAB_POOL_MIN_TABS,
|
||||
idle_timeout: merged.TAB_POOL_IDLE_TIMEOUT,
|
||||
acquire_timeout: merged.TAB_POOL_ACQUIRE_TIMEOUT,
|
||||
stuck_timeout: merged.TAB_POOL_STUCK_TIMEOUT
|
||||
};
|
||||
|
||||
return base;
|
||||
},
|
||||
|
||||
async loadBrowserConstants() {
|
||||
this.isLoadingConstants = true;
|
||||
try {
|
||||
const data = await this.apiRequest('/api/settings/browser-constants');
|
||||
this.browserConstantsRaw = JSON.parse(JSON.stringify(data.config || {}));
|
||||
this.browserConstants = this.normalizeBrowserConstantsForEditor(this.browserConstantsRaw);
|
||||
this.browserConstantsOriginal = JSON.parse(JSON.stringify(this.browserConstants));
|
||||
} catch (error) {
|
||||
console.error('加载浏览器常量失败:', error);
|
||||
this.browserConstants = this.getBrowserConstantsDefaults();
|
||||
this.browserConstantsRaw = this.serializeBrowserConstants(this.browserConstants, {});
|
||||
this.browserConstantsOriginal = JSON.parse(JSON.stringify(this.browserConstants));
|
||||
} finally {
|
||||
this.isLoadingConstants = false;
|
||||
}
|
||||
},
|
||||
|
||||
getBrowserConstantsDefaults() {
|
||||
return this.normalizeBrowserConstantsForEditor({});
|
||||
},
|
||||
|
||||
async saveBrowserConstants() {
|
||||
this.isSavingConstants = true;
|
||||
try {
|
||||
// 修复:browserConstantsRaw 只在首屏/首次进设置页加载各一次,期间「标签页池」页签
|
||||
// 可能已通过 PUT /api/tab-pool/config 改过同一个 browser_config.json。用陈旧快照做
|
||||
// merge 基底会把 route_groups / excluded_urls / allocation_mode 等整块回退。
|
||||
// 这里只重新拉取 raw 基底,不调用 loadBrowserConstants(),以免覆盖用户当前未保存的编辑。
|
||||
let rawBase = this.browserConstantsRaw;
|
||||
try {
|
||||
const fresh = await this.apiRequest('/api/settings/browser-constants');
|
||||
if (fresh && fresh.config && typeof fresh.config === 'object') {
|
||||
rawBase = fresh.config;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('刷新浏览器常量基底失败,沿用上次快照:', error);
|
||||
}
|
||||
|
||||
const payload = this.serializeBrowserConstants(this.browserConstants, rawBase);
|
||||
await this.apiRequest('/api/settings/browser-constants', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ config: payload })
|
||||
});
|
||||
|
||||
this.browserConstantsRaw = JSON.parse(JSON.stringify(payload));
|
||||
this.browserConstants = this.normalizeBrowserConstantsForEditor(payload);
|
||||
this.browserConstantsOriginal = JSON.parse(JSON.stringify(this.browserConstants));
|
||||
this.applyDashboardRuntimeSettings();
|
||||
this.notify('浏览器常量已保存', 'success');
|
||||
} catch (error) {
|
||||
this.notify('保存失败: ' + error.message, 'error');
|
||||
} finally {
|
||||
this.isSavingConstants = false;
|
||||
}
|
||||
},
|
||||
|
||||
resetBrowserConstants() {
|
||||
if (!confirm('确定要重置浏览器常量为默认值吗?')) return;
|
||||
|
||||
this.browserConstants = this.getBrowserConstantsDefaults();
|
||||
this.notify('已重置为默认值,请点击保存以应用', 'info');
|
||||
},
|
||||
|
||||
// ========== 更新白名单 ==========
|
||||
|
||||
async loadUpdatePreserveSettings() {
|
||||
this.isLoadingUpdatePreserve = true;
|
||||
try {
|
||||
const data = await this.apiRequest('/api/settings/update-preserve');
|
||||
this.updatePreserveOptions = Array.isArray(data.options) ? data.options : [];
|
||||
this.updatePreserveSelected = Array.isArray(data.selected_patterns) ? data.selected_patterns.slice() : [];
|
||||
this.updatePreserveSelectedOriginal = JSON.parse(JSON.stringify(this.updatePreserveSelected));
|
||||
} catch (error) {
|
||||
console.error('加载更新白名单失败:', error);
|
||||
this.updatePreserveOptions = [];
|
||||
this.updatePreserveSelected = [];
|
||||
this.updatePreserveSelectedOriginal = [];
|
||||
} finally {
|
||||
this.isLoadingUpdatePreserve = false;
|
||||
}
|
||||
},
|
||||
|
||||
toggleUpdatePreserve(pattern) {
|
||||
const value = String(pattern || '').trim();
|
||||
if (!value) return;
|
||||
const next = new Set(this.updatePreserveSelected || []);
|
||||
if (next.has(value)) {
|
||||
next.delete(value);
|
||||
} else {
|
||||
next.add(value);
|
||||
}
|
||||
this.updatePreserveSelected = Array.from(next);
|
||||
},
|
||||
|
||||
async saveUpdatePreserveSettings() {
|
||||
this.isSavingUpdatePreserve = true;
|
||||
try {
|
||||
const data = await this.apiRequest('/api/settings/update-preserve', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
selected_patterns: this.updatePreserveSelected
|
||||
})
|
||||
});
|
||||
this.updatePreserveSelected = Array.isArray(data.selected_patterns)
|
||||
? data.selected_patterns.slice()
|
||||
: this.updatePreserveSelected;
|
||||
this.updatePreserveSelectedOriginal = JSON.parse(JSON.stringify(this.updatePreserveSelected));
|
||||
this.notify('更新白名单已保存,下次自动更新生效', 'success');
|
||||
} catch (error) {
|
||||
this.notify('保存失败: ' + error.message, 'error');
|
||||
} finally {
|
||||
this.isSavingUpdatePreserve = false;
|
||||
}
|
||||
},
|
||||
|
||||
resetUpdatePreserveSettings() {
|
||||
this.updatePreserveSelected = JSON.parse(JSON.stringify(this.updatePreserveSelectedOriginal));
|
||||
this.notify('已恢复到上次保存的更新白名单', 'info');
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,238 @@
|
||||
// R2-8:由 dashboard-methods.js 拆分——工具功能。方法原样迁出,由 dashboard-methods.js 统一组装。
|
||||
(() => {
|
||||
const {
|
||||
DEFAULT_SELECTOR_DEFINITIONS,
|
||||
BROWSER_CONSTANTS_SCHEMA,
|
||||
ENV_CONFIG_SCHEMA,
|
||||
DASHBOARD_TOKEN_STORAGE_KEY,
|
||||
LEGACY_API_TOKEN_STORAGE_KEY,
|
||||
SITE_CONFIG_IMPORT_MAX_BYTES,
|
||||
SETTINGS_BACKUP_IMPORT_MAX_BYTES,
|
||||
importFileSizeError,
|
||||
formatGitCompareErrorText,
|
||||
getStoredDashboardToken,
|
||||
setStoredDashboardToken,
|
||||
SITE_FRIENDLY_NAMES,
|
||||
GENERIC_DOMAIN_LABELS,
|
||||
siteDisplayName,
|
||||
} = window.DashboardShared;
|
||||
(window.DashboardMethodParts = window.DashboardMethodParts || []).push({
|
||||
// ========== 工具功能 ==========
|
||||
|
||||
copyJson(textOverride) {
|
||||
const text = typeof textOverride === 'string'
|
||||
? textOverride
|
||||
: JSON.stringify(this.getJsonPreviewData(), null, 2)
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
this.notify('已复制到剪贴板', 'success')
|
||||
}).catch(() => {
|
||||
this.notify('复制失败', 'error')
|
||||
})
|
||||
},
|
||||
|
||||
getJsonPreviewData() {
|
||||
// 修复:先把面板草稿回写到 presetConfig,否则预览显示的是未包含本次编辑的旧值
|
||||
this.flushConfigTabDrafts()
|
||||
const config = this.getActivePresetConfig() || {}
|
||||
return JSON.parse(JSON.stringify(config))
|
||||
},
|
||||
|
||||
async saveJsonPreview(rawText) {
|
||||
// 修复:保存前同样要 flush 面板草稿,否则这条保存路径会静默丢弃用户未回写的编辑
|
||||
this.flushConfigTabDrafts()
|
||||
if (!this.currentDomain) {
|
||||
this.notify('请先选择站点', 'warning')
|
||||
return
|
||||
}
|
||||
|
||||
let parsed
|
||||
try {
|
||||
parsed = JSON.parse(rawText)
|
||||
} catch (error) {
|
||||
this.notify('JSON 解析失败: ' + error.message, 'error')
|
||||
return
|
||||
}
|
||||
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
this.notify('JSON 顶层必须是对象', 'error')
|
||||
return
|
||||
}
|
||||
|
||||
if (parsed.selectors !== undefined && (typeof parsed.selectors !== 'object' || Array.isArray(parsed.selectors))) {
|
||||
this.notify('selectors 必须是对象', 'error')
|
||||
return
|
||||
}
|
||||
|
||||
if (parsed.workflow !== undefined && !Array.isArray(parsed.workflow)) {
|
||||
this.notify('workflow 必须是数组', 'error')
|
||||
return
|
||||
}
|
||||
|
||||
if (parsed.presets && typeof parsed.presets === 'object' && !Array.isArray(parsed.presets)) {
|
||||
const normalized = this.normalizeConfig({ [this.currentDomain]: parsed })
|
||||
if (normalized[this.currentDomain]) {
|
||||
this.sites[this.currentDomain] = normalized[this.currentDomain]
|
||||
}
|
||||
|
||||
try {
|
||||
await this.apiRequest('/api/config', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ config: this.sites })
|
||||
})
|
||||
this.showJsonPreview = false
|
||||
this.notify('站点 JSON 已保存', 'success')
|
||||
} catch (error) {
|
||||
this.notify('保存失败: ' + error.message, 'error')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const site = JSON.parse(JSON.stringify(this.sites[this.currentDomain] || {}))
|
||||
const presets = site.presets || { '主预设': {} }
|
||||
const activePresetName = this.getActivePresetName()
|
||||
const presetName = this.resolveExistingPresetName(site, activePresetName) || activePresetName
|
||||
const currentPreset = presets[presetName] || presets['主预设'] || {}
|
||||
const { domain, preset_name, timestamp, ...presetPatch } = parsed
|
||||
|
||||
presets[presetName] = {
|
||||
...currentPreset,
|
||||
...presetPatch,
|
||||
selectors: presetPatch.selectors !== undefined ? presetPatch.selectors : (currentPreset.selectors || {}),
|
||||
workflow: presetPatch.workflow !== undefined ? presetPatch.workflow : (currentPreset.workflow || []),
|
||||
stealth: presetPatch.stealth !== undefined ? !!presetPatch.stealth : !!currentPreset.stealth
|
||||
}
|
||||
|
||||
site.presets = presets
|
||||
if (!site.default_preset || !site.presets[site.default_preset]) {
|
||||
site.default_preset = site.presets['主预设'] ? '主预设' : (Object.keys(site.presets)[0] || '主预设')
|
||||
}
|
||||
this.sites[this.currentDomain] = site
|
||||
|
||||
try {
|
||||
await this.apiRequest('/api/config', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ config: this.sites })
|
||||
})
|
||||
this.showJsonPreview = false
|
||||
this.notify('JSON 修改已保存', 'success')
|
||||
} catch (error) {
|
||||
this.notify('保存失败: ' + error.message, 'error')
|
||||
}
|
||||
},
|
||||
|
||||
saveToken() {
|
||||
const token = this.tempToken.trim()
|
||||
if (token) {
|
||||
setStoredDashboardToken(token)
|
||||
this.notify('控制面板访问密钥已保存', 'success')
|
||||
} else {
|
||||
setStoredDashboardToken('')
|
||||
this.notify('控制面板访问密钥已清除', 'info')
|
||||
}
|
||||
this.syncTokenPresence()
|
||||
|
||||
this.showTokenDialog = false
|
||||
this.tempToken = ''
|
||||
|
||||
this.loadConfig(true)
|
||||
},
|
||||
|
||||
restoreSitesCache() {
|
||||
const cached = window.loadStoredSitesCache()
|
||||
if (!cached || !cached.sites) {
|
||||
return
|
||||
}
|
||||
this.sites = this.normalizeConfig(cached.sites)
|
||||
const domains = Object.keys(this.sites)
|
||||
if (domains.length === 0) {
|
||||
return
|
||||
}
|
||||
if (cached.currentDomain && this.sites[cached.currentDomain]) {
|
||||
this.currentDomain = cached.currentDomain
|
||||
return
|
||||
}
|
||||
if (!this.currentDomain) {
|
||||
this.currentDomain = domains[0]
|
||||
}
|
||||
},
|
||||
|
||||
async refreshStatus() {
|
||||
const [configOk, healthOk] = await Promise.all([
|
||||
this.loadConfig(true),
|
||||
this.loadHealthStatus({ timeoutMs: 2500 }),
|
||||
this.fetchSystemStats({ timeoutMs: 2500 })
|
||||
])
|
||||
|
||||
if (configOk || healthOk) {
|
||||
this.notify('状态已刷新', 'success')
|
||||
} else {
|
||||
this.notify('刷新失败', 'error')
|
||||
}
|
||||
},
|
||||
|
||||
async fetchSystemStats({ timeoutMs = 0 } = {}) {
|
||||
if (!this.getBrowserConstantBool('DASHBOARD_SYSTEM_STATS_ENABLED', true)) {
|
||||
return this.systemStats
|
||||
}
|
||||
if (this.isFetchingSystemStats) {
|
||||
return this.systemStatsRequestPromise || this.systemStats
|
||||
}
|
||||
this.isFetchingSystemStats = true
|
||||
const requestPromise = this.apiRequest('/api/system/stats', {
|
||||
timeoutMs: timeoutMs || 2500
|
||||
})
|
||||
.then((stats) => {
|
||||
this.systemStats = stats
|
||||
return this.systemStats
|
||||
})
|
||||
.catch(() => this.systemStats)
|
||||
.finally(() => {
|
||||
if (this.systemStatsRequestPromise === requestPromise) {
|
||||
this.systemStatsRequestPromise = null
|
||||
this.isFetchingSystemStats = false
|
||||
}
|
||||
})
|
||||
this.systemStatsRequestPromise = requestPromise
|
||||
return requestPromise
|
||||
},
|
||||
|
||||
async loadHealthStatus({ silent = false, timeoutMs = 0 } = {}) {
|
||||
try {
|
||||
const health = await this.apiRequest('/health', {
|
||||
timeoutMs: timeoutMs || 2500
|
||||
})
|
||||
this.browserStatus = health.browser || {}
|
||||
this.authEnabled = health.config?.dashboard_auth_enabled ?? health.config?.auth_enabled ?? false
|
||||
return true
|
||||
} catch (error) {
|
||||
if (error.message === 'UNAUTHORIZED') {
|
||||
this.authEnabled = true
|
||||
return true
|
||||
}
|
||||
|
||||
console.error('状态检查失败:', error)
|
||||
if (!silent) {
|
||||
this.notify('状态检查失败: ' + error.message, 'error')
|
||||
}
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
notify(message, type) {
|
||||
if (!type) type = 'info'
|
||||
const id = this.toastCounter++
|
||||
this.toasts.push({ id: id, message: message, type: type })
|
||||
|
||||
const self = this
|
||||
setTimeout(function () {
|
||||
self.removeToast(id)
|
||||
}, 3000)
|
||||
},
|
||||
|
||||
removeToast(id) {
|
||||
this.toasts = this.toasts.filter(function (t) {
|
||||
return t.id !== id
|
||||
})
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,580 @@
|
||||
// R2-8:由 dashboard-methods.js 拆分——配置导入与导出。方法原样迁出,由 dashboard-methods.js 统一组装。
|
||||
(() => {
|
||||
const {
|
||||
DEFAULT_SELECTOR_DEFINITIONS,
|
||||
BROWSER_CONSTANTS_SCHEMA,
|
||||
ENV_CONFIG_SCHEMA,
|
||||
DASHBOARD_TOKEN_STORAGE_KEY,
|
||||
LEGACY_API_TOKEN_STORAGE_KEY,
|
||||
SITE_CONFIG_IMPORT_MAX_BYTES,
|
||||
SETTINGS_BACKUP_IMPORT_MAX_BYTES,
|
||||
importFileSizeError,
|
||||
formatGitCompareErrorText,
|
||||
getStoredDashboardToken,
|
||||
setStoredDashboardToken,
|
||||
SITE_FRIENDLY_NAMES,
|
||||
GENERIC_DOMAIN_LABELS,
|
||||
siteDisplayName,
|
||||
} = window.DashboardShared;
|
||||
(window.DashboardMethodParts = window.DashboardMethodParts || []).push({
|
||||
// ========== 导入功能(支持全量和单站点) ==========
|
||||
|
||||
triggerImport() {
|
||||
this.forceSingleSiteImport = false;
|
||||
this.singleSiteImportTargetDomain = '';
|
||||
if (this.$refs.importFileInput) {
|
||||
this.$refs.importFileInput.click();
|
||||
}
|
||||
},
|
||||
|
||||
triggerImportSingleSite() {
|
||||
this.forceSingleSiteImport = true;
|
||||
this.singleSiteImportTargetDomain = this.currentDomain || '';
|
||||
if (this.$refs.importFileInput) {
|
||||
this.$refs.importFileInput.click();
|
||||
}
|
||||
},
|
||||
|
||||
handleImportFile(event) {
|
||||
const file = event.target.files[0];
|
||||
if (!file) return;
|
||||
|
||||
const sizeError = importFileSizeError(file, SITE_CONFIG_IMPORT_MAX_BYTES, '配置文件');
|
||||
if (sizeError) {
|
||||
this.notify(sizeError, 'error');
|
||||
this.singleSiteImportTargetDomain = '';
|
||||
this.forceSingleSiteImport = false;
|
||||
event.target.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
this.importFileName = file.name;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onerror = () => {
|
||||
this.notify('读取导入文件失败', 'error');
|
||||
this.singleSiteImportTargetDomain = '';
|
||||
this.forceSingleSiteImport = false;
|
||||
};
|
||||
reader.onload = (e) => {
|
||||
try {
|
||||
const config = JSON.parse(e.target.result);
|
||||
|
||||
// 检测是单站点还是全量配置
|
||||
const detectResult = this.detectConfigType(config, this.forceSingleSiteImport);
|
||||
|
||||
if (!detectResult.valid) {
|
||||
this.notify('导入文件格式无效', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
this.importType = detectResult.type;
|
||||
this.importedConfig = detectResult.normalizedConfig;
|
||||
this.singleSiteImportDomain = detectResult.suggestedDomain || this.singleSiteImportTargetDomain || this.currentDomain || '';
|
||||
this.singleSiteImportTargetDomain = '';
|
||||
this.forceSingleSiteImport = false;
|
||||
this.showImportDialog = true;
|
||||
} catch (error) {
|
||||
this.notify('JSON 解析失败: ' + error.message, 'error');
|
||||
this.singleSiteImportTargetDomain = '';
|
||||
this.forceSingleSiteImport = false;
|
||||
}
|
||||
};
|
||||
reader.readAsText(file);
|
||||
|
||||
event.target.value = '';
|
||||
},
|
||||
|
||||
// 从配置内容内部提取站点域名标识(优先识别文件内部元数据与单站点包装)
|
||||
extractDomainFromContent(config, knownDomains = []) {
|
||||
if (!config || typeof config !== 'object' || Array.isArray(config)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 1. 严格限定域名语义字段,避免被通用的 name/id 字段误导
|
||||
const candidateKeys = ['domain', 'site_domain', 'target_domain', 'site', '_domain'];
|
||||
for (const key of candidateKeys) {
|
||||
const val = config[key];
|
||||
if (typeof val === 'string') {
|
||||
let cleanVal = val.trim();
|
||||
if (!cleanVal || cleanVal.startsWith('_')) continue;
|
||||
// 剥离协议头、端口与路径(如 https://chat.deepseek.com/ -> chat.deepseek.com)
|
||||
cleanVal = cleanVal.replace(/^https?:\/\//i, '').split('/')[0].split(':')[0].trim();
|
||||
if (!cleanVal) continue;
|
||||
|
||||
const matched = knownDomains.find(d => d.toLowerCase() === cleanVal.toLowerCase());
|
||||
if (matched) return matched;
|
||||
// 基本域名格式特征:包含点且由合法字符构成
|
||||
if (/^[a-zA-Z0-9][-a-zA-Z0-9.]*\.[a-zA-Z0-9]+$/.test(cleanVal)) {
|
||||
return cleanVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 检查单站点包装格式(如 { "chat.deepseek.com": { presets: ... } })
|
||||
const validKeys = Object.keys(config).filter(k => k && !k.startsWith('_'));
|
||||
if (validKeys.length === 1 && this.validateSingleSiteConfig(config[validKeys[0]])) {
|
||||
const singleKey = validKeys[0].trim();
|
||||
const matched = knownDomains.find(d => d.toLowerCase() === singleKey.toLowerCase());
|
||||
return matched || singleKey;
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
|
||||
// 从文件名中清洗并提取站点域名(支持去除 (4)、_1、- 副本、-config 等)
|
||||
extractDomainFromFilename(filename, knownDomains = []) {
|
||||
if (!filename || typeof filename !== 'string') {
|
||||
return '';
|
||||
}
|
||||
|
||||
let name = filename.trim();
|
||||
// 剥离 .json 后缀
|
||||
name = name.replace(/\.json$/i, '').trim();
|
||||
|
||||
// 循环剥离末尾的重复下载序号、括号序号、副本标记与配置后缀
|
||||
const dupSuffixRegex = /(?:\s*\(\s*\d+\s*\)|\s*\[\s*\d+\s*\]|[-_\s]+\d+|[-_\s]*(?:副本|复本|copy)(?:\s*\(\d+\))?)$/i;
|
||||
const configSuffixRegex = /[-_.]*(?:(?:sites?|site|presets?)[-_.]*)?config(?:uration)?$/i;
|
||||
|
||||
let prev = null;
|
||||
let loopCount = 0;
|
||||
while (prev !== name && loopCount < 10) {
|
||||
prev = name;
|
||||
name = name.replace(dupSuffixRegex, '').trim();
|
||||
name = name.replace(configSuffixRegex, '').trim();
|
||||
loopCount++;
|
||||
}
|
||||
|
||||
if (!name) return '';
|
||||
|
||||
// 1. 优先完全匹配已知站点域名(不区分大小写)
|
||||
const exactMatch = knownDomains.find(d => d.toLowerCase() === name.toLowerCase());
|
||||
if (exactMatch) return exactMatch;
|
||||
|
||||
// 2. 若清洗后的 name 本身符合标准域名结构,直接采纳,严禁退化去匹配更短的父域或任意子串
|
||||
if (/^[a-zA-Z0-9][-a-zA-Z0-9.]*\.[a-zA-Z0-9]+$/.test(name)) {
|
||||
return name;
|
||||
}
|
||||
|
||||
// 3. 仅当末尾带有未剥离的连接符后缀时,按最长前缀优先匹配已有站点(如 chat.deepseek.com-v2)
|
||||
const sortedKnown = [...knownDomains].sort((a, b) => b.length - a.length);
|
||||
const lowN = name.toLowerCase();
|
||||
const prefixMatch = sortedKnown.find(d => {
|
||||
const lowD = d.toLowerCase();
|
||||
return lowN.startsWith(lowD + '-') || lowN.startsWith(lowD + '_') || lowN.startsWith(lowD + '.');
|
||||
});
|
||||
if (prefixMatch) return prefixMatch;
|
||||
|
||||
return name;
|
||||
},
|
||||
|
||||
// 检测配置类型:全量配置 or 单站点配置
|
||||
detectConfigType(config, forceSingle = false) {
|
||||
if (typeof config !== 'object' || config === null || Array.isArray(config)) {
|
||||
return { valid: false };
|
||||
}
|
||||
|
||||
const knownDomains = Object.keys(this.sites || {}).filter(k => k && !k.startsWith('_'));
|
||||
// 优先从文件内容内部提取站点域名标识,次选从清洗后的文件名提取
|
||||
const contentDomain = this.extractDomainFromContent(config, knownDomains);
|
||||
const filenameDomain = this.extractDomainFromFilename(this.importFileName, knownDomains);
|
||||
const suggestedDomain = contentDomain || filenameDomain || this.singleSiteImportTargetDomain || '';
|
||||
|
||||
// 检查是否是单站点格式(旧格式 selectors/workflow,或新格式 presets/default_preset)
|
||||
if (
|
||||
config.selectors !== undefined
|
||||
|| config.workflow !== undefined
|
||||
|| (config.presets && typeof config.presets === 'object' && !Array.isArray(config.presets))
|
||||
) {
|
||||
// 单站点格式
|
||||
if (!this.validateSingleSiteConfig(config)) {
|
||||
return { valid: false };
|
||||
}
|
||||
|
||||
return {
|
||||
valid: true,
|
||||
type: 'single',
|
||||
normalizedConfig: config,
|
||||
suggestedDomain: suggestedDomain || this.singleSiteImportTargetDomain || ''
|
||||
};
|
||||
}
|
||||
|
||||
const keys = Object.keys(config).filter(k => k && !k.startsWith('_'));
|
||||
// 若显式指定单站点导入且文件只包含 1 个站点对象
|
||||
if (forceSingle && keys.length === 1 && this.validateSingleSiteConfig(config[keys[0]])) {
|
||||
return {
|
||||
valid: true,
|
||||
type: 'single',
|
||||
normalizedConfig: config[keys[0]],
|
||||
suggestedDomain: keys[0] || suggestedDomain || this.singleSiteImportTargetDomain || ''
|
||||
};
|
||||
}
|
||||
|
||||
// 检查是否是全量格式(域名 -> 配置)
|
||||
if (!this.validateImportedConfig(config)) {
|
||||
return { valid: false };
|
||||
}
|
||||
|
||||
return {
|
||||
valid: true,
|
||||
type: 'full',
|
||||
normalizedConfig: config
|
||||
};
|
||||
},
|
||||
|
||||
validateSingleSiteConfig(config) {
|
||||
if (typeof config !== 'object' || config === null || Array.isArray(config)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.presets !== undefined) {
|
||||
if (typeof config.presets !== 'object' || config.presets === null || Array.isArray(config.presets)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const presetData of Object.values(config.presets)) {
|
||||
if (typeof presetData !== 'object' || presetData === null || Array.isArray(presetData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (presetData.selectors !== undefined && (typeof presetData.selectors !== 'object' || Array.isArray(presetData.selectors))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (presetData.workflow !== undefined && !Array.isArray(presetData.workflow)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// selectors 必须是对象(如果存在)
|
||||
if (config.selectors !== undefined && (typeof config.selectors !== 'object' || Array.isArray(config.selectors))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// workflow 必须是数组(如果存在)
|
||||
if (config.workflow !== undefined && !Array.isArray(config.workflow)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
validateImportedConfig(config) {
|
||||
if (typeof config !== 'object' || config === null || Array.isArray(config)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const [domain, siteConfig] of Object.entries(config)) {
|
||||
if (!domain || typeof domain !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.validateSingleSiteConfig(siteConfig)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
mergeSiteConfigs(existingSite, importedSite) {
|
||||
const normalizedImported = this.normalizeConfig({ imported: importedSite || {} }).imported
|
||||
if (!normalizedImported) {
|
||||
return existingSite || null
|
||||
}
|
||||
|
||||
if (!existingSite) {
|
||||
return normalizedImported
|
||||
}
|
||||
|
||||
const normalizedExisting = this.normalizeConfig({ existing: existingSite }).existing || {
|
||||
default_preset: '主预设',
|
||||
presets: {}
|
||||
}
|
||||
|
||||
const mergedPresets = {
|
||||
...(normalizedExisting.presets || {}),
|
||||
...(normalizedImported.presets || {})
|
||||
}
|
||||
|
||||
let mergedDefault = normalizedImported.default_preset
|
||||
if (!mergedDefault || !mergedPresets[mergedDefault]) {
|
||||
mergedDefault = normalizedExisting.default_preset
|
||||
}
|
||||
if (!mergedDefault || !mergedPresets[mergedDefault]) {
|
||||
mergedDefault = mergedPresets['主预设'] ? '主预设' : (Object.keys(mergedPresets)[0] || '主预设')
|
||||
}
|
||||
|
||||
return {
|
||||
...normalizedExisting,
|
||||
...normalizedImported,
|
||||
presets: mergedPresets,
|
||||
default_preset: mergedDefault
|
||||
}
|
||||
},
|
||||
|
||||
async executeImport() {
|
||||
if (!this.importedConfig) return;
|
||||
|
||||
if (this.importType === 'single') {
|
||||
// 单站点导入
|
||||
const domain = this.singleSiteImportDomain.trim();
|
||||
if (!domain) {
|
||||
this.notify('请输入站点域名', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
const normalizedMap = this.normalizeConfig({ [domain]: this.importedConfig });
|
||||
const normalizedSite = normalizedMap[domain];
|
||||
if (!normalizedSite) {
|
||||
this.notify('导入文件格式无效', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const exists = !!this.sites[domain];
|
||||
if (exists) {
|
||||
const message = this.importMode === 'replace'
|
||||
? '站点 "' + domain + '" 已存在,将完整替换该站点的当前配置,是否继续?'
|
||||
: '站点 "' + domain + '" 已存在,将按预设合并导入,同名预设会被覆盖,是否继续?';
|
||||
if (!confirm(message)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.sites[domain] = this.importMode === 'replace'
|
||||
? normalizedSite
|
||||
: this.mergeSiteConfigs(this.sites[domain], normalizedSite);
|
||||
this.currentDomain = domain;
|
||||
|
||||
try {
|
||||
await this.apiRequest('/api/config', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ config: this.sites })
|
||||
});
|
||||
|
||||
this.notify('成功导入站点: ' + domain, 'success');
|
||||
} catch (error) {
|
||||
this.notify('保存失败: ' + error.message, 'error');
|
||||
}
|
||||
} else {
|
||||
// 全量导入
|
||||
const importCount = Object.keys(this.importedConfig).length;
|
||||
|
||||
if (this.importMode === 'replace') {
|
||||
this.sites = this.normalizeConfig(this.importedConfig);
|
||||
} else {
|
||||
const normalized = this.normalizeConfig(this.importedConfig);
|
||||
this.sites = { ...this.sites, ...normalized };
|
||||
}
|
||||
|
||||
try {
|
||||
await this.apiRequest('/api/config', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ config: this.sites })
|
||||
});
|
||||
|
||||
this.notify('成功导入 ' + importCount + ' 个站点配置', 'success');
|
||||
} catch (error) {
|
||||
this.notify('保存失败: ' + error.message, 'error');
|
||||
}
|
||||
|
||||
if (!this.currentDomain && Object.keys(this.sites).length > 0) {
|
||||
this.currentDomain = Object.keys(this.sites)[0];
|
||||
}
|
||||
}
|
||||
|
||||
// 清理
|
||||
this.showImportDialog = false;
|
||||
this.importedConfig = null;
|
||||
this.importFileName = '';
|
||||
this.singleSiteImportDomain = '';
|
||||
},
|
||||
|
||||
cancelImport() {
|
||||
this.showImportDialog = false;
|
||||
this.importedConfig = null;
|
||||
this.importFileName = '';
|
||||
this.singleSiteImportDomain = '';
|
||||
},
|
||||
|
||||
// ========== 导出功能(支持全量和单站点) ==========
|
||||
|
||||
exportConfig() {
|
||||
this.flushConfigTabDrafts()
|
||||
const dataStr = JSON.stringify(this.sites, null, 2)
|
||||
const blob = new Blob([dataStr], { type: 'application/json' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = 'sites-config-' + Date.now() + '.json'
|
||||
a.click()
|
||||
URL.revokeObjectURL(url)
|
||||
|
||||
this.notify('全量配置已导出', 'success')
|
||||
},
|
||||
|
||||
// 导出单个站点
|
||||
exportSingleSite(domain) {
|
||||
this.flushConfigTabDrafts()
|
||||
if (!domain || !this.sites[domain]) {
|
||||
this.notify('站点不存在', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// 导出整个站点(含所有预设与站点域名自描述)
|
||||
const siteConfig = this.sites[domain];
|
||||
const exportPayload = {
|
||||
...siteConfig,
|
||||
domain: domain
|
||||
};
|
||||
const dataStr = JSON.stringify(exportPayload, null, 2);
|
||||
const blob = new Blob([dataStr], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = domain + '-config.json';
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
this.notify('站点配置已导出: ' + domain, 'success');
|
||||
},
|
||||
|
||||
// 导出当前站点
|
||||
exportCurrentSite() {
|
||||
if (!this.currentDomain) {
|
||||
this.notify('请先选择站点', 'warning');
|
||||
return;
|
||||
}
|
||||
this.exportSingleSite(this.currentDomain);
|
||||
},
|
||||
|
||||
triggerSettingsBackupImport() {
|
||||
if (this.$refs.backupImportInput) {
|
||||
this.$refs.backupImportInput.click();
|
||||
}
|
||||
},
|
||||
|
||||
handleSettingsBackupImportFile(event) {
|
||||
const file = event.target.files[0];
|
||||
if (!file) return;
|
||||
|
||||
const sizeError = importFileSizeError(file, SETTINGS_BACKUP_IMPORT_MAX_BYTES, '备份文件');
|
||||
if (sizeError) {
|
||||
this.notify('完整备份导入失败: ' + sizeError, 'error');
|
||||
event.target.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onerror = () => {
|
||||
this.notify('完整备份导入失败: 读取文件出错', 'error');
|
||||
};
|
||||
reader.onload = async (e) => {
|
||||
try {
|
||||
const payload = JSON.parse(e.target.result);
|
||||
await this.importSettingsBackup(payload);
|
||||
} catch (error) {
|
||||
this.notify('完整备份导入失败: ' + error.message, 'error');
|
||||
}
|
||||
};
|
||||
reader.readAsText(file, 'utf-8');
|
||||
|
||||
event.target.value = '';
|
||||
},
|
||||
|
||||
getDashboardPreferencesBackup() {
|
||||
// S13:备份文件会被下载/转存/分享,浏览器本地保存的面板令牌不再写入备份。
|
||||
// 旧版备份里的 dashboard_token / api_token 仍可在导入时读取(见下方 apply)。
|
||||
return {
|
||||
dark_mode: !!this.darkMode
|
||||
};
|
||||
},
|
||||
|
||||
applyDashboardPreferencesBackup(preferences) {
|
||||
if (!preferences || typeof preferences !== 'object') return;
|
||||
|
||||
if (typeof preferences.dark_mode === 'boolean') {
|
||||
this.darkMode = preferences.dark_mode;
|
||||
}
|
||||
|
||||
if (typeof preferences.dashboard_token === 'string' || typeof preferences.api_token === 'string') {
|
||||
const token = String(preferences.dashboard_token || preferences.api_token || '').trim();
|
||||
try {
|
||||
setStoredDashboardToken(token);
|
||||
} catch (e) { }
|
||||
this.tempToken = token;
|
||||
this.syncTokenPresence();
|
||||
}
|
||||
},
|
||||
|
||||
async exportSettingsBackup() {
|
||||
try {
|
||||
const payload = await this.apiRequest('/api/settings/backup');
|
||||
const exportPayload = {
|
||||
...payload,
|
||||
dashboard_preferences: this.getDashboardPreferencesBackup()
|
||||
};
|
||||
const dataStr = JSON.stringify(exportPayload, null, 2);
|
||||
const blob = new Blob([dataStr], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = 'settings-backup-' + Date.now() + '.json';
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
const redactedKeys = Array.isArray(payload && payload.redacted_env_keys)
|
||||
? payload.redacted_env_keys
|
||||
: [];
|
||||
this.notify(
|
||||
redactedKeys.length
|
||||
? `完整配置备份已导出(已剔除 ${redactedKeys.length} 项令牌/密钥,导入时保留目标机器现值)`
|
||||
: '完整配置备份已导出',
|
||||
'success'
|
||||
);
|
||||
} catch (error) {
|
||||
this.notify('完整备份导出失败: ' + error.message, 'error');
|
||||
}
|
||||
},
|
||||
|
||||
// 修复:此处原有一份与下方「浏览器常量」区块完全相同的
|
||||
// normalizeBrowserConstantsForEditor / serializeBrowserConstants 重复定义(后定义者生效),
|
||||
// 已删除这份无效的前置副本,只保留下方那份。
|
||||
|
||||
async importSettingsBackup(payload) {
|
||||
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
||||
throw new Error('备份文件格式无效');
|
||||
}
|
||||
|
||||
const result = await this.apiRequest('/api/settings/backup', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
this.applyDashboardPreferencesBackup(payload.dashboard_preferences);
|
||||
|
||||
if (!result.will_restart) {
|
||||
await Promise.all([
|
||||
this.loadConfig(true),
|
||||
this.loadEnvConfig(),
|
||||
this.loadBrowserConstants(),
|
||||
this.loadUpdatePreserveSettings(),
|
||||
this.loadSelectorDefinitions()
|
||||
]);
|
||||
}
|
||||
|
||||
const sections = Array.isArray(result.imported_sections)
|
||||
? result.imported_sections.join('、')
|
||||
: '';
|
||||
this.notify(
|
||||
result.will_restart
|
||||
? '完整备份已导入,服务将自动重启' + (sections ? ':' + sections : '')
|
||||
: '完整备份已导入' + (sections ? ':' + sections : ''),
|
||||
result.will_restart ? 'warning' : 'success'
|
||||
);
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,205 @@
|
||||
// R2-8:由 dashboard-methods.js 拆分——版本管理。方法原样迁出,由 dashboard-methods.js 统一组装。
|
||||
(() => {
|
||||
const {
|
||||
DEFAULT_SELECTOR_DEFINITIONS,
|
||||
BROWSER_CONSTANTS_SCHEMA,
|
||||
ENV_CONFIG_SCHEMA,
|
||||
DASHBOARD_TOKEN_STORAGE_KEY,
|
||||
LEGACY_API_TOKEN_STORAGE_KEY,
|
||||
SITE_CONFIG_IMPORT_MAX_BYTES,
|
||||
SETTINGS_BACKUP_IMPORT_MAX_BYTES,
|
||||
importFileSizeError,
|
||||
formatGitCompareErrorText,
|
||||
getStoredDashboardToken,
|
||||
setStoredDashboardToken,
|
||||
SITE_FRIENDLY_NAMES,
|
||||
GENERIC_DOMAIN_LABELS,
|
||||
siteDisplayName,
|
||||
} = window.DashboardShared;
|
||||
(window.DashboardMethodParts = window.DashboardMethodParts || []).push({
|
||||
// ========== 版本管理方法 ==========
|
||||
|
||||
applyUpdateCheck(data) {
|
||||
const current = this.updateCheck && typeof this.updateCheck === 'object'
|
||||
? this.updateCheck
|
||||
: {};
|
||||
// 修复:检查失败时后端会把 latest_* 显式清空,这里若继续用 `||` 回落旧值,
|
||||
// 界面会同时显示"最新版本号"和"检查失败",语义矛盾。
|
||||
// 只有后端确实没带这些键(如轮询中的部分响应)才回落。
|
||||
const hasKey = (key) => !!data && Object.prototype.hasOwnProperty.call(data, key);
|
||||
const pick = (key) => String((hasKey(key) ? data[key] : current[key]) || '');
|
||||
this.updateCheck = {
|
||||
checked: !!(data && data.checked),
|
||||
checking: !!(data && data.checking),
|
||||
available: !!(data && data.available),
|
||||
current_version: String((data && data.current_version) || current.current_version || ''),
|
||||
latest_version: pick('latest_version'),
|
||||
latest_tag: pick('latest_tag'),
|
||||
published_at: pick('published_at'),
|
||||
repo: String((data && data.repo) || current.repo || ''),
|
||||
checked_at: data && data.checked_at ? data.checked_at : (current.checked_at || null),
|
||||
error: String((data && data.error) || '')
|
||||
};
|
||||
if (this.updateCheck.current_version && !this.releasesCurrentVersion) {
|
||||
this.releasesCurrentVersion = this.updateCheck.current_version;
|
||||
}
|
||||
return this.updateCheck;
|
||||
},
|
||||
|
||||
async loadUpdateCheck({ silent = false } = {}) {
|
||||
try {
|
||||
const data = await this.apiRequest('/api/update/check', { timeoutMs: 2500 });
|
||||
return this.applyUpdateCheck(data);
|
||||
} catch (error) {
|
||||
if (!silent) {
|
||||
this.notify('版本检查状态读取失败: ' + error.message, 'error');
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
async refreshUpdateCheck() {
|
||||
// 补齐入口:后端 POST /api/update/check 会真正访问 GitHub 重查一次,
|
||||
// 而 GET 只读启动时的缓存状态(system.py 注释明确「不会访问 GitHub」)。
|
||||
// 此前前端只调 GET,用户没有任何"立即检查更新"的入口。
|
||||
if (this.updateCheckRefreshing) return;
|
||||
this.updateCheckRefreshing = true;
|
||||
try {
|
||||
const data = await this.apiRequest('/api/update/check', { method: 'POST', timeoutMs: 20000 });
|
||||
const applied = this.applyUpdateCheck(data);
|
||||
if (applied.error) {
|
||||
this.notify('版本检查失败: ' + applied.error, 'error');
|
||||
} else if (applied.available) {
|
||||
this.notify('发现新版本: ' + (applied.latest_tag || applied.latest_version), 'info');
|
||||
} else {
|
||||
this.notify('已是最新版本', 'success');
|
||||
}
|
||||
return applied;
|
||||
} catch (error) {
|
||||
this.notify('版本检查失败: ' + error.message, 'error');
|
||||
} finally {
|
||||
this.updateCheckRefreshing = false;
|
||||
}
|
||||
},
|
||||
|
||||
scheduleUpdateCheckStatusRefresh(status, attempt = 0) {
|
||||
if (this.updateCheckTimer) {
|
||||
clearTimeout(this.updateCheckTimer);
|
||||
this.updateCheckTimer = null;
|
||||
}
|
||||
const stillPending = status && (status.checking || !status.checked);
|
||||
if (!stillPending || attempt >= 12) {
|
||||
return;
|
||||
}
|
||||
this.updateCheckTimer = setTimeout(() => {
|
||||
this.updateCheckTimer = null;
|
||||
this.loadUpdateCheck({ silent: true })
|
||||
.then((nextStatus) => this.scheduleUpdateCheckStatusRefresh(nextStatus, attempt + 1))
|
||||
.catch(() => {});
|
||||
}, 1500);
|
||||
},
|
||||
|
||||
async loadReleases() {
|
||||
this.releasesLoading = true;
|
||||
this.releasesError = '';
|
||||
try {
|
||||
const data = await this.apiRequest('/api/update/releases');
|
||||
this.releases = Array.isArray(data.releases) ? data.releases : [];
|
||||
this.releasesCurrentVersion = data.current_version || '';
|
||||
if (data.update_check) {
|
||||
this.applyUpdateCheck(data.update_check);
|
||||
}
|
||||
} catch (error) {
|
||||
this.releasesError = '加载失败: ' + error.message;
|
||||
this.releases = [];
|
||||
} finally {
|
||||
this.releasesLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
async switchToVersion(tag) {
|
||||
if (this.switchingTag) {
|
||||
this.notify('已有版本切换任务正在运行,请稍候', 'warning');
|
||||
return;
|
||||
}
|
||||
if (!confirm('确定要切换到 ' + tag + ' 吗?\n切换完成后服务将自动重启,页面需要手动刷新。')) {
|
||||
return;
|
||||
}
|
||||
this.switchingTag = tag;
|
||||
try {
|
||||
await this.apiRequest('/api/update/switch', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ tag: tag })
|
||||
});
|
||||
this.notify('版本切换任务已启动:' + tag + ',下载中...', 'info');
|
||||
this.startSwitchStatusPolling();
|
||||
} catch (error) {
|
||||
this.notify('启动版本切换失败: ' + error.message, 'error');
|
||||
this.switchingTag = null;
|
||||
}
|
||||
},
|
||||
|
||||
startSwitchStatusPolling() {
|
||||
this.stopSwitchStatusPolling();
|
||||
this.switchStatusPollingActive = true;
|
||||
const pollStatus = async () => {
|
||||
if (!this.switchStatusPollingActive || this.switchStatusPollingInFlight) {
|
||||
return;
|
||||
}
|
||||
this.switchStatusPollingInFlight = true;
|
||||
let shouldContinue = true;
|
||||
try {
|
||||
const status = await this.apiRequest('/api/update/status');
|
||||
if (!status.running) {
|
||||
shouldContinue = false;
|
||||
this.stopSwitchStatusPolling();
|
||||
if (status.success === true) {
|
||||
this.notify('版本 ' + status.tag + ' 切换成功,服务正在重启,请稍后刷新页面', 'success');
|
||||
} else if (status.success === false) {
|
||||
var errMsg = status.error ? ':' + status.error : '';
|
||||
this.notify('版本 ' + status.tag + ' 切换失败' + errMsg, 'error');
|
||||
this.switchingTag = null;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// 服务重启中,连接可能断开
|
||||
} finally {
|
||||
this.switchStatusPollingInFlight = false;
|
||||
if (shouldContinue && this.switchStatusPollingActive) {
|
||||
this.switchStatusPolling = setTimeout(() => {
|
||||
this.switchStatusPolling = null;
|
||||
pollStatus();
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
pollStatus();
|
||||
},
|
||||
|
||||
stopSwitchStatusPolling() {
|
||||
this.switchStatusPollingActive = false;
|
||||
if (this.switchStatusPolling) {
|
||||
clearTimeout(this.switchStatusPolling);
|
||||
this.switchStatusPolling = null;
|
||||
}
|
||||
this.switchStatusPollingInFlight = false;
|
||||
},
|
||||
|
||||
showChangelog(tag, body) {
|
||||
this.changelogTag = tag;
|
||||
this.changelogContent = body || '(无更新说明)';
|
||||
this.showChangelogModal = true;
|
||||
},
|
||||
|
||||
formatReleaseDate(isoStr) {
|
||||
if (!isoStr) return '—';
|
||||
try {
|
||||
var d = new Date(isoStr);
|
||||
var pad = function(n) { return String(n).padStart(2, '0'); };
|
||||
return d.getFullYear() + '/' + pad(d.getMonth()+1) + '/' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds());
|
||||
} catch (e) {
|
||||
return isoStr;
|
||||
}
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,100 @@
|
||||
// R2-8:由 dashboard-methods.js 拆分——各方法分组共用的常量与辅助函数(原 IIFE 头部,原样迁出)。
|
||||
(() => {
|
||||
const DEFAULT_SELECTOR_DEFINITIONS = window.DEFAULT_SELECTOR_DEFINITIONS || []
|
||||
const BROWSER_CONSTANTS_SCHEMA = window.BROWSER_CONSTANTS_SCHEMA || {}
|
||||
const ENV_CONFIG_SCHEMA = window.ENV_CONFIG_SCHEMA || {}
|
||||
const DASHBOARD_TOKEN_STORAGE_KEY = 'dashboard_token'
|
||||
const LEGACY_API_TOKEN_STORAGE_KEY = 'api_token'
|
||||
// H14:导入文件大小上限(整个文件读进内存再 JSON.parse,超大文件会卡死页面)。
|
||||
// 正常站点配置 / 完整备份都在数百 KB 级,上限留足余量。
|
||||
const SITE_CONFIG_IMPORT_MAX_BYTES = 8 * 1024 * 1024
|
||||
const SETTINGS_BACKUP_IMPORT_MAX_BYTES = 32 * 1024 * 1024
|
||||
|
||||
function importFileSizeError(file, maxBytes, label) {
|
||||
const size = Number(file && file.size) || 0
|
||||
if (size <= maxBytes) return ''
|
||||
const mb = (n) => (n / 1024 / 1024).toFixed(n >= 10 * 1024 * 1024 ? 0 : 1)
|
||||
return `${label}过大(${mb(size)} MiB),上限 ${mb(maxBytes)} MiB`
|
||||
}
|
||||
window.importFileSizeError = importFileSizeError
|
||||
|
||||
function formatGitCompareErrorText(error) {
|
||||
const raw = String((error && error.message) || error || '').trim()
|
||||
return raw || '读取官方配置失败'
|
||||
}
|
||||
window.formatGitCompareErrorText = formatGitCompareErrorText
|
||||
|
||||
function getStoredDashboardToken() {
|
||||
try {
|
||||
return String(
|
||||
localStorage.getItem(DASHBOARD_TOKEN_STORAGE_KEY)
|
||||
|| localStorage.getItem(LEGACY_API_TOKEN_STORAGE_KEY)
|
||||
|| ''
|
||||
).trim()
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function setStoredDashboardToken(token) {
|
||||
const value = String(token || '').trim()
|
||||
if (value) {
|
||||
localStorage.setItem(DASHBOARD_TOKEN_STORAGE_KEY, value)
|
||||
return
|
||||
}
|
||||
localStorage.removeItem(DASHBOARD_TOKEN_STORAGE_KEY)
|
||||
localStorage.removeItem(LEGACY_API_TOKEN_STORAGE_KEY)
|
||||
}
|
||||
|
||||
// 站点友好名称:解决 "domain.split('.')[0]" 在 chat.deepseek.com / chat.qwen.ai
|
||||
// 或 aistudio.google.com / aistudio.xiaomimimo.com 这类站点上撞出一堆同名(chat、aistudio)的问题
|
||||
const SITE_FRIENDLY_NAMES = {
|
||||
'aistudio.google.com': 'Google AI Studio',
|
||||
'aistudio.xiaomimimo.com': '小米 MiMo AI Studio',
|
||||
'grok.com': 'Grok',
|
||||
'chatgpt.com': 'ChatGPT',
|
||||
'gemini.google.com': 'Gemini',
|
||||
'chat.deepseek.com': 'DeepSeek',
|
||||
'www.doubao.com': '豆包 Doubao',
|
||||
'claude.ai': 'Claude',
|
||||
'arena.ai': 'LMArena',
|
||||
'chat.qwen.ai': '通义千问 Qwen',
|
||||
'www.kimi.com': 'Kimi',
|
||||
'chatglm.cn': '智谱清言 ChatGLM',
|
||||
'ai.google.dev': 'Google AI (ai.google.dev)',
|
||||
'www.google.com': 'Google'
|
||||
}
|
||||
// 域名首段是这些通用词时,单独显示会分不清是哪个站点(比如两个 "chat")
|
||||
const GENERIC_DOMAIN_LABELS = new Set(['www', 'chat', 'ai', 'app', 'api', 'web', 'my', 'portal', 'console', 'platform'])
|
||||
|
||||
function siteDisplayName(domain) {
|
||||
const value = String(domain || '').trim()
|
||||
if (!value) return domain
|
||||
if (SITE_FRIENDLY_NAMES[value]) return SITE_FRIENDLY_NAMES[value]
|
||||
|
||||
const labels = value.replace(/^www\./, '').split('.')
|
||||
const first = labels[0] || value
|
||||
if (GENERIC_DOMAIN_LABELS.has(first.toLowerCase()) && labels.length > 1) {
|
||||
return first + ' · ' + labels[1]
|
||||
}
|
||||
return first
|
||||
}
|
||||
window.siteDisplayName = siteDisplayName
|
||||
|
||||
window.DashboardShared = {
|
||||
DEFAULT_SELECTOR_DEFINITIONS,
|
||||
BROWSER_CONSTANTS_SCHEMA,
|
||||
ENV_CONFIG_SCHEMA,
|
||||
DASHBOARD_TOKEN_STORAGE_KEY,
|
||||
LEGACY_API_TOKEN_STORAGE_KEY,
|
||||
SITE_CONFIG_IMPORT_MAX_BYTES,
|
||||
SETTINGS_BACKUP_IMPORT_MAX_BYTES,
|
||||
importFileSizeError,
|
||||
formatGitCompareErrorText,
|
||||
getStoredDashboardToken,
|
||||
setStoredDashboardToken,
|
||||
SITE_FRIENDLY_NAMES,
|
||||
GENERIC_DOMAIN_LABELS,
|
||||
siteDisplayName,
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,84 @@
|
||||
// ==================== SVG 图标定义 ====================
|
||||
window.$icons = {
|
||||
window: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="M3 9h18M7 6.5h.01M10 6.5h.01"/></svg>`,
|
||||
checkCircle: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="m8 12 3 3 5-6"/></svg>`,
|
||||
exclamationTriangle: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="m10.3 4.4-8 14A1.8 1.8 0 0 0 4 21h16a1.8 1.8 0 0 0 1.6-2.6l-8-14a1.9 1.9 0 0 0-3.3 0Z"/><path d="M12 9v4m0 4h.01"/></svg>`,
|
||||
documentText: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9Z"/><path d="M14 3v6h6M8 13h8M8 17h5"/></svg>`,
|
||||
link: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7 .1l3-3a5 5 0 0 0-7-7l-1.7 1.7M14 11a5 5 0 0 0-7-.1l-3 3a5 5 0 0 0 7 7l1.7-1.7"/></svg>`,
|
||||
minus: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/></svg>`,
|
||||
check: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12 4 4L19 6"/></svg>`,
|
||||
codeBracket: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="m8 5-6 7 6 7m8-14 6 7-6 7m-3-15-2 16"/></svg>`,
|
||||
photo: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="3"/><circle cx="8.5" cy="8" r="1.5"/><path d="m3 17 5-5 4 4 4-6 5 7"/></svg>`,
|
||||
cursorArrowRays: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="m4 3 7 18 3-7 7-3L4 3Z"/><path d="m15 15 5 5"/></svg>`,
|
||||
home: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m3 11 9-8 9 8M5 10v10h14V10M9 20v-6h6v6"/></svg>`,
|
||||
|
||||
activity: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>`,
|
||||
|
||||
globe: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" stroke-width="2"/><path stroke-linecap="round" stroke-width="2" d="M3 12h18M12 3c2.3 2.5 3.5 5.5 3.5 9S14.3 18.5 12 21M12 3c-2.3 2.5-3.5 5.5-3.5 9S9.7 18.5 12 21"/></svg>`,
|
||||
|
||||
timer: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><circle cx="12" cy="13" r="8" stroke-width="2"/><path stroke-linecap="round" stroke-width="2" d="M12 9v4l2.5 2M9 2h6"/></svg>`,
|
||||
|
||||
server: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="6" rx="2" stroke-width="2"/><rect x="3" y="14" width="18" height="6" rx="2" stroke-width="2"/><path stroke-linecap="round" stroke-width="2" d="M7 7h.01M7 17h.01"/></svg>`,
|
||||
|
||||
arrowRight: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14m-6-6 6 6-6 6"/></svg>`,
|
||||
|
||||
magnifyingGlass: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7" stroke-width="2"/><path stroke-linecap="round" stroke-width="2" d="m20 20-4-4"/></svg>`,
|
||||
|
||||
beaker: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"/></svg>`,
|
||||
|
||||
arrowDownTray: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"/></svg>`,
|
||||
|
||||
arrowPath: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"/></svg>`,
|
||||
|
||||
plusCircle: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>`,
|
||||
|
||||
trash: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"/></svg>`,
|
||||
|
||||
xMark: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>`,
|
||||
|
||||
chevronUp: `<svg class="w-3 h-3 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.5 15.75l7.5-7.5 7.5 7.5"/></svg>`,
|
||||
|
||||
chevronDown: `<svg class="w-3 h-3 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.5 8.25l-7.5 7.5-7.5-7.5"/></svg>`,
|
||||
|
||||
clipboardList: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"/></svg>`,
|
||||
|
||||
bookOpen: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"/></svg>`,
|
||||
|
||||
moon: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21.752 15.002A9.718 9.718 0 0118 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 003 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 009.002-5.998z"/></svg>`,
|
||||
|
||||
sun: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v2.25m6.364.386l-1.591 1.591M21 12h-2.25m-.386 6.364l-1.591-1.591M12 18.75V21m-4.773-4.227l-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z"/></svg>`,
|
||||
|
||||
chartBar: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z"/></svg>`,
|
||||
|
||||
arrowUpTray: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"/></svg>`,
|
||||
|
||||
cog: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 011.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 01-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.397.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 01-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.505-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.107-1.204l-.527-.738a1.125 1.125 0 01.12-1.45l.773-.773a1.125 1.125 0 011.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/></svg>`,
|
||||
|
||||
folderOpen: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"/></svg>`,
|
||||
|
||||
shoppingBag: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16.5 10.5V6.75a4.5 4.5 0 10-9 0v3.75m-2.625 0h14.25A1.125 1.125 0 0120.25 11.7l-.75 7.5A2.25 2.25 0 0117.262 21H6.738A2.25 2.25 0 014.5 19.2l-.75-7.5A1.125 1.125 0 014.875 10.5z"/></svg>`,
|
||||
|
||||
documentArrowDown: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m.75 12l3 3m0 0l3-3m-3 3v-6m-1.5-9H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"/></svg>`,
|
||||
|
||||
arrowPathRoundedSquare: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.5 12c0-1.232-.046-2.453-.138-3.662a4.006 4.006 0 00-3.7-3.7 48.678 48.678 0 00-7.324 0 4.006 4.006 0 00-3.7 3.7c-.017.22-.032.441-.046.662M19.5 12l3-3m-3 3l-3-3m-12 3c0 1.232.046 2.453.138 3.662a4.006 4.006 0 003.7 3.7 48.656 48.656 0 007.324 0 4.006 4.006 0 003.7-3.7c.017-.22.032-.441.046-.662M4.5 12l3 3m-3-3l-3 3"/></svg>`,
|
||||
|
||||
arrowTopRightOnSquare: `<svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.5 6H19.5m0 0V12m0-6L10.5 15m6.75-10.5H8.25A2.25 2.25 0 006 6.75v9A2.25 2.25 0 008.25 18h9A2.25 2.25 0 0019.5 15.75v-9"/></svg>`,
|
||||
|
||||
pencil: `<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>`,
|
||||
|
||||
arrowUp: `<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19V5m0 0-6 6m6-6 6 6"/></svg>`,
|
||||
|
||||
arrowDown: `<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5v14m0 0 6-6m-6 6-6-6"/></svg>`,
|
||||
|
||||
play: `<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m8 5 11 7-11 7V5Z"/></svg>`,
|
||||
|
||||
pause: `<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5v14m6-14v14"/></svg>`,
|
||||
|
||||
power: `<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v9m6.4-6.4a9 9 0 1 1-12.8 0"/></svg>`,
|
||||
|
||||
ellipsisVertical: `<svg class="h-4 w-4" fill="currentColor" viewBox="0 0 24 24"><circle cx="12" cy="5" r="1.75"/><circle cx="12" cy="12" r="1.75"/><circle cx="12" cy="19" r="1.75"/></svg>`,
|
||||
|
||||
copy: `<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><rect x="9" y="9" width="11" height="11" rx="2" stroke-width="2"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h3"/></svg>`,
|
||||
|
||||
gripVertical: `<svg class="w-3.5 h-3.5" fill="currentColor" viewBox="0 0 24 24"><circle cx="9" cy="5" r="1.5"/><circle cx="15" cy="5" r="1.5"/><circle cx="9" cy="12" r="1.5"/><circle cx="15" cy="12" r="1.5"/><circle cx="9" cy="19" r="1.5"/><circle cx="15" cy="19" r="1.5"/></svg>`
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,791 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Lifecycle Probe</title>
|
||||
<style>
|
||||
:root {
|
||||
color-scheme: light;
|
||||
--bg: #f4efe7;
|
||||
--card: rgba(255, 251, 245, 0.92);
|
||||
--ink: #1f2430;
|
||||
--muted: #596274;
|
||||
--accent: #b55239;
|
||||
--accent-soft: rgba(181, 82, 57, 0.12);
|
||||
--ok: #1d6b4e;
|
||||
--warn: #9b5a00;
|
||||
--danger: #9b2c2c;
|
||||
--line: rgba(31, 36, 48, 0.12);
|
||||
--shadow: 0 24px 60px rgba(63, 41, 24, 0.14);
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
color: var(--ink);
|
||||
background:
|
||||
radial-gradient(circle at top left, rgba(210, 149, 103, 0.22), transparent 32%),
|
||||
radial-gradient(circle at right 20%, rgba(105, 143, 112, 0.16), transparent 26%),
|
||||
linear-gradient(135deg, #f8f3eb 0%, #f1e6d8 54%, #efe7df 100%);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.page {
|
||||
width: min(1200px, calc(100vw - 32px));
|
||||
margin: 24px auto 40px;
|
||||
}
|
||||
|
||||
.hero,
|
||||
.panel,
|
||||
.log-card {
|
||||
background: var(--card);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 24px;
|
||||
box-shadow: var(--shadow);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.hero {
|
||||
padding: 28px 28px 24px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.hero::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: auto -60px -60px auto;
|
||||
width: 220px;
|
||||
height: 220px;
|
||||
background: radial-gradient(circle, rgba(181, 82, 57, 0.16), transparent 72%);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0 0 8px;
|
||||
font-size: clamp(32px, 5vw, 52px);
|
||||
line-height: 1;
|
||||
letter-spacing: -0.04em;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
margin: 0;
|
||||
max-width: 780px;
|
||||
color: var(--muted);
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin-top: 22px;
|
||||
}
|
||||
|
||||
button {
|
||||
appearance: none;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
padding: 12px 18px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.primary {
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #c85d42, #9f412d);
|
||||
box-shadow: 0 12px 24px rgba(159, 65, 45, 0.22);
|
||||
}
|
||||
|
||||
.secondary {
|
||||
color: var(--ink);
|
||||
background: #f8f1e8;
|
||||
border: 1px solid rgba(31, 36, 48, 0.12);
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin-top: 16px;
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(12, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.panel.span-4 {
|
||||
grid-column: span 4;
|
||||
}
|
||||
|
||||
.panel.span-6 {
|
||||
grid-column: span 6;
|
||||
}
|
||||
|
||||
.panel.span-8 {
|
||||
grid-column: span 8;
|
||||
}
|
||||
|
||||
.panel.span-12,
|
||||
.log-card {
|
||||
grid-column: span 12;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.12em;
|
||||
color: var(--muted);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.metric {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.metric strong {
|
||||
font-size: clamp(28px, 4vw, 42px);
|
||||
line-height: 1;
|
||||
letter-spacing: -0.05em;
|
||||
}
|
||||
|
||||
.metric span {
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.mini-list {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.mini-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
font-size: 14px;
|
||||
color: var(--muted);
|
||||
border-top: 1px solid rgba(31, 36, 48, 0.08);
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.mini-row b {
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.pill-wrap {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.pill {
|
||||
border-radius: 999px;
|
||||
padding: 8px 10px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
border: 1px solid rgba(31, 36, 48, 0.08);
|
||||
background: rgba(255, 255, 255, 0.66);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.pill.ok {
|
||||
color: var(--ok);
|
||||
background: rgba(29, 107, 78, 0.12);
|
||||
border-color: rgba(29, 107, 78, 0.2);
|
||||
}
|
||||
|
||||
.pill.warn {
|
||||
color: var(--warn);
|
||||
background: rgba(155, 90, 0, 0.12);
|
||||
border-color: rgba(155, 90, 0, 0.2);
|
||||
}
|
||||
|
||||
.pill.danger {
|
||||
color: var(--danger);
|
||||
background: rgba(155, 44, 44, 0.12);
|
||||
border-color: rgba(155, 44, 44, 0.2);
|
||||
}
|
||||
|
||||
.summary {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.summary-box {
|
||||
padding: 14px 16px;
|
||||
border-radius: 18px;
|
||||
border: 1px solid rgba(31, 36, 48, 0.08);
|
||||
background: rgba(255, 255, 255, 0.62);
|
||||
}
|
||||
|
||||
.summary-box h2 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.summary-box p {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
line-height: 1.6;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.log-card {
|
||||
margin-top: 18px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.log-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.log-head h2 {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.log {
|
||||
background: #1c1f27;
|
||||
color: #e6edf3;
|
||||
border-radius: 18px;
|
||||
padding: 16px;
|
||||
min-height: 260px;
|
||||
max-height: 420px;
|
||||
overflow: auto;
|
||||
font-family: Consolas, "SFMono-Regular", Monaco, monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.test-steps {
|
||||
margin-top: 12px;
|
||||
color: var(--muted);
|
||||
font-size: 14px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.test-steps strong {
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.panel.span-4,
|
||||
.panel.span-6,
|
||||
.panel.span-8 {
|
||||
grid-column: span 12;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="page">
|
||||
<section class="hero">
|
||||
<div class="label">Lifecycle / Background Throttle Probe</div>
|
||||
<h1>后台节流探针</h1>
|
||||
<p class="subtitle">
|
||||
这个页面不查传统 webdriver 指纹,只测受控浏览器在切标签、最小化、失焦和后台驻留时到底有没有继续跑计时器、worker 和动画帧。
|
||||
它更适合判断你那组 anti-throttle 启动参数是不是在产生“非常驻前台也像前台”的副作用。
|
||||
</p>
|
||||
<div class="toolbar">
|
||||
<button class="primary" id="startBtn">重置并开始一次测试</button>
|
||||
<button class="secondary" id="copyBtn">复制本次摘要</button>
|
||||
<button class="secondary" id="clearBtn">清空日志</button>
|
||||
</div>
|
||||
<div class="hint">
|
||||
建议流程:先点“重置并开始一次测试”,然后切到别的标签页或把浏览器最小化 30 秒,再回来观察主线程、worker 和 rAF 的漂移差异。
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="grid">
|
||||
<article class="panel span-4">
|
||||
<div class="label">当前状态</div>
|
||||
<div class="metric">
|
||||
<strong id="visibilityState">visible</strong>
|
||||
<span id="focusState">focused</span>
|
||||
</div>
|
||||
<div class="pill-wrap" id="statusPills"></div>
|
||||
<div class="mini-list">
|
||||
<div class="mini-row"><span>自上次重置已运行</span><b id="uptime">0.0s</b></div>
|
||||
<div class="mini-row"><span>隐藏累计时长</span><b id="hiddenTime">0.0s</b></div>
|
||||
<div class="mini-row"><span>最后一次变 hidden</span><b id="lastHiddenAt">-</b></div>
|
||||
<div class="mini-row"><span>document.wasDiscarded</span><b id="wasDiscarded">false</b></div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="panel span-4">
|
||||
<div class="label">主线程 Interval</div>
|
||||
<div class="metric">
|
||||
<strong id="mainAvgDrift">0ms</strong>
|
||||
<span>平均漂移</span>
|
||||
</div>
|
||||
<div class="mini-list">
|
||||
<div class="mini-row"><span>最大漂移</span><b id="mainMaxDrift">0ms</b></div>
|
||||
<div class="mini-row"><span>隐藏时样本数</span><b id="hiddenIntervalSamples">0</b></div>
|
||||
<div class="mini-row"><span>隐藏时最大漂移</span><b id="hiddenMaxDrift">0ms</b></div>
|
||||
<div class="mini-row"><span>最近一次 tick</span><b id="mainLastDelta">0ms</b></div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="panel span-4">
|
||||
<div class="label">Worker Interval</div>
|
||||
<div class="metric">
|
||||
<strong id="workerAvgDrift">0ms</strong>
|
||||
<span>平均漂移</span>
|
||||
</div>
|
||||
<div class="mini-list">
|
||||
<div class="mini-row"><span>最大漂移</span><b id="workerMaxDrift">0ms</b></div>
|
||||
<div class="mini-row"><span>隐藏时样本数</span><b id="workerHiddenSamples">0</b></div>
|
||||
<div class="mini-row"><span>隐藏时最大漂移</span><b id="workerHiddenMaxDrift">0ms</b></div>
|
||||
<div class="mini-row"><span>最近一次 tick</span><b id="workerLastDelta">0ms</b></div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="panel span-6">
|
||||
<div class="label">requestAnimationFrame</div>
|
||||
<div class="metric">
|
||||
<strong id="rafRate">0 fps</strong>
|
||||
<span>当前窗口</span>
|
||||
</div>
|
||||
<div class="mini-list">
|
||||
<div class="mini-row"><span>最近 2 秒帧数</span><b id="rafFrames">0</b></div>
|
||||
<div class="mini-row"><span>隐藏期间是否仍在跑</span><b id="rafHidden">未知</b></div>
|
||||
<div class="mini-row"><span>最大帧间隔</span><b id="rafMaxGap">0ms</b></div>
|
||||
<div class="mini-row"><span>最后一帧间隔</span><b id="rafLastGap">0ms</b></div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="panel span-6">
|
||||
<div class="label">生命周期事件</div>
|
||||
<div class="pill-wrap" id="eventPills"></div>
|
||||
<div class="mini-list">
|
||||
<div class="mini-row"><span>visibilitychange 次数</span><b id="visibilityEvents">0</b></div>
|
||||
<div class="mini-row"><span>freeze 次数</span><b id="freezeEvents">0</b></div>
|
||||
<div class="mini-row"><span>resume 次数</span><b id="resumeEvents">0</b></div>
|
||||
<div class="mini-row"><span>pageshow/pagehide</span><b id="pageShowHide">0 / 0</b></div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="panel span-8">
|
||||
<div class="label">自动解读</div>
|
||||
<div class="summary" id="summaryBoxes"></div>
|
||||
</article>
|
||||
|
||||
<article class="panel span-4">
|
||||
<div class="label">测试步骤</div>
|
||||
<div class="test-steps">
|
||||
<strong>1.</strong> 保持这个页面在前台,先点一次“重置并开始一次测试”。<br>
|
||||
<strong>2.</strong> 切换到别的标签页,或者把浏览器最小化,停留 30 到 60 秒。<br>
|
||||
<strong>3.</strong> 回来后看三件事:主线程漂移、worker 漂移、是否收到了 freeze/resume。<br>
|
||||
<strong>4.</strong> 如果隐藏期间主线程和 worker 都几乎不漂,且 rAF 也不怎么停,这通常说明后台节流被明显放松。<br>
|
||||
<strong>5.</strong> 如果隐藏后出现大漂移、freeze 或恢复事件,更接近普通 Chrome 默认行为。
|
||||
</div>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="log-card">
|
||||
<div class="log-head">
|
||||
<h2>事件日志</h2>
|
||||
<div class="label" id="lastSummaryAt">尚未生成摘要</div>
|
||||
</div>
|
||||
<div class="log" id="log"></div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
const state = {
|
||||
startedAt: performance.now(),
|
||||
hiddenStartedAt: null,
|
||||
totalHiddenMs: 0,
|
||||
lastHiddenHuman: '-',
|
||||
visibilityEvents: 0,
|
||||
freezeEvents: 0,
|
||||
resumeEvents: 0,
|
||||
pageShowEvents: 0,
|
||||
pageHideEvents: 0,
|
||||
mainDrifts: [],
|
||||
mainHiddenDrifts: [],
|
||||
workerDrifts: [],
|
||||
workerHiddenDrifts: [],
|
||||
mainLastDelta: 0,
|
||||
workerLastDelta: 0,
|
||||
rafFramesRecent: [],
|
||||
rafHiddenObserved: false,
|
||||
rafLastGap: 0,
|
||||
rafMaxGap: 0,
|
||||
summaryText: '',
|
||||
worker: null
|
||||
};
|
||||
|
||||
const el = (id) => document.getElementById(id);
|
||||
const logEl = el('log');
|
||||
|
||||
function fmtMs(value) {
|
||||
if (!Number.isFinite(value)) return '-';
|
||||
return `${Math.round(value)}ms`;
|
||||
}
|
||||
|
||||
function fmtSec(value) {
|
||||
if (!Number.isFinite(value)) return '-';
|
||||
return `${(value / 1000).toFixed(1)}s`;
|
||||
}
|
||||
|
||||
function avg(values) {
|
||||
if (!values.length) return 0;
|
||||
return values.reduce((sum, item) => sum + item, 0) / values.length;
|
||||
}
|
||||
|
||||
function max(values) {
|
||||
if (!values.length) return 0;
|
||||
return Math.max(...values);
|
||||
}
|
||||
|
||||
function log(message) {
|
||||
const stamp = new Date().toLocaleTimeString('zh-CN', { hour12: false });
|
||||
logEl.textContent += `[${stamp}] ${message}\n`;
|
||||
logEl.scrollTop = logEl.scrollHeight;
|
||||
}
|
||||
|
||||
function setPills(targetId, pills) {
|
||||
const host = el(targetId);
|
||||
host.innerHTML = '';
|
||||
pills.forEach(({ text, level }) => {
|
||||
const node = document.createElement('span');
|
||||
node.className = `pill ${level || ''}`.trim();
|
||||
node.textContent = text;
|
||||
host.appendChild(node);
|
||||
});
|
||||
}
|
||||
|
||||
function summaryBoxes() {
|
||||
const hiddenMain = max(state.mainHiddenDrifts);
|
||||
const hiddenWorker = max(state.workerHiddenDrifts);
|
||||
const hiddenSamples = state.mainHiddenDrifts.length + state.workerHiddenDrifts.length;
|
||||
const boxes = [];
|
||||
|
||||
if (!hiddenSamples) {
|
||||
boxes.push({
|
||||
title: '还没拿到隐藏期样本',
|
||||
text: '先切到别的标签页或最小化 30 秒以上,再回来,这样才有办法判断后台节流是否被放松。'
|
||||
});
|
||||
} else if (hiddenMain < 400 && hiddenWorker < 400) {
|
||||
boxes.push({
|
||||
title: '隐藏期计时器仍然非常活跃',
|
||||
text: '主线程和 worker 在页面隐藏期间都没有出现明显漂移,这更像后台节流被显著放松,不太像普通 Chrome 默认表现。'
|
||||
});
|
||||
} else if (hiddenMain > 1500 || hiddenWorker > 1500) {
|
||||
boxes.push({
|
||||
title: '隐藏期出现明显节流或冻结',
|
||||
text: '隐藏期间出现了秒级漂移,说明浏览器在回到后台后确实压制了定时器,更接近默认浏览器行为。'
|
||||
});
|
||||
} else {
|
||||
boxes.push({
|
||||
title: '隐藏期有轻度节流',
|
||||
text: '后台确实出现了漂移,但不算特别重,通常说明某些默认节流机制被放松了,但没有完全失效。'
|
||||
});
|
||||
}
|
||||
|
||||
if (state.freezeEvents > 0 || state.resumeEvents > 0) {
|
||||
boxes.push({
|
||||
title: '检测到 Page Lifecycle 冻结事件',
|
||||
text: '浏览器显式触发了 freeze/resume,这通常更接近系统或浏览器默认的后台资源回收路径。'
|
||||
});
|
||||
} else {
|
||||
boxes.push({
|
||||
title: '没有收到 freeze/resume',
|
||||
text: '这不代表一定异常,但如果你长时间最小化也一直收不到事件,通常要结合漂移结果一起看。'
|
||||
});
|
||||
}
|
||||
|
||||
if (state.rafHiddenObserved) {
|
||||
boxes.push({
|
||||
title: '隐藏期间 rAF 仍被观察到',
|
||||
text: 'requestAnimationFrame 在后台通常会停得很厉害。如果隐藏期间它仍持续产生活动,这会让页面生命周期看起来偏“前台化”。'
|
||||
});
|
||||
} else {
|
||||
boxes.push({
|
||||
title: '隐藏期间 rAF 基本停住',
|
||||
text: '这更接近常见浏览器在后台对动画帧的默认处理方式。'
|
||||
});
|
||||
}
|
||||
|
||||
const host = el('summaryBoxes');
|
||||
host.innerHTML = '';
|
||||
boxes.forEach((box) => {
|
||||
const node = document.createElement('div');
|
||||
node.className = 'summary-box';
|
||||
node.innerHTML = `<h2>${box.title}</h2><p>${box.text}</p>`;
|
||||
host.appendChild(node);
|
||||
});
|
||||
|
||||
const summary = [
|
||||
`visibility=${document.visibilityState}`,
|
||||
`focus=${document.hasFocus()}`,
|
||||
`hidden_total=${fmtSec(state.totalHiddenMs)}`,
|
||||
`main_hidden_max=${fmtMs(hiddenMain)}`,
|
||||
`worker_hidden_max=${fmtMs(hiddenWorker)}`,
|
||||
`freeze=${state.freezeEvents}`,
|
||||
`resume=${state.resumeEvents}`,
|
||||
`raf_hidden=${state.rafHiddenObserved}`
|
||||
].join(', ');
|
||||
state.summaryText = summary;
|
||||
el('lastSummaryAt').textContent = `最近摘要: ${summary}`;
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
const now = performance.now();
|
||||
const totalHiddenMs = state.totalHiddenMs + (document.hidden && state.hiddenStartedAt ? now - state.hiddenStartedAt : 0);
|
||||
|
||||
el('visibilityState').textContent = document.visibilityState;
|
||||
el('focusState').textContent = document.hasFocus() ? 'focused' : 'blurred';
|
||||
el('uptime').textContent = fmtSec(now - state.startedAt);
|
||||
el('hiddenTime').textContent = fmtSec(totalHiddenMs);
|
||||
el('lastHiddenAt').textContent = state.lastHiddenHuman;
|
||||
el('wasDiscarded').textContent = String(document.wasDiscarded || false);
|
||||
el('mainAvgDrift').textContent = fmtMs(avg(state.mainDrifts));
|
||||
el('mainMaxDrift').textContent = fmtMs(max(state.mainDrifts));
|
||||
el('hiddenIntervalSamples').textContent = String(state.mainHiddenDrifts.length);
|
||||
el('hiddenMaxDrift').textContent = fmtMs(max(state.mainHiddenDrifts));
|
||||
el('mainLastDelta').textContent = fmtMs(state.mainLastDelta);
|
||||
el('workerAvgDrift').textContent = fmtMs(avg(state.workerDrifts));
|
||||
el('workerMaxDrift').textContent = fmtMs(max(state.workerDrifts));
|
||||
el('workerHiddenSamples').textContent = String(state.workerHiddenDrifts.length);
|
||||
el('workerHiddenMaxDrift').textContent = fmtMs(max(state.workerHiddenDrifts));
|
||||
el('workerLastDelta').textContent = fmtMs(state.workerLastDelta);
|
||||
el('rafFrames').textContent = String(state.rafFramesRecent.length);
|
||||
el('rafRate').textContent = `${Math.round(state.rafFramesRecent.length / 2)} fps`;
|
||||
el('rafHidden').textContent = state.rafHiddenObserved ? '是' : '否';
|
||||
el('rafMaxGap').textContent = fmtMs(state.rafMaxGap);
|
||||
el('rafLastGap').textContent = fmtMs(state.rafLastGap);
|
||||
el('visibilityEvents').textContent = String(state.visibilityEvents);
|
||||
el('freezeEvents').textContent = String(state.freezeEvents);
|
||||
el('resumeEvents').textContent = String(state.resumeEvents);
|
||||
el('pageShowHide').textContent = `${state.pageShowEvents} / ${state.pageHideEvents}`;
|
||||
|
||||
const status = [
|
||||
{ text: `visibility: ${document.visibilityState}`, level: document.hidden ? 'warn' : 'ok' },
|
||||
{ text: document.hasFocus() ? 'focus=true' : 'focus=false', level: document.hasFocus() ? 'ok' : 'warn' },
|
||||
{ text: `wasDiscarded=${document.wasDiscarded || false}`, level: document.wasDiscarded ? 'danger' : 'ok' }
|
||||
];
|
||||
setPills('statusPills', status);
|
||||
|
||||
const events = [
|
||||
{ text: `visibilitychange ${state.visibilityEvents}`, level: state.visibilityEvents ? 'ok' : '' },
|
||||
{ text: `freeze ${state.freezeEvents}`, level: state.freezeEvents ? 'warn' : '' },
|
||||
{ text: `resume ${state.resumeEvents}`, level: state.resumeEvents ? 'ok' : '' },
|
||||
{ text: `pageshow ${state.pageShowEvents}`, level: state.pageShowEvents ? 'ok' : '' },
|
||||
{ text: `pagehide ${state.pageHideEvents}`, level: state.pageHideEvents ? 'warn' : '' }
|
||||
];
|
||||
setPills('eventPills', events);
|
||||
|
||||
summaryBoxes();
|
||||
}
|
||||
|
||||
function resetState() {
|
||||
state.startedAt = performance.now();
|
||||
state.hiddenStartedAt = null;
|
||||
state.totalHiddenMs = 0;
|
||||
state.lastHiddenHuman = '-';
|
||||
state.visibilityEvents = 0;
|
||||
state.freezeEvents = 0;
|
||||
state.resumeEvents = 0;
|
||||
state.pageShowEvents = 0;
|
||||
state.pageHideEvents = 0;
|
||||
state.mainDrifts = [];
|
||||
state.mainHiddenDrifts = [];
|
||||
state.workerDrifts = [];
|
||||
state.workerHiddenDrifts = [];
|
||||
state.mainLastDelta = 0;
|
||||
state.workerLastDelta = 0;
|
||||
state.rafFramesRecent = [];
|
||||
state.rafHiddenObserved = false;
|
||||
state.rafLastGap = 0;
|
||||
state.rafMaxGap = 0;
|
||||
logEl.textContent = '';
|
||||
log('测试状态已重置。');
|
||||
refresh();
|
||||
}
|
||||
|
||||
function installMainIntervalProbe() {
|
||||
let last = performance.now();
|
||||
window.setInterval(() => {
|
||||
const now = performance.now();
|
||||
const delta = now - last;
|
||||
last = now;
|
||||
state.mainLastDelta = delta;
|
||||
const drift = Math.max(0, delta - 1000);
|
||||
state.mainDrifts.push(drift);
|
||||
if (state.mainDrifts.length > 200) state.mainDrifts.shift();
|
||||
if (document.hidden) {
|
||||
state.mainHiddenDrifts.push(drift);
|
||||
if (state.mainHiddenDrifts.length > 120) state.mainHiddenDrifts.shift();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function installWorkerProbe() {
|
||||
const workerCode = `
|
||||
let last = performance.now();
|
||||
setInterval(() => {
|
||||
const now = performance.now();
|
||||
const delta = now - last;
|
||||
last = now;
|
||||
self.postMessage({ type: 'tick', delta });
|
||||
}, 1000);
|
||||
`;
|
||||
const blob = new Blob([workerCode], { type: 'application/javascript' });
|
||||
state.worker = new Worker(URL.createObjectURL(blob));
|
||||
state.worker.onmessage = (event) => {
|
||||
const delta = Number(event.data.delta) || 0;
|
||||
state.workerLastDelta = delta;
|
||||
const drift = Math.max(0, delta - 1000);
|
||||
state.workerDrifts.push(drift);
|
||||
if (state.workerDrifts.length > 200) state.workerDrifts.shift();
|
||||
if (document.hidden) {
|
||||
state.workerHiddenDrifts.push(drift);
|
||||
if (state.workerHiddenDrifts.length > 120) state.workerHiddenDrifts.shift();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function installRAFProbe() {
|
||||
let last = performance.now();
|
||||
function frame(now) {
|
||||
const gap = now - last;
|
||||
last = now;
|
||||
state.rafLastGap = gap;
|
||||
state.rafMaxGap = Math.max(state.rafMaxGap, gap);
|
||||
state.rafFramesRecent.push(now);
|
||||
if (document.hidden) {
|
||||
state.rafHiddenObserved = true;
|
||||
}
|
||||
while (state.rafFramesRecent.length && now - state.rafFramesRecent[0] > 2000) {
|
||||
state.rafFramesRecent.shift();
|
||||
}
|
||||
requestAnimationFrame(frame);
|
||||
}
|
||||
requestAnimationFrame(frame);
|
||||
}
|
||||
|
||||
function addLifecycleListeners() {
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
state.visibilityEvents += 1;
|
||||
if (document.hidden) {
|
||||
state.hiddenStartedAt = performance.now();
|
||||
state.lastHiddenHuman = new Date().toLocaleTimeString('zh-CN', { hour12: false });
|
||||
log(`visibilitychange -> hidden`);
|
||||
} else {
|
||||
if (state.hiddenStartedAt) {
|
||||
state.totalHiddenMs += performance.now() - state.hiddenStartedAt;
|
||||
state.hiddenStartedAt = null;
|
||||
}
|
||||
log(`visibilitychange -> visible`);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
|
||||
window.addEventListener('focus', () => {
|
||||
log('window focus');
|
||||
refresh();
|
||||
});
|
||||
|
||||
window.addEventListener('blur', () => {
|
||||
log('window blur');
|
||||
refresh();
|
||||
});
|
||||
|
||||
document.addEventListener('freeze', () => {
|
||||
state.freezeEvents += 1;
|
||||
log('document freeze');
|
||||
refresh();
|
||||
});
|
||||
|
||||
document.addEventListener('resume', () => {
|
||||
state.resumeEvents += 1;
|
||||
log('document resume');
|
||||
refresh();
|
||||
});
|
||||
|
||||
window.addEventListener('pageshow', (event) => {
|
||||
state.pageShowEvents += 1;
|
||||
log(`pageshow persisted=${event.persisted}`);
|
||||
refresh();
|
||||
});
|
||||
|
||||
window.addEventListener('pagehide', (event) => {
|
||||
state.pageHideEvents += 1;
|
||||
log(`pagehide persisted=${event.persisted}`);
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
|
||||
el('startBtn').addEventListener('click', () => {
|
||||
resetState();
|
||||
log('请现在切到别的标签页,或把浏览器最小化 30 到 60 秒。');
|
||||
});
|
||||
|
||||
el('clearBtn').addEventListener('click', () => {
|
||||
logEl.textContent = '';
|
||||
log('日志已清空。');
|
||||
});
|
||||
|
||||
el('copyBtn').addEventListener('click', async () => {
|
||||
refresh();
|
||||
const lines = [
|
||||
'[Lifecycle Probe Summary]',
|
||||
state.summaryText,
|
||||
`main_avg=${fmtMs(avg(state.mainDrifts))}`,
|
||||
`worker_avg=${fmtMs(avg(state.workerDrifts))}`,
|
||||
`raf_max_gap=${fmtMs(state.rafMaxGap)}`,
|
||||
`visibility_events=${state.visibilityEvents}`,
|
||||
`freeze=${state.freezeEvents}`,
|
||||
`resume=${state.resumeEvents}`
|
||||
].join('\n');
|
||||
try {
|
||||
await navigator.clipboard.writeText(lines);
|
||||
log('已复制摘要到剪贴板。');
|
||||
} catch (error) {
|
||||
log(`复制失败: ${error}`);
|
||||
}
|
||||
});
|
||||
|
||||
installMainIntervalProbe();
|
||||
installWorkerProbe();
|
||||
installRAFProbe();
|
||||
addLifecycleListeners();
|
||||
log(`页面已初始化。wasDiscarded=${document.wasDiscarded || false}, visibility=${document.visibilityState}`);
|
||||
refresh();
|
||||
window.setInterval(refresh, 500);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large.
Load diff
Binary file not shown.
|
After Width: | Height: | Size: 277 KiB |
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Universal Web-to-API Tutorial Redirect</title>
|
||||
<script>
|
||||
const target = './tutorial/index.html' + (window.location.hash || '');
|
||||
window.location.replace(target);
|
||||
</script>
|
||||
<noscript>
|
||||
<meta http-equiv="refresh" content="0; url=./tutorial/index.html">
|
||||
</noscript>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
File diff suppressed because it is too large.
Load diff
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @license lucide v1.26.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
(function(a,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(a=typeof globalThis<"u"?globalThis:a||self,i(a.lucide={}))})(this,(function(a){"use strict";const i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"},ka=([t,h,d])=>{const c=document.createElementNS("http://www.w3.org/2000/svg",t);return Object.keys(h).forEach(M=>{c.setAttribute(M,String(h[M]))}),d?.length&&d.forEach(M=>{const p=ka(M);c.appendChild(p)}),c},Pa=(t,h={})=>{const d={...i,...h};return ka(["svg",d,t])},GA=t=>{for(const h in t)if(h.startsWith("aria-")||h==="role"||h==="title")return!0;return!1},WA=(...t)=>t.filter((h,d,c)=>!!h&&h.trim()!==""&&c.indexOf(h)===d).join(" ").trim(),EA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(h,d,c)=>c?c.toUpperCase():d.toLowerCase()),IA=t=>{const h=EA(t);return h.charAt(0).toUpperCase()+h.slice(1)},XA=t=>Array.from(t.attributes).reduce((h,d)=>(h[d.name]=d.value,h),{}),Ba=t=>typeof t=="string"?t:!t||!t.class?"":t.class&&typeof t.class=="string"?t.class.split(" "):t.class&&Array.isArray(t.class)?t.class:"",za=(t,{nameAttr:h,icons:d,attrs:c})=>{const M=t.getAttribute(h);if(M==null)return;const p=IA(M),La=d[p];if(!La)return console.warn(`${t.outerHTML} icon name was not found in the provided icons object.`);const fa=XA(t),jA=GA(fa)?{}:{"aria-hidden":"true"},OA={...i,"data-lucide":M,...jA,...c,...fa},NA=Ba(fa),KA=Ba(c),ZA=WA("lucide",`lucide-${M}`,...NA,...KA);ZA&&Object.assign(OA,{class:ZA});const QA=Pa(La,OA);return t.parentNode?.replaceChild(QA,t)},Da=[["path",{d:"m14 12 4 4 4-4"}],["path",{d:"M18 16V7"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16"}],["path",{d:"M3.304 13h6.392"}]],Fa=[["path",{d:"m14 11 4-4 4 4"}],["path",{d:"M18 16V7"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16"}],["path",{d:"M3.304 13h6.392"}]],Ra=[["circle",{cx:"16",cy:"4",r:"1"}],["path",{d:"m18 19 1-7-6 1"}],["path",{d:"m5 8 3-3 5.5 3-2.36 3.5"}],["path",{d:"M4.24 14.5a5 5 0 0 0 6.88 6"}],["path",{d:"M13.76 17.5a5 5 0 0 0-6.88-6"}]],ba=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]],qa=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16"}],["path",{d:"M15.697 14h5.606"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16"}],["path",{d:"M3.304 13h6.392"}]],Ta=[["path",{d:"M10 13H6"}],["path",{d:"M10 15v-4a2 2 0 0 0-4 0v4"}],["path",{d:"M14 14.5a.5.5 0 0 0 .5.5h1a2.5 2.5 0 0 0 2.5-2.5v-1A2.5 2.5 0 0 0 15.5 9h-1a.5.5 0 0 0-.5.5z"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}]],Ua=[["path",{d:"M18 17.5a2.5 2.5 0 1 1-4 2.03V12"}],["path",{d:"M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}],["path",{d:"M6 8h12"}],["path",{d:"M6.6 15.572A2 2 0 1 0 10 17v-5"}]],Oa=[["path",{d:"M5 17H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-1"}],["path",{d:"m12 15 5 6H7Z"}]],g=[["circle",{cx:"12",cy:"13",r:"8"}],["path",{d:"M5 3 2 6"}],["path",{d:"m22 6-3-3"}],["path",{d:"M6.38 18.7 4 21"}],["path",{d:"M17.64 18.67 20 21"}],["path",{d:"M9 13h6"}]],C=[["circle",{cx:"12",cy:"13",r:"8"}],["path",{d:"M5 3 2 6"}],["path",{d:"m22 6-3-3"}],["path",{d:"M6.38 18.7 4 21"}],["path",{d:"M17.64 18.67 20 21"}],["path",{d:"m9 13 2 2 4-4"}]],Za=[["path",{d:"M6.87 6.87a8 8 0 1 0 11.26 11.26"}],["path",{d:"M19.9 14.25a8 8 0 0 0-9.15-9.15"}],["path",{d:"m22 6-3-3"}],["path",{d:"M6.26 18.67 4 21"}],["path",{d:"m2 2 20 20"}],["path",{d:"M4 4 2 6"}]],u=[["circle",{cx:"12",cy:"13",r:"8"}],["path",{d:"M5 3 2 6"}],["path",{d:"m22 6-3-3"}],["path",{d:"M6.38 18.7 4 21"}],["path",{d:"M17.64 18.67 20 21"}],["path",{d:"M12 10v6"}],["path",{d:"M9 13h6"}]],Ga=[["circle",{cx:"12",cy:"13",r:"8"}],["path",{d:"M12 9v4l2 2"}],["path",{d:"M5 3 2 6"}],["path",{d:"m22 6-3-3"}],["path",{d:"M6.38 18.7 4 21"}],["path",{d:"M17.64 18.67 20 21"}]],Wa=[["path",{d:"M11 21c0-2.5 2-2.5 2-5"}],["path",{d:"M16 21c0-2.5 2-2.5 2-5"}],["path",{d:"m19 8-.8 3a1.25 1.25 0 0 1-1.2 1H7a1.25 1.25 0 0 1-1.2-1L5 8"}],["path",{d:"M21 3a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a1 1 0 0 1 1-1z"}],["path",{d:"M6 21c0-2.5 2-2.5 2-5"}]],Ea=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}],["polyline",{points:"11 3 11 11 14 8 17 11 17 3"}]],Ia=[["path",{d:"M2 12h20"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1"}]],Xa=[["path",{d:"M12 2v20"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1"}]],ja=[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2Line truncated
|
||||
If you want to use all the icons you can import it like:
|
||||
\`import { createIcons, icons } from 'lucide';
|
||||
lucide.createIcons({icons});\``);if(typeof c>"u")throw new Error("`createIcons()` only works in a browser environment.");if(Array.from(c.querySelectorAll(`[${h}]`)).forEach(p=>za(p,{nameAttr:h,icons:t,attrs:d})),M&&Array.from(c.querySelectorAll("template")).forEach(p=>UA({icons:t,nameAttr:h,attrs:d,root:p.content,inTemplates:M})),h==="data-lucide"){const p=c.querySelectorAll("[icon-name]");p.length>0&&(console.warn("[Lucide] Some icons were found with the now deprecated icon-name attribute. These will still be replaced for backwards compatibility, but will no longer be supported in v1.0 and you should switch to data-lucide"),Array.from(p).forEach(La=>za(La,{nameAttr:"icon-name",icons:t,attrs:d})))}};a.AArrowDown=Da,a.AArrowUp=Fa,a.ALargeSmall=qa,a.Accessibility=Ra,a.Activity=ba,a.ActivitySquare=d0,a.Ad=Ta,a.AirVent=Ua,a.Airplay=Oa,a.AlarmCheck=C,a.AlarmClock=Ga,a.AlarmClockCheck=C,a.AlarmClockMinus=g,a.AlarmClockOff=Za,a.AlarmClockPlus=u,a.AlarmMinus=g,a.AlarmPlus=u,a.AlarmSmoke=Wa,a.Album=Ea,a.AlertCircle=K,a.AlertOctagon=D2,a.AlertTriangle=ra,a.AlignCenter=ca,a.AlignCenterHorizontal=Ia,a.AlignCenterVertical=Xa,a.AlignEndHorizontal=ja,a.AlignEndVertical=Ka,a.AlignHorizontalDistributeCenter=Na,a.AlignHorizontalDistributeEnd=Qa,a.AlignHorizontalDistributeStart=Ja,a.AlignHorizontalJustifyCenter=Ya,a.AlignHorizontalJustifyEnd=_a,a.AlignHorizontalJustifyStart=xa,a.AlignHorizontalSpaceAround=at,a.AlignHorizontalSpaceBetween=ht,a.AlignJustify=pa,a.AlignLeft=s,a.AlignRight=Ma,a.AlignStartHorizontal=tt,a.AlignStartVertical=dt,a.AlignVerticalDistributeCenter=ct,a.AlignVerticalDistributeEnd=Mt,a.AlignVerticalDistributeStart=pt,a.AlignVerticalJustifyCenter=lt,a.AlignVerticalJustifyEnd=it,a.AlignVerticalJustifyStart=nt,a.AlignVerticalSpaceAround=et,a.AlignVerticalSpaceBetween=rt,a.Ambulance=ot,a.Ampersand=$t,a.Ampersands=vt,a.Amphora=mt,a.Anchor=yt,a.Angry=st,a.Annoyed=gt,a.Antenna=Ct,a.Anvil=ut,a.Aperture=At,a.AppWindow=wt,a.AppWindowMac=Ht,a.Apple=Vt,a.Archive=kt,a.ArchiveRestore=St,a.ArchiveX=Lt,a.AreaChart=b,a.Armchair=ft,a.ArrowBigDown=Bt,a.ArrowBigDownDash=Pt,a.ArrowBigLeft=Dt,a.ArrowBigLeftDash=zt,a.ArrowBigRight=Rt,a.ArrowBigRightDash=Ft,a.ArrowBigUp=qt,a.ArrowBigUpDash=bt,a.ArrowDown=Nt,a.ArrowDown01=Tt,a.ArrowDown10=Ut,a.ArrowDownAZ=A,a.ArrowDownAz=A,a.ArrowDownCircle=Q,a.ArrowDownFromLine=Ot,a.ArrowDownLeft=Zt,a.ArrowDownLeftFromCircle=Y,a.ArrowDownLeftFromSquare=i0,a.ArrowDownLeftSquare=c0,a.ArrowDownNarrowWide=Gt,a.ArrowDownRight=Wt,a.ArrowDownRightFromCircle=_,a.ArrowDownRightFromSquare=n0,a.ArrowDownRightSquare=M0,a.ArrowDownSquare=p0,a.ArrowDownToDot=It,a.ArrowDownToLine=Et,a.ArrowDownUp=Xt,a.ArrowDownWideNarrow=H,a.ArrowDownZA=V,a.ArrowDownZa=V,a.ArrowLeft=Jt,a.ArrowLeftCircle=J,a.ArrowLeftFromLine=jt,a.ArrowLeftRight=Kt,a.ArrowLeftSquare=l0,a.ArrowLeftToLine=Qt,a.ArrowRight=ah,a.ArrowRightCircle=t1,a.ArrowRightFromLine=Yt,a.ArrowRightLeft=_t,a.ArrowRightSquare=o0,a.ArrowRightToLine=xt,a.ArrowUp=eh,a.ArrowUp01=th,a.ArrowUp10=hh,a.ArrowUpAZ=w,a.ArrowUpAz=w,a.ArrowUpCircle=h1,a.ArrowUpDown=dh,a.ArrowUpFromDot=ch,a.ArrowUpFromLine=Mh,a.ArrowUpLeft=ph,a.ArrowUpLeftFromCircle=x,a.ArrowUpLeftFromSquare=e0,a.ArrowUpLeftSquare=v0,a.ArrowUpNarrowWide=S,a.ArrowUpRight=lh,a.ArrowUpRightFromCircle=a1,a.ArrowUpRightFromSquare=r0,a.ArrowUpRightSquare=$0,a.ArrowUpSquare=m0,a.ArrowUpToLine=ih,a.ArrowUpWideNarrow=nh,a.ArrowUpZA=L,a.ArrowUpZa=L,a.ArrowsUpFromLine=oh,a.Asterisk=rh,a.AsteriskSquare=y0,a.Astroid=vh,a.AtSign=$h,a.Atom=mh,a.AudioLines=yh,a.AudioWaveform=Ch,a.Award=sh,a.Axe=gh,a.Axis3D=f,a.Axis3d=f,a.Baby=Ah,a.Backpack=uh,a.Badge=Th,a.BadgeAlert=Hh,a.BadgeCent=Vh,a.BadgeCheck=k,a.BadgeDollarSign=wh,a.BadgeEuro=Sh,a.BadgeHelp=P,a.BadgeIndianRupee=Lh,a.BadgeInfo=fh,a.BadgeJapaneseYen=kh,a.BadgeMinus=Ph,a.BadgePercent=Bh,a.BadgePlus=zh,a.BadgePoundSterling=Dh,a.BadgeQuestionMark=P,a.BadgeRussianRuble=Fh,a.BadgeSwissFranc=Rh,a.BadgeTurkishLira=bh,a.BadgeX=qh,a.BaggageClaim=Uh,a.Balloon=Oh,a.Ban=Zh,a.Banana=Gh,a.Bandage=Wh,a.Banknote=Nh,a.BanknoteArrowDown=Eh,a.BanknoteArrowUp=Ih,a.BanknoteCheck=Xh,a.BanknoteX=jh,a.BarChart=E,a.BarChart2=I,a.BarChart3=G,a.BarChart4=Z,a.BarChartBig=O,a.BarChartHorizontal=T,a.BarChartHorizontalBig=q,a.Barcode=Kh,a.Barrel=Qh,a.Baseline=Jh,a.Bath=Yh,a.Battery=c4,a.BatteryCharging=_h,a.BatteryFull=xh,a.BatteryLow=a4,a.BatteryMedium=t4,a.BatteryPlus=h4,a.BatteryWarning=d4,a.Beaker=M4,a.Bean=l4,a.BeanOff=p4,a.Bed=e4,a.BedDouble=i4,a.BedSingle=n4,a.Beef=o4,a.BeefOff=r4,a.Beer=$4,a.BeerOff=v4,a.Bell=H4,a.BellCheck=y4,a.BellDot=m4,a.BellElectric=s4,a.BellMinus=g4,a.BellOff=C4,a.BellPlus=u4,a.BellRing=A4,a.BetweenHorizonalEnd=B,a.BetweenHorizonalStart=z,a.BetweenHorizontalEnd=B,a.BetweenHorizontalStart=z,a.BetweenVerticalEnd=V4,a.BetweenVerticalStart=w4,a.BicepsFlexed=S4,a.Bike=L4,a.Binary=f4,a.Binoculars=P4,a.Biohazard=k4,a.Bird=B4,a.Birdhouse=z4,a.Bitcoin=D4,a.Blend=F4,a.Blender=b4,a.Blinds=R4,a.Blocks=q4,a.Bluetooth=Z4,a.BluetoothConnected=T4,a.BluetoothOff=U4,a.BluetoothSearching=O4,a.BLine truncated
|
||||
//# sourceMappingURL=lucide.min.js.map
|
||||
@@ -0,0 +1,313 @@
|
||||
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
||||
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-pan-x:initial;--tw-pan-y:initial;--tw-pinch-zoom:initial;--tw-scroll-snap-strictness:proximity;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-x-reverse:0;--tw-border-style:solid;--tw-divide-y-reverse:0;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-contain-size:initial;--tw-contain-layout:initial;--tw-contain-paint:initial;--tw-contain-style:initial;--tw-content:""}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-orange-500:oklch(70.5% .213 47.604);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-amber-900:oklch(41.4% .112 45.904);--color-yellow-50:oklch(98.7% .026 102.212);--color-yellow-100:oklch(97.3% .071 103.193);--color-yellow-200:oklch(94.5% .129 101.54);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-yellow-700:oklch(55.4% .135 66.442);--color-yellow-800:oklch(47.6% .114 61.907);--color-yellow-900:oklch(42.1% .095 57.708);--color-green-50:oklch(98.2% .018 155.826);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-green-800:oklch(44.8% .119 151.328);--color-green-900:oklch(39.3% .095 152.535);--color-emerald-50:oklch(97.9% .021 166.113);--color-emerald-100:oklch(95% .052 163.051);--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-700:oklch(50.8% .118 165.612);--color-emerald-800:oklch(43.2% .095 166.913);--color-emerald-900:oklch(37.8% .077 168.94);--color-emerald-950:oklch(26.2% .051 172.552);--color-teal-50:oklch(98.4% .014 180.72);--color-teal-200:oklch(91% .096 180.426);--color-teal-300:oklch(85.5% .138 181.071);--color-teal-700:oklch(51.1% .096 186.391);--color-teal-800:oklch(Line truncated
|
||||
|
||||
/* ============ 主题变量 ============ */
|
||||
:root{
|
||||
--font:"Inter","Noto Sans SC",-apple-system,"PingFang SC","Microsoft YaHei",sans-serif;
|
||||
--mono:"JetBrains Mono","SFMono-Regular",Consolas,monospace;
|
||||
--sb-w:280px; --hd-h:60px;
|
||||
}
|
||||
[data-theme="dark"]{
|
||||
--bg:#080d18; --bg2:#0b1222; --panel:#0e1628; --panel2:#111b31; --panel3:#16223c;
|
||||
--line:rgba(148,163,184,.13); --line2:rgba(148,163,184,.07);
|
||||
--tx:#dde7f6; --tx2:#97a7c4; --tx3:#5f7089;
|
||||
--acc:#5cc8ff; --acc2:#8b7cff; --acc-dim:rgba(92,200,255,.12);
|
||||
--info:#38bdf8; --tip:#34d399; --warn:#fbbf24; --danger:#fb7185;
|
||||
--code-bg:#0a101f; --code-top:#0d1528;
|
||||
--shadow:0 18px 50px -12px rgba(0,0,0,.55);
|
||||
--glow:radial-gradient(600px 300px at 20% -5%,rgba(92,200,255,.09),transparent 60%),radial-gradient(700px 340px at 85% -8%,rgba(139,124,255,.08),transparent 60%);
|
||||
}
|
||||
[data-theme="light"]{
|
||||
--bg:#f5f7fc; --bg2:#eef1f8; --panel:#ffffff; --panel2:#f8fafd; --panel3:#eef2f9;
|
||||
--line:rgba(15,23,42,.11); --line2:rgba(15,23,42,.06);
|
||||
--tx:#1c2b44; --tx2:#51617e; --tx3:#8494ad;
|
||||
--acc:#0284c7; --acc2:#6d5ef0; --acc-dim:rgba(2,132,199,.09);
|
||||
--info:#0284c7; --tip:#059669; --warn:#b45309; --danger:#e11d48;
|
||||
--code-bg:#0b1221; --code-top:#101a30;
|
||||
--shadow:0 18px 46px -18px rgba(15,23,42,.18);
|
||||
--glow:radial-gradient(600px 300px at 20% -5%,rgba(2,132,199,.07),transparent 60%),radial-gradient(700px 340px at 85% -8%,rgba(109,94,240,.06),transparent 60%);
|
||||
}
|
||||
/* ============ 基础 ============ */
|
||||
*{box-sizing:border-box}
|
||||
html{scroll-behavior:smooth}
|
||||
body{margin:0;font-family:var(--font);background:var(--bg);color:var(--tx);font-size:15.5px;line-height:1.85;-webkit-font-smoothing:antialiased;transition:background .3s,color .3s}
|
||||
a{color:var(--acc);text-decoration:none}
|
||||
a:hover{text-decoration:underline}
|
||||
::selection{background:rgba(92,200,255,.28)}
|
||||
code,kbd{font-family:var(--mono)}
|
||||
p{margin:0 0 14px}
|
||||
strong{color:var(--tx);font-weight:700}
|
||||
::-webkit-scrollbar{width:10px;height:10px}
|
||||
::-webkit-scrollbar-thumb{background:rgba(130,150,180,.28);border-radius:8px;border:2px solid var(--bg)}
|
||||
::-webkit-scrollbar-track{background:transparent}
|
||||
/* ============ 进度条 & 回到顶部 ============ */
|
||||
#progress{position:fixed;top:0;left:0;height:2.5px;width:0;background:linear-gradient(90deg,var(--acc),var(--acc2));z-index:200;box-shadow:0 0 12px rgba(92,200,255,.6)}
|
||||
#toTop{position:fixed;right:26px;bottom:26px;width:42px;height:42px;border-radius:12px;border:1px solid var(--line);background:var(--panel);color:var(--tx2);display:flex;align-items:center;justify-content:center;cursor:pointer;opacity:0;pointer-events:none;transition:.3s;z-index:150;box-shadow:var(--shadow)}
|
||||
#toTop.show{opacity:1;pointer-events:auto}
|
||||
#toTop:hover{color:var(--acc);border-color:var(--acc);transform:translateY(-3px)}
|
||||
/* ============ 布局 ============ */
|
||||
.app{display:flex;min-height:100vh}
|
||||
.shell{flex:1;min-width:0;display:flex;flex-direction:column}
|
||||
.body-wrap{flex:1;display:grid;grid-template-columns:minmax(0,1fr) 236px;max-width:1330px;width:100%;margin:0 auto;padding:0 34px}
|
||||
.content{min-width:0;padding:44px 8px 90px 0;max-width:860px}
|
||||
/* ============ 侧边栏 ============ */
|
||||
.sidebar{width:var(--sb-w);flex-shrink:0;position:sticky;top:0;height:100vh;overflow-y:auto;border-right:1px solid var(--line2);background:linear-gradient(180deg,var(--bg) 0%,var(--bg2) 100%);padding:20px 16px 40px;z-index:120}
|
||||
.sb-brand{display:flex;align-items:center;gap:11px;padding:4px 8px 18px;border-bottom:1px solid var(--line2)}
|
||||
.sb-logo{width:38px;height:38px;border-radius:11px;background:linear-gradient(135deg,#0ea5e9,#8b5cf6);display:flex;align-items:center;justify-content:center;color:#fff;box-shadow:0 6px 18px -4px rgba(56,189,248,.45);flex-shrink:0}
|
||||
.sb-name{font-weight:800;font-size:15px;letter-spacing:-.02em;line-height:1.25}
|
||||
.sb-sub{font-size:11.5px;color:var(--tx3);font-family:var(--mono);letter-spacing:.04em}
|
||||
.sb-search{position:relative;margin:14px 4px 6px}
|
||||
.sb-search input{width:100%;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:8px 12px 8px 34px;color:var(--tx);font-size:13px;font-family:var(--font);outline:none;transition:.2s}
|
||||
.sb-search input:focus{border-color:var(--acc);box-shadow:0 0 0 3px var(--acc-dim)}
|
||||
.sb-search>svg,.sb-search>i{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--tx3);pointer-events:none}
|
||||
.sb-search kbd{position:absolute;right:9px;top:50%;transform:translateY(-50%);font-size:10.5px;color:var(--tx3);border:1px solid var(--line);border-radius:5px;padding:1px 6px;background:var(--bg)}
|
||||
.sb-results{position:static;margin-top:6px;background:var(--panel);border:1px solid var(--line);border-radius:12px;overflow:hidden;display:none;max-height:420px;overflow-y:auto;box-shadow:var(--shadow)}
|
||||
.sb-results.on{display:block}
|
||||
.sb-r{display:block;padding:9px 13px;border-bottom:1px solid var(--line2);cursor:pointer}
|
||||
.sb-r:last-child{border-bottom:none}
|
||||
.sb-r:hover,.sb-r.hl{background:var(--acc-dim);text-decoration:none}
|
||||
.sb-r b{display:block;font-size:13px;color:var(--tx)}
|
||||
.sb-r small{display:block;font-size:11.5px;color:var(--tx3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.sb-r .grp{font-size:10px;color:var(--acc);font-weight:700;letter-spacing:.06em;text-transform:uppercase}
|
||||
.sb-none{padding:14px;font-size:12.5px;color:var(--tx3);text-align:center}
|
||||
.nav-group{margin-top:18px}
|
||||
.nav-gt{font-size:10.5px;font-weight:800;letter-spacing:.14em;color:var(--tx3);text-transform:uppercase;padding:0 10px 7px}
|
||||
.nav-link{display:flex;align-items:center;gap:9px;padding:6.5px 10px;border-radius:9px;color:var(--tx2);font-size:13.5px;font-weight:500;position:relative;transition:.15s;margin-bottom:1px}
|
||||
.nav-link:hover{background:var(--acc-dim);color:var(--tx);text-decoration:none}
|
||||
.nav-link .n-num{font-family:var(--mono);font-size:10.5px;color:var(--tx3);width:20px;flex-shrink:0}
|
||||
.nav-link.active{background:linear-gradient(90deg,var(--acc-dim),transparent);color:var(--acc);font-weight:700}
|
||||
.nav-link.active::before{content:"";position:absolute;left:-16px;top:8px;bottom:8px;width:3px;border-radius:3px;background:linear-gradient(180deg,var(--acc),var(--acc2))}
|
||||
/* ============ 顶栏 ============ */
|
||||
.topbar{height:var(--hd-h);display:flex;align-items:center;gap:14px;padding:0 22px;border-bottom:1px solid var(--line2);position:sticky;top:0;background:color-mix(in srgb,var(--bg) 82%,transparent);backdrop-filter:blur(14px);z-index:110}
|
||||
.tb-crumb{font-size:13px;color:var(--tx3);display:flex;align-items:center;gap:8px;min-width:0}
|
||||
.tb-crumb b{color:var(--tx2);font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.tb-right{margin-left:auto;display:flex;align-items:center;gap:9px}
|
||||
.tb-btn{display:inline-flex;align-items:center;gap:7px;padding:7px 13px;border-radius:9px;border:1px solid var(--line);background:var(--panel);color:var(--tx2);font-size:13px;font-weight:600;cursor:pointer;transition:.2s;font-family:var(--font);white-space:nowrap}
|
||||
.tb-btn:hover{border-color:var(--acc);color:var(--acc);text-decoration:none;transform:translateY(-1px)}
|
||||
.tb-ver{font-family:var(--mono);font-size:11.5px;color:var(--acc);background:var(--acc-dim);border:1px solid rgba(92,200,255,.25);padding:3px 10px;border-radius:99px}
|
||||
#menuBtn{display:none}
|
||||
/* ============ 正文排版 ============ */
|
||||
.doc-section{scroll-margin-top:calc(var(--hd-h) + 18px);padding-top:56px;margin-top:8px;border-top:1px solid var(--line2)}
|
||||
.doc-section:first-of-type{border-top:none;padding-top:8px}
|
||||
.sec-kicker{display:flex;align-items:center;gap:10px;margin-bottom:10px}
|
||||
.sec-num{font-family:var(--mono);font-size:11.5px;font-weight:600;color:var(--acc);background:var(--acc-dim);border:1px solid rgba(92,200,255,.22);padding:2.5px 9px;border-radius:7px;letter-spacing:.05em}
|
||||
.sec-tag{font-size:11px;font-weight:700;letter-spacing:.12em;text-transform:uppercase;color:var(--tx3)}
|
||||
.doc-section h2{font-size:27px;font-weight:800;letter-spacing:-.02em;margin:0 0 16px;display:flex;align-items:center;gap:12px;line-height:1.35}
|
||||
.doc-section h2 .h-ic{width:40px;height:40px;border-radius:12px;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;background:linear-gradient(135deg,var(--acc-dim),transparent);border:1px solid rgba(92,200,255,.2);color:var(--acc)}
|
||||
.doc-section h2 .h-anchor{opacity:0;color:var(--tx3);transition:.2s;margin-left:-4px}
|
||||
.doc-section h2:hover .h-anchor{opacity:1}
|
||||
.doc-section h3{font-size:18.5px;font-weight:800;margin:38px 0 12px;padding-left:13px;border-left:3px solid var(--acc);letter-spacing:-.01em;scroll-margin-top:calc(var(--hd-h) + 18px)}
|
||||
.doc-section h4{font-size:15.5px;font-weight:700;margin:24px 0 10px}
|
||||
.doc-section p{color:var(--tx2)}
|
||||
.doc-section ul,.doc-section ol{color:var(--tx2);padding-left:22px;margin:0 0 14px}
|
||||
.doc-section li{margin-bottom:5px}
|
||||
.doc-section li::marker{color:var(--acc)}
|
||||
p code,li code,td code,h3 code,h4 code{font-family:var(--mono);font-size:.83em;background:var(--code-bg);color:#7dd3fc;border:1px solid rgba(125,211,252,.16);padding:1.5px 7px;border-radius:6px;white-space:nowrap}
|
||||
.lead{font-size:16.5px;color:var(--tx2);line-height:1.9}
|
||||
/* ============ Callout ============ */
|
||||
.co{display:flex;gap:13px;padding:15px 17px;border-radius:14px;border:1px solid;margin:18px 0;background:var(--panel);position:relative;overflow:hidden}
|
||||
.co>i,.co>svg{flex-shrink:0;margin-top:2px}
|
||||
.co-bd{min-width:0;flex:1}
|
||||
.co-bd p:last-child,.co-bd ul:last-child,.co-bd ol:last-child{margin-bottom:0}
|
||||
.co-bd .co-t{font-weight:800;font-size:14px;display:block;margin-bottom:4px}
|
||||
.co-co,.co-info{border-color:rgba(56,189,248,.28);background:linear-gradient(120deg,rgba(56,189,248,.07),var(--panel) 65%)}
|
||||
.co-info>i{color:var(--info)}
|
||||
.co-tip{border-color:rgba(52,211,153,.3);background:linear-gradient(120deg,rgba(52,211,153,.07),var(--panel) 65%)}
|
||||
.co-tip>i{color:var(--tip)}
|
||||
.co-warn{border-color:rgba(251,191,36,.3);background:linear-gradient(120deg,rgba(251,191,36,.07),var(--panel) 65%)}
|
||||
.co-warn>i{color:var(--warn)}
|
||||
.co-danger{border-color:rgba(251,113,133,.3);background:linear-gradient(120deg,rgba(251,113,133,.07),var(--panel) 65%)}
|
||||
.co-danger>i{color:var(--danger)}
|
||||
.co p{color:var(--tx2);font-size:14px}
|
||||
.co ol,.co ul{font-size:14px}
|
||||
/* ============ 代码块 ============ */
|
||||
.cb{border:1px solid rgba(125,211,252,.14);border-radius:14px;background:var(--code-bg);margin:18px 0;overflow:hidden;box-shadow:0 10px 34px -14px rgba(0,0,0,.5)}
|
||||
.cb-top{display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--code-top);border-bottom:1px solid rgba(125,211,252,.1)}
|
||||
.cb-dots{display:flex;gap:5.5px}
|
||||
.cb-dots i{width:9px;height:9px;border-radius:50%;}
|
||||
.cb-dots i:nth-child(1){background:#ff5f57}.cb-dots i:nth-child(2){background:#febc2e}.cb-dots i:nth-child(3){background:#28c840}
|
||||
.cb-lang{font-family:var(--mono);font-size:10.5px;letter-spacing:.14em;text-transform:uppercase;color:#5f7ca6;font-weight:600}
|
||||
.cb-copy{margin-left:auto;display:inline-flex;align-items:center;gap:6px;background:transparent;border:1px solid rgba(125,211,252,.18);color:#7d92b5;font-size:11.5px;font-weight:600;padding:3.5px 10px;border-radius:7px;cursor:pointer;transition:.2s;font-family:var(--font)}
|
||||
.cb-copy:hover{color:#7dd3fc;border-color:#7dd3fc;background:rgba(125,211,252,.08)}
|
||||
.cb-copy.ok{color:#34d399;border-color:#34d399}
|
||||
.cb pre{margin:0;padding:16px 18px;overflow-x:auto;font-family:var(--mono);font-size:12.8px;line-height:1.8;color:#c6d5ee}
|
||||
.cb pre::-webkit-scrollbar{height:8px}
|
||||
.tk-s{color:#a5e3a1}.tk-k{color:#7dd3fc}.tk-c{color:#5b7398;font-style:italic}.tk-n{color:#f9a8d4}.tk-b{color:#c4b5fd}
|
||||
/* ============ 表格 ============ */
|
||||
.tw{overflow-x:auto;margin:18px 0;border:1px solid var(--line);border-radius:14px;box-shadow:0 8px 26px -16px rgba(0,0,0,.4)}
|
||||
.tbl{width:100%;border-collapse:collapse;font-size:13.8px;min-width:520px}
|
||||
.tbl th{text-align:left;padding:10px 15px;background:var(--panel2);font-size:11.5px;letter-spacing:.08em;text-transform:uppercase;color:var(--tx3);font-weight:800;border-bottom:1px solid var(--line);white-space:nowrap}
|
||||
.tbl td{padding:10px 15px;border-bottom:1px solid var(--line2);color:var(--tx2);vertical-align:top;line-height:1.65}
|
||||
.tbl tr:last-child td{border-bottom:none}
|
||||
.tbl tbody tr{transition:background .15s}
|
||||
.tbl tbody tr:hover{background:var(--acc-dim)}
|
||||
.tbl td:first-child{color:var(--tx);font-weight:600;white-space:nowrap}
|
||||
/* ============ 步骤 / 卡片 / 徽章 ============ */
|
||||
.steps{list-style:none;counter-reset:st;padding:0;margin:18px 0}
|
||||
.steps li{counter-increment:st;position:relative;padding:0 0 20px 46px;margin:0}
|
||||
.steps li::before{content:counter(st,decimal-leading-zero);position:absolute;left:0;top:1px;width:30px;height:30px;border-radius:10px;background:var(--panel);border:1px solid rgba(92,200,255,.28);color:var(--acc);font-family:var(--mono);font-size:11.5px;font-weight:600;display:flex;align-items:center;justify-content:center}
|
||||
.steps li::after{content:"";position:absolute;left:15px;top:34px;bottom:4px;width:1px;background:linear-gradient(180deg,rgba(92,200,255,.3),transparent)}
|
||||
.steps li:last-child::after{display:none}
|
||||
.quickstart-welcome{display:flex;gap:14px;align-items:flex-start;margin:18px 0 12px;padding:18px 0;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}
|
||||
.quickstart-welcome-icon{width:42px;height:42px;border-radius:12px;display:flex;align-items:center;justify-content:center;flex-shrink:0;color:var(--acc);background:var(--acc-dim);border:1px solid rgba(92,200,255,.24)}
|
||||
.quickstart-welcome strong{display:block;font-size:17px;margin:1px 0 4px}
|
||||
.quickstart-welcome p{margin:0;max-width:680px;font-size:14px}
|
||||
.quickstart-links{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border-top:1px solid var(--line2);border-bottom:1px solid var(--line2);margin:12px 0 30px}
|
||||
.quickstart-links>a{display:grid;grid-template-columns:34px minmax(0,1fr) 18px;align-items:center;gap:11px;padding:15px 16px;color:var(--tx);transition:.2s}
|
||||
.quickstart-links>a+a{border-left:1px solid var(--line2)}
|
||||
.quickstart-links>a:hover{background:var(--acc-dim);text-decoration:none}
|
||||
.quickstart-links>a>svg:last-child{color:var(--tx3)}
|
||||
.quickstart-link-icon{width:34px;height:34px;border-radius:9px;display:flex;align-items:center;justify-content:center;color:var(--acc);background:var(--panel);border:1px solid var(--line)}
|
||||
.quickstart-links strong{display:block;font-size:13.5px}
|
||||
.quickstart-links small{display:block;color:var(--tx3);font-size:11.5px;line-height:1.55;margin-top:2px}
|
||||
.browser-compare{margin:18px 0 8px;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}
|
||||
.browser-kind{display:grid;grid-template-columns:38px minmax(0,1fr);gap:12px;padding:15px 4px}
|
||||
.browser-kind+.browser-kind{border-top:1px solid var(--line2)}
|
||||
.browser-kind-icon{width:34px;height:34px;border-radius:10px;display:flex;align-items:center;justify-content:center;color:var(--tx3);background:var(--panel);border:1px solid var(--line)}
|
||||
.browser-kind.is-controlled .browser-kind-icon{color:var(--tip);background:rgba(52,211,153,.08);border-color:rgba(52,211,153,.25)}
|
||||
.browser-kind strong{font-size:14px}
|
||||
.browser-kind p{font-size:13px;margin:3px 0 0;line-height:1.7}
|
||||
.quickstart-actions{margin:18px 0 30px}
|
||||
.quickstart-reference-links{display:flex;flex-wrap:wrap;gap:9px;margin:16px 0 22px}
|
||||
.quickstart-reference-links a{display:inline-flex;align-items:center;gap:8px;padding:8px 12px;border:1px solid var(--line);border-radius:9px;background:var(--panel);color:var(--tx2);font-size:13px;font-weight:700;transition:.2s}
|
||||
.quickstart-reference-links a:hover{color:var(--acc);border-color:rgba(92,200,255,.35);text-decoration:none;transform:translateY(-1px)}
|
||||
.quickstart-reference-links a>svg:last-child{color:var(--tx3)}
|
||||
#api-key-config,#routing-methods,#browser-profile-reuse,#quickstart-browser,#quickstart-gemini{scroll-margin-top:calc(var(--hd-h) + 18px)}
|
||||
.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin:18px 0}
|
||||
.grid3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin:18px 0}
|
||||
.q-card{background:var(--panel);border:1px solid var(--line);border-radius:16px;padding:18px;transition:.25s;position:relative;overflow:hidden}
|
||||
.q-card::before{content:"";position:absolute;inset:0;background:radial-gradient(340px 120px at 20% 0%,var(--acc-dim),transparent);opacity:0;transition:.3s}
|
||||
.q-card:hover{border-color:rgba(92,200,255,.35);transform:translateY(-3px);box-shadow:var(--shadow)}
|
||||
.q-card:hover::before{opacity:1}
|
||||
.q-card .qc-ic{width:34px;height:34px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:var(--acc-dim);color:var(--acc);margin-bottom:11px}
|
||||
.q-card h5{margin:0 0 6px;font-size:14.5px;font-weight:800}
|
||||
.q-card p{margin:0;font-size:13px;color:var(--tx2);line-height:1.7}
|
||||
.chips{display:flex;flex-wrap:wrap;gap:8px;margin:14px 0}
|
||||
.chip{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;font-weight:600;color:var(--tx2);background:var(--panel);border:1px solid var(--line);padding:4.5px 12px;border-radius:99px}
|
||||
.chip i{color:var(--acc)}
|
||||
.bdg{display:inline-flex;align-items:center;font-family:var(--mono);font-size:10.5px;font-weight:600;padding:2px 8px;border-radius:6px;background:var(--acc-dim);color:var(--acc);border:1px solid rgba(92,200,255,.22);letter-spacing:.03em;white-space:nowrap}
|
||||
.bdg.g{background:rgba(52,211,153,.1);color:var(--tip);border-color:rgba(52,211,153,.25)}
|
||||
.bdg.a{background:rgba(251,191,36,.1);color:var(--warn);border-color:rgba(251,191,36,.25)}
|
||||
.bdg.r{background:rgba(251,113,133,.1);color:var(--danger);border-color:rgba(251,113,133,.25)}
|
||||
/* ============ Hero ============ */
|
||||
.hero{padding:54px 0 30px;position:relative}
|
||||
.hero::before{content:"";position:absolute;inset:-60px 0 auto;height:420px;background:var(--glow);pointer-events:none}
|
||||
.hero-in{position:relative}
|
||||
.hero-eyebrow{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:18px}
|
||||
.hero h1{font-size:clamp(32px,4.6vw,46px);font-weight:900;letter-spacing:-0.04em;line-height:1.18;margin:0 0 16px}
|
||||
.hero h1 .grad{background:linear-gradient(92deg,#38bdf8 10%,#8b7cff 60%,#e879f9 110%);-webkit-background-clip:text;background-clip:text;color:transparent}
|
||||
.hero .lead{max-width:660px;margin-bottom:24px}
|
||||
.hero-cta{display:flex;gap:12px;flex-wrap:wrap;align-items:center}
|
||||
.btn{display:inline-flex;align-items:center;gap:8px;padding:10px 20px;border-radius:12px;font-size:14px;font-weight:700;cursor:pointer;border:1px solid transparent;transition:.22s;font-family:var(--font)}
|
||||
.btn-pri{background:linear-gradient(135deg,#0ea5e9,#6366f1);color:#fff;box-shadow:0 10px 26px -8px rgba(56,189,248,.5)}
|
||||
.btn-pri:hover{transform:translateY(-2px);box-shadow:0 14px 32px -8px rgba(56,189,248,.62);text-decoration:none;filter:brightness(1.07)}
|
||||
.btn-gh{background:var(--panel);border-color:var(--line);color:var(--tx)}
|
||||
.btn-gh:hover{border-color:var(--tx3);transform:translateY(-2px);text-decoration:none}
|
||||
.repo-card{display:flex;align-items:center;gap:14px;background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:13px 17px;margin-top:26px;max-width:560px;transition:.2s}
|
||||
.repo-card:hover{border-color:rgba(92,200,255,.35)}
|
||||
.repo-card .rc-ic{color:var(--tx2);flex-shrink:0}
|
||||
.repo-card b{font-size:13.5px;display:block}
|
||||
.repo-card code{font-size:12px;color:var(--tx3);background:none;border:none;padding:0}
|
||||
.repo-card a{margin-left:auto;flex-shrink:0}
|
||||
/* ============ 架构图 ============ */
|
||||
.arch{background:linear-gradient(160deg,var(--panel2),var(--panel) 55%);border:1px solid var(--line);border-radius:20px;padding:26px 22px;margin:20px 0;position:relative;overflow:hidden}
|
||||
.arch::before{content:"";position:absolute;inset:0;background:radial-gradient(520px 220px at 50% -10%,rgba(92,200,255,.06),transparent)}
|
||||
.arch>*{position:relative}
|
||||
.a-tier{display:flex;justify-content:center}
|
||||
.a-node{--c:#94a3b8;flex:1;min-width:230px;max-width:430px;background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:14px 18px;position:relative;transition:.25s;box-shadow:0 6px 20px -10px rgba(0,0,0,.45)}
|
||||
.a-node::before{content:"";position:absolute;left:0;top:12px;bottom:12px;width:3px;border-radius:3px;background:var(--c)}
|
||||
.a-node:hover{transform:translateY(-3px);border-color:var(--c);box-shadow:0 14px 30px -10px color-mix(in srgb,var(--c) 30%,transparent)}
|
||||
.a-lay{position:absolute;top:11px;right:13px;font-family:var(--mono);font-size:9.5px;letter-spacing:.1em;color:var(--tx3);border:1px solid var(--line);border-radius:5px;padding:1px 7px;background:var(--bg)}
|
||||
.a-tt{display:flex;align-items:center;gap:9px;font-weight:800;font-size:14.5px;color:var(--tx)}
|
||||
.a-tt i,.a-tt svg{color:var(--c);flex-shrink:0}
|
||||
.a-path{font-family:var(--mono);font-size:11px;color:var(--c);background:color-mix(in srgb,var(--c) 10%,transparent);padding:1.5px 8px;border-radius:6px;margin-top:7px;display:inline-block}
|
||||
.a-ds{font-size:12.5px;color:var(--tx2);margin-top:7px;line-height:1.6}
|
||||
.a-arrow{display:flex;flex-direction:column;align-items:center;padding:3px 0}
|
||||
.a-cap{font-size:11px;font-weight:600;color:var(--tx3);background:var(--bg);border:1px solid var(--line);padding:2px 13px;border-radius:99px;margin-bottom:1px}
|
||||
.a-arrow .ln{width:1.5px;height:12px;background:linear-gradient(180deg,rgba(92,200,255,.5),rgba(92,200,255,.14))}
|
||||
.a-arrow .tri{color:rgba(92,200,255,.55);animation:pulse 2.2s infinite ease-in-out;line-height:1}
|
||||
.a-split{display:flex;width:100%;max-width:800px;justify-content:space-between}
|
||||
.a-split .a-arrow{width:50%}
|
||||
.a-row{display:flex;gap:16px;justify-content:center;flex-wrap:wrap}
|
||||
.a-base{margin-top:20px;border:1px dashed rgba(148,163,184,.24);border-radius:15px;padding:16px 18px;background:color-mix(in srgb,var(--bg) 55%,transparent)}
|
||||
.a-base-t{font-size:12px;font-weight:800;letter-spacing:.1em;text-transform:uppercase;color:var(--tx3);padding-bottom:9px;margin-bottom:12px;border-bottom:1px solid var(--line2);display:flex;align-items:center;gap:8px}
|
||||
.a-rel{display:flex;flex-wrap:wrap;gap:9px;justify-content:center;margin-top:12px}
|
||||
.a-rel span{font-family:var(--mono);font-size:11px;color:var(--tx3);background:var(--bg);border:1px solid var(--line2);padding:3px 11px;border-radius:99px}
|
||||
@keyframes pulse{0%,100%{opacity:.35;transform:translateY(0)}50%{opacity:1;transform:translateY(2.5px)}}
|
||||
/* ============ 站点卡片 ============ */
|
||||
.site-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(158px,1fr));gap:11px;margin:18px 0}
|
||||
.site-card{background:var(--panel);border:1px solid var(--line);border-radius:13px;padding:13px 15px;cursor:pointer;transition:.2s;position:relative;overflow:hidden}
|
||||
.site-card:hover{border-color:rgba(92,200,255,.4);transform:translateY(-2px)}
|
||||
.site-card .sc-n{font-weight:800;font-size:13.5px;display:flex;align-items:center;gap:7px}
|
||||
.site-card .sc-dot{width:7px;height:7px;border-radius:50%;background:var(--tip);box-shadow:0 0 8px var(--tip);flex-shrink:0}
|
||||
.site-card .sc-d{font-family:var(--mono);font-size:11px;color:var(--tx3);margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.site-card .sc-c{position:absolute;top:9px;right:11px;color:var(--tx3);opacity:0;transition:.2s}
|
||||
.site-card:hover .sc-c{opacity:1}
|
||||
/* ============ 控制台示意图 ============ */
|
||||
.mock{border:1px solid var(--line);border-radius:18px;overflow:hidden;margin:20px 0;background:var(--panel);box-shadow:var(--shadow)}
|
||||
.mock-bar{display:flex;align-items:center;gap:8px;padding:10px 14px;background:var(--panel2);border-bottom:1px solid var(--line)}
|
||||
.mock-bar i{width:10px;height:10px;border-radius:50%}
|
||||
.mock-bar i:nth-child(1){background:#ff5f57}.mock-bar i:nth-child(2){background:#febc2e}.mock-bar i:nth-child(3){background:#28c840}
|
||||
.mock-url{margin-left:10px;font-family:var(--mono);font-size:11px;color:var(--tx3);background:var(--bg);border:1px solid var(--line2);border-radius:7px;padding:3px 12px}
|
||||
.mock-body{display:grid;grid-template-columns:150px 1fr;min-height:230px}
|
||||
.mock-side{border-right:1px solid var(--line);padding:12px 10px;background:color-mix(in srgb,var(--bg) 40%,transparent)}
|
||||
.mock-side .mi{height:9px;border-radius:5px;margin-bottom:9px;background:linear-gradient(90deg,var(--panel3),color-mix(in srgb,var(--panel3) 60%,transparent))}
|
||||
.mock-side .mi.on{background:linear-gradient(90deg,rgba(92,200,255,.5),rgba(139,124,255,.3))}
|
||||
.mock-main{padding:14px;display:flex;flex-direction:column;gap:10px}
|
||||
.mock-row{display:flex;gap:10px}
|
||||
.mock-kpi{flex:1;border:1px solid var(--line2);border-radius:10px;padding:9px 11px;background:var(--panel2)}
|
||||
.mock-kpi b{display:block;font-size:13px;color:var(--acc)}
|
||||
.mock-kpi span{font-size:10px;color:var(--tx3);letter-spacing:.06em;text-transform:uppercase}
|
||||
.mock-log{border:1px solid var(--line2);border-radius:10px;padding:9px 11px;background:var(--code-bg);font-family:var(--mono);font-size:10.5px;line-height:1.9;color:#5f7ca6;flex:1}
|
||||
.mock-log .l-ok{color:#34d399}.mock-log .l-acc{color:#7dd3fc}.mock-log .l-warn{color:#fbbf24}
|
||||
.mock-cap{text-align:center;font-size:12.5px;color:var(--tx3);margin:6px 0 0}
|
||||
/* ============ 流程链条 ============ */
|
||||
.flowline{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:16px 0}
|
||||
.fl{display:inline-flex;align-items:center;gap:7px;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:6px 13px;font-family:var(--mono);font-size:12px;color:#7dd3fc}
|
||||
.fl i{color:var(--acc2)}
|
||||
.fl-c{color:var(--tx3)}
|
||||
/* ============ 手风琴 FAQ ============ */
|
||||
.acc{border:1px solid var(--line);border-radius:15px;background:var(--panel);margin:13px 0;overflow:hidden;transition:border-color .2s}
|
||||
.acc summary{list-style:none;cursor:pointer;padding:15px 19px;display:flex;align-items:center;gap:12px;font-weight:700;font-size:14.5px;color:var(--tx);transition:.15s}
|
||||
.acc summary::-webkit-details-marker{display:none}
|
||||
.acc summary:hover{color:var(--acc)}
|
||||
.acc summary .ac-ic{color:var(--acc);flex-shrink:0}
|
||||
.acc summary .chev{margin-left:auto;transition:transform .25s;color:var(--tx3);flex-shrink:0}
|
||||
.acc[open]{border-color:rgba(92,200,255,.3)}
|
||||
.acc[open] .chev{transform:rotate(90deg)}
|
||||
.acc-bd{padding:2px 19px 17px 51px;font-size:14px;color:var(--tx2)}
|
||||
.acc-bd p:last-child,.acc-bd ul:last-child,.acc-bd ol:last-child{margin-bottom:0}
|
||||
/* ============ 右侧 TOC ============ */
|
||||
.toc{position:sticky;top:calc(var(--hd-h) + 26px);align-self:start;height:fit-content;padding:26px 0 40px 26px;border-left:1px solid var(--line2);margin-top:44px}
|
||||
.toc-t{font-size:10.5px;font-weight:800;letter-spacing:.14em;text-transform:uppercase;color:var(--tx3);margin-bottom:11px;display:flex;align-items:center;gap:7px}
|
||||
.toc a{display:block;padding:3.5px 0 3.5px 13px;font-size:12.8px;color:var(--tx2);border-left:2px solid transparent;margin-left:-1px;transition:.15s;line-height:1.5}
|
||||
.toc a:hover{color:var(--tx);text-decoration:none}
|
||||
.toc a.on{color:var(--acc);border-left-color:var(--acc);font-weight:700}
|
||||
/* ============ 页脚 & Toast & 移动端 ============ */
|
||||
.foot{border-top:1px solid var(--line2);padding:26px 34px;display:flex;flex-wrap:wrap;gap:14px;align-items:center;justify-content:space-between;color:var(--tx3);font-size:12.5px}
|
||||
.toast{position:fixed;bottom:30px;left:50%;transform:translateX(-50%) translateY(16px);background:var(--panel3);border:1px solid rgba(92,200,255,.3);color:var(--tx);padding:9px 20px;border-radius:11px;font-size:13px;font-weight:600;opacity:0;pointer-events:none;transition:.3s;z-index:300;box-shadow:var(--shadow);display:flex;gap:8px;align-items:center}
|
||||
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
|
||||
.toast i{color:var(--tip)}
|
||||
.overlay{position:fixed;inset:0;background:rgba(3,7,15,.6);backdrop-filter:blur(3px);z-index:115;opacity:0;pointer-events:none;transition:.25s}
|
||||
.overlay.on{opacity:1;pointer-events:auto}
|
||||
[data-reveal]{opacity:0;transform:translateY(22px);transition:opacity .7s cubic-bezier(.2,.7,.3,1),transform .7s cubic-bezier(.2,.7,.3,1)}
|
||||
[data-reveal].rv{opacity:1;transform:none}
|
||||
@media(max-width:1240px){.body-wrap{grid-template-columns:minmax(0,1fr)}.toc{display:none}}
|
||||
@media(max-width:1080px){
|
||||
.sidebar{position:fixed;left:0;top:0;transform:translateX(-104%);transition:transform .3s cubic-bezier(.2,.8,.3,1);box-shadow:var(--shadow);width:300px}
|
||||
.sidebar.open{transform:none}
|
||||
#menuBtn{display:inline-flex}
|
||||
.body-wrap{padding:0 20px}
|
||||
.content{padding-top:30px}
|
||||
}
|
||||
@media(max-width:640px){.hide-sm{display:none}}
|
||||
@media(max-width:760px){
|
||||
.grid2,.grid3,.quickstart-links{grid-template-columns:1fr}
|
||||
.quickstart-links>a+a{border-left:none;border-top:1px solid var(--line2)}
|
||||
p code,li code{white-space:normal;overflow-wrap:anywhere;word-break:break-word}
|
||||
.mock-body{grid-template-columns:1fr}
|
||||
.mock-side{display:flex;gap:8px;overflow:hidden;border-right:none;border-bottom:1px solid var(--line);padding:9px}
|
||||
.mock-side .mi{width:60px;margin:0}
|
||||
.hero-cta{flex-direction:column;align-items:stretch}
|
||||
.tb-crumb b{display:none}
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
var Vue=function(e){"use strict";function t(e,t){const n=Object.create(null),o=e.split(",");for(let r=0;r<o.length;r++)n[o[r]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}const n={},o=[],r=()=>{},s=()=>!1,i=/^on[^a-z]/,l=e=>i.test(e),c=e=>e.startsWith("onUpdate:"),a=Object.assign,u=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},p=Object.prototype.hasOwnProperty,f=(e,t)=>p.call(e,t),d=Array.isArray,h=e=>"[object Map]"===C(e),m=e=>"[object Set]"===C(e),g=e=>"[object Date]"===C(e),v=e=>"function"==typeof e,y=e=>"string"==typeof e,_=e=>"symbol"==typeof e,b=e=>null!==e&&"object"==typeof e,S=e=>b(e)&&v(e.then)&&v(e.catch),x=Object.prototype.toString,C=e=>x.call(e),k=e=>"[object Object]"===C(e),w=e=>y(e)&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,T=t(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),E=t("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"),N=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},O=/-(\w)/g,$=N((e=>e.replace(O,((e,t)=>t?t.toUpperCase():"")))),P=/\B([A-Z])/g,A=N((e=>e.replace(P,"-$1").toLowerCase())),F=N((e=>e.charAt(0).toUpperCase()+e.slice(1))),R=N((e=>e?`on${F(e)}`:"")),M=(e,t)=>!Object.is(e,t),V=(e,t)=>{for(let n=0;n<e.length;n++)e[n](t)},I=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})},B=e=>{const t=parseFloat(e);return isNaN(t)?e:t},L=e=>{const t=y(e)?Number(e):NaN;return isNaN(t)?e:t};let j;const U=t("Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console");function D(e){if(d(e)){const t={};for(let n=0;n<e.length;n++){const o=e[n],r=y(o)?K(o):D(o);if(r)for(const e in r)t[e]=r[e]}return t}return y(e)||b(e)?e:void 0}const H=/;(?![^(]*\))/g,W=/:([^]+)/,z=/\/\*[^]*?\*\//g;function K(e){const t={};return e.replace(z,"").split(H).forEach((e=>{if(e){const n=e.split(W);n.length>1&&(t[n[0].trim()]=n[1].trim())}})),t}function G(e){let t="";if(y(e))t=e;else if(d(e))for(let n=0;n<e.length;n++){const o=G(e[n]);o&&(t+=o+" ")}else if(b(e))for(const n in e)e[n]&&(t+=n+" ");return t.trim()}const q=t("html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot"),J=t("svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view"),Z=t("area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr"),Y=t("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function Q(e){return!!e||""===e}function X(e,t){if(e===t)return!0;let n=g(e),o=g(t);if(n||o)return!(!n||!o)&&e.getTime()===t.getTime();if(n=_(e),o=_(t),n||o)return e===t;if(n=d(e),o=d(t),n||o)return!(!n||!o)&&function(e,t){if(e.length!==t.length)return!1;let n=!0;for(let o=0;n&&o<e.length;o++)n=X(e[o],t[o]);return n}(e,t);if(n=b(e),o=b(t),n||o){if(!n||!o)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e){const o=e.hasOwnProperty(n),r=t.hasOwnProperty(n);if(o&&!r||!o&&r||!X(e[n],t[n]))return!1}}return String(e)===String(t)}function ee(e,t){return e.findIndex((e=>X(e,t)))}const te=(e,t)=>t&&t.__v_isRef?te(e,t.value):h(t)?{[`Map(${t.size})`]:[...t.entries()].reduce(((e,[t,n])=>(e[`${t} =>`]=n,e)),{})}:m(t)?{[`Set(${t.size})`]:[...t.values()]}:!b(t)||d(t)||k(t)?t:String(t);let ne;class oe{constructor(e=!1){this.detached=e,this._active=!0,this.effects=[],this.cleanups=[],this.parent=ne,!e&&ne&&(this.index=(ne.scopes||(ne.scopes=[])).push(this)-1)}get active(){return this._active}run(e){if(this._active){const t=ne;try{return ne=this,e()}finally{ne=t}}}on(){ne=this}off(){ne=this.parent}stop(e){if(this._active){let t,n;for(t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.scopes)for(t=0,n=this.scopes.length;t<n;t++)Line truncated
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 255 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 267 KiB |
@@ -0,0 +1,965 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
// ==================== 配置区域 ====================
|
||||
const CONFIG = {
|
||||
// 捕获模式:'strict'(严格) 或 'loose'(宽松)
|
||||
mode: 'loose',
|
||||
|
||||
// 宽松模式:捕获这些方法
|
||||
looseMethods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
|
||||
|
||||
// 严格模式:只捕获这些方法
|
||||
strictMethods: ['POST', 'PUT', 'PATCH'],
|
||||
|
||||
// 高优先级关键词(这些一定会被捕获)
|
||||
highPriorityKeywords: [
|
||||
// AI服务
|
||||
'chat', 'message', 'conversation', 'completion', 'generate', 'stream',
|
||||
'claude', 'anthropic', 'openai', 'gpt', 'gemini', 'bard', 'copilot',
|
||||
'llama', 'mistral', 'perplexity',
|
||||
// 文件相关
|
||||
'upload', 'presign', 'signed-url', 'attachment', 'file', 'image',
|
||||
'media', 'blob', 'asset', 's3', 'r2', 'storage', 'cloudflare',
|
||||
// 评估相关
|
||||
'evaluation', 'arena', 'vote', 'feedback'
|
||||
],
|
||||
|
||||
// 中优先级关键词
|
||||
mediumPriorityKeywords: [
|
||||
'api', '/v1/', '/v2/', '/v3/', '/v4/',
|
||||
'nextjs-api', 'graphql', 'query', 'mutation',
|
||||
'session', 'auth', 'token'
|
||||
],
|
||||
|
||||
// 一定排除的关键词(静态资源等)
|
||||
alwaysExclude: [
|
||||
'.css', '.js', '.woff', '.woff2', '.ttf', '.eot',
|
||||
'.ico', 'favicon', 'manifest.json',
|
||||
'.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp', // 静态图片
|
||||
'google-analytics', 'googletagmanager', 'doubleclick',
|
||||
'facebook.com/tr', 'analytics.js', 'gtag'
|
||||
],
|
||||
|
||||
// 可选排除的关键词(宽松模式下也会捕获)
|
||||
optionalExclude: [
|
||||
'analytics', 'tracking', 'telemetry', 'beacon', 'pixel',
|
||||
'logging', 'metrics', 'heartbeat', 'ping', 'health'
|
||||
],
|
||||
|
||||
// 请求体中要清理的字段
|
||||
cleanBodyFields: [
|
||||
{ pattern: /^recaptcha.*token$/i, replacement: '[RECAPTCHA]' },
|
||||
{ pattern: /^.*captcha.*$/i, replacement: '[CAPTCHA]' },
|
||||
{ pattern: /^g-recaptcha-response$/i, replacement: '[CAPTCHA]' },
|
||||
{ pattern: /^cf[_-]?turnstile$/i, replacement: '[TURNSTILE]' }
|
||||
],
|
||||
|
||||
// 保留所有headers,但这些会被部分隐藏
|
||||
hideHeaderPatterns: [
|
||||
/^cookie$/i,
|
||||
/^authorization$/i,
|
||||
/^.*api[_-]?key.*$/i,
|
||||
/^.*secret.*$/i
|
||||
],
|
||||
|
||||
// 字符串处理
|
||||
maxStringLength: 50000, // 增加限制
|
||||
tokenDetectLength: 1000, // token检测阈值
|
||||
base64PreviewLength: 100, // base64预览长度
|
||||
|
||||
// === 新增配置 ===
|
||||
maxRequests: 1000, // 最大保留请求数(防止内存溢出)
|
||||
captureResponse: true, // 是否捕获响应体
|
||||
maxResponseLength: 100000, // 响应体最大长度
|
||||
recordTiming: true, // 是否记录请求耗时
|
||||
|
||||
// 响应体排除的 Content-Type(二进制文件等)
|
||||
excludeResponseTypes: [
|
||||
'image/', 'video/', 'audio/', 'font/',
|
||||
'application/octet-stream', 'application/zip',
|
||||
'application/pdf', 'application/wasm'
|
||||
]
|
||||
};
|
||||
|
||||
// ==================== 预编译关键词(性能优化)====================
|
||||
const COMPILED = {
|
||||
highPriority: CONFIG.highPriorityKeywords.map(k => k.toLowerCase()),
|
||||
mediumPriority: CONFIG.mediumPriorityKeywords.map(k => k.toLowerCase()),
|
||||
alwaysExclude: CONFIG.alwaysExclude.map(k => k.toLowerCase()),
|
||||
optionalExclude: CONFIG.optionalExclude.map(k => k.toLowerCase())
|
||||
};
|
||||
|
||||
// ==================== 存储 ====================
|
||||
const capturedRequests = [];
|
||||
let isCapturing = true;
|
||||
let requestCounter = 0;
|
||||
|
||||
// ==================== 统一捕获判断(合并优先级计算,避免重复遍历)====================
|
||||
function analyzeRequest(url, method) {
|
||||
if (!isCapturing) return { shouldCapture: false, priority: null };
|
||||
|
||||
const urlLower = url.toLowerCase();
|
||||
const methodUpper = method.toUpperCase();
|
||||
|
||||
// 1. 一定排除的检查
|
||||
for (const keyword of COMPILED.alwaysExclude) {
|
||||
if (urlLower.includes(keyword)) {
|
||||
return { shouldCapture: false, priority: null };
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 方法过滤
|
||||
const methods = CONFIG.mode === 'loose' ? CONFIG.looseMethods : CONFIG.strictMethods;
|
||||
if (!methods.includes(methodUpper)) {
|
||||
return { shouldCapture: false, priority: null };
|
||||
}
|
||||
|
||||
// 3. 严格模式下检查可选排除
|
||||
if (CONFIG.mode === 'strict') {
|
||||
for (const keyword of COMPILED.optionalExclude) {
|
||||
if (urlLower.includes(keyword)) {
|
||||
return { shouldCapture: false, priority: null };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 检查高优先级
|
||||
for (const keyword of COMPILED.highPriority) {
|
||||
if (urlLower.includes(keyword)) {
|
||||
return { shouldCapture: true, priority: 'HIGH' };
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 检查中优先级
|
||||
for (const keyword of COMPILED.mediumPriority) {
|
||||
if (urlLower.includes(keyword)) {
|
||||
return { shouldCapture: true, priority: 'MEDIUM' };
|
||||
}
|
||||
}
|
||||
|
||||
// 6. POST/PUT/PATCH 默认中优先级
|
||||
if (['POST', 'PUT', 'PATCH'].includes(methodUpper)) {
|
||||
return { shouldCapture: true, priority: 'MEDIUM' };
|
||||
}
|
||||
|
||||
// 7. 宽松模式额外规则
|
||||
if (CONFIG.mode === 'loose') {
|
||||
if (urlLower.includes('api') || urlLower.match(/\/v\d+\//)) {
|
||||
return { shouldCapture: true, priority: 'LOW' };
|
||||
}
|
||||
if (methodUpper !== 'GET') {
|
||||
return { shouldCapture: true, priority: 'LOW' };
|
||||
}
|
||||
}
|
||||
|
||||
return { shouldCapture: false, priority: 'LOW' };
|
||||
}
|
||||
|
||||
// 兼容旧调用(保留原有函数名)
|
||||
function shouldCapture(url, method) {
|
||||
return analyzeRequest(url, method).shouldCapture;
|
||||
}
|
||||
|
||||
function getPriority(url, method) {
|
||||
return analyzeRequest(url, method).priority || 'LOW';
|
||||
}
|
||||
|
||||
// ==================== 处理Headers ====================
|
||||
function processHeaders(headers) {
|
||||
if (!headers) return null;
|
||||
|
||||
const result = {};
|
||||
let headerObj;
|
||||
|
||||
if (headers instanceof Headers) {
|
||||
headerObj = Object.fromEntries(headers.entries());
|
||||
} else if (typeof headers === 'object') {
|
||||
headerObj = headers;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (const [key, value] of Object.entries(headerObj)) {
|
||||
let shouldHide = false;
|
||||
for (const pattern of CONFIG.hideHeaderPatterns) {
|
||||
if (pattern.test(key)) {
|
||||
shouldHide = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldHide) {
|
||||
if (value.length > 30) {
|
||||
result[key] = value.substring(0, 15) + '...[HIDDEN]...' + value.substring(value.length - 10);
|
||||
} else if (value.length > 10) {
|
||||
result[key] = value.substring(0, 5) + '...[HIDDEN]';
|
||||
} else {
|
||||
result[key] = '[HIDDEN]';
|
||||
}
|
||||
} else {
|
||||
result[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return Object.keys(result).length > 0 ? result : null;
|
||||
}
|
||||
|
||||
// ==================== 智能字符串处理 ====================
|
||||
function smartProcessString(str, fieldName = '') {
|
||||
if (typeof str !== 'string') return str;
|
||||
|
||||
const fieldLower = fieldName.toLowerCase();
|
||||
|
||||
// 检查是否应该清理该字段
|
||||
for (const rule of CONFIG.cleanBodyFields) {
|
||||
if (rule.pattern.test(fieldName)) {
|
||||
return rule.replacement;
|
||||
}
|
||||
}
|
||||
|
||||
// data:image base64
|
||||
if (str.startsWith('data:image/')) {
|
||||
const match = str.match(/^(data:image\/[^;]+;base64,)(.+)$/);
|
||||
if (match) {
|
||||
const [, prefix, data] = match;
|
||||
const preview = data.substring(0, CONFIG.base64PreviewLength);
|
||||
return `${prefix}${preview}...[BASE64_${data.length}_CHARS]`;
|
||||
}
|
||||
}
|
||||
|
||||
// 纯base64 (长字符串)
|
||||
if (str.length > CONFIG.tokenDetectLength && /^[A-Za-z0-9+/]+=*$/.test(str)) {
|
||||
const preview = str.substring(0, CONFIG.base64PreviewLength);
|
||||
return `${preview}...[BASE64_${str.length}_CHARS]`;
|
||||
}
|
||||
|
||||
// URL安全base64
|
||||
if (str.length > CONFIG.tokenDetectLength && /^[A-Za-z0-9_-]+$/.test(str)) {
|
||||
const preview = str.substring(0, CONFIG.base64PreviewLength);
|
||||
return `${preview}...[TOKEN_${str.length}_CHARS]`;
|
||||
}
|
||||
|
||||
// 普通长字符串
|
||||
if (str.length > CONFIG.maxStringLength) {
|
||||
return str.substring(0, CONFIG.maxStringLength) + `...[TRUNCATED_${str.length - CONFIG.maxStringLength}_MORE]`;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
// ==================== 处理Body ====================
|
||||
function processBody(body, depth = 0) {
|
||||
if (depth > 20) return '[MAX_DEPTH]';
|
||||
if (body === null || body === undefined) return null;
|
||||
|
||||
// FormData
|
||||
if (body instanceof FormData) {
|
||||
const result = { _type: 'FormData', fields: {} };
|
||||
for (const [key, value] of body.entries()) {
|
||||
if (value instanceof File) {
|
||||
result.fields[key] = {
|
||||
_type: 'File',
|
||||
name: value.name,
|
||||
size: value.size,
|
||||
sizeKB: (value.size / 1024).toFixed(2) + ' KB',
|
||||
mimeType: value.type,
|
||||
lastModified: new Date(value.lastModified).toISOString()
|
||||
};
|
||||
} else if (value instanceof Blob) {
|
||||
result.fields[key] = {
|
||||
_type: 'Blob',
|
||||
size: value.size,
|
||||
sizeKB: (value.size / 1024).toFixed(2) + ' KB',
|
||||
mimeType: value.type
|
||||
};
|
||||
} else {
|
||||
result.fields[key] = smartProcessString(value, key);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Blob
|
||||
if (body instanceof Blob) {
|
||||
return {
|
||||
_type: 'Blob',
|
||||
size: body.size,
|
||||
sizeKB: (body.size / 1024).toFixed(2) + ' KB',
|
||||
mimeType: body.type
|
||||
};
|
||||
}
|
||||
|
||||
// ArrayBuffer
|
||||
if (body instanceof ArrayBuffer) {
|
||||
return {
|
||||
_type: 'ArrayBuffer',
|
||||
byteLength: body.byteLength
|
||||
};
|
||||
}
|
||||
|
||||
// String
|
||||
if (typeof body === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(body);
|
||||
return processBodyRecursive(parsed, depth + 1, ''); // 🔧 传递空字段名作为根
|
||||
} catch {
|
||||
return smartProcessString(body);
|
||||
}
|
||||
}
|
||||
|
||||
// Object/Array
|
||||
if (typeof body === 'object') {
|
||||
return processBodyRecursive(body, depth);
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
function processBodyRecursive(obj, depth = 0, fieldName = '') {
|
||||
if (depth > 20) return '[MAX_DEPTH]';
|
||||
if (obj === null || obj === undefined) return obj;
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map((item, index) => processBodyRecursive(item, depth + 1, `${fieldName}[${index}]`));
|
||||
}
|
||||
|
||||
if (typeof obj === 'string') {
|
||||
return smartProcessString(obj, fieldName); // 🔧 修复:传递字段名
|
||||
}
|
||||
|
||||
if (typeof obj === 'object') {
|
||||
const result = {};
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
result[key] = processBodyRecursive(value, depth + 1, key); // 🔧 修复:传递字段名
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
// ==================== 响应处理 ====================
|
||||
function shouldCaptureResponse(contentType) {
|
||||
if (!contentType) return true;
|
||||
const typeLower = contentType.toLowerCase();
|
||||
return !CONFIG.excludeResponseTypes.some(excluded => typeLower.includes(excluded));
|
||||
}
|
||||
|
||||
async function processResponse(response, requestId) {
|
||||
if (!CONFIG.captureResponse) return null;
|
||||
|
||||
const record = capturedRequests.find(r => r._id === requestId);
|
||||
if (!record) return null;
|
||||
|
||||
try {
|
||||
const contentType = response.headers.get('content-type') || '';
|
||||
|
||||
const responseData = {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
headers: processHeaders(response.headers),
|
||||
contentType: contentType,
|
||||
body: null,
|
||||
bodyTruncated: false
|
||||
};
|
||||
|
||||
// 检查是否应该捕获响应体
|
||||
if (shouldCaptureResponse(contentType)) {
|
||||
const cloned = response.clone();
|
||||
let bodyText = await cloned.text();
|
||||
|
||||
if (bodyText.length > CONFIG.maxResponseLength) {
|
||||
responseData.body = bodyText.substring(0, CONFIG.maxResponseLength);
|
||||
responseData.bodyTruncated = true;
|
||||
responseData.bodyOriginalLength = bodyText.length;
|
||||
} else {
|
||||
// 尝试解析 JSON
|
||||
try {
|
||||
responseData.body = JSON.parse(bodyText);
|
||||
responseData.bodyType = 'json';
|
||||
} catch {
|
||||
responseData.body = bodyText;
|
||||
responseData.bodyType = 'text';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
responseData.body = `[BINARY: ${contentType}]`;
|
||||
responseData.bodyType = 'binary';
|
||||
}
|
||||
|
||||
record._response = responseData;
|
||||
} catch (e) {
|
||||
record._response = { error: e.message };
|
||||
}
|
||||
|
||||
return record._response;
|
||||
}
|
||||
|
||||
function updateRequestTiming(requestId, error = null) {
|
||||
const record = capturedRequests.find(r => r._id === requestId);
|
||||
if (record && record._timing) {
|
||||
record._timing.endTime = Date.now();
|
||||
record._timing.duration = record._timing.endTime - record._timing.startTime;
|
||||
if (error) {
|
||||
record._error = {
|
||||
message: error.message || String(error),
|
||||
name: error.name,
|
||||
stack: error.stack?.split('\n').slice(0, 3).join('\n')
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ==================== URL处理 ====================
|
||||
function parseUrl(url) {
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
return {
|
||||
full: url,
|
||||
protocol: urlObj.protocol,
|
||||
host: urlObj.host,
|
||||
hostname: urlObj.hostname,
|
||||
port: urlObj.port,
|
||||
pathname: urlObj.pathname,
|
||||
search: urlObj.search,
|
||||
hash: urlObj.hash,
|
||||
origin: urlObj.origin
|
||||
};
|
||||
} catch {
|
||||
try {
|
||||
const urlObj = new URL(url, window.location.origin);
|
||||
return {
|
||||
full: url,
|
||||
protocol: urlObj.protocol,
|
||||
host: urlObj.host,
|
||||
hostname: urlObj.hostname,
|
||||
port: urlObj.port,
|
||||
pathname: urlObj.pathname,
|
||||
search: urlObj.search,
|
||||
hash: urlObj.hash,
|
||||
origin: urlObj.origin,
|
||||
_relative: true
|
||||
};
|
||||
} catch {
|
||||
return { full: url, pathname: url };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 添加请求 ====================
|
||||
function addCapturedRequest(data) {
|
||||
requestCounter++;
|
||||
|
||||
// 🔧 使用合并后的分析函数(避免重复计算)
|
||||
const analysis = analyzeRequest(data.url.full || data.url.pathname, data.method);
|
||||
const priority = analysis.priority || 'LOW';
|
||||
|
||||
const record = {
|
||||
_id: requestCounter,
|
||||
_capturedAt: new Date().toISOString(),
|
||||
_priority: priority,
|
||||
_timing: {
|
||||
startTime: Date.now(),
|
||||
duration: null,
|
||||
endTime: null
|
||||
},
|
||||
_response: null, // 响应占位,稍后填充
|
||||
_error: null, // 错误占位
|
||||
...data
|
||||
};
|
||||
|
||||
capturedRequests.push(record);
|
||||
|
||||
// 🔧 内存保护:超过最大限制时移除最旧的低优先级请求
|
||||
if (capturedRequests.length > CONFIG.maxRequests) {
|
||||
// 优先删除 LOW 优先级,其次 MEDIUM
|
||||
const indexToRemove = capturedRequests.findIndex(r => r._priority === 'LOW')
|
||||
?? capturedRequests.findIndex(r => r._priority === 'MEDIUM')
|
||||
?? 0;
|
||||
const removed = capturedRequests.splice(indexToRemove, 1)[0];
|
||||
console.warn(`%c⚠️ Memory limit reached, removed request #${removed._id}`, 'color: #FF9800;');
|
||||
}
|
||||
|
||||
const colors = {
|
||||
HIGH: '#FF5722',
|
||||
MEDIUM: '#4CAF50',
|
||||
LOW: '#9E9E9E'
|
||||
};
|
||||
|
||||
const emoji = {
|
||||
HIGH: '🔴',
|
||||
MEDIUM: '🟢',
|
||||
LOW: '⚪'
|
||||
};
|
||||
|
||||
console.log(
|
||||
`%c${emoji[priority]} [#${requestCounter}] ${data.method} ${data.url.pathname || data.url.full}`,
|
||||
`color: ${colors[priority]}; font-weight: ${priority === 'HIGH' ? 'bold' : 'normal'};`
|
||||
);
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
// ==================== 拦截Fetch ====================
|
||||
const originalFetch = window.fetch;
|
||||
window.fetch = async function(input, init = {}) {
|
||||
const url = input instanceof Request ? input.url : String(input);
|
||||
const method = init.method || (input instanceof Request ? input.method : 'GET');
|
||||
|
||||
const analysis = analyzeRequest(url, method);
|
||||
|
||||
if (!analysis.shouldCapture) {
|
||||
return originalFetch.apply(this, arguments);
|
||||
}
|
||||
|
||||
let capturedRecord = null;
|
||||
|
||||
try {
|
||||
let bodyData = init.body;
|
||||
if (input instanceof Request && !init.body) {
|
||||
try {
|
||||
bodyData = await input.clone().text();
|
||||
} catch (e) {
|
||||
bodyData = { _error: 'Failed to read Request body', _reason: e.message };
|
||||
}
|
||||
}
|
||||
|
||||
capturedRecord = addCapturedRequest({
|
||||
type: 'fetch',
|
||||
method: method.toUpperCase(),
|
||||
url: parseUrl(url),
|
||||
headers: processHeaders(init.headers || (input instanceof Request ? input.headers : null)),
|
||||
body: processBody(bodyData),
|
||||
credentials: init.credentials || 'same-origin',
|
||||
mode: init.mode || 'cors'
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('❌ Capture error:', e);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await originalFetch.apply(this, arguments);
|
||||
|
||||
// 捕获响应
|
||||
if (capturedRecord) {
|
||||
updateRequestTiming(capturedRecord._id);
|
||||
await processResponse(response, capturedRecord._id);
|
||||
|
||||
// 标记失败的请求
|
||||
if (!response.ok) {
|
||||
capturedRecord._httpError = {
|
||||
status: response.status,
|
||||
statusText: response.statusText
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
// 网络错误等
|
||||
if (capturedRecord) {
|
||||
updateRequestTiming(capturedRecord._id, e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
// ==================== 拦截XHR ====================
|
||||
const originalXHROpen = XMLHttpRequest.prototype.open;
|
||||
const originalXHRSend = XMLHttpRequest.prototype.send;
|
||||
const originalXHRSetHeader = XMLHttpRequest.prototype.setRequestHeader;
|
||||
|
||||
XMLHttpRequest.prototype.open = function(method, url, ...args) {
|
||||
this._captureInfo = {
|
||||
method: method.toUpperCase(),
|
||||
url: String(url),
|
||||
headers: {}
|
||||
};
|
||||
return originalXHROpen.apply(this, [method, url, ...args]);
|
||||
};
|
||||
|
||||
XMLHttpRequest.prototype.setRequestHeader = function(name, value) {
|
||||
if (this._captureInfo) {
|
||||
this._captureInfo.headers[name] = value;
|
||||
}
|
||||
return originalXHRSetHeader.apply(this, arguments);
|
||||
};
|
||||
|
||||
XMLHttpRequest.prototype.send = function(body) {
|
||||
const self = this;
|
||||
let capturedRecord = null;
|
||||
|
||||
if (this._captureInfo && shouldCapture(this._captureInfo.url, this._captureInfo.method)) {
|
||||
try {
|
||||
capturedRecord = addCapturedRequest({
|
||||
type: 'xhr',
|
||||
method: this._captureInfo.method,
|
||||
url: parseUrl(this._captureInfo.url),
|
||||
headers: processHeaders(this._captureInfo.headers),
|
||||
body: processBody(body)
|
||||
});
|
||||
|
||||
// 保存引用以便在回调中使用
|
||||
this._capturedRecordId = capturedRecord._id;
|
||||
} catch (e) {
|
||||
console.warn('❌ XHR capture error:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 监听响应
|
||||
if (capturedRecord && CONFIG.captureResponse) {
|
||||
const originalOnReadyStateChange = this.onreadystatechange;
|
||||
|
||||
this.onreadystatechange = function() {
|
||||
if (self.readyState === 4 && self._capturedRecordId) {
|
||||
const record = capturedRequests.find(r => r._id === self._capturedRecordId);
|
||||
if (record) {
|
||||
updateRequestTiming(record._id);
|
||||
|
||||
const contentType = self.getResponseHeader('content-type') || '';
|
||||
|
||||
record._response = {
|
||||
status: self.status,
|
||||
statusText: self.statusText,
|
||||
contentType: contentType,
|
||||
headers: null, // XHR 无法方便获取所有响应头
|
||||
body: null
|
||||
};
|
||||
|
||||
// 捕获响应体
|
||||
if (shouldCaptureResponse(contentType)) {
|
||||
try {
|
||||
let responseBody = self.responseText;
|
||||
|
||||
if (responseBody.length > CONFIG.maxResponseLength) {
|
||||
record._response.body = responseBody.substring(0, CONFIG.maxResponseLength);
|
||||
record._response.bodyTruncated = true;
|
||||
record._response.bodyOriginalLength = responseBody.length;
|
||||
} else {
|
||||
try {
|
||||
record._response.body = JSON.parse(responseBody);
|
||||
record._response.bodyType = 'json';
|
||||
} catch {
|
||||
record._response.body = responseBody;
|
||||
record._response.bodyType = 'text';
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
record._response.body = { _error: 'Failed to read response', _reason: e.message };
|
||||
}
|
||||
} else {
|
||||
record._response.body = `[BINARY: ${contentType}]`;
|
||||
record._response.bodyType = 'binary';
|
||||
}
|
||||
|
||||
// 标记失败
|
||||
if (self.status >= 400) {
|
||||
record._httpError = {
|
||||
status: self.status,
|
||||
statusText: self.statusText
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (originalOnReadyStateChange) {
|
||||
originalOnReadyStateChange.apply(self, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
// 监听错误
|
||||
const originalOnError = this.onerror;
|
||||
this.onerror = function(e) {
|
||||
if (self._capturedRecordId) {
|
||||
updateRequestTiming(self._capturedRecordId, { message: 'Network error', name: 'NetworkError' });
|
||||
}
|
||||
if (originalOnError) {
|
||||
originalOnError.apply(self, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return originalXHRSend.apply(this, arguments);
|
||||
};
|
||||
|
||||
// ==================== 导出命令 ====================
|
||||
|
||||
// 导出(可选优先级过滤)
|
||||
window.exportRequests = function(options = {}) {
|
||||
const {
|
||||
filename = `requests-${Date.now()}.json`,
|
||||
priority = null, // 'HIGH', 'MEDIUM', 'LOW' 或 null(全部)
|
||||
minPriority = null // 'MEDIUM'(包含HIGH和MEDIUM), 'LOW'(全部)
|
||||
} = typeof options === 'string' ? { filename: options } : options;
|
||||
|
||||
let filtered = capturedRequests;
|
||||
|
||||
if (priority) {
|
||||
filtered = filtered.filter(r => r._priority === priority);
|
||||
} else if (minPriority === 'MEDIUM') {
|
||||
filtered = filtered.filter(r => ['HIGH', 'MEDIUM'].includes(r._priority));
|
||||
} else if (minPriority === 'HIGH') {
|
||||
filtered = filtered.filter(r => r._priority === 'HIGH');
|
||||
}
|
||||
|
||||
if (filtered.length === 0) {
|
||||
console.warn('⚠️ No requests to export!');
|
||||
return;
|
||||
}
|
||||
|
||||
const exportData = {
|
||||
_exportedAt: new Date().toISOString(),
|
||||
_totalRequests: filtered.length,
|
||||
_source: window.location.href,
|
||||
_captureMode: CONFIG.mode,
|
||||
requests: filtered
|
||||
};
|
||||
|
||||
const json = JSON.stringify(exportData, null, 2);
|
||||
const blob = new Blob([json], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
console.log(`%c✅ Exported ${filtered.length} requests to ${filename}`, 'color: #4CAF50; font-weight: bold;');
|
||||
return exportData;
|
||||
};
|
||||
|
||||
// 查看列表
|
||||
window.viewRequests = function(priority = null) {
|
||||
let filtered = capturedRequests;
|
||||
if (priority) {
|
||||
filtered = filtered.filter(r => r._priority === priority);
|
||||
}
|
||||
|
||||
if (filtered.length === 0) {
|
||||
console.log('📭 No requests');
|
||||
return [];
|
||||
}
|
||||
|
||||
console.table(filtered.map(r => ({
|
||||
ID: r._id,
|
||||
Priority: r._priority,
|
||||
Time: r._capturedAt.split('T')[1].split('.')[0],
|
||||
Type: r.type,
|
||||
Method: r.method,
|
||||
Path: (r.url.pathname || r.url.full || '').substring(0, 60)
|
||||
})));
|
||||
|
||||
return filtered;
|
||||
};
|
||||
|
||||
// 查看单个
|
||||
window.viewRequest = function(id) {
|
||||
const r = capturedRequests.find(r => r._id === id);
|
||||
if (!r) {
|
||||
console.warn(`⚠️ Request #${id} not found`);
|
||||
return null;
|
||||
}
|
||||
console.log(JSON.stringify(r, null, 2));
|
||||
return r;
|
||||
};
|
||||
|
||||
// 搜索
|
||||
window.searchRequests = function(keyword) {
|
||||
const keywordLower = keyword.toLowerCase();
|
||||
const results = capturedRequests.filter(r => {
|
||||
const json = JSON.stringify(r).toLowerCase();
|
||||
return json.includes(keywordLower);
|
||||
});
|
||||
|
||||
console.log(`%c🔍 Found ${results.length} requests containing "${keyword}"`, 'color: #2196F3;');
|
||||
console.table(results.map(r => ({
|
||||
ID: r._id,
|
||||
Priority: r._priority,
|
||||
Method: r.method,
|
||||
Path: (r.url.pathname || r.url.full || '').substring(0, 60)
|
||||
})));
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
// 统计
|
||||
window.requestStats = function() {
|
||||
const stats = {
|
||||
total: capturedRequests.length,
|
||||
byPriority: {},
|
||||
byMethod: {},
|
||||
byType: {},
|
||||
isCapturing,
|
||||
mode: CONFIG.mode
|
||||
};
|
||||
|
||||
capturedRequests.forEach(r => {
|
||||
stats.byPriority[r._priority] = (stats.byPriority[r._priority] || 0) + 1;
|
||||
stats.byMethod[r.method] = (stats.byMethod[r.method] || 0) + 1;
|
||||
stats.byType[r.type] = (stats.byType[r.type] || 0) + 1;
|
||||
});
|
||||
|
||||
console.log('%c📊 Request Statistics', 'color: #2196F3; font-size: 14px; font-weight: bold;');
|
||||
console.table(stats);
|
||||
return stats;
|
||||
};
|
||||
|
||||
// 清空
|
||||
window.clearRequests = function() {
|
||||
const count = capturedRequests.length;
|
||||
capturedRequests.length = 0;
|
||||
requestCounter = 0;
|
||||
console.log(`%c🗑️ Cleared ${count} requests`, 'color: #FF9800;');
|
||||
};
|
||||
|
||||
// 暂停/恢复
|
||||
window.toggleCapture = function() {
|
||||
isCapturing = !isCapturing;
|
||||
console.log(
|
||||
`%c${isCapturing ? '▶️ Capturing RESUMED' : '⏸️ Capturing PAUSED'}`,
|
||||
`color: ${isCapturing ? '#4CAF50' : '#FF9800'}; font-weight: bold;`
|
||||
);
|
||||
return isCapturing;
|
||||
};
|
||||
// 复制到剪贴板
|
||||
window.copyRequests = async function(options = {}) {
|
||||
const {
|
||||
priority = null,
|
||||
minPriority = null,
|
||||
format = 'json' // 'json' 或 'curl'
|
||||
} = typeof options === 'string' ? { priority: options } : options;
|
||||
|
||||
let filtered = capturedRequests;
|
||||
|
||||
if (priority) {
|
||||
filtered = filtered.filter(r => r._priority === priority);
|
||||
} else if (minPriority === 'MEDIUM') {
|
||||
filtered = filtered.filter(r => ['HIGH', 'MEDIUM'].includes(r._priority));
|
||||
} else if (minPriority === 'HIGH') {
|
||||
filtered = filtered.filter(r => r._priority === 'HIGH');
|
||||
}
|
||||
|
||||
if (filtered.length === 0) {
|
||||
console.warn('⚠️ No requests to copy!');
|
||||
return;
|
||||
}
|
||||
|
||||
let text;
|
||||
if (format === 'curl') {
|
||||
text = filtered.map(r => {
|
||||
let curl = `curl -X ${r.method} '${r.url.full}'`;
|
||||
if (r.headers) {
|
||||
for (const [key, value] of Object.entries(r.headers)) {
|
||||
if (!value.includes('[HIDDEN]')) {
|
||||
curl += ` \\\n -H '${key}: ${value}'`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (r.body && typeof r.body === 'object') {
|
||||
curl += ` \\\n -d '${JSON.stringify(r.body)}'`;
|
||||
} else if (r.body) {
|
||||
curl += ` \\\n -d '${r.body}'`;
|
||||
}
|
||||
return curl;
|
||||
}).join('\n\n---\n\n');
|
||||
} else {
|
||||
text = JSON.stringify(filtered, null, 2);
|
||||
}
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
console.log(`%c📋 Copied ${filtered.length} requests to clipboard (${format} format)`, 'color: #4CAF50; font-weight: bold;');
|
||||
} catch (e) {
|
||||
// 降级方案
|
||||
console.log('📋 Clipboard API failed, printing to console:');
|
||||
console.log(text);
|
||||
}
|
||||
|
||||
return text;
|
||||
};
|
||||
|
||||
// 查看失败的请求
|
||||
window.viewErrors = function() {
|
||||
const errors = capturedRequests.filter(r => r._error || r._httpError);
|
||||
if (errors.length === 0) {
|
||||
console.log('✅ No errors captured');
|
||||
return [];
|
||||
}
|
||||
|
||||
console.log(`%c❌ Found ${errors.length} requests with errors`, 'color: #f44336; font-weight: bold;');
|
||||
console.table(errors.map(r => ({
|
||||
ID: r._id,
|
||||
Method: r.method,
|
||||
Path: (r.url.pathname || '').substring(0, 40),
|
||||
Status: r._httpError?.status || 'N/A',
|
||||
Error: r._error?.message || r._httpError?.statusText || 'Unknown'
|
||||
})));
|
||||
|
||||
return errors;
|
||||
};
|
||||
|
||||
// 查看慢请求
|
||||
window.viewSlow = function(thresholdMs = 1000) {
|
||||
const slow = capturedRequests.filter(r => r._timing?.duration > thresholdMs);
|
||||
if (slow.length === 0) {
|
||||
console.log(`✅ No requests slower than ${thresholdMs}ms`);
|
||||
return [];
|
||||
}
|
||||
|
||||
slow.sort((a, b) => (b._timing?.duration || 0) - (a._timing?.duration || 0));
|
||||
|
||||
console.log(`%c🐌 Found ${slow.length} requests slower than ${thresholdMs}ms`, 'color: #FF9800; font-weight: bold;');
|
||||
console.table(slow.map(r => ({
|
||||
ID: r._id,
|
||||
Method: r.method,
|
||||
Path: (r.url.pathname || '').substring(0, 40),
|
||||
Duration: r._timing?.duration + 'ms',
|
||||
Status: r._response?.status || 'N/A'
|
||||
})));
|
||||
|
||||
return slow;
|
||||
};
|
||||
|
||||
// 切换模式
|
||||
window.setCaptureMode = function(mode) {
|
||||
if (!['strict', 'loose'].includes(mode)) {
|
||||
console.error('❌ Mode must be "strict" or "loose"');
|
||||
return;
|
||||
}
|
||||
CONFIG.mode = mode;
|
||||
console.log(`%c🔧 Capture mode set to: ${mode.toUpperCase()}`, 'color: #2196F3; font-weight: bold;');
|
||||
return mode;
|
||||
};
|
||||
|
||||
// ==================== 启动信息 ====================
|
||||
console.log(
|
||||
`%c🔍 AI Request Monitor Pro v4.0 (Enhanced)
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
Mode: ${CONFIG.mode.toUpperCase()} | Priority: 🔴HIGH 🟢MEDIUM ⚪LOW
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
Commands:
|
||||
exportRequests(options) - Export all or filtered
|
||||
viewRequests(priority) - View list (optional filter)
|
||||
viewRequest(id) - View single request
|
||||
searchRequests(keyword) - Search in all requests
|
||||
requestStats() - Show statistics
|
||||
clearRequests() - Clear all
|
||||
toggleCapture() - Pause/Resume
|
||||
setCaptureMode(mode) - Switch 'strict'/'loose'
|
||||
|
||||
📦 NEW in v4.0:
|
||||
copyRequests(options) - Copy to clipboard (format: 'json'/'curl')
|
||||
viewErrors() - View failed requests
|
||||
viewSlow(ms) - View slow requests (default: >1000ms)
|
||||
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`,
|
||||
'color: #2196F3; font-size: 14px;'
|
||||
);
|
||||
|
||||
})();
|
||||
Reference in new issue
Block a user