dsh-design-studio 0.20.0 → 0.22.0

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/README.en.md CHANGED
@@ -43,7 +43,8 @@ If DSH can't reach the npm registry, it falls back to a mirror in China. To upda
43
43
  - **Design check:** one click finds overflowing text, low contrast, small tap targets and tiny text, marked right on the page. In Design mode the model also checks its own work and fixes what it finds.
44
44
  - **Versions and compare:** every turn is saved; drag a slider to compare, and go back to any version.
45
45
  - **Export and phone preview:** showcase images, PDF and PowerPoint (links between screens still work); scan a QR code to see it on your phone at real size. Slides and posters larger than the default canvas now use the page's real size. You can also set it by adding `WIDTHxHEIGHT` after the type, for example `<meta name="dsh-design" content="slides 1440x810">`. Export options let you pick the page size (16:9, 4:3, A3 landscape or custom), what each page shows (one screen, full page or a set height) and two screens per page. If anything would be cut off, you get a checklist first, with a one-click fix that fits the canvas to the content.
46
- - **Diagrams:** mind maps, technical route charts (the kind in grant proposals and theses), product roadmaps and system architecture diagrams. Lines, branches and arrows are laid out for you and re-flow when you change text or add nodes; colors follow the design style, and a high-resolution PNG or PDF export drops straight into Word or PowerPoint.
46
+ - **Diagrams:** mind maps, technical route charts (the kind in grant proposals and theses), product roadmaps and system architecture diagrams. Lines, branches and arrows are laid out for you and re-flow when you change text or add nodes; colors follow the design style, and a high-resolution PNG or PDF export drops straight into Word or PowerPoint. For grant-proposal and final-report frameworks, the model first lists how the parts relate (which problem maps to which task) for you to confirm, then draws labelled arrows between the blocks, in a bold 3D-gradient "proposal" style by default or after a reference image you give it.
47
+ - **DSH plugins:** design a plugin inside the real DSH desktop frame (left sidebar entry, settings section, session tab or right sidebar panel, in light and dark). Only the plugin area is designed, so you see exactly how it looks once installed; the design check warns if the frame gets changed.
47
48
  - **Design library and gallery:** everything you've designed, plus saved references and styles, lives in the Library. Browse templates, design systems and style cards others shared, and "Start from this" copies one for you to keep editing. Share your own with "Share to the gallery": it's checked, zipped and submitted on a web page, and listed once reviewed. The gallery catalog comes from npm mirrors and is used only when its signature and checksums match; to keep it offline, turn on "Design library offline" on the Plugins page.
48
49
  - **Your brand, and real code:** give a site URL to extract a brand design system and design with it from then on; turn a finished design into React / Vue / HTML (mini programs straight into uni-app or native WeChat code, HBuilderX projects included), compared screen by screen against the design.
49
50
  - **Built-in photo library:** for designs that rely on photos (hotels, food, cafes, fitness, beauty, fashion, education, travel), the model uses real-looking photos instead of only drawing illustrations. About 8 MB is downloaded the first time it is needed. All of them are AI-generated placeholders, so replace them with real photos before launch.
package/README.md CHANGED
@@ -43,7 +43,8 @@
43
43
  - **设计体检**:一键查文字溢出、对比度不够、按钮太小、字太小,问题直接标在页面上;模型做完也会自己查一遍再改。
44
44
  - **版本和对比**:每轮自动存一版,左右拖动对比,随时回到任意一版。
45
45
  - **导出和手机上看**:导出展示图、PDF、PPT(屏和屏之间的跳转照样能点);扫码在手机上按真机尺寸看。页面比默认画幅大的幻灯片、海报,画幅自动跟页面走;也可以在类型后面跟 `宽x高` 指定,比如 `<meta name="dsh-design" content="slides 1440x810">`。导出选项里可以选版面(16:9、4:3、A3 横向、自定义)、每页取景(一屏、整页、指定高度)和每页拼 2 屏;有内容会被裁时,导出前先给一张清单,可以一键按内容改画幅。
46
- - **图表**:思维导图、技术路线图(申报书、开题报告那种)、产品路线图、系统架构图。连线、分叉、箭头自动排好,改字、加节点自己重排;配色跟着设计风格走,导出高清 PNG 或 PDF 贴进 Word / PPT。
46
+ - **图表**:思维导图、技术路线图(申报书、开题报告那种)、产品路线图、系统架构图。连线、分叉、箭头自动排好,改字、加节点自己重排;配色跟着设计风格走,导出高清 PNG 或 PDF 贴进 Word / PPT。申报书、结题报告的框架图先帮你理清「哪个问题对应哪项内容」请你确认再画,版块之间画出带关系词的箭头;默认是立体渐变的「申报书炫酷样式」,也能照你给的参考图画。
47
+ - **DSH 插件**:给 DSH 做插件界面时,四周直接套上 DSH 桌面端的外框(左侧栏入口、设置分区、会话标签页、右侧栏面板四个位置,浅色、深色都有),只设计插件那一块,一眼看出装进 DSH 是什么样;外框被改了体检会提醒。
47
48
  - **设计库和设计市场**:以前做过的设计、收的参考图和风格都在「设计库」里;市场里逛大家分享的模板、设计系统和风格卡,点「用这个开始」复制一份接着改。自己做的点「分享到设计市场」,查过打成 zip,在网页里交上去,审过就上架。市场目录从 npm 镜像取,签了名、核对过才用;不想让它联网,在插件页打开「设计库不联网」。
48
49
  - **照品牌风格做、转成代码**:给官网地址,提一套品牌设计系统,以后都照它做;做好的设计转成 React / Vue / HTML,小程序直接转成 uni-app 或原生小程序代码(HBuilderX 建的项目也认得出),逐屏和设计稿比对。
49
50
  - **自带照片库**:民宿酒店、餐饮、奶茶咖啡、健身、美妆、服饰、教育、旅行风景这些靠照片说话的设计,模型会直接用上照片,不再只画插画。第一次用到时下载约 8 MB。都是 AI 生成的示意图,上线前请换成真实照片。
