ソースを参照

feat: accept pasted AI table share link as Base ID

粘贴 alidocs 分享链接(/i/nodes/<ID>)自动提取节点 ID,免去找 ID 的麻烦。
KenZ1117 2 週間 前
親
コミット
c7b3430ab5
2 ファイル変更、8 行追加、2 行削除
  1. 2 1
      public/index.html
  2. 6 1
      server/routes/settings.js

+ 2 - 1
public/index.html

@@ -574,8 +574,9 @@
               </div>
               <div class="field">
                 <label>Base ID / 数据表名称</label>
-                <input type="text" id="settingsAitableBaseId" placeholder="AI 表格的 Base ID" autocomplete="off">
+                <input type="text" id="settingsAitableBaseId" placeholder="粘贴 AI 表格分享链接或直接填 Base ID" autocomplete="off">
                 <input type="text" id="settingsAitableSheetName" placeholder="经营数据" autocomplete="off" style="margin-top:6px;">
+                <div class="help">Base ID 可直接粘贴分享链接(形如 alidocs.dingtalk.com/i/nodes/xxx),保存时自动提取 ID;网页版打开表格时地址栏里也能看到。</div>
               </div>
               <div class="settings-links">
                 <button type="button" class="settings-link settings-link-btn" id="btnTestAitable"><span>测试连通</span></button>

+ 6 - 1
server/routes/settings.js

@@ -91,7 +91,12 @@ function register(app, ctx) {
       if (!config.aitable || typeof config.aitable !== 'object') config.aitable = { enabled: false, appKey: '', appSecret: '', baseId: '', sheetName: '经营数据' };
       if (body.aitableEnabled !== undefined) config.aitable.enabled = !!body.aitableEnabled;
       if (body.aitableAppKey !== undefined) config.aitable.appKey = String(body.aitableAppKey).trim();
-      if (body.aitableBaseId !== undefined) config.aitable.baseId = String(body.aitableBaseId).trim();
+      if (body.aitableBaseId !== undefined) {
+        // 支持直接粘贴 AI 表格分享链接:自动提取 /i/nodes/<ID> 里的节点 ID 作为 Base ID
+        const raw = String(body.aitableBaseId).trim();
+        const m = /i\/nodes\/([A-Za-z0-9]+)/.exec(raw) || /[?&]baseId=([A-Za-z0-9]+)/.exec(raw);
+        config.aitable.baseId = m ? m[1] : raw;
+      }
       if (body.aitableSheetName !== undefined) config.aitable.sheetName = String(body.aitableSheetName).trim() || '经营数据';
       if (body.aitableAppSecret !== undefined) {
         const sec = String(body.aitableAppSecret).trim();