From e7fe83a872a72c563c0c2e329615e08c029c86b6 Mon Sep 17 00:00:00 2001 From: uncle6me-web Date: Sun, 26 Jul 2026 00:16:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(t54):=20=E5=B0=8F=E5=B9=AB=E6=89=8B?= =?UTF-8?q?=E6=86=91=E5=B8=B3=E5=AF=86=E8=87=AA=E5=8F=96=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E2=80=94=E2=80=94=E6=96=B0=E7=AB=AF=E9=BB=9E=20POST=20/portal/?= =?UTF-8?q?daemon/config=EF=BC=88=E5=B8=B3=E5=AF=86=E9=A9=97=E8=AD=89?= =?UTF-8?q?=E5=90=8C=20login=EF=BC=8C=E5=9B=9E=E9=80=A3=E7=B7=9A=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E4=B8=8D=E5=90=AB=E7=9F=A5=E8=AD=98=E5=85=A7=E5=AE=B9?= =?UTF-8?q?=EF=BC=89=EF=BC=9Bportal=20=E6=B8=85=E5=96=AE=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=20config.json=20=E4=B8=8B=E8=BC=89=EF=BC=883=20=E6=AD=A5?= =?UTF-8?q?=E2=86=922=20=E6=AD=A5=EF=BC=89=E3=80=82leo=2007-25=EF=BC=9A?= =?UTF-8?q?=E3=80=8C=E6=9C=80=E5=A5=BD=E7=9A=84=E5=B0=B1=E6=98=AF=E6=8A=8A?= =?UTF-8?q?=E5=AE=83=E7=9A=84=E5=B8=B3=E5=AF=86=E7=9B=B4=E6=8E=A5=E8=BC=B8?= =?UTF-8?q?=E5=85=A5=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- console-ui/public/portal/index.html | 31 +++++---------------- cypher-executor/src/routes/portal.ts | 40 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 24 deletions(-) diff --git a/console-ui/public/portal/index.html b/console-ui/public/portal/index.html index 2ed0b05..b484d37 100644 --- a/console-ui/public/portal/index.html +++ b/console-ui/public/portal/index.html @@ -676,7 +676,7 @@ function taipeiMonthDay(ms) { var d = new Date(ms + TAIPEI_OFFSET_MS); return { var p = S.profile || {}; if (p.role !== 'admin') return; var s = setupSteps(); - if (s.daemon && s.config && s.key) return; // 三件齊=安裝真的完成,不再打擾 + if (s.daemon && s.key) return; // t54 起只剩兩件:設定改由小幫手輸入帳密自取,不再下載檔案 var cfg = window.ARCRUN_CONFIG || {}; var daemonUrl = cfg.daemonDownload || 'https://raw.githubusercontent.com/youlinhsieh/arcrun-rag-bundles/main/daemon/ArcrunRAG-mac-unsigned.zip'; var row = function (done, id, html) { @@ -686,7 +686,7 @@ function taipeiMonthDay(ms) { var d = new Date(ms + TAIPEI_OFFSET_MS); return { var el = document.createElement('div'); el.id = 'setup-checklist'; el.style.cssText = 'position:fixed;right:20px;bottom:20px;z-index:60;max-width:400px;width:calc(100% - 40px);padding:18px 20px;border-radius:14px;background:rgba(var(--amber-rgb),.10);border:1px solid rgba(var(--amber-rgb),.45);backdrop-filter:blur(8px);font-size:14px;line-height:1.65'; - el.innerHTML = '還差 ' + (3 - (s.daemon?1:0) - (s.config?1:0) - (s.key?1:0)) + ' 步,安裝就真的完成了' + el.innerHTML = '還差 ' + (2 - (s.daemon?1:0) - (s.key?1:0)) + ' 步,安裝就真的完成了' + row(s.daemon, 'daemon', '下載同步小幫手(把資料夾變成知識庫)
' + (daemonUrl @@ -695,10 +695,10 @@ function taipeiMonthDay(ms) { var d = new Date(ms + TAIPEI_OFFSET_MS); return { // 誠實降級(leo 判準:按了連到錯的機制=不友善):沒有可用下載點時 // 不放死連結,說明現況並讓這步可手動打勾,不卡住清單。 : '封測期由我們直接寄給你安裝檔(Mac 版);' - + '收到後回來按 我已經裝好了')) - + row(s.config, 'config', - '下載設定檔 放到 ~/.arcrun-rag/config.json
' - + '下載 config.json') + + '收到後回來按 我已經裝好了。') + // t54(leo:「最好的就是把它的帳密直接輸入」):設定不再是一個要下載的檔案—— + // 小幫手第一次開啟會問網址+帳密,自己去換設定。 + + '
裝好第一次開啟時,貼上這個網址+你的帳號密碼就連上了,不用下載設定檔。
') + row(s.key, 'key', '啟用 AI 問答aistudio.google.com 免費申請)
' + ' ' @@ -708,24 +708,7 @@ function taipeiMonthDay(ms) { var d = new Date(ms + TAIPEI_OFFSET_MS); return { document.body.appendChild(el); var dl = document.getElementById('sc-daemon'); if (dl) dl.addEventListener('click', function () { markStep('daemon'); }); - var cb = document.getElementById('sc-config'); - if (cb) cb.addEventListener('click', function (ev) { - ev.preventDefault(); - var conf = { - watch_folders: [], - manifest: '~/.arcrun-rag/manifest.json', - cypher_url: cfg.apiBase || '', - namespace: cfg.tenant || '', - library: 'kb', - extractor: 'claude', - email: (S.profile && S.profile.email) || '' - }; - var a = document.createElement('a'); - a.href = 'data:application/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(conf, null, 2)); - a.download = 'config.json'; - document.body.appendChild(a); a.click(); a.remove(); - markStep('config'); - }); + // t54:config.json 下載鈕已移除(設定由小幫手憑帳密自取) var kb = document.getElementById('sc-key-save'); if (kb) kb.addEventListener('click', function () { var k = (document.getElementById('sc-key').value || '').trim(); diff --git a/cypher-executor/src/routes/portal.ts b/cypher-executor/src/routes/portal.ts index 15e63fa..8c1d872 100644 --- a/cypher-executor/src/routes/portal.ts +++ b/cypher-executor/src/routes/portal.ts @@ -699,6 +699,46 @@ function toPublicLibrary(rec: PortalRecord) { }; } +// POST /portal/daemon/config — body {email, password}。同步小幫手憑「用戶剛設的帳密」 +// 直接換到自己的設定(t54,leo 07-25:「最好的就是把它的帳密直接輸入」)—— +// 用戶不必再下載 config.json 丟隱藏資料夾,托盤第一次開啟輸入網址+帳密就上工。 +// 認證=與 /portal/login 同一把(同樣吃節流與停用檢查);回傳只含連線設定,不含任何知識內容。 +portalRouter.post('/portal/daemon/config', (c) => + run(c, async () => { + const body = (await c.req.json().catch(() => null)) as { email?: string; password?: string } | null; + const email = String(body?.email ?? '').trim().toLowerCase(); + const password = String(body?.password ?? ''); + if (!email || !password) return c.json({ error: 'email 與 password 必填' }, 400); + if (await isLocked(c.env, email)) { + return c.json({ error: '登入失敗次數過多,已暫時鎖定,請 15 分鐘後再試' }, 429); + } + const recordId = await findUserRecordId(c.env, email); + const rec = recordId ? await getRecordById(c.env, recordId) : null; + if (!rec) { + await recordLoginFail(c.env, email); + return c.json({ error: 'email 或密碼錯誤' }, 401); + } + if ((rec.values.status ?? '') !== 'active') return c.json({ error: '帳號已停用' }, 403); + if (!(await verifyPassword(password, rec.values.password_hash ?? ''))) { + await recordLoginFail(c.env, email); + return c.json({ error: 'email 或密碼錯誤' }, 401); + } + await clearLoginFail(c.env, email); + const tenant = portalTenant(c.env); + return c.json({ + success: true, + config: { + cypher_url: new URL(c.req.url).origin, + namespace: tenant, + library: 'kb', + extractor: 'claude', + email, + instance_name: String(rec.values.display_name ?? ''), + }, + }); + }), +); + // POST /portal/admin/chat-key — body {key}。站內啟用 AI 問答(t53,leo 07-25: // 「他進到網站要去給 gemini API Key」——不再回安裝器)。手法=G10 直嵌同款: // 改寫 tenant 的 rag_chat workflow 記錄,把 x-goog-api-key 換成實值(KV 覆寫=重推)。