t176 套到 CIS 版 portal:刪 AI 設定區塊(修我把視覺打回舊版的錯)
【我犯的錯】08-03 出貨時用 `main` 建 UI bundle,但 CIS 新視覺在本分支 (fix/cis-round3-portal),main 上沒有 ⇒ **把 portal 打回 CIS 之前的樣子**。 leo 截圖坐實:新 AI 文案在(t176 生效)但 CIS 全不見(底色/字體/logo 都退回舊版)。 【為什麼會用錯】wiki 記「portal 真身=matrix/arcrun main」——那是 08-01 記的, 而 CIS 是 08-02 才進本分支 ⇒ **記錄過時**。且我沒照規矩「抓線上內容反查真身」驗證。 【本 commit】把 t176 的改動(移除 AI 設定區塊+其前端邏輯)套到 CIS 版上, 使兩者同時成立: CIS 特徵:--paper-a #FDFCFB ×8、IBM Plex Sans ×10、apple-touch-icon ×1 t176:「這裡不需要任何設定」×1、st-ai-use-claude ×0 前端 JS 語法檢查通過(4 個 script 區塊 1344 行,node --check 綠)。 重建 UI bundle 後檔數 6 → **9**(多了 favicon.ico/favicon.svg/apple-touch-icon.png) =先前那份 bundle 確實漏了 CIS 資產的機械證據。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -385,32 +385,18 @@
|
||||
<div style="margin-top:8px;font-size:13px;line-height:1.7;color:rgba(var(--ink-rgb),.5)">封測版未簽章,第一次請右鍵→打開。裝好第一次開啟時,貼上這個網址+你的帳號密碼就連上了。</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- t131 合併 AI 設定(Gemini API Key 必填;Claude 加強版視 daemon 回報 enable) -->
|
||||
<div class="panel" id="st-ai-panel">
|
||||
<!-- t176(leo 08-03):AI 設定整塊移除。
|
||||
雲端聊天問答走 Workers AI(用戶自己 CF 帳號內建,**免金鑰、裝好就能用**);
|
||||
地端萃取用哪把金鑰改由「同步小幫手」自己設定(托盤選單「AI 設定…」)。
|
||||
為什麼移除:雲端的 extractor 設定是全租戶共用一把 KV,任一處設了 claude
|
||||
會讓所有沒裝 Claude Code 的機器萃取全滅,而這裡的 Claude 勾選框又恆為
|
||||
disabled(daemon 從未回報 has_claude)⇒ 用戶自己解不開(08-03 封測實證)。
|
||||
leo:「搞不清楚設定 AI 是設雲端還是地端」——設定只留一處,就不會再搞混。 -->
|
||||
<div class="panel">
|
||||
<div style="font-size:17px;font-weight:600">AI 設定</div>
|
||||
<div style="margin-top:14px;display:flex;flex-direction:column;gap:16px">
|
||||
<!-- 第一格:Gemini API Key(必填,聊天+萃取共用) -->
|
||||
<div>
|
||||
<div style="font-size:14px;font-weight:500;margin-bottom:4px">Gemini API Key</div>
|
||||
<div style="font-size:13px;line-height:1.6;color:rgba(var(--ink-rgb),.55);margin-bottom:8px">聊天問答與文件萃取都用這一把。<a href="https://aistudio.google.com/apikey" target="_blank" rel="noopener">免費申請</a>,金鑰只存在你自己的知識庫裡。</div>
|
||||
<input type="password" id="st-ai-key" class="txt" placeholder="貼上 Gemini API Key" autocomplete="off">
|
||||
</div>
|
||||
<!-- 第二格:Claude 加強版(選填,依 daemon 回報 enable) -->
|
||||
<div style="padding-top:12px;border-top:1px solid rgba(var(--ink-rgb),.08)">
|
||||
<div style="font-size:14px;font-weight:500;margin-bottom:6px">讓知識卡整理得更好(選填)</div>
|
||||
<label style="display:flex;gap:8px;align-items:flex-start;cursor:pointer">
|
||||
<input type="checkbox" id="st-ai-use-claude" style="margin-top:3px;flex:none" disabled>
|
||||
<span style="font-size:14px">本地萃取改用 Claude Code</span>
|
||||
</label>
|
||||
<div id="st-ai-claude-desc" style="margin-top:8px;font-size:13px;line-height:1.65;color:rgba(var(--ink-rgb),.55)">
|
||||
讀你文件、整理成知識卡的那個 AI,換成更強的模型。<b style="color:var(--ink)">卡片會更抓得到重點、關聯也連得更準</b>,之後搜尋和問答的品質跟著提升。需要你的電腦已安裝 Claude Code。不填就用上面那把 Gemini,一樣能用。
|
||||
</div>
|
||||
<div id="st-ai-claude-hint" style="margin-top:6px;font-size:13px;color:rgba(var(--ink-rgb),.4);display:none"></div>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn" id="st-ai-save">儲存 AI 設定</button>
|
||||
<div id="st-ai-status" style="font-size:14px;min-height:1.2em;margin-top:8px"></div>
|
||||
</div>
|
||||
<div style="margin-top:12px;font-size:13.5px;line-height:1.7;color:rgba(var(--ink-rgb),.55);background:rgba(var(--ink-rgb),.03);border-radius:9px;padding:11px 13px">
|
||||
<b style="color:var(--ink)">這裡不需要任何設定。</b>聊天問答用的是你自己 Cloudflare 帳號內建的 AI,裝好就能直接問。<br>
|
||||
文件整理成知識卡的部分,請在<b style="color:var(--ink)">同步小幫手</b>(電腦上的托盤圖示)的「AI 設定…」填一把 Gemini API Key。
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn3" id="st-logout" style="padding:14px;font-size:16px;border-radius:11px">登出</button>
|
||||
@@ -824,72 +810,10 @@ function taipeiMonthDay(ms) { var d = new Date(ms + TAIPEI_OFFSET_MS); return {
|
||||
}
|
||||
})();
|
||||
|
||||
// t131 AI 設定(合併 Gemini API Key+Claude 加強版)
|
||||
(function () {
|
||||
// 進入設定頁時讀取現有設定(GET /portal/admin/ai)
|
||||
function loadAiConfig() {
|
||||
if (!(S.profile && S.profile.role === 'admin')) return;
|
||||
fetch(API_BASE + '/portal/admin/ai', { headers: authHeaders() })
|
||||
.then(function (r) { return r.ok ? safeJson(r) : null; })
|
||||
.then(function (d) {
|
||||
if (!d) return;
|
||||
var ki = $('st-ai-key');
|
||||
if (ki && d.has_key) ki.placeholder = '已設定(留空=不變更)';
|
||||
var cb = $('st-ai-use-claude');
|
||||
if (cb) {
|
||||
// 有 claude 才能勾;沒有則停用並顯示提示
|
||||
var hint = $('st-ai-claude-hint');
|
||||
if (d.claude_available) {
|
||||
cb.disabled = false;
|
||||
cb.checked = !!d.use_claude_for_extract;
|
||||
if (hint) hint.style.display = 'none';
|
||||
} else {
|
||||
cb.disabled = true;
|
||||
cb.checked = false;
|
||||
if (hint) {
|
||||
hint.style.display = '';
|
||||
// 區分:從未連上小幫手 vs 有連上但沒裝 Claude
|
||||
hint.textContent = d.has_key
|
||||
? '你的電腦沒有偵測到 Claude Code;裝好並讓小幫手重連一次後,這個選項就會開啟。'
|
||||
: '連上小幫手後才知道你的電腦有沒有 Claude Code。';
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function () { /* 讀不到不擋頁面 */ });
|
||||
}
|
||||
window._loadAiConfig = loadAiConfig;
|
||||
|
||||
// 儲存
|
||||
var sb = $('st-ai-save');
|
||||
if (sb) sb.addEventListener('click', function () {
|
||||
var m = $('st-ai-status');
|
||||
var k = (($('st-ai-key') && $('st-ai-key').value) || '').trim();
|
||||
var cb = $('st-ai-use-claude');
|
||||
var useClaud = cb && !cb.disabled ? cb.checked : undefined;
|
||||
var body = {};
|
||||
if (k) body.gemini_api_key = k;
|
||||
if (useClaud !== undefined) body.use_claude_for_extract = useClaud;
|
||||
sb.disabled = true; m.textContent = '儲存中…'; m.style.color = '';
|
||||
fetch(API_BASE + '/portal/admin/ai', {
|
||||
method: 'POST',
|
||||
headers: Object.assign({ 'Content-Type': 'application/json' }, authHeaders()),
|
||||
body: JSON.stringify(body)
|
||||
}).then(function (r) { return safeJson(r).then(function (d) { return { ok: r.ok, status: r.status, d: d }; }); })
|
||||
.then(function (x) {
|
||||
sb.disabled = false;
|
||||
if (guard401(x.status)) return;
|
||||
if (!x.ok) { m.textContent = (x.d && x.d.error) || '儲存失敗'; m.style.color = '#b03a26'; return; }
|
||||
if ($('st-ai-key')) { $('st-ai-key').value = ''; $('st-ai-key').placeholder = '已設定(留空=不變更)'; }
|
||||
var claudeOn = x.d && x.d.use_claude_for_extract;
|
||||
m.textContent = claudeOn
|
||||
? '已儲存,萃取改用 Claude Code。小幫手請重連一次生效。'
|
||||
: '已儲存,AI 問答與萃取皆可使用。';
|
||||
m.style.color = '#3f7a4f';
|
||||
})
|
||||
.catch(function (e) { sb.disabled = false; m.textContent = friendlyErr(e); m.style.color = '#b03a26'; });
|
||||
});
|
||||
})();
|
||||
// t176(leo 08-03):AI 設定的前端邏輯整段移除。
|
||||
// 雲端聊天走 Workers AI(免金鑰);地端萃取金鑰改由同步小幫手托盤「AI 設定…」自己設。
|
||||
// 原本這裡有 Claude 勾選框的 enable/disable 邏輯——它依賴 daemon 回報 has_claude,
|
||||
// 而 daemon 從未實作該回報 ⇒ 勾選框恆為 disabled(leo 實測「hover 變可點但點擊沒反應」)。
|
||||
|
||||
$('st-logout').addEventListener('click', function () {
|
||||
fetch(API_BASE + '/portal/logout', { method: 'POST', headers: authHeaders() }).catch(function () { /* 盡力而為 */ });
|
||||
|
||||
Reference in New Issue
Block a user