dsh-data-window 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/BRIDGE.md CHANGED
@@ -75,6 +75,12 @@ window.dispatchEvent(new CustomEvent('dsh-data-window:response', {
75
75
  3. 多个候选时按**环境顺序取第一个**,回执里带全部 `candidates`,调用方可提示用户;
76
76
  4. 没有候选 → `table-not-found`。
77
77
 
78
+ `openSql` 不查表,按这条顺序选库:
79
+
80
+ 1. 请求带了 `schema` → 精确匹配该库;
81
+ 2. 否则**只在本工作区发现出来的库**里取第一个(资源树是全机共享的,同一个实例下还挂着别的项目的库;`shared.js` 会给本项目发现的库打 `inWorkspace: true`);
82
+ 3. 本工作区一个库都没发现(比如只有共享/手动连接)→ 退回全量列表的第一个。
83
+
78
84
  ## 只读边界
79
85
 
80
86
  桥只负责打开控制台、粘贴文本、执行生成的只读 `SELECT`。所有真正发往 MySQL 的语句仍然经过 Host 的只读网关(白名单 / 单语句 / 写关键字 / `SET SESSION TRANSACTION READ ONLY`)。`openSql` 从不自动执行外部传入的 SQL。
package/docs/DETAIL.md CHANGED
@@ -67,7 +67,7 @@ bootstrap.yml spring.application.name = demo-order-service
67
67
  |---|---|
68
68
  | 连接 | 清掉子节点与补全缓存,重新跑一次发现(重读工作区配置),新库/改过的地址会进来 |
69
69
  | 库 | 重新拉一次 `tables` 并展开该库;同时清掉该库的补全缓存,编辑器建议随之更新 |
70
- | 表 / 视图 | 重新拉一次 `columns`;如果这张表的建表语句标签页开着,一并刷新 |
70
+ | 表 / 视图 | 重新拉一次 `columns` |
71
71
 
72
72
  刷新只读:只读元数据(`information_schema` / `SHOW`),不执行任何 DDL/DML。
73
73
 
@@ -107,9 +107,9 @@ bootstrap.yml spring.application.name = demo-order-service
107
107
 
108
108
  | 需求 | 实现 |
109
109
  |---|---|
110
- | 点工作区自动加载配置、缓存地址与账号 | 打开面板即解析工作区 → 环境 → 实例 → 库,结果按工作区缓存;`重新读取配置` 强制刷新 |
110
+ | 点工作区自动加载配置、缓存地址与账号 | 打开面板即解析工作区 → 环境 → 实例 → 库,结果按工作区缓存;资源管理器标题栏的刷新按钮强制重新读取 |
111
111
  | 看到实例、库、表、字段 | 左侧树逐层展开;实例上的网格按钮打开「选择数据库」勾选面板,表可展开字段(类型、主键、NOT NULL、注释) |
112
- | 快捷键查看建表语句 | 选中表后按 **F4** 或 **⌘/Ctrl + Shift + D**;也可右键「查看建表语句」 |
112
+ | 快捷键查看建表语句 | 选中表后按 **F4** 或 **⌘/Ctrl + Shift + D**;也可右键「查看建表语句」;在弹窗里查看并复制,不打开工作标签。右键**库**(或选中库按 F4)则是「查看全部建表语句」:逐表读取,带 `x/y` 进度,失败的表在末尾用注释标出 |
113
113
  | 每个库一个 SQL 工作台 | 点库名打开该库的工作台,标签页常驻 |
114
114
  | 每张表一个窗口 | 双击表打开/聚焦该表自己的标签,并在末尾追加一条 `SELECT *` 基础查询;重复双击不会新开标签、不覆盖已有内容,且只执行刚追加的那一条 |
115
115
  | 代码工作区联动 | 代码工作区右键实体类(`@TableName`)直接打开该表并执行基础查询;右键 Mapper 方法把 XML/注解里的 SQL 粘贴到数据窗口(不自动执行)。契约见 `docs/BRIDGE.md` |
@@ -117,9 +117,11 @@ bootstrap.yml spring.application.name = demo-order-service
117
117
  | SQL 高亮 | 关键字、函数、字符串、数字、注释分色显示,颜色跟着深/浅色主题可读 |
118
118
  | 字段提示 | 输入时列出表、字段、关键字;`别名.` 只列该表字段;数据来自 Host 一次性读取的库结构,每库缓存 |
119
119
  | 一键格式化 | 编辑栏「格式化」:子句换行、select 列表一行一项、join 与 and 缩进,关键字大小写保持原样 |
120
- | 运行日志 | 每条执行语句(含总行数刷新用的 `COUNT`)都以 `SQL` 行记入日志,失败语句也会记录 |
120
+ | 运行日志 | 每条执行语句(含总行数刷新用的 `COUNT`)都以 `SQL` 行记入日志,失败语句也会记录;展开后拖动日志顶部的分隔条调整高度(双击还原),高度按浏览器记住 |
121
121
  | 总行数 | 结果栏「共 — 行」旁的刷新按钮按当前语句执行一次 `COUNT(*)`,统计前会去掉最外层的 `LIMIT`(子查询里的保留);只读、按需触发 |
122
122
  | 控制台持久化 | 每个工作区的 SQL 存成 Host 文件(`workspaces/<hash>-<名字>.consoles.json`,0600),切换工作区、刷新或重启后自动恢复;关掉标签即删除;只恢复语句,不恢复结果 |
123
+ | 收藏 SQL | 编辑器或标签页右键「收藏 SQL」:起一个唯一名称,连同库名、表名一起保存;资源管理器顶部的「数据库 / 收藏夹」两个标签页分开显示,收藏页按 库 → 表 → 语句 分组 |
124
+ | `@` 索引收藏 | 工作台输入 `@` 弹出收藏列表(按名称/库名/表名过滤,↑↓ 选择,Enter 或点击插入),选中的 SQL 直接替换光标处的 `@…` |
123
125
  | 设置页 | DSH 设置里独立一页「数据窗口」:进入时收起侧栏、默认行数上限、快捷键与控制台保存位置 |
124
126
  | 全局快捷键 | 默认 `⌘3`(Windows/Linux `Ctrl+3`)在任意界面打开数据窗口;设置页「快捷键」可修改/恢复默认 |
125
127
  | 界面配色 | 跟随 `dsh-ide-window` 选择的主题(同一套 `dsh-theme` 契约);没有选择时跟随 DSH 默认配色 |
@@ -127,6 +129,25 @@ bootstrap.yml spring.application.name = demo-order-service
127
129
  | 调整列表宽度 | 拖动资源管理器与工作台之间的分隔条;双击分隔条恢复默认宽度 |
128
130
  | 进入即全宽 | 进入数据窗口时自动收起 DSH 侧栏;工具栏按钮可随时展开或收起 |
129
131
 
132
+ ## 收藏 SQL 与 `@` 索引
133
+
134
+ 编辑器右键菜单(以及 SQL 标签页右键菜单)里的「收藏 SQL」打开命名弹窗:
135
+
136
+ | 字段 | 说明 |
137
+ |---|---|
138
+ | 名称 | 必填,在收藏夹里唯一(大小写不敏感);也是 `@` 索引时输入的关键字 |
139
+ | 库名 | 从当前工作台带入,可修改;收藏夹按它分组 |
140
+ | 表名 | 可选,留空归入「未指定表」;表控制台或语句里第一个表会自动带入 |
141
+ | SQL | 只读预览:右键时选中的那一段,没选中就是整段语句 |
142
+
143
+ - 保存到 `~/.dsh/storages/dsh-data-window/favorites/favorites.json`(0600,临时文件 + rename 原子写),**全机共享**,和资源树一样不随工作区切换;
144
+ - 资源管理器顶部是 **数据库 / ★ 收藏夹** 两个标签页(同 DataGrip 的 Database 窗口):数据库页是配置解析出来的环境树,收藏页按 **库 → 表 → 语句名称** 分组;收藏页标签带条数角标,右侧有刷新按钮;
145
+ - 保存成功后自动切到收藏页、展开对应的库/表并选中新条目;单击展开目录,双击语句在对应库的工作台打开(树里没有这个库时,运行日志会说明是哪个库);
146
+ - 收藏节点的右键菜单:打开、复制 SQL、编辑收藏(改名/改库名表名)、删除收藏;
147
+ - 工作台输入 `@` 弹出收藏索引:继续输入按名称/库名/表名过滤,↑↓ 移动、Enter 或 Tab 插入、Esc 关闭;插入时把光标处的 `@关键字` 换成整段 SQL,光标停在 SQL 末尾;
148
+ - 输入框与 `@` 索引兼容中文输入法:候选词确认/取消的 Enter、Esc 只交给输入法,不会触发保存、关闭弹窗、插入候选或结束单元格编辑;收藏名称框在 `compositionend` 后 100ms 内的回车也按输入法处理(覆盖把确认回车当普通按键投递的浏览器);
149
+ - 只保存和插入语句,**不会执行**;Host 校验名称、库名与大小上限(单条 128KB,最多 500 条),重名返回 `duplicate-favorite`。
150
+
130
151
  ## 编辑器右键菜单与 AI 优化
131
152
 
132
153
  SQL 编辑器接管了浏览器右键菜单,保留常用编辑动作并多了一项「AI 优化 SQL」:
@@ -134,15 +155,39 @@ SQL 编辑器接管了浏览器右键菜单,保留常用编辑动作并多了
134
155
  | 菜单项 | 行为 |
135
156
  |---|---|
136
157
  | 撤销 / 重做 | 走 textarea 原生历史 |
137
- | 剪切 / 复制 / 粘贴 / 全选 | 异步剪贴板;浏览器拒绝读剪贴板时提示改用 ⌘V |
158
+ | 剪贴/复制/全选 | 异步剪贴板;浏览器拒绝读剪贴板时提示改用 ⌘V |
159
+ | **收藏 SQL** | 把**选中的部分**(没选中则整段)收藏为一条命名 SQL,连同当前库名、表名保存 |
138
160
  | **AI 优化 SQL** | 把**选中的部分**(没选中则整段)交给设置里配置的模型,弹出优化建议 |
139
161
 
140
162
  - 模型来源:设置 → 数据库窗口 → AI 里选的那个(`aiModel`),不是另配一套;
141
163
  - 优化说明的语言跟随系统(`navigator.language`,如 `zh-CN` → 简体中文);
142
164
  - 没配置模型时弹窗直接说明去哪里配置;
143
165
  - Host 侧 `optimizeSql` 只调用模型,**不连数据库、不执行 SQL**;SQL 上限 20,000 字符;
166
+ - 结果以**左右对照 diff** 展示:左边原始 SQL、右边优化后 SQL,改动按 token 标色(左红右绿),
167
+ token 级比较是为了兼容"原 SQL 多行、模型返回一行"的常见情况;两侧滚动同步;
144
168
  - 结果只展示和复制,**不会自动改写编辑器里的语句**——仍然遵守"不覆盖用户 SQL"。
145
169
 
170
+ ## 资源树的点击
171
+
172
+ 行点击只**选中**,不展开;展开/收起只由行首的三角控制(收藏页的库/表目录是例外:单击即展开或收起,因为它们只用于浏览)。双击是"打开":库打开控制台并展开,表/视图打开数据,环境/实例展开;实例行右侧的网格按钮仍然打开选库面板;双击收藏的 SQL 则在它保存时那个库的工作台打开。
173
+
174
+ ## 标签页右键菜单
175
+
176
+ SQL 标签页(库控制台 / 表控制台)右键出菜单:
177
+
178
+ | 菜单项 | 行为 |
179
+ |---|---|
180
+ | 关闭 | 关闭当前标签,激活右侧邻居(没有就左侧) |
181
+ | 关闭其他标签页 / 关闭所有标签页 | 批量关闭,同样把激活位置落到邻居 |
182
+ | 关闭左侧标签页 / 关闭右侧标签页 | 只关一侧;没有可关的就置灰 |
183
+ | 收藏 SQL | 把整个标签页的语句收藏为一条命名 SQL(选中片段请用编辑器里的右键菜单) |
184
+ | 复制引用 | 复制 `库.表`(表控制台)或 `库`(库控制台) |
185
+ | 复制引用到对话 | 先复制,再尝试把引用插入 DSH 对话输入框(`[data-composer-seat]` 的 contenteditable);输入框没打开时只复制并提示 |
186
+
187
+ 菜单本身沿用 `dsh-ide-window` 的样式:图标 + 文字、27px 行高、分隔线、禁用的左侧/右侧项置灰,并夹在面板矩形内展开。
188
+
189
+ `⌘W` / 中键仍可关闭单个标签;批量关闭会立即保存控制台快照。
190
+
146
191
  ## 结果翻页
147
192
 
148
193
  语句末尾带 `LIMIT` 时,结果栏会出现 `‹ 上一页 · 第 N 页 · 每页 X 行 · 下一页 ›`:
package/locale/en.json CHANGED
@@ -7,7 +7,10 @@
7
7
  "openPanel": "Data window",
8
8
  "openPanelHint": "Open the data window",
9
9
  "treeTitle": "Explorer",
10
+ "treeTabsLabel": "Resource manager tabs",
11
+ "treeTabDatabases": "Databases",
10
12
  "filterPlaceholder": "Filter the loaded databases and tables",
13
+ "filterFavoritesPlaceholder": "Filter saved SQL by name, schema or table",
11
14
  "treeLoading": "Loading…",
12
15
  "treeNoMatch": "Nothing matches this filter",
13
16
  "treeEmpty": "No database configuration found for this workspace",
@@ -96,6 +99,7 @@
96
99
  "warning.unparsed-jdbc-url": "A datasource URL could not be parsed as jdbc:mysql.",
97
100
  "projectSwitch": "Switch workspace",
98
101
  "resizeTree": "Drag to resize the list (double-click resets)",
102
+ "resizeLog": "Drag to resize the run log (double-click resets)",
99
103
  "hideSidebar": "Hide the DSH sidebar",
100
104
  "showSidebar": "Show the DSH sidebar",
101
105
  "formatSql": "Format",
@@ -282,5 +286,64 @@
282
286
  "aiModelUnknown": "not configured",
283
287
  "optimizeNotes": "Notes",
284
288
  "optimizeCopy": "Copy SQL",
285
- "log.optimizeCopied": "Optimized SQL copied"
289
+ "log.optimizeCopied": "Optimized SQL copied",
290
+ "tabClose": "Close",
291
+ "tabCloseOthers": "Close other tabs",
292
+ "tabCloseAll": "Close all tabs",
293
+ "tabCloseLeft": "Close tabs to the left",
294
+ "tabCloseRight": "Close tabs to the right",
295
+ "copyReference": "Copy reference",
296
+ "copyReferenceToChat": "Copy reference to chat",
297
+ "log.copiedReference": "Reference copied: {reference}",
298
+ "log.copiedReferenceToChat": "Reference inserted into the chat: {reference}",
299
+ "log.copiedReferenceOnly": "Chat input is closed; reference copied: {reference}",
300
+ "tabMenuLabel": "Tab menu",
301
+ "optimizeOriginal": "Original SQL",
302
+ "optimizeOptimized": "Optimized SQL",
303
+ "menuDdlAll": "Show all create statements",
304
+ "ddlAllEmpty": "This database has no tables",
305
+ "ddlAllPartial": "{count} table(s) could not be read; noted at the end of the script",
306
+ "log.ddlAll": "Read all create statements of {database}: {count} tables · {ms}",
307
+ "log.copiedDdlAll": "Copied all create statements of {database} ({count} tables)",
308
+ "favoritesTitle": "Favorites",
309
+ "favoritesCount": "saved",
310
+ "favoritesEmptyHint": "No saved SQL yet. Right-click in the editor and choose “Save SQL”.",
311
+ "favoritesReload": "Reload favorites",
312
+ "favoriteNoTable": "No table",
313
+ "favoriteNoDatabase": "Unknown schema",
314
+ "favoriteSave": "Save SQL",
315
+ "favoriteSaveTitle": "Save SQL",
316
+ "favoriteEditTitle": "Edit saved SQL",
317
+ "favoriteDialogHint": "The schema and table are stored with the statement and group the favorites node; typing @ indexes it by name.",
318
+ "favoriteName": "Name",
319
+ "favoriteNameHint": "Unique among saved SQL, and the keyword used by the @ index",
320
+ "favoriteDatabase": "Schema",
321
+ "favoriteDatabaseHint": "Prefilled from the workbench; editable",
322
+ "favoriteTable": "Table",
323
+ "favoriteTableHint": "Optional; empty goes under “No table”",
324
+ "favoriteSql": "SQL",
325
+ "favoriteSaveAction": "Save",
326
+ "favoriteUpdateAction": "Save changes",
327
+ "favoriteNameRequired": "Give this statement a name first",
328
+ "favoriteDatabaseRequired": "A schema name is required",
329
+ "favoriteMentionLabel": "Saved SQL",
330
+ "favoriteMentionEmpty": "No saved SQL matches",
331
+ "favoriteMentionNoFavorites": "No saved SQL yet: right-click in the editor and choose “Save SQL”",
332
+ "suggestFavorite": "saved",
333
+ "menuOpenFavorite": "Open saved SQL",
334
+ "menuCopyFavoriteSql": "Copy SQL",
335
+ "menuEditFavorite": "Edit saved SQL",
336
+ "menuRemoveFavorite": "Delete saved SQL",
337
+ "removeFavoriteTitle": "Delete saved SQL",
338
+ "removeFavoriteHint": "Delete “{name}”? This cannot be undone.",
339
+ "removeFavoriteConfirm": "Delete",
340
+ "log.favoriteSaved": "Saved SQL: {name} ({database})",
341
+ "log.favoriteRemoved": "Deleted saved SQL: {name}",
342
+ "log.favoriteOpened": "Opened saved SQL: {name}",
343
+ "log.favoriteNoDatabase": "The tree has no schema {database}, so this saved statement cannot be opened",
344
+ "log.favoriteLoadFailed": "Reading saved SQL failed: {message}",
345
+ "log.favoriteInserted": "Inserted saved SQL: {name}",
346
+ "log.favoriteCopied": "Copied saved SQL: {name}",
347
+ "log.favoriteRemoveFailed": "Deleting saved SQL failed: {message}",
348
+ "error.duplicateFavorite": "That name is already taken by another saved statement"
286
349
  }
package/locale/zh.json CHANGED
@@ -7,7 +7,10 @@
7
7
  "openPanel": "数据窗口",
8
8
  "openPanelHint": "打开数据窗口",
9
9
  "treeTitle": "资源管理器",
10
+ "treeTabsLabel": "资源管理标签",
11
+ "treeTabDatabases": "数据库",
10
12
  "filterPlaceholder": "过滤已加载的库名与表名",
13
+ "filterFavoritesPlaceholder": "过滤收藏的名称、库名与表名",
11
14
  "treeLoading": "加载中…",
12
15
  "treeNoMatch": "没有匹配的节点",
13
16
  "treeEmpty": "没有在当前工作区发现数据库配置",
@@ -96,6 +99,7 @@
96
99
  "warning.unparsed-jdbc-url": "有数据源地址无法解析为 jdbc:mysql。",
97
100
  "projectSwitch": "切换工作区",
98
101
  "resizeTree": "拖动调整列表宽度(双击还原)",
102
+ "resizeLog": "拖动调整运行日志高度(双击还原)",
99
103
  "hideSidebar": "隐藏 DSH 侧栏",
100
104
  "showSidebar": "显示 DSH 侧栏",
101
105
  "formatSql": "格式化",
@@ -282,5 +286,64 @@
282
286
  "aiModelUnknown": "未配置",
283
287
  "optimizeNotes": "优化说明",
284
288
  "optimizeCopy": "复制 SQL",
285
- "log.optimizeCopied": "优化后的 SQL 已复制"
289
+ "log.optimizeCopied": "优化后的 SQL 已复制",
290
+ "tabClose": "关闭",
291
+ "tabCloseOthers": "关闭其他标签页",
292
+ "tabCloseAll": "关闭所有标签页",
293
+ "tabCloseLeft": "关闭左侧标签页",
294
+ "tabCloseRight": "关闭右侧标签页",
295
+ "copyReference": "复制引用",
296
+ "copyReferenceToChat": "复制引用到对话",
297
+ "log.copiedReference": "已复制引用:{reference}",
298
+ "log.copiedReferenceToChat": "已把引用插入对话:{reference}",
299
+ "log.copiedReferenceOnly": "对话输入框未打开,已复制引用:{reference}",
300
+ "tabMenuLabel": "标签页菜单",
301
+ "optimizeOriginal": "原始 SQL",
302
+ "optimizeOptimized": "优化后 SQL",
303
+ "menuDdlAll": "查看全部建表语句",
304
+ "ddlAllEmpty": "这个库还没有表",
305
+ "ddlAllPartial": "{count} 张表读取失败,已在脚本末尾用注释标出",
306
+ "log.ddlAll": "读取 {database} 的全部建表语句:{count} 张表 · {ms}",
307
+ "log.copiedDdlAll": "已复制 {database} 的全部建表语句({count} 张表)",
308
+ "favoritesTitle": "收藏夹",
309
+ "favoritesCount": "条",
310
+ "favoritesEmptyHint": "还没有收藏 SQL。在编辑器里右键 →「收藏 SQL」即可收藏当前语句。",
311
+ "favoritesReload": "刷新收藏夹",
312
+ "favoriteNoTable": "未指定表",
313
+ "favoriteNoDatabase": "未知库",
314
+ "favoriteSave": "收藏 SQL",
315
+ "favoriteSaveTitle": "收藏 SQL",
316
+ "favoriteEditTitle": "编辑收藏",
317
+ "favoriteDialogHint": "保存时会连同库名与表名一起记录,收藏夹按这两层分组;输入 @ 时用名称索引这条 SQL。",
318
+ "favoriteName": "名称",
319
+ "favoriteNameHint": "名称在收藏夹里唯一,也是 @ 索引时输入的关键字",
320
+ "favoriteDatabase": "库名",
321
+ "favoriteDatabaseHint": "从工作台带入,可修改",
322
+ "favoriteTable": "表名",
323
+ "favoriteTableHint": "可选;留空归入「未指定表」",
324
+ "favoriteSql": "SQL",
325
+ "favoriteSaveAction": "收藏",
326
+ "favoriteUpdateAction": "保存修改",
327
+ "favoriteNameRequired": "请先给这条 SQL 起一个名称",
328
+ "favoriteDatabaseRequired": "请填写库名",
329
+ "favoriteMentionLabel": "收藏的 SQL",
330
+ "favoriteMentionEmpty": "没有匹配的收藏 SQL",
331
+ "favoriteMentionNoFavorites": "还没有收藏 SQL:在编辑器里右键 →「收藏 SQL」",
332
+ "suggestFavorite": "收藏",
333
+ "menuOpenFavorite": "打开收藏的 SQL",
334
+ "menuCopyFavoriteSql": "复制 SQL",
335
+ "menuEditFavorite": "编辑收藏",
336
+ "menuRemoveFavorite": "删除收藏",
337
+ "removeFavoriteTitle": "删除收藏",
338
+ "removeFavoriteHint": "确定删除收藏「{name}」?删除后不可恢复。",
339
+ "removeFavoriteConfirm": "删除",
340
+ "log.favoriteSaved": "已收藏 SQL:{name}({database})",
341
+ "log.favoriteRemoved": "已删除收藏:{name}",
342
+ "log.favoriteOpened": "已打开收藏的 SQL:{name}",
343
+ "log.favoriteNoDatabase": "资源树里没有库 {database},无法打开这条收藏",
344
+ "log.favoriteLoadFailed": "读取收藏夹失败:{message}",
345
+ "log.favoriteInserted": "已插入收藏的 SQL:{name}",
346
+ "log.favoriteCopied": "已复制收藏的 SQL:{name}",
347
+ "log.favoriteRemoveFailed": "删除收藏失败:{message}",
348
+ "error.duplicateFavorite": "这个名称已经被收藏了,请换一个名称"
286
349
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-data-window",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "DataGrip-style database window for DeepSeek Harness: reads the workspace's own config to find the environment hosts, then browses instances, databases, tables and columns and runs read-only SQL in one workbench per database.",
5
5
  "type": "module",
6
6
  "icon": "icon.svg",
@@ -141,6 +141,13 @@ const DW_CSS = `
141
141
  color: var(--dsw-alias-label-primary-inverted, #fff);
142
142
  font-weight: 600;
143
143
  }
144
+ /*
145
+ * The panel and the sidebar-foot action each inject this stylesheet, so the second
146
+ * copy's plain .dw-btn color rule would otherwise override the first copy's accent
147
+ * label and paint white text on the brand fill. The extra class keeps the inverted
148
+ * label winning wherever the rules land.
149
+ */
150
+ .dw-btn.dw-btn-accent { color: var(--dsw-alias-label-primary-inverted, #fff); }
144
151
  .dw-btn-accent:hover { filter: brightness(1.08); background: var(--dsw-alias-brand-primary, #4b8bf5); }
145
152
  .dw-btn-icon { width: 26px; padding: 0; justify-content: center; }
146
153
  /*
@@ -225,6 +232,59 @@ const DW_CSS = `
225
232
  letter-spacing: .04em;
226
233
  text-transform: uppercase;
227
234
  }
235
+ /* The resource manager's tabs: the configured tree and the saved statements. */
236
+ .dw-tree-tabs {
237
+ display: flex;
238
+ align-items: center;
239
+ gap: 2px;
240
+ flex: 0 0 auto;
241
+ padding: 4px 6px 0;
242
+ border-bottom: 1px solid var(--dsw-alias-border-l1, #2c2f36);
243
+ }
244
+ .dw-tree-tab {
245
+ display: inline-flex;
246
+ align-items: center;
247
+ gap: 5px;
248
+ height: 24px;
249
+ padding: 0 8px;
250
+ border: 0;
251
+ border-bottom: 2px solid transparent;
252
+ border-radius: 6px 6px 0 0;
253
+ background: transparent;
254
+ color: var(--dsw-alias-label-secondary, #8b919d);
255
+ font: inherit;
256
+ font-size: 11.5px;
257
+ cursor: pointer;
258
+ white-space: nowrap;
259
+ }
260
+ .dw-tree-tab:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, .12)); color: var(--dsw-alias-label-primary, #e6e8ec); }
261
+ .dw-tree-tab.on {
262
+ color: var(--dsw-alias-label-primary, #e6e8ec);
263
+ border-bottom-color: var(--dsw-alias-brand-primary, #4b8bf5);
264
+ }
265
+ .dw-tree-tab-count {
266
+ min-width: 14px;
267
+ padding: 0 4px;
268
+ border-radius: 7px;
269
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, .12));
270
+ color: var(--dsw-alias-label-secondary, #8b919d);
271
+ font-size: 10px;
272
+ line-height: 14px;
273
+ text-align: center;
274
+ }
275
+ .dw-tree-tabs .dw-btn {
276
+ width: 22px;
277
+ height: 22px;
278
+ padding: 0;
279
+ justify-content: center;
280
+ border-color: transparent;
281
+ background: transparent;
282
+ color: var(--dsw-alias-label-secondary, #8b919d);
283
+ }
284
+ .dw-tree-tabs .dw-btn:hover:not(:disabled) {
285
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, .12));
286
+ color: var(--dsw-alias-label-primary, #e6e8ec);
287
+ }
228
288
  .dw-tree { flex: 1 1 auto; overflow: auto; padding: 4px 0 12px; }
229
289
  .dw-node {
230
290
  display: flex;
@@ -450,6 +510,32 @@ const DW_CSS = `
450
510
  .dw-complete-label { flex: 1 1 auto; font-family: var(--ds-font-family-code, ui-monospace, Menlo, monospace); font-size: 12px; }
451
511
  .dw-complete-detail { flex: 0 1 auto; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-secondary, #8b919d); font-size: 10.5px; }
452
512
  .dw-complete-kind { flex: 0 0 auto; color: var(--dsw-alias-label-secondary, #8b919d); font-size: 10px; opacity: .8; }
513
+ .dw-complete-empty {
514
+ padding: 6px 9px;
515
+ max-width: 300px;
516
+ color: var(--dsw-alias-label-secondary, #8b919d);
517
+ font-size: 11.5px;
518
+ line-height: 1.55;
519
+ }
520
+ /* The at-sign index: statements, so a little wider than the column list. */
521
+ .dw-mention { min-width: 280px; max-width: 420px; }
522
+ .dw-fav-sql {
523
+ margin: 0;
524
+ max-height: 170px;
525
+ overflow: auto;
526
+ padding: 8px 10px;
527
+ border: 1px solid var(--dsw-alias-border-l1, #31353d);
528
+ border-radius: 6px;
529
+ background: var(--dsw-alias-bg-layer-2, #262930);
530
+ color: var(--dsw-alias-label-primary, #e6e8ec);
531
+ font-family: var(--ds-font-family-code, ui-monospace, Menlo, monospace);
532
+ font-size: 11.5px;
533
+ line-height: 1.55;
534
+ white-space: pre;
535
+ }
536
+ .dw-fav-dialog { width: min(620px, 100%); }
537
+ .dw-fav-split { display: flex; gap: 10px; }
538
+ .dw-fav-split .dw-form-row { flex: 1 1 0; min-width: 0; }
453
539
 
454
540
  .dw-drag {
455
541
  height: 5px;
@@ -631,6 +717,63 @@ const DW_CSS = `
631
717
  background: var(--dsw-alias-bg-overlay, #23262d);
632
718
  box-shadow: 0 10px 26px rgba(0,0,0,.42);
633
719
  }
720
+ .dw-tabmenu-backdrop {
721
+ position: fixed;
722
+ inset: 0;
723
+ z-index: 70;
724
+ background: transparent;
725
+ }
726
+ /* The tab menu mirrors the code workspace's menu (icons + labels, IDEA-like). */
727
+ .dw-tabmenu {
728
+ position: fixed;
729
+ overflow-y: auto;
730
+ overscroll-behavior: contain;
731
+ min-width: 232px;
732
+ padding: 5px;
733
+ border: 0.5px solid var(--dsw-alias-border-l2, rgba(255, 255, 255, .1));
734
+ border-radius: var(--dsw-radius-md, 10px);
735
+ background: var(--dsw-specific-menu, var(--dsw-alias-bg-layer-2, #23262b));
736
+ backdrop-filter: var(--dsw-menu-backdrop-filter, none);
737
+ box-shadow: var(--dsw-elevation-prominent, 0 12px 32px rgba(0, 0, 0, .35));
738
+ color: var(--dsw-alias-label-primary, inherit);
739
+ }
740
+ .dw-tabmenu-item {
741
+ display: flex;
742
+ align-items: center;
743
+ gap: 9px;
744
+ width: 100%;
745
+ height: 27px;
746
+ padding: 0 9px;
747
+ border: 0;
748
+ border-radius: var(--dsw-radius-sm, 6px);
749
+ background: transparent;
750
+ color: inherit;
751
+ font: inherit;
752
+ font-size: 12.5px;
753
+ line-height: 27px;
754
+ text-align: left;
755
+ cursor: default;
756
+ }
757
+ .dw-tabmenu-item:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, rgba(255, 255, 255, .08)); }
758
+ .dw-tabmenu-item:disabled { opacity: .45; }
759
+ .dw-tabmenu-item:focus-visible {
760
+ outline: none;
761
+ box-shadow: inset 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary, #4a7dff));
762
+ }
763
+ .dw-tabmenu-icon {
764
+ display: inline-flex;
765
+ flex: none;
766
+ align-items: center;
767
+ justify-content: center;
768
+ width: 14px;
769
+ color: var(--dsw-alias-label-secondary, inherit);
770
+ }
771
+ .dw-tabmenu-label { flex: 1 1 auto; }
772
+ .dw-tabmenu-sep {
773
+ height: 0.5px;
774
+ margin: 5px 8px;
775
+ background: var(--dsw-alias-border-l1, rgba(255, 255, 255, .08));
776
+ }
634
777
  .dw-menu-note {
635
778
  padding: 4px 8px 5px;
636
779
  color: var(--dsw-alias-label-secondary, #8b919d);
@@ -908,7 +1051,67 @@ const DW_CSS = `
908
1051
  word-break: break-all;
909
1052
  }
910
1053
  .dw-cell-dialog { width: min(720px, 100%); }
911
- .dw-optimize-dialog { width: min(760px, 100%); }
1054
+ .dw-optimize-dialog { width: min(1100px, 100%); }
1055
+ .dw-ddl-dialog { width: min(900px, 100%); }
1056
+ /*
1057
+ * The DDL is the only scroll container in this dialog: one scrollbar pair, at the
1058
+ * code box, instead of the modal body plus the pre each growing their own.
1059
+ */
1060
+ .dw-ddl-dialog .dw-modal-body {
1061
+ display: flex;
1062
+ flex-direction: column;
1063
+ min-height: 0;
1064
+ overflow: hidden;
1065
+ }
1066
+ .dw-ddl-result {
1067
+ display: flex;
1068
+ flex: 1 1 auto;
1069
+ flex-direction: column;
1070
+ min-height: 0;
1071
+ }
1072
+ .dw-ddl-result .dw-log-warn { margin-bottom: 6px; }
1073
+ .dw-ddl-code {
1074
+ flex: 1 1 auto;
1075
+ min-height: 0;
1076
+ max-height: none;
1077
+ overflow: auto;
1078
+ /* Keep the server's line breaks: long COMMENTs scroll sideways, never wrap. */
1079
+ white-space: pre;
1080
+ word-break: normal;
1081
+ }
1082
+ .dw-diff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
1083
+ .dw-diff-col { display: flex; flex-direction: column; min-width: 0; }
1084
+ .dw-diff-head {
1085
+ padding-bottom: 5px;
1086
+ color: var(--dsw-alias-label-secondary, #8b919d);
1087
+ font-size: 11px;
1088
+ }
1089
+ .dw-diff-pane {
1090
+ margin: 0;
1091
+ padding: 10px 12px;
1092
+ max-height: 320px;
1093
+ overflow: auto;
1094
+ border: 1px solid var(--dsw-alias-border-l1, #31353d);
1095
+ border-radius: 8px;
1096
+ background: var(--dsw-alias-bg-layer-2, #262930);
1097
+ color: var(--dsw-alias-label-primary, #e6e8ec);
1098
+ font-family: var(--dsw-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1099
+ font-size: 12px;
1100
+ line-height: 1.55;
1101
+ white-space: pre-wrap;
1102
+ word-break: break-word;
1103
+ }
1104
+ .dw-diff-del {
1105
+ border-radius: 2px;
1106
+ background: color-mix(in srgb, var(--dsw-alias-state-error-primary, #e5534b) 26%, transparent);
1107
+ }
1108
+ .dw-diff-add {
1109
+ border-radius: 2px;
1110
+ background: color-mix(in srgb, var(--dsw-alias-state-success-primary, #3fb950) 26%, transparent);
1111
+ }
1112
+ @media (max-width: 720px) {
1113
+ .dw-diff { grid-template-columns: 1fr; }
1114
+ }
912
1115
  .dw-optimize-model { padding-bottom: 8px; color: var(--dsw-alias-label-secondary, #8b919d); font-size: 11px; }
913
1116
  .dw-optimize-notes {
914
1117
  max-height: 120px;
@@ -65,6 +65,27 @@ function DwIcon({ name, size = 14, className }) {
65
65
  return h('svg', { ...common, fill: 'currentColor', stroke: 'none' }, [h('path', { d: 'M4.6 2.9l8 5.1-8 5.1z' })])
66
66
  case 'stop':
67
67
  return h('svg', { ...common, fill: 'currentColor', stroke: 'none' }, [h('rect', { x: 4, y: 4, width: 8, height: 8, rx: 1.4 })])
68
+ case 'layers':
69
+ return h('svg', common, [
70
+ h('rect', { key: 'a', x: 2.4, y: 2.4, width: 7, height: 7, rx: 1.4 }),
71
+ h('rect', { key: 'b', x: 6.6, y: 6.6, width: 7, height: 7, rx: 1.4 }),
72
+ ])
73
+ case 'stack':
74
+ return h('svg', common, [
75
+ h('path', { key: 'a', d: 'M2 6 8 3.2 14 6 8 8.8Z' }),
76
+ h('path', { key: 'b', d: 'M2 10.4 8 13.2 14 10.4' }),
77
+ ])
78
+ case 'arrow-left':
79
+ return h('svg', common, [h('path', { key: 'a', d: 'M12.5 8H3.5M7 4.5 3.5 8 7 11.5' })])
80
+ case 'arrow-right':
81
+ return h('svg', common, [h('path', { key: 'a', d: 'M3.5 8h9M9 4.5 12.5 8 9 11.5' })])
82
+ case 'at':
83
+ return h('svg', common, [
84
+ h('circle', { key: 'a', cx: 8, cy: 8, r: 2.4 }),
85
+ h('path', { key: 'b', d: 'M10.4 8v1.4a2.1 2.1 0 0 0 4.2 0V8A6.4 6.4 0 1 0 8 14.4c1.2 0 2.2-.2 3-.7' }),
86
+ ])
87
+ case 'star':
88
+ return h('svg', common, [h('path', { d: 'M8 2.1l1.82 3.69 4.07.59-2.94 2.87.69 4.06L8 11.4l-3.64 1.91.69-4.06L2.11 6.38l4.07-.59z' })])
68
89
  case 'close':
69
90
  return h('svg', common, [h('path', { d: 'M4.2 4.2l7.6 7.6M11.8 4.2l-7.6 7.6' })])
70
91
  case 'download':
@@ -43,6 +43,9 @@ function dwBridgeDatabases(state) {
43
43
  env: environment.env,
44
44
  envLabel: environment.label ?? environment.env,
45
45
  instanceLabel: instance.label ?? '',
46
+ // 资源树是全机共享的,同一个实例下会挂着别的项目的库;只有本项目发现出来的
47
+ // 库才带这个标记,`openSql` 靠它选库。
48
+ inWorkspace: database.inWorkspace === true,
46
49
  })
47
50
  }
48
51
  }
@@ -154,7 +157,13 @@ async function dwBridgeHandle(detail, deps) {
154
157
  return
155
158
  }
156
159
  const schema = typeof detail.schema === 'string' ? detail.schema.trim() : ''
157
- const target = databases.find((entry) => schema !== '' && entry.database === schema) ?? databases[0]
160
+ // 库的定位:显式 schema 优先;没有就只在本项目发现出来的库里挑。
161
+ // 以前直接取 databases[0],共享资源树里第一个常常是别的项目的库
162
+ // (bluewhale-order-service 的 Mapper 被打开在 tiangong_tk_order 下)。
163
+ const own = databases.filter((entry) => entry.inWorkspace === true)
164
+ const pool = own.length > 0 ? own : databases
165
+ const target = (schema === '' ? null : databases.find((entry) => entry.database === schema))
166
+ ?? pool[0]
158
167
  layout()?.selectPanel?.(DW_PANEL_ID)
159
168
  // Paste only: Mapper SQL usually carries #{...} parameters and dynamic
160
169
  // fragments, so running it automatically would just produce an error.