package/lib/client.js CHANGED
@@ -61,6 +61,7 @@ window.__ModuleLoader__.load({
61
61
  exSlides: '新品发布会的五页幻灯片:问题、方案、数字、价格、下一步',
62
62
  exEmail: '会员生日月的优惠邮件:一张大图、一段祝福、一个按钮',
63
63
  exDiagram: '「产品经理入门」的思维导图:用户研究、需求分析、原型、数据、项目管理',
64
+ exDshplugin: "做一个 DSH 插件「番茄钟」:会话标签页里放计时器和今日记录",
64
65
  askKindLine: '类型:{k}',
65
66
  askMore: '更多开始方式',
66
67
  askMoreD: '打开已有的 HTML、用自己的品牌、从设计库打开',
@@ -146,12 +147,14 @@ window.__ModuleLoader__.load({
146
147
  refJoin: '、',
147
148
  refAsk: '照这张参考图的风格改现在的设计:先把配色、圆角、阴影和字体气质更新到 tokens.css,再让各屏跟着变;布局和文案先不动。',
148
149
  refAskNew: '照这张参考图的风格来做:先把配色、圆角、阴影和字体气质定在 tokens.css 里,再出页面。',
150
+ refAskDg: '照这张参考图画:先打开参考图看清它的版式和画法(分几层几栏、层名和标题怎么标、卡片和标签的样子、箭头怎么连、编号、字号比例),照着画,配色定在 tokens.css 里;版块之间谁支撑谁、谁对应谁也照它用箭头和标注画出来。内容用我的,别抄图里的字;字要大,贴进 Word 也看得清。',
151
+ refAskDgRe: '照这张参考图重画现在的图表:先打开参考图看清它的版式和画法(分几层几栏、层名和标题怎么标、卡片和标签的样子、箭头怎么连、编号、字号比例),版式、画法和配色都照它改,配色更新到 tokens.css;版块之间谁支撑谁、谁对应谁也照它用箭头和标注画出来。内容不变,别抄图里的字;字要大,贴进 Word 也看得清。',
149
152
  textOne: '点页面里的文字直接改 · 回车保存 · Esc 退出',
150
153
  picking: '选择中…',
151
154
  canvas: '画布:几屏并排看',
152
155
  single: '单页:只看一屏',
153
156
  sizes: '多尺寸:同一屏在手机 / 平板 / 电脑上并排看',
154
- sizesNo: '海报、幻灯片、邮件、图表是固定画幅,没有多尺寸',
157
+ sizesNo: '海报、幻灯片、邮件、图表、DSH 插件是固定画幅,没有多尺寸',
155
158
  szPhone: '手机',
156
159
  szTablet: '平板',
157
160
  szDesktop: '电脑',
@@ -168,6 +171,7 @@ window.__ModuleLoader__.load({
168
171
  kindSlides: '幻灯片',
169
172
  kindEmail: '邮件',
170
173
  kindDiagram: '图表',
174
+ kindDshplugin: "DSH 插件",
171
175
  tokens: '设计规范',
172
176
  tokensTip: '点一个放进输入框,补一句怎么改;改它所有屏一起变',
173
177
  tokensEmpty: '这套设计还没有设计变量(:root 上的 CSS 变量),颜色字号散在各处,改起来不统一。',
@@ -271,6 +275,9 @@ window.__ModuleLoader__.load({
271
275
  ck_dgmany: '一层放太多',
272
276
  ck_dgbar: '横条超出时间轴',
273
277
  ck_dgtext: '节点字太多',
278
+ ck_dgsmall: '字偏小',
279
+ ck_dglink: '箭头没对着模块',
280
+ ck_frame: '外框被改动',
274
281
  cd_hscroll: '伸出屏幕 {px}px',
275
282
  cd_clipped: '被切掉 {px}px',
276
283
  cd_overflow: '伸出框 {px}px',
@@ -298,6 +305,9 @@ window.__ModuleLoader__.load({
298
305
  cd_dgmany: '{n} 个(最多 {max} 个):合并几个或拆开',
299
306
  cd_dgbar: '从第 {from} 段起占 {span} 段,时间轴只有 {cols} 段',
300
307
  cd_dgtext: '{chars} 个字(最好 ≤ {max}):写关键词,补充放小字',
308
+ cd_dglink: '这排箭头和上下两层的模块对不上:个数要一样,层里的递进改用不占位的箭头',
309
+ cd_frame: 'DSH 的外框和模板对不上:外框要原样复制,插件只写在 data-slot 里面,样式都从 [data-slot="main"] 开头',
310
+ cd_dgsmall: '正文约 {px}px、画幅 {vw} 宽:贴进 Word 只有约 {pt} 磅。把字放大到 {need}px 左右,或把画幅改窄',
301
311
  ckOs_mac: ' Mac ',
302
312
  ckOs_win: ' Windows ',
303
313
  ckZone_mac: '左上角 x 80、y 40 以内',
@@ -940,6 +950,7 @@ window.__ModuleLoader__.load({
940
950
  exSlides: 'Five-slide launch deck: problem, solution, numbers, pricing, next steps',
941
951
  exEmail: 'Birthday-month offer email for members: one big image, a short note, one button',
942
952
  exDiagram: 'A mind map for "Product management 101": user research, requirements, prototyping, data, project management',
953
+ exDshplugin: "A DSH plugin \"Pomodoro\": a timer and today's log in a session tab",
943
954
  askKindLine: 'Type: {k}',
944
955
  askMore: 'More ways to start',
945
956
  askMoreD: 'Open existing HTML, use your own brand, open from the library',
@@ -1025,12 +1036,14 @@ window.__ModuleLoader__.load({
1025
1036
  refJoin: ', ',
1026
1037
  refAsk: 'Restyle the current design after this reference: update colors, radii, shadows and type feel in tokens.css first, then let every screen follow. Keep layout and copy for now.',
1027
1038
  refAskNew: 'Design in the style of this reference: set colors, radii, shadows and type feel in tokens.css first, then build the pages.',
1039
+ refAskDg: 'Draw this diagram after the reference: open the reference first and study its layout and drawing (how many layers and columns, how layer names and headings are marked, the look of cards and tags, how arrows connect, numbering, type sizes), then follow it; set the colors in tokens.css. Show which block supports or corresponds to which with arrows and labels, as the reference does. Use my content, not the text in the image; keep the text large enough to read in a Word document.',
1040
+ refAskDgRe: 'Redraw the current diagram after the reference: open the reference first and study its layout and drawing (how many layers and columns, how layer names and headings are marked, the look of cards and tags, how arrows connect, numbering, type sizes), then change the layout, drawing and colors to match, updating tokens.css. Show which block supports or corresponds to which with arrows and labels, as the reference does. Keep the content, not the text in the image; keep the text large enough to read in a Word document.',
1028
1041
  textOne: 'Click any text in the page to edit · Enter to save · Esc to stop',
1029
1042
  picking: 'Selecting…',
1030
1043
  canvas: 'Canvas: screens side by side',
1031
1044
  single: 'Single: one screen',
1032
1045
  sizes: 'Sizes: the same screen on phone, tablet and desktop side by side',
1033
- sizesNo: 'Posters, slides, emails and diagrams have a fixed size',
1046
+ sizesNo: 'Posters, slides, emails, diagrams and DSH plugins have a fixed size',
1034
1047
  szPhone: 'Phone',
1035
1048
  szTablet: 'Tablet',
1036
1049
  szDesktop: 'Desktop',
@@ -1047,6 +1060,7 @@ window.__ModuleLoader__.load({
1047
1060
  kindSlides: 'Slides',
1048
1061
  kindEmail: 'Email',
1049
1062
  kindDiagram: 'Diagram',
1063
+ kindDshplugin: "DSH plugin",
1050
1064
  tokens: 'Design tokens',
1051
1065
  tokensTip: 'Click one to put it in the input, then say how to change it. All screens follow',
1052
1066
  tokensEmpty: 'This design has no tokens yet (CSS variables on :root), so colors and sizes are scattered.',
@@ -1150,6 +1164,9 @@ window.__ModuleLoader__.load({
1150
1164
  ck_dgmany: 'Too many in one level',
1151
1165
  ck_dgbar: 'Bar runs past the timeline',
1152
1166
  ck_dgtext: 'Node text too long',
1167
+ ck_dgsmall: 'Text too small',
1168
+ ck_dglink: 'Arrows miss the modules',
1169
+ ck_frame: 'Frame was changed',
1153
1170
  cd_hscroll: 'sticks out {px}px',
1154
1171
  cd_clipped: '{px}px cut off',
1155
1172
  cd_overflow: 'sticks out {px}px',
@@ -1177,6 +1194,9 @@ window.__ModuleLoader__.load({
1177
1194
  cd_dgmany: '{n} of them ({max} at most): merge some or split them up',
1178
1195
  cd_dgbar: 'starts at period {from} and spans {span}, but the timeline has only {cols}',
1179
1196
  cd_dgtext: '{chars} characters ({max} at most): use keywords, put details in small text',
1197
+ cd_dglink: 'this row of arrows does not line up with the modules above and below: use as many arrows as modules, and arrows that take no space inside a layer',
1198
+ cd_frame: 'the DSH frame no longer matches its template: copy the frame as is, write the plugin only inside data-slot, and start every style rule with [data-slot="main"]',
1199
+ cd_dgsmall: 'body text is about {px}px on a {vw}px-wide canvas: about {pt}pt once placed in a Word page. Enlarge it to about {need}px or make the canvas narrower',
1180
1200
  ckOs_mac: ' Mac ',
1181
1201
  ckOs_win: ' Windows ',
1182
1202
  ckZone_mac: 'the top-left 80×40',
@@ -2128,6 +2148,7 @@ window.__ModuleLoader__.load({
2128
2148
  .ddp-wait .card.k-slides{aspect-ratio:16/9}
2129
2149
  .ddp-wait .card.k-email{width:min(60%,380px);aspect-ratio:3/4}
2130
2150
  .ddp-wait .card.k-diagram{aspect-ratio:16/10}
2151
+ .ddp-wait .card.k-dshplugin{aspect-ratio:16/10}
2131
2152
  .ddp-wait .card:has(.ddp-gd){animation:none}
2132
2153
  .ddp-wait p{margin:0;color:var(--dsw-alias-label-tertiary);text-align:center;line-height:1.6}
2133
2154
  .ddp-toast{position:absolute;left:12px;right:12px;top:14px;width:fit-content;max-width:calc(100% - 24px);margin-inline:auto;z-index:7;padding:7px 14px;border-radius:14px;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-1);font-size:12px;line-height:1.5;text-align:center;overflow-wrap:anywhere;box-shadow:0 6px 20px rgba(0,0,0,.2);animation:ddp-in .2s ease}
@@ -2814,6 +2835,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
2814
2835
  slides: () => svg([h('rect', { key: 1, x: 2.5, y: 4, width: 19, height: 12, rx: 1.8 }), h('path', { key: 2, d: 'M12 16v3M8.5 20.5h7' }), h('path', { key: 3, d: 'M6.5 8h6M6.5 11h4' })]),
2815
2836
  email: () => svg([h('rect', { key: 1, x: 3, y: 5, width: 18, height: 14, rx: 2.2 }), h('path', { key: 2, d: 'M3.5 6.5l8.5 6.5 8.5-6.5' })]),
2816
2837
  diagram: () => svg([h('rect', { key: 1, x: 2.5, y: 9.5, width: 6, height: 5, rx: 1.4 }), h('rect', { key: 2, x: 15.5, y: 3.5, width: 6, height: 4, rx: 1.2 }), h('rect', { key: 3, x: 15.5, y: 10, width: 6, height: 4, rx: 1.2 }), h('rect', { key: 4, x: 15.5, y: 16.5, width: 6, height: 4, rx: 1.2 }), h('path', { key: 5, d: 'M8.5 12h3.5M12 5.5v13M12 5.5h3.5M12 12h3.5M12 18.5h3.5' })]),
2838
+ dshplugin: () => svg([h('rect', { key: 1, x: 2.5, y: 4, width: 19, height: 16, rx: 2 }), h('path', { key: 2, d: 'M8 4v16' }), h('rect', { key: 3, x: 11, y: 8, width: 7.5, height: 8, rx: 1.4, strokeDasharray: '2 1.6' })]),
2817
2839
  caret: () => svg([h('path', { key: 1, d: 'M6 9.5l6 6 6-6', strokeWidth: 2.4 })], { className: 'cr' }),
2818
2840
  palette: () => svg([h('path', { key: 1, d: 'M12 3a9 9 0 1 0 0 18c1.1 0 1.7-.8 1.7-1.6 0-.9-.8-1.3-.8-2.1 0-.9.8-1.6 1.7-1.6H17a4 4 0 0 0 4-4C21 6.8 17 3 12 3z' }),
2819
2841
  h('circle', { key: 2, cx: 7.6, cy: 11.2, r: 1.25, fill: 'currentColor', stroke: 'none' }), h('circle', { key: 3, cx: 10.2, cy: 7.4, r: 1.25, fill: 'currentColor', stroke: 'none' }),
@@ -3206,7 +3228,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
3206
3228
  card: (v, t, s) => { const it = s.split('\n').filter((l) => /^\d+\. /.test(l)); return [['b', t('chipCheck', { n: v.n })], ...it.slice(0, 4).map((l) => ['span', l.replace(/ — .*$/, '')]), it.length > 4 ? ['span', '…'] : null] } },
3207
3229
  { i: 'code', label: (v, t) => t('chipCode'), alts: both('hoText', { only: '(?:,screens: [^\\n]*)?' }),
3208
3230
  card: (v, t) => [['b', t('chipCode')], ['code', v.fw], ['span', v.dest], ['span', v.scope]] },
3209
- { i: 'image', label: (v, t) => t('chipRef'), alts: L.map((x) => tplSrc(x.refText, { ask: lit(['refAsk', 'refAskNew']), w: '\\d+', h: '\\d+' })),
3231
+ { i: 'image', label: (v, t) => t('chipRef'), alts: L.map((x) => tplSrc(x.refText, { ask: lit(['refAsk', 'refAskNew', 'refAskDg', 'refAskDgRe']), w: '\\d+', h: '\\d+' })),
3210
3232
  card: (v, t) => [['b', t('chipRef')], ['img', chipThumbs.get(v.path)], ['sw', hexes(v.colors)], ['span', `${v.w}×${v.h} · ${v.tone}`], ['span', baseName(v.path)]] },
3211
3233
  { i: 'style', label: (v, t) => t('chipTweak'), alts: L.map((x) => ({ src: `${tplSrc(x.twAskHead).src}(?:\\n- [^\\n]*)+\\n${tplSrc(x.twAskTail).src}`, keys: [] })),
3212
3234
  card: (v, t, s) => [['b', t('chipTweak')], ...s.split('\n').filter((l) => l.startsWith('- ')).slice(0, 5).map((l) => ['span', l.slice(2)])] },
@@ -3769,6 +3791,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
3769
3791
  function autoStyle(text, kind) {
3770
3792
  const s = String(text || '')
3771
3793
  if (!s.trim()) return null
3794
+ if (kind === 'dshplugin') return null // DSH 插件默认用 DSH 自己的样子(外框的 --dsh-* 变量),不替它挑风格卡
3772
3795
  const said = s.replace(NOT_STYLE_FENG, ' ')
3773
3796
  if (SAID_STYLE.test(said) || STYLES.some((x) => said.includes(x.zh) || new RegExp(`\\b${x.en}\\s+(style|look|theme|aesthetic|vibe)\\b`, 'i').test(said))) return null
3774
3797
  const by = (id) => STYLES.find((x) => x.id === id) || null
@@ -4066,7 +4089,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
4066
4089
 
4067
4090
  // ── 导出图片:设备外框、整套展示图 ───────────────────────────────────────
4068
4091
 
4069
- const SHOW_COLS = { app: 4, miniprogram: 4, tablet: 3, desktop: 2, web: 2, poster: 3, slides: 2, email: 3, diagram: 2 }
4092
+ const SHOW_COLS = { app: 4, miniprogram: 4, tablet: 3, desktop: 2, web: 2, poster: 3, slides: 2, email: 3, diagram: 2, dshplugin: 2 }
4070
4093
  const CANVAS_FONT = '-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif'
4071
4094
  const FRAMED = { app: 1, miniprogram: 1, tablet: 1, desktop: 1, web: 1 }
4072
4095
 
@@ -4358,9 +4381,11 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
4358
4381
  }
4359
4382
 
4360
4383
  /** 参考图 → 输入框里的一段字:路径、尺寸、深浅、主要颜色,加一句怎么用 */
4361
- function formatRef(t, { path, w, h, palette, hasDesign }) {
4384
+ // 图表(kind 'diagram'):不光照配色,版式、画法、版块之间怎么连也照参考图
4385
+ function formatRef(t, { path, w, h, palette, hasDesign, kind }) {
4362
4386
  const colors = palette.colors.map((c) => `${c.hex} ${Math.max(1, Math.round(c.share * 100))}%${c.accent ? t('refAccent') : ''}`).join(t('refJoin'))
4363
- return t('refText', { path, w, h, tone: t(palette.light ? 'refLight' : 'refDark'), colors: colors || '—', ask: t(hasDesign ? 'refAsk' : 'refAskNew') })
4387
+ const ask = kind === 'diagram' ? (hasDesign ? 'refAskDgRe' : 'refAskDg') : hasDesign ? 'refAsk' : 'refAskNew'
4388
+ return t('refText', { path, w, h, tone: t(palette.light ? 'refLight' : 'refDark'), colors: colors || '—', ask: t(ask) })
4364
4389
  }
4365
4390
 
4366
4391
  /** 读参考图:缩小了取颜色;文件本身原样送去存(太大或不是常见格式就重新编成 PNG) */
@@ -4547,12 +4572,12 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
4547
4572
 
4548
4573
  // ── 设计类型:画幅和外框 ─────────────────────────────────────────────────
4549
4574
 
4550
- const KIND_LIST = ['web', 'app', 'miniprogram', 'tablet', 'desktop', 'poster', 'slides', 'email', 'diagram']
4551
- const KIND_KEY = { web: 'kindWeb', app: 'kindApp', miniprogram: 'kindMini', tablet: 'kindTablet', desktop: 'kindDesktop', poster: 'kindPoster', slides: 'kindSlides', email: 'kindEmail', diagram: 'kindDiagram' }
4575
+ const KIND_LIST = ['web', 'app', 'miniprogram', 'tablet', 'desktop', 'poster', 'slides', 'email', 'diagram', 'dshplugin']
4576
+ const KIND_KEY = { web: 'kindWeb', app: 'kindApp', miniprogram: 'kindMini', tablet: 'kindTablet', desktop: 'kindDesktop', poster: 'kindPoster', slides: 'kindSlides', email: 'kindEmail', diagram: 'kindDiagram', dshplugin: 'kindDshplugin' }
4552
4577
  const GHOST_MS = 90000 // 这么久没出新屏就撤掉「生成中…」占位
4553
4578
  const HOLD_MAX = 15000 // 草稿放到一半真文件就落地了:最多再放这么久(一般几秒放完自己说一声)
4554
4579
  const EDIT_GRACE_MS = 3000 // 退出改字后这么久里,页面交上来的最后一处改动还收
4555
- const KIND_SIZE = { web: [1280, 800], app: [390, 844], miniprogram: [375, 812], tablet: [820, 1180], desktop: [1280, 800], poster: [1080, 1350], slides: [1280, 720], email: [640, 960], diagram: [1600, 1000] }
4580
+ const KIND_SIZE = { web: [1280, 800], app: [390, 844], miniprogram: [375, 812], tablet: [820, 1180], desktop: [1280, 800], poster: [1080, 1350], slides: [1280, 720], email: [640, 960], diagram: [1600, 1000], dshplugin: [1280, 800] }
4556
4581
  // 外框:pad 边框厚度、top 顶上一条(浏览器栏)、r 外圆角、ir 屏幕圆角、island 灵动岛离顶的距离、capsule 小程序右上角的胶囊、win 桌面软件的窗口按钮
4557
4582
  const FRAME = {
4558
4583
  web: { pad: 0, top: 34, r: 10, ir: 0 },
@@ -4564,6 +4589,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
4564
4589
  slides: { pad: 0, top: 0, r: 8, ir: 8 },
4565
4590
  email: { pad: 0, top: 0, r: 10, ir: 10 },
4566
4591
  diagram: { pad: 0, top: 0, r: 8, ir: 8 },
4592
+ dshplugin: { pad: 0, top: 0, r: 10, ir: 10 },
4567
4593
  }
4568
4594
 
4569
4595
  /** 某个大小的外框:矮的手机(SE 那种,高不到宽的 1.9 倍)没有灵动岛,不然压住页面最上面 */
@@ -4576,7 +4602,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
4576
4602
  // 桌面软件的窗口按钮(和 picker.js 的一样):Mac 红绿灯在左上 x 20、y 20 起,三个 12px 圆点隔 8;Windows 最小化 / 最大化 / 关闭在右上角,各 46×32
4577
4603
  const LIGHTS = { x: 20, y: 20, d: 12, gap: 8 }
4578
4604
  const WINBTN = { w: 46, h: 32 }
4579
- const META_ALIAS = { phone: 'app', mobile: 'app', ios: 'app', android: 'app', mini: 'miniprogram', miniapp: 'miniprogram', weapp: 'miniprogram', wechat: 'miniprogram', 小程序: 'miniprogram', pad: 'tablet', ipad: 'tablet', pc: 'desktop', electron: 'desktop', tauri: 'desktop', mac: 'desktop', macos: 'desktop', windows: 'desktop', win: 'desktop', 桌面: 'desktop', 桌面软件: 'desktop', social: 'poster', image: 'poster', slide: 'slides', deck: 'slides', ppt: 'slides', mail: 'email', mindmap: 'diagram', roadmap: 'diagram', architecture: 'diagram', flowchart: 'diagram', 思维导图: 'diagram', 导图: 'diagram', 路线图: 'diagram', 架构图: 'diagram', 图表: 'diagram' }
4605
+ const META_ALIAS = { phone: 'app', mobile: 'app', ios: 'app', android: 'app', mini: 'miniprogram', miniapp: 'miniprogram', weapp: 'miniprogram', wechat: 'miniprogram', 小程序: 'miniprogram', pad: 'tablet', ipad: 'tablet', pc: 'desktop', electron: 'desktop', tauri: 'desktop', mac: 'desktop', macos: 'desktop', windows: 'desktop', win: 'desktop', 桌面: 'desktop', 桌面软件: 'desktop', social: 'poster', image: 'poster', slide: 'slides', deck: 'slides', ppt: 'slides', mail: 'email', mindmap: 'diagram', roadmap: 'diagram', architecture: 'diagram', flowchart: 'diagram', 思维导图: 'diagram', 导图: 'diagram', 路线图: 'diagram', 架构图: 'diagram', 图表: 'diagram', dsh: 'dshplugin', 'dsh-plugin': 'dshplugin', dsh插件: 'dshplugin' }
4580
4606
 
4581
4607
  /** 页面里 <meta name="dsh-design" content="app"> / "poster 1080x1920" / "desktop windows" → { kind, size, os }(os:win,不写是 Mac) */
4582
4608
  function parseMeta(content) {
@@ -5057,6 +5083,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5057
5083
  slides: [[6, 10, 60, 13], [6, 32, 40, 52], [52, 32, 42, 52]],
5058
5084
  email: [[10, 4, 80, 7], [10, 14, 80, 30], [10, 48, 60, 5], [10, 56, 80, 14], [10, 75, 30, 6]],
5059
5085
  diagram: [[38, 40, 24, 18], [6, 14, 22, 10], [6, 45, 22, 10], [6, 76, 22, 10], [72, 14, 22, 10], [72, 45, 22, 10], [72, 76, 22, 10]],
5086
+ dshplugin: [[0, 0, 22, 100], [26, 6, 40, 8], [26, 20, 70, 74]],
5060
5087
  }
5061
5088
  const GD_C = ['#4d6bfe', '#e8590c', '#0ca678']
5062
5089
  /** 占位里的鼠标什么时候动:换了在做的事、或者又写了 15 行就加一;不在生成就不动 */
@@ -7029,7 +7056,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7029
7056
  const n = { name: name || t('exThisName') } // 写出是哪一屏,别只说「这一屏」
7030
7057
  if (FRAMED[kind]) items.push(['frame', I.single, t('exFrame', n)])
7031
7058
  items.push(['raw', I.image, t('exRaw', n)])
7032
- if (kind !== 'poster' && kind !== 'slides' && kind !== 'diagram') items.push(['long', I.long, t('exLong', n)]) // 海报、幻灯片、图表画幅是定的,没有「整页」
7059
+ if (kind !== 'poster' && kind !== 'slides' && kind !== 'diagram' && kind !== 'dshplugin') items.push(['long', I.long, t('exLong', n)]) // 海报、幻灯片、图表画幅是定的,没有「整页」
7033
7060
  if (count > 1) items.push(['show', I.canvas, t('exShow')])
7034
7061
  items.push(['pdf', I.pdf, t('exPdf')], ['pptx', I.deck, t('exPptx')], ['opts', I.sliders, t('exOpts')])
7035
7062
  return items
@@ -7392,7 +7419,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7392
7419
 
7393
7420
  // ── 设计库 › 市场 ──
7394
7421
  const GALLERY_REPO = 'https://github.com/OrderG-X/dsh-design-gallery'
7395
- const MK_KINDS = ['web', 'app', 'miniprogram', 'tablet', 'desktop', 'poster', 'slides', 'email', 'diagram']
7422
+ const MK_KINDS = ['web', 'app', 'miniprogram', 'tablet', 'desktop', 'poster', 'slides', 'email', 'diagram', 'dshplugin']
7396
7423
  const mkPick = (t, x) => { const o = x || {}; return String((t('lang') === 'en' ? o.en || o.zh : o.zh || o.en) || '') }
7397
7424
  const mkUrl = (e) => e.submission || `${GALLERY_REPO}/tree/main/${e.type === 'system' ? 'systems' : e.type === 'style' ? 'styles' : 'templates'}/${e.id}`
7398
7425
  const mkErr = (t, e) => { const k = String((e && e.message) || e || ''); const m = t('mkErr_' + k); return m && m !== 'mkErr_' + k ? m : k }
@@ -7456,8 +7483,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7456
7483
  }
7457
7484
 
7458
7485
  // 首页大输入框:说一句 + 类型 + 风格 → onSend(发给模型)。没写字时 Tab 用占位里的例子
7459
- const ASK_KINDS = ['app', 'miniprogram', 'web', 'poster', 'slides', 'diagram', 'tablet', 'desktop', 'email']
7460
- const ASK_EX = { web: 'exWeb', app: 'exApp', miniprogram: 'exMini', tablet: 'exTablet', desktop: 'exDesktop', poster: 'exPoster', slides: 'exSlides', email: 'exEmail', diagram: 'exDiagram' }
7486
+ const ASK_KINDS = ['app', 'miniprogram', 'web', 'poster', 'slides', 'diagram', 'dshplugin', 'tablet', 'desktop', 'email']
7487
+ const ASK_EX = { web: 'exWeb', app: 'exApp', miniprogram: 'exMini', tablet: 'exTablet', desktop: 'exDesktop', poster: 'exPoster', slides: 'exSlides', email: 'exEmail', diagram: 'exDiagram', dshplugin: 'exDshplugin' }
7461
7488
  function HomeAsk({ t, onSend, onRef, plus, draft, note, autoFocus }) {
7462
7489
  const d0 = (draft && draft.current) || {}
7463
7490
  const [text, setText] = useState(d0.text || '')
@@ -7675,7 +7702,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7675
7702
  isTpl ? h('button', { className: 'ddp-pbtn', disabled: busy, title: t('mkUseTip'), onClick: use }, t('mkUse')) : null,
7676
7703
  e.type === 'system' ? h('button', { className: 'ddp-pbtn', disabled: busy, onClick: install }, t('mkInstall')) : null,
7677
7704
  // 海报、幻灯片、图表是定尺寸的画面、没什么可点的:只看截图(实时看会按原尺寸撑出框)
7678
- !err && e.type !== 'style' && e.kind !== 'poster' && e.kind !== 'slides' && e.kind !== 'diagram' ? h('button', { className: 'ddp-sbtn', disabled: busy, title: t('mkLiveTip'), onClick: () => (live ? setLive(null) : goLive()) }, live ? t('mkShotsBack') : t('mkLive')) : null,
7705
+ !err && e.type !== 'style' && e.kind !== 'poster' && e.kind !== 'slides' && e.kind !== 'diagram' && e.kind !== 'dshplugin' ? h('button', { className: 'ddp-sbtn', disabled: busy, title: t('mkLiveTip'), onClick: () => (live ? setLive(null) : goLive()) }, live ? t('mkShotsBack') : t('mkLive')) : null,
7679
7706
  e.type !== 'style' ? h('button', { className: 'ddp-sbtn' + (fav ? ' on' : ''), title: t('mkFavTip'), 'aria-pressed': !!fav, onClick: toggleFav }, fav ? '★ ' + t('mkFaved') : '☆ ' + t('mkFav')) : null),
7680
7707
  h('ul', { className: 'facts' },
7681
7708
  h('li', null, t('mkSafe')),
@@ -7714,7 +7741,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7714
7741
  * over 比画幅大(横向永远会被裁;幻灯片、海报竖向也算);long 长页只截到一部分;dead 点了没反应的链接
7715
7742
  */
7716
7743
  function precheckOf(list, kind, limit) {
7717
- const fixed = kind === 'slides' || kind === 'poster' || kind === 'diagram'
7744
+ const fixed = kind === 'slides' || kind === 'poster' || kind === 'diagram' || kind === 'dshplugin'
7718
7745
  const r = { over: 0, long: 0, moved: 0, dead: 0, fail: 0, ai: new Set(list.flatMap((m) => (Array.isArray(m.aiPhotos) ? m.aiPhotos : []))).size }
7719
7746
  for (const m of list) {
7720
7747
  if (m.failed) { r.fail++; continue }
@@ -7730,7 +7757,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7730
7757
 
7731
7758
  /** 「按内容改画幅」改成多大:'宽x高',不用改或改不了返回 ''。幻灯片、海报按量到的版面,别的只把宽度加上去;竖着堆了好几页的不改高 */
7732
7759
  function fitCanvas(list, kind, size) {
7733
- const fixed = kind === 'slides' || kind === 'poster' || kind === 'diagram'
7760
+ const fixed = kind === 'slides' || kind === 'poster' || kind === 'diagram' || kind === 'dshplugin'
7734
7761
  let [W, H] = size
7735
7762
  for (const m of list) {
7736
7763
  if (m.failed) continue
@@ -9953,7 +9980,10 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9953
9980
  const r = await readRef(file)
9954
9981
  const saved = await post('ref', { session: sid, name: file.name || 'ref', data: r.data })
9955
9982
  keepThumb(saved.path, r.img)
9956
- insert(formatRef(t, { path: saved.path, w: r.w, h: r.h, palette: r.palette, hasDesign: !!url }), 'insertedSend')
9983
+ // 首页开着:按首页选的类型(新做);不然按开着的设计
9984
+ const home = !url || homeAt === 'on'
9985
+ const rk = home ? (homeDraft.current && homeDraft.current.kind) || '' : kind
9986
+ insert(formatRef(t, { path: saved.path, w: r.w, h: r.h, palette: r.palette, hasDesign: !home, kind: rk }), 'insertedSend')
9957
9987
  } catch (e) {
9958
9988
  say(t('refFail', { msg: e.message }))
9959
9989
  }
package/lib/core.js CHANGED
@@ -35,7 +35,7 @@ const MAX_SCREENS = 60 // 右侧最多显示几屏,再多的收起来并提示
35
35
  const MAX_ROUTES = 300 // 开发服务器的路由先都记着(只为算出收起了几屏);再多就是写飞了
36
36
 
37
37
  // 设计类型:决定右侧用什么画幅显示(网页框、手机、小程序、平板、桌面软件窗口、海报、幻灯片、邮件、图表)
38
- export const KINDS = ['web', 'app', 'miniprogram', 'tablet', 'desktop', 'poster', 'slides', 'email', 'diagram']
38
+ export const KINDS = ['web', 'app', 'miniprogram', 'tablet', 'desktop', 'poster', 'slides', 'email', 'diagram', 'dshplugin']
39
39
  const KIND_ALIAS = {
40
40
  website: 'web', site: 'web', page: 'web', landing: 'web', dashboard: 'web',
41
41
  phone: 'app', mobile: 'app', ios: 'app', android: 'app',
@@ -46,6 +46,7 @@ const KIND_ALIAS = {
46
46
  slide: 'slides', deck: 'slides', ppt: 'slides', presentation: 'slides',
47
47
  mail: 'email', newsletter: 'email', edm: 'email',
48
48
  mindmap: 'diagram', 'mind-map': 'diagram', roadmap: 'diagram', architecture: 'diagram', arch: 'diagram', flowchart: 'diagram', 思维导图: 'diagram', 导图: 'diagram', 脑图: 'diagram', 路线图: 'diagram', 技术路线图: 'diagram', 架构图: 'diagram', 图表: 'diagram',
49
+ dsh: 'dshplugin', 'dsh-plugin': 'dshplugin', dshplug: 'dshplugin', harness: 'dshplugin', dsh插件: 'dshplugin', 'dsh 插件': 'dshplugin',
49
50
  }
50
51
 
51
52
  /** 类型名(含常见别名)→ KINDS 里的一个;认不出返回 '' */
@@ -38,10 +38,10 @@ export const capsOf = (mode) => (mode === 'share' || mode === 'ci'
38
38
  : { files: LIMITS.localFiles, screens: LIMITS.localScreens, total: LIMITS.localTotal })
39
39
  export const TYPES = ['template', 'system', 'style']
40
40
  export const LICENSES = ['CC0-1.0', 'CC-BY-4.0']
41
- export const KINDS = ['web', 'app', 'miniprogram', 'tablet', 'desktop', 'poster', 'slides', 'email', 'diagram']
41
+ export const KINDS = ['web', 'app', 'miniprogram', 'tablet', 'desktop', 'poster', 'slides', 'email', 'diagram', 'dshplugin']
42
42
  export const STYLE_IDS = ['minimal', 'warm', 'editorial', 'dark', 'playful', 'fresh', 'tech', 'glass', 'soft', 'guochao', 'ink', 'cyber', 'cute', 'retro', 'sale', 'japandi', 'swiss', 'brutal', 'cream', 'sport']
43
43
  export const HEADS = ['SANS', 'SERIF', 'ROUND', 'MONO', 'GROTESK'] // 风格卡的字体只能是这几种系统字体栈
44
- const META_ALIAS = { phone: 'app', mobile: 'app', ios: 'app', android: 'app', mini: 'miniprogram', miniapp: 'miniprogram', weapp: 'miniprogram', wechat: 'miniprogram', 小程序: 'miniprogram', pad: 'tablet', ipad: 'tablet', pc: 'desktop', electron: 'desktop', tauri: 'desktop', mac: 'desktop', macos: 'desktop', windows: 'desktop', win: 'desktop', 桌面: 'desktop', 桌面软件: 'desktop', social: 'poster', image: 'poster', slide: 'slides', deck: 'slides', ppt: 'slides', mail: 'email', mindmap: 'diagram', roadmap: 'diagram', architecture: 'diagram', flowchart: 'diagram', 思维导图: 'diagram', 导图: 'diagram', 路线图: 'diagram', 架构图: 'diagram', 图表: 'diagram' }
44
+ const META_ALIAS = { phone: 'app', mobile: 'app', ios: 'app', android: 'app', mini: 'miniprogram', miniapp: 'miniprogram', weapp: 'miniprogram', wechat: 'miniprogram', 小程序: 'miniprogram', pad: 'tablet', ipad: 'tablet', pc: 'desktop', electron: 'desktop', tauri: 'desktop', mac: 'desktop', macos: 'desktop', windows: 'desktop', win: 'desktop', 桌面: 'desktop', 桌面软件: 'desktop', social: 'poster', image: 'poster', slide: 'slides', deck: 'slides', ppt: 'slides', mail: 'email', mindmap: 'diagram', roadmap: 'diagram', architecture: 'diagram', flowchart: 'diagram', 思维导图: 'diagram', 导图: 'diagram', 路线图: 'diagram', 架构图: 'diagram', 图表: 'diagram', dsh: 'dshplugin', 'dsh-plugin': 'dshplugin', dsh插件: 'dshplugin' }
45
45
 
46
46
  const EXT = { html: 'html', css: 'css', svg: 'svg', png: 'image', jpg: 'image', jpeg: 'image', webp: 'image', gif: 'image', avif: 'image', json: 'json', md: 'md' }
47
47
  const DATA_IMAGE = /^data:image\/(png|jpe?g|webp|gif|avif)(;[a-z0-9=._-]+)*(;base64)?,/i
package/lib/index.js CHANGED
@@ -99,7 +99,7 @@ export const studio = { tracker: null, autoOpen: 0, offline: 0, annotations: 0,
99
99
  export const designSkill = {
100
100
  name: 'ui-design',
101
101
  description:
102
- '做网页、App 界面、小程序、平板界面、桌面软件、海报 / 社媒图、幻灯片、邮件、图表(思维导图、技术路线图、产品路线图、架构图)、组件这类设计之前先加载:' +
102
+ '做网页、App 界面、小程序、平板界面、桌面软件、海报 / 社媒图、幻灯片、邮件、图表(思维导图、技术路线图、产品路线图、架构图)、DSH 插件界面、组件这类设计之前先加载:' +
103
103
  '配合右侧「设计工作台」画布的做法(一屏一个文件、设计变量、类型标记)、现代设计原则、中文排版、各类型画幅要点、避免 AI 味、设计自查清单。' +
104
104
  '只是把回答做成一页给用户看或用(对比、表格、清单、数据图表、计算器这类,或者在对话里随手看一张导图)不算设计:有 show_page 工具就直接用它,不加载这个技能;' +
105
105
  '要「设计」、做好看的、要导出成图片 / PDF / PPT 的思维导图、路线图、架构图才用这个技能。',
@@ -130,7 +130,7 @@ export const previewTool = {
130
130
  name: 'preview_page',
131
131
  description:
132
132
  '在右侧栏「设计工作台」里实时打开一个页面,用户能边看边点选要改的地方。' +
133
- '做网页、App 界面、小程序、海报、幻灯片、邮件、图表(思维导图、路线图、架构图)这类设计时用:写好第一个 HTML 文件、或启动开发服务器后调一次就行,之后改文件会自动刷新,不用再调。' +
133
+ '做网页、App 界面、小程序、海报、幻灯片、邮件、图表(思维导图、路线图、架构图)、DSH 插件界面这类设计时用:写好第一个 HTML 文件、或启动开发服务器后调一次就行,之后改文件会自动刷新,不用再调。' +
134
134
  '只是把回答做成一页(对比、表格、清单、数据图表、计算器)给用户看或用时,有 show_page 工具就用它,不用这里。' +
135
135
  '本地 HTML 写文件路径;开发服务器写地址或端口(如 http://localhost:5173)。只能预览本机页面。' +
136
136
  'kind 说明是哪类设计,右侧按它的画幅显示(App 套手机外框、幻灯片 16:9 …)。' +
@@ -143,7 +143,7 @@ export const previewTool = {
143
143
  kind: {
144
144
  type: 'string',
145
145
  enum: KINDS,
146
- description: '设计类型:web 网页(默认)、app 手机 App 界面(390×844)、miniprogram 微信小程序(375×812,外框带右上角胶囊)、tablet 平板、desktop 桌面软件(1280×800 的 Mac 窗口;Windows 软件在页面 meta 写 desktop windows)、poster 海报 / 社媒图(1080×1350)、slides 幻灯片(16:9)、email 邮件、diagram 图表(思维导图、技术路线图、产品路线图、架构图,默认 1600×1000,图多大画幅跟着多大)',
146
+ description: '设计类型:web 网页(默认)、app 手机 App 界面(390×844)、miniprogram 微信小程序(375×812,外框带右上角胶囊)、tablet 平板、desktop 桌面软件(1280×800 的 Mac 窗口;Windows 软件在页面 meta 写 desktop windows)、poster 海报 / 社媒图(1080×1350)、slides 幻灯片(16:9)、email 邮件、diagram 图表(思维导图、技术路线图、产品路线图、架构图,默认 1600×1000,图多大画幅跟着多大)、dshplugin DSH 插件(1280×800,套 DSH 桌面端外框,只设计插件那块:左侧栏入口 / 设置分区 / 会话标签页 / 右侧栏面板)',
147
147
  },
148
148
  size: { type: 'string', description: '画幅尺寸,可选,如 1080x1920;不填按类型的默认尺寸' },
149
149
  screens: {
@@ -612,7 +612,7 @@ export const styleTool = {
612
612
  '用户点了风格卡(消息里有〔风格〕)、自己定了具体的风格或配色、或有默认的品牌设计系统时不用调;只说「你定」「帮我推荐一个」「出几个风格挑」算没定,要调。',
613
613
  parameters: specToJsonSchema({
614
614
  subject: { type: 'string', required: true, description: '这次要做什么,直接写用户的原话' },
615
- kind: { type: 'string', enum: ['web', 'app', 'miniprogram', 'tablet', 'desktop', 'poster', 'slides', 'email', 'diagram'], description: '设计类型' },
615
+ kind: { type: 'string', enum: ['web', 'app', 'miniprogram', 'tablet', 'desktop', 'poster', 'slides', 'email', 'diagram', 'dshplugin'], description: '设计类型' },
616
616
  count: { type: 'number', description: '要几个方向,1–3,默认 1;要先出三个方向时填 3,每个方向一张不同的卡' },
617
617
  }),
618
618
  output: {
package/lib/look.js CHANGED
@@ -9,9 +9,9 @@
9
9
  import fs from 'node:fs'
10
10
  import path from 'node:path'
11
11
 
12
- export const KIND_SIZE = { web: [1280, 800], app: [390, 844], miniprogram: [375, 812], tablet: [820, 1180], desktop: [1280, 800], poster: [1080, 1350], slides: [1280, 720], email: [640, 960], diagram: [1600, 1000] }
12
+ export const KIND_SIZE = { web: [1280, 800], app: [390, 844], miniprogram: [375, 812], tablet: [820, 1180], desktop: [1280, 800], poster: [1080, 1350], slides: [1280, 720], email: [640, 960], diagram: [1600, 1000], dshplugin: [1280, 800] }
13
13
  const KIND_LIST = Object.keys(KIND_SIZE)
14
- const META_ALIAS = { phone: 'app', mobile: 'app', ios: 'app', android: 'app', mini: 'miniprogram', miniapp: 'miniprogram', weapp: 'miniprogram', wechat: 'miniprogram', 小程序: 'miniprogram', pad: 'tablet', ipad: 'tablet', pc: 'desktop', electron: 'desktop', tauri: 'desktop', mac: 'desktop', macos: 'desktop', windows: 'desktop', win: 'desktop', 桌面: 'desktop', 桌面软件: 'desktop', social: 'poster', image: 'poster', slide: 'slides', deck: 'slides', ppt: 'slides', mail: 'email', mindmap: 'diagram', roadmap: 'diagram', architecture: 'diagram', flowchart: 'diagram', 思维导图: 'diagram', 导图: 'diagram', 路线图: 'diagram', 架构图: 'diagram', 图表: 'diagram' }
14
+ const META_ALIAS = { phone: 'app', mobile: 'app', ios: 'app', android: 'app', mini: 'miniprogram', miniapp: 'miniprogram', weapp: 'miniprogram', wechat: 'miniprogram', 小程序: 'miniprogram', pad: 'tablet', ipad: 'tablet', pc: 'desktop', electron: 'desktop', tauri: 'desktop', mac: 'desktop', macos: 'desktop', windows: 'desktop', win: 'desktop', 桌面: 'desktop', 桌面软件: 'desktop', social: 'poster', image: 'poster', slide: 'slides', deck: 'slides', ppt: 'slides', mail: 'email', mindmap: 'diagram', roadmap: 'diagram', architecture: 'diagram', flowchart: 'diagram', 思维导图: 'diagram', 导图: 'diagram', 路线图: 'diagram', 架构图: 'diagram', 图表: 'diagram', dsh: 'dshplugin', 'dsh-plugin': 'dshplugin', dsh插件: 'dshplugin' }
15
15
  // 只给宽度时的高:常见真机的屏幕高;别的宽度按这一类默认的宽高比
16
16
  const PHONE_H = { 320: 568, 360: 780, 375: 667, 390: 844, 393: 852, 402: 874, 412: 915, 414: 896, 428: 926, 430: 932, 440: 956 }
17
17
  const TABLET_H = { 744: 1133, 768: 1024, 810: 1080, 820: 1180, 834: 1194, 1024: 1366, 1032: 1376 }
@@ -403,7 +403,7 @@ const TYPE = {
403
403
  tiny: '字太小', img: '图片没加载出来', fonts: '字号太杂', distort: '图片被拉变形', long: '一行太长', wrap: '文字被挤断行',
404
404
  covered: '被固定栏压住', tight: '离固定栏太近', jserr: '页面脚本报错', missing: '文件没载出来', deadlink: '跳到的页面不存在',
405
405
  capsule: '被小程序胶囊挡住', island: '被灵动岛挡住', homebar: '伸进底部横条区', tabbar: '标签栏项太多', navbar: '没有导航栏',
406
- winctl: '被窗口按钮挡住', dgsize: '图比画幅大', dgli: '导图节点写法不对', dgmany: '一层放太多', dgbar: '横条超出时间轴', dgtext: '节点字太多',
406
+ winctl: '被窗口按钮挡住', dgsize: '图比画幅大', dgli: '导图节点写法不对', dgmany: '一层放太多', dgbar: '横条超出时间轴', dgtext: '节点字太多', dgsmall: '字偏小', dglink: '箭头没对着模块', frame: '外框被改动',
407
407
  }
408
408
  const EDGE = { top: '顶栏', bottom: '底栏' }
409
409
  const WHAT = { css: '样式表', script: '脚本', font: '字体', link: '文件', video: '视频', audio: '音频', source: '媒体', iframe: '内嵌页' }
@@ -455,11 +455,16 @@ export function detailOf(it) {
455
455
  : `伸进左上角红绿灯 ${it.px}px(外框画的、盖在页面上面,在 x 20–72、y 20–32:工具栏 / 侧栏顶上左边空出 80px,标题、按钮从 x 80 以后放)`
456
456
  case 'jserr': return `${it.msg}${it.src ? `(${it.src}${it.line ? `:${it.line}` : ''})` : ''}`
457
457
  case 'missing': return `${WHAT[it.what] || '文件'} ${it.src} 载不出来(路径写错了,或者文件不在)`
458
+ case 'frame': return it.what === 'style'
459
+ ? `外框的样式被改了:${it.sel} 的 ${it.prop} 应该是 ${it.want},现在是 ${it.got}。多半是插件样式写了 body / * / button 这种不带前缀的选择器,或者改了 dsh-shell.css:插件样式都从 [data-slot="main"] 开头,dsh-shell.css 从技能目录 frames/dsh/ 重新原样复制`
460
+ : `外框(${it.frame})的结构或文字被改了:外框只能原样复制(技能目录 frames/dsh/),插件只写 data-slot 里面。重新复制外框,再把槽位里的内容放回去`
458
461
  case 'dgsize': return `图有 ${it.w}×${it.h},画幅只有 ${it.vw}×${it.vh}:把 meta 改成 diagram ${it.w}x${it.h}(preview_page 的 size 也改),或者删减节点、改小间距`
459
462
  case 'dgli': return '字直接写在 li 里,或者 li 的第一个孩子不是 <span class="mm-node">:连线会对不上,改成 <li><span class="mm-node">…</span><ul>…</ul></li>'
460
463
  case 'dgmany': return it.what === 'box' ? `一行 ${it.n} 个框(最多 ${it.max} 个):拆成两行,或者合并几个` : `这一层 ${it.n} 个分支(最多 ${it.max} 个):合并几个、往下多分一层,或者拆成两张图`
461
464
  case 'dgbar': return `从第 ${it.from} 段起占 ${it.span} 段,可时间轴只有 ${it.cols} 段(--cols):改小 --span / --from,或者加大 --cols 并补上表头`
462
465
  case 'dgtext': return `${it.chars} 个字(最好 ≤ ${it.max}):节点写关键词,补充放 <small>,或者拆成下一级`
466
+ case 'dglink': return '这排箭头和上下两层的模块对不上:箭头个数和模块个数一样(空栏放 <i></i>);层里的递进别插 dg-link,改成 <div class="ar-mods seq">(箭头画在空隙里);挨着箭头的层别用 ar-group'
467
+ case 'dgsmall': return `正文约 ${it.px}px,画幅 ${it.vw} 宽:贴进 Word(16 厘米宽)只有约 ${it.pt} 磅,看不清。正文放大到 ${it.need}px 左右(diagram.css 的字整体放大:.dg-page { --dg-scale: … }),或者把画幅改窄;放不下就删减、拆成两张图——加大画幅字一样小`
463
468
  default: return ''
464
469
  }
465
470
  }
package/lib/picker.js CHANGED
@@ -3245,7 +3245,7 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
3245
3245
  const all = body.getElementsByTagName('*')
3246
3246
  for (let i = 0; i < all.length && atoms.length < CHECK_ATOMS; i++) {
3247
3247
  const el = all[i]
3248
- if (isOurs(el) || el.closest('dsh-design-picker,dsh-design-fx,dsh-design-edit,script,style,noscript,template,svg')) continue
3248
+ if (isOurs(el) || el.closest('dsh-design-picker,dsh-design-fx,dsh-design-edit,script,style,noscript,template,svg') || inFrame(el)) continue
3249
3249
  if (!ownText(el)) continue
3250
3250
  const cs = getComputedStyle(el)
3251
3251
  if (cs.display === 'none' || cs.visibility !== 'visible') continue
@@ -3377,11 +3377,11 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
3377
3377
  } })
3378
3378
 
3379
3379
  // 5. 点击区太小(App / 小程序 / 平板 44,网页 24;文字中间的链接不算)
3380
- const minTap = kind === 'app' || kind === 'miniprogram' || kind === 'tablet' ? 44 : kind === 'web' || kind === 'email' || kind === 'desktop' ? 24 : 0
3380
+ const minTap = kind === 'app' || kind === 'miniprogram' || kind === 'tablet' ? 44 : kind === 'web' || kind === 'email' || kind === 'desktop' || kind === 'dshplugin' ? 24 : 0
3381
3381
  if (minTap) {
3382
3382
  const small = []
3383
3383
  for (const el of body.querySelectorAll(CLICKABLE)) {
3384
- if (isOurs(el) || el.closest('dsh-design-picker,dsh-design-fx,dsh-design-edit')) continue
3384
+ if (isOurs(el) || el.closest('dsh-design-picker,dsh-design-fx,dsh-design-edit') || inFrame(el)) continue
3385
3385
  const r = el.getBoundingClientRect()
3386
3386
  if (r.width < 1 || r.height < 1 || (r.width >= minTap && r.height >= minTap)) continue
3387
3387
  const cs = getComputedStyle(el)
@@ -3475,8 +3475,11 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
3475
3475
  if (kind === 'app' || kind === 'miniprogram') phoneCheck(add, atoms, vw, kind)
3476
3476
  // 15. 桌面软件:窗口按钮挡住的字和按钮
3477
3477
  if (kind === 'desktop') winCheck(add, atoms, vw)
3478
- // 16. 图表:比画幅大、导图节点写法、一层太多、横条超出时间轴、节点字太多
3478
+ // 16. 图表:比画幅大、导图节点写法、一层太多、横条超出时间轴、节点字太多、字偏小(贴进 Word 看不清)
3479
3479
  if (kind === 'diagram' || document.querySelector('.dg.mm, .dg.tr, .dg.rm, .dg.ar')) diagramCheck(add, kind, vw)
3480
+ if (kind === 'diagram') smallTextCheck(add, vw)
3481
+ // 17. DSH 插件:外框被改动(结构、文字、样式和模板对不上)
3482
+ frameCheck(add)
3480
3483
 
3481
3484
  issues.sort((x, y) => y.sev - x.sev)
3482
3485
  const se0 = se()
@@ -3603,6 +3606,59 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
3603
3606
  }
3604
3607
  }
3605
3608
 
3609
+ /**
3610
+ * DSH 插件外框(skills/ui-design/frames/dsh)锁住:模型只写 data-slot 里面。
3611
+ * 结构指纹 = 外框里槽位以外的标签、class、style、data-slot 名和自己的字;和模板对不上就是外框被改了。
3612
+ * 样式:量几处外框的算出来的样式(宽高、底色、字号),插件样式漏到外框上(body / * / button 这种选择器)、改了 dsh-shell.css 都会变。
3613
+ * 改了外框文件要重算 FRAME_SIGS(test-look 会报出新指纹)。
3614
+ */
3615
+ const FRAME_SIGS = { 'dsh/sidebar': 'f6cf6564', 'dsh/settings': 'e85d0eca', 'dsh/view': '2522b3ea', 'dsh/panel': '0ea5d6de' }
3616
+ const FRAME_PROBES = [ // [选择器, 样式, 浅色值, 深色值(一样就省略)]
3617
+ ['.dsh-app', 'font-size', '14px'],
3618
+ ['.dsh-side', 'width', '280px'],
3619
+ ['.dsh-side', 'background-color', 'rgb(249, 250, 251)', 'rgb(27, 27, 28)'],
3620
+ ['.dsh-new', 'height', '38px'],
3621
+ ['.dsh-row', 'font-size', '15px'],
3622
+ ['.dsh-row', 'color', 'rgb(15, 17, 21)', 'rgb(249, 250, 251)'],
3623
+ ['.dsh-head', 'height', '76px'],
3624
+ ['.dsh-tab.on', 'color', 'rgb(65, 118, 230)', 'rgb(122, 170, 255)'],
3625
+ ['.dsh-right', 'width', '575px'],
3626
+ ['.dsh-modal', 'width', '800px'],
3627
+ ['.dsh-scell', 'font-size', '14px'],
3628
+ ]
3629
+ const inFrame = (el) => !!(el.closest && el.closest('.dsh-app[data-frame]') && !el.closest('[data-slot="main"]')) // 入口图标、名字那些小槽位跟着外框的样式走,也不查
3630
+ function frameSig(root) {
3631
+ const out = []
3632
+ const walk = (el) => {
3633
+ if (SIG_SKIP.has(el.tagName) || /^DSH-DESIGN-/.test(el.tagName)) return
3634
+ const slot = el.getAttribute('data-slot')
3635
+ // 槽位本身只记标签和名字:槽位上的 class、style(调样式改的内边距、底色)算插件的
3636
+ out.push(slot === null ? [el.tagName.toLowerCase(), el.getAttribute('class') || '', el.getAttribute('style') || '', '', ownText(el)].join('|') : [el.tagName.toLowerCase(), '', '', slot, ''].join('|'))
3637
+ if (slot === null) for (const c of el.children) walk(c)
3638
+ }
3639
+ walk(root)
3640
+ const s = out.join('\n')
3641
+ let h = 0x811c9dc5
3642
+ for (let i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 0x01000193) }
3643
+ return (h >>> 0).toString(16).padStart(8, '0')
3644
+ }
3645
+ function frameCheck(add) {
3646
+ const root = document.querySelector('.dsh-app[data-frame]')
3647
+ if (!root) return
3648
+ const id = root.getAttribute('data-frame')
3649
+ if (!Object.prototype.hasOwnProperty.call(FRAME_SIGS, id)) return // 以后的自定外框:还没有模板指纹
3650
+ const got = frameSig(root)
3651
+ if (got !== FRAME_SIGS[id]) { add('frame', root, { what: 'dom', frame: id, got }, 2); return }
3652
+ const dark = document.documentElement.getAttribute('data-theme') === 'dark'
3653
+ for (const [sel, prop, light, darkV] of FRAME_PROBES) {
3654
+ const el = [root, ...root.querySelectorAll(sel)].find((x) => x.matches(sel) && !x.closest('[data-slot]')) // 只量外框自己的(槽位里插件也可能用同名类)
3655
+ if (!el) continue
3656
+ const want = dark && darkV ? darkV : light
3657
+ const v = getComputedStyle(el).getPropertyValue(prop)
3658
+ if (v !== want) { add('frame', el, { what: 'style', frame: id, sel, prop, want, got: v }, 2); return }
3659
+ }
3660
+ }
3661
+
3606
3662
  /** 图表(diagram.css)的结构问题:连线是样式按结构画的,结构写错了线就对不上 */
3607
3663
  function diagramCheck(add, kind, vw) {
3608
3664
  const de = document.scrollingElement || document.documentElement
@@ -3638,6 +3694,18 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
3638
3694
  const span = num(el, '--span', 1)
3639
3695
  if (from < 1 || span < 1 || from !== Math.round(from) || span !== Math.round(span) || from + span - 1 > cols) add('dgbar', el, { from, span, cols }, 2)
3640
3696
  }
3697
+ // 架构图两层之间的一排箭头:每个箭头都得落在上下两层的某个模块上(个数对不上、层里塞了占位的横箭头、模块分了组,都会连偏)
3698
+ let off = 0
3699
+ for (const link of document.querySelectorAll('.dg.ar .ar-main > .dg-links > .dg-link')) {
3700
+ if (off >= 3) break
3701
+ const row = link.parentElement
3702
+ const mods = [row.previousElementSibling, row.nextElementSibling]
3703
+ .filter((x) => x && x.classList.contains('ar-layer'))
3704
+ .map((x) => [...x.querySelectorAll(':scope > .ar-mods > :not(.dg-link)')].map((m) => m.getBoundingClientRect()))
3705
+ if (!mods.length || !shown(link)) continue
3706
+ const r = link.getBoundingClientRect(), cx = r.left + r.width / 2
3707
+ if (mods.some((list) => !list.some((m) => cx >= m.left && cx <= m.right))) { add('dglink', link, {}, 2); off++ }
3708
+ }
3641
3709
  // 节点字太多:只算节点自己的字,<small> 里的补充不算。汉字算 1 个,字母、数字算半个
3642
3710
  const MAX = [['.dg.mm .mm-node', 16], ['.dg.tr .tr-box', 28], ['.dg.rm .rm-bar', 24], ['.dg.ar .ar-mod', 16]]
3643
3711
  let long = 0
@@ -3654,6 +3722,38 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
3654
3722
  }
3655
3723
  }
3656
3724
 
3725
+ /**
3726
+ * 图表的字偏小:按字数取正文字号的中位数,比画幅宽 ÷ 100 还小就提醒。
3727
+ * 图贴进 Word 会缩到页宽(约 16 厘米 = 453 磅),画幅 1600 宽、正文 14px 只剩 4 磅
3728
+ */
3729
+ /** SVG 里的字(含 foreignObject 里的)按 viewBox 缩放到屏幕上才是真字号:取屏幕变换的缩放倍数,不在 SVG 里的是 1 */
3730
+ function svgScale(el) {
3731
+ const g = typeof SVGElement === 'function' && el instanceof SVGElement ? el : el.closest && el.closest('foreignObject')
3732
+ const m = g && typeof g.getScreenCTM === 'function' ? g.getScreenCTM() : null
3733
+ const k = m ? Math.sqrt(Math.abs(m.a * m.d - m.b * m.c)) : 1
3734
+ return k > 0 && isFinite(k) ? k : 1
3735
+ }
3736
+
3737
+ function smallTextCheck(add, vw) {
3738
+ const sizes = []
3739
+ let total = 0
3740
+ const tw = document.createTreeWalker(document.body || document.documentElement, NodeFilter.SHOW_TEXT)
3741
+ for (let n = tw.nextNode(); n; n = tw.nextNode()) {
3742
+ const s = n.nodeValue.replace(/\s+/g, '')
3743
+ const el = n.parentElement
3744
+ if (!s || !el || /^(SCRIPT|STYLE|NOSCRIPT|TEMPLATE|TITLE)$/i.test(el.tagName) || hiddenChain(el) || !el.getClientRects().length) continue
3745
+ const fs = parseFloat(getComputedStyle(el).fontSize) * svgScale(el)
3746
+ if (!(fs > 0)) continue
3747
+ sizes.push([fs, s.length])
3748
+ total += s.length
3749
+ }
3750
+ if (total < 20 || !(vw > 0)) return
3751
+ sizes.sort((a, b) => a[0] - b[0])
3752
+ let acc = 0, med = 0
3753
+ for (const [fs, c] of sizes) { acc += c; if (acc * 2 >= total) { med = fs; break } }
3754
+ if (med && med < vw / 100) add('dgsmall', null, { px: Math.round(med * 10) / 10, vw, pt: Math.round((med * 453) / vw * 2) / 2, need: Math.ceil(vw / 70) }, 1)
3755
+ }
3756
+
3657
3757
  /**
3658
3758
  * 伪元素在屏幕上的框(量不到它自己,按算出来的样式推):
3659
3759
  * - 绝对 / 固定定位:算出来的 left / top / 宽高摆进包含块;
package/lib/styles.js CHANGED
@@ -137,6 +137,7 @@ export const SAID_STYLE = /风格|配色|色调|主色|色系|[红橙黄绿青
137
137
  export function autoStyle(text, kind) {
138
138
  const s = String(text || '')
139
139
  if (!s.trim()) return null
140
+ if (kind === 'dshplugin') return null // DSH 插件默认用 DSH 自己的样子(外框的 --dsh-* 变量),不替它挑风格卡
140
141
  const said = s.replace(NOT_STYLE_FENG, ' ')
141
142
  if (SAID_STYLE.test(said) || STYLES.some((x) => said.includes(x.zh) || new RegExp(`\\b${x.en}\\s+(style|look|theme|aesthetic|vibe)\\b`, 'i').test(said))) return null
142
143
  return topicStyle(s, kind)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-design-studio",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test --test-concurrency=1 test/*.mjs"