dsh-design-studio 0.20.0 → 0.21.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 +1 -1
- package/README.md +1 -1
- package/lib/client.js +21 -4
- package/lib/look.js +3 -1
- package/lib/picker.js +46 -1
- package/package.json +1 -1
- package/skills/ui-design/SKILL.md +1 -1
- package/skills/ui-design/diagram.css +693 -36
- package/skills/ui-design/references/diagram.md +127 -3
package/README.en.md
CHANGED
|
@@ -43,7 +43,7 @@ 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
47
|
- **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
48
|
- **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
49
|
- **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,7 @@
|
|
|
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
47
|
- **设计库和设计市场**:以前做过的设计、收的参考图和风格都在「设计库」里;市场里逛大家分享的模板、设计系统和风格卡,点「用这个开始」复制一份接着改。自己做的点「分享到设计市场」,查过打成 zip,在网页里交上去,审过就上架。市场目录从 npm 镜像取,签了名、核对过才用;不想让它联网,在插件页打开「设计库不联网」。
|
|
48
48
|
- **照品牌风格做、转成代码**:给官网地址,提一套品牌设计系统,以后都照它做;做好的设计转成 React / Vue / HTML,小程序直接转成 uni-app 或原生小程序代码(HBuilderX 建的项目也认得出),逐屏和设计稿比对。
|
|
49
49
|
- **自带照片库**:民宿酒店、餐饮、奶茶咖啡、健身、美妆、服饰、教育、旅行风景这些靠照片说话的设计,模型会直接用上照片,不再只画插画。第一次用到时下载约 8 MB。都是 AI 生成的示意图,上线前请换成真实照片。
|
package/lib/client.js
CHANGED
|
@@ -146,6 +146,8 @@ window.__ModuleLoader__.load({
|
|
|
146
146
|
refJoin: '、',
|
|
147
147
|
refAsk: '照这张参考图的风格改现在的设计:先把配色、圆角、阴影和字体气质更新到 tokens.css,再让各屏跟着变;布局和文案先不动。',
|
|
148
148
|
refAskNew: '照这张参考图的风格来做:先把配色、圆角、阴影和字体气质定在 tokens.css 里,再出页面。',
|
|
149
|
+
refAskDg: '照这张参考图画:先打开参考图看清它的版式和画法(分几层几栏、层名和标题怎么标、卡片和标签的样子、箭头怎么连、编号、字号比例),照着画,配色定在 tokens.css 里;版块之间谁支撑谁、谁对应谁也照它用箭头和标注画出来。内容用我的,别抄图里的字;字要大,贴进 Word 也看得清。',
|
|
150
|
+
refAskDgRe: '照这张参考图重画现在的图表:先打开参考图看清它的版式和画法(分几层几栏、层名和标题怎么标、卡片和标签的样子、箭头怎么连、编号、字号比例),版式、画法和配色都照它改,配色更新到 tokens.css;版块之间谁支撑谁、谁对应谁也照它用箭头和标注画出来。内容不变,别抄图里的字;字要大,贴进 Word 也看得清。',
|
|
149
151
|
textOne: '点页面里的文字直接改 · 回车保存 · Esc 退出',
|
|
150
152
|
picking: '选择中…',
|
|
151
153
|
canvas: '画布:几屏并排看',
|
|
@@ -271,6 +273,8 @@ window.__ModuleLoader__.load({
|
|
|
271
273
|
ck_dgmany: '一层放太多',
|
|
272
274
|
ck_dgbar: '横条超出时间轴',
|
|
273
275
|
ck_dgtext: '节点字太多',
|
|
276
|
+
ck_dgsmall: '字偏小',
|
|
277
|
+
ck_dglink: '箭头没对着模块',
|
|
274
278
|
cd_hscroll: '伸出屏幕 {px}px',
|
|
275
279
|
cd_clipped: '被切掉 {px}px',
|
|
276
280
|
cd_overflow: '伸出框 {px}px',
|
|
@@ -298,6 +302,8 @@ window.__ModuleLoader__.load({
|
|
|
298
302
|
cd_dgmany: '{n} 个(最多 {max} 个):合并几个或拆开',
|
|
299
303
|
cd_dgbar: '从第 {from} 段起占 {span} 段,时间轴只有 {cols} 段',
|
|
300
304
|
cd_dgtext: '{chars} 个字(最好 ≤ {max}):写关键词,补充放小字',
|
|
305
|
+
cd_dglink: '这排箭头和上下两层的模块对不上:个数要一样,层里的递进改用不占位的箭头',
|
|
306
|
+
cd_dgsmall: '正文约 {px}px、画幅 {vw} 宽:贴进 Word 只有约 {pt} 磅。把字放大到 {need}px 左右,或把画幅改窄',
|
|
301
307
|
ckOs_mac: ' Mac ',
|
|
302
308
|
ckOs_win: ' Windows ',
|
|
303
309
|
ckZone_mac: '左上角 x 80、y 40 以内',
|
|
@@ -1025,6 +1031,8 @@ window.__ModuleLoader__.load({
|
|
|
1025
1031
|
refJoin: ', ',
|
|
1026
1032
|
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
1033
|
refAskNew: 'Design in the style of this reference: set colors, radii, shadows and type feel in tokens.css first, then build the pages.',
|
|
1034
|
+
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.',
|
|
1035
|
+
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
1036
|
textOne: 'Click any text in the page to edit · Enter to save · Esc to stop',
|
|
1029
1037
|
picking: 'Selecting…',
|
|
1030
1038
|
canvas: 'Canvas: screens side by side',
|
|
@@ -1150,6 +1158,8 @@ window.__ModuleLoader__.load({
|
|
|
1150
1158
|
ck_dgmany: 'Too many in one level',
|
|
1151
1159
|
ck_dgbar: 'Bar runs past the timeline',
|
|
1152
1160
|
ck_dgtext: 'Node text too long',
|
|
1161
|
+
ck_dgsmall: 'Text too small',
|
|
1162
|
+
ck_dglink: 'Arrows miss the modules',
|
|
1153
1163
|
cd_hscroll: 'sticks out {px}px',
|
|
1154
1164
|
cd_clipped: '{px}px cut off',
|
|
1155
1165
|
cd_overflow: 'sticks out {px}px',
|
|
@@ -1177,6 +1187,8 @@ window.__ModuleLoader__.load({
|
|
|
1177
1187
|
cd_dgmany: '{n} of them ({max} at most): merge some or split them up',
|
|
1178
1188
|
cd_dgbar: 'starts at period {from} and spans {span}, but the timeline has only {cols}',
|
|
1179
1189
|
cd_dgtext: '{chars} characters ({max} at most): use keywords, put details in small text',
|
|
1190
|
+
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',
|
|
1191
|
+
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
1192
|
ckOs_mac: ' Mac ',
|
|
1181
1193
|
ckOs_win: ' Windows ',
|
|
1182
1194
|
ckZone_mac: 'the top-left 80×40',
|
|
@@ -3206,7 +3218,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
3206
3218
|
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
3219
|
{ i: 'code', label: (v, t) => t('chipCode'), alts: both('hoText', { only: '(?:,screens: [^\\n]*)?' }),
|
|
3208
3220
|
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+' })),
|
|
3221
|
+
{ 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
3222
|
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
3223
|
{ 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
3224
|
card: (v, t, s) => [['b', t('chipTweak')], ...s.split('\n').filter((l) => l.startsWith('- ')).slice(0, 5).map((l) => ['span', l.slice(2)])] },
|
|
@@ -4358,9 +4370,11 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
4358
4370
|
}
|
|
4359
4371
|
|
|
4360
4372
|
/** 参考图 → 输入框里的一段字:路径、尺寸、深浅、主要颜色,加一句怎么用 */
|
|
4361
|
-
|
|
4373
|
+
// 图表(kind 'diagram'):不光照配色,版式、画法、版块之间怎么连也照参考图
|
|
4374
|
+
function formatRef(t, { path, w, h, palette, hasDesign, kind }) {
|
|
4362
4375
|
const colors = palette.colors.map((c) => `${c.hex} ${Math.max(1, Math.round(c.share * 100))}%${c.accent ? t('refAccent') : ''}`).join(t('refJoin'))
|
|
4363
|
-
|
|
4376
|
+
const ask = kind === 'diagram' ? (hasDesign ? 'refAskDgRe' : 'refAskDg') : hasDesign ? 'refAsk' : 'refAskNew'
|
|
4377
|
+
return t('refText', { path, w, h, tone: t(palette.light ? 'refLight' : 'refDark'), colors: colors || '—', ask: t(ask) })
|
|
4364
4378
|
}
|
|
4365
4379
|
|
|
4366
4380
|
/** 读参考图:缩小了取颜色;文件本身原样送去存(太大或不是常见格式就重新编成 PNG) */
|
|
@@ -9953,7 +9967,10 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9953
9967
|
const r = await readRef(file)
|
|
9954
9968
|
const saved = await post('ref', { session: sid, name: file.name || 'ref', data: r.data })
|
|
9955
9969
|
keepThumb(saved.path, r.img)
|
|
9956
|
-
|
|
9970
|
+
// 首页开着:按首页选的类型(新做);不然按开着的设计
|
|
9971
|
+
const home = !url || homeAt === 'on'
|
|
9972
|
+
const rk = home ? (homeDraft.current && homeDraft.current.kind) || '' : kind
|
|
9973
|
+
insert(formatRef(t, { path: saved.path, w: r.w, h: r.h, palette: r.palette, hasDesign: !home, kind: rk }), 'insertedSend')
|
|
9957
9974
|
} catch (e) {
|
|
9958
9975
|
say(t('refFail', { msg: e.message }))
|
|
9959
9976
|
}
|
package/lib/look.js
CHANGED
|
@@ -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: '箭头没对着模块',
|
|
407
407
|
}
|
|
408
408
|
const EDGE = { top: '顶栏', bottom: '底栏' }
|
|
409
409
|
const WHAT = { css: '样式表', script: '脚本', font: '字体', link: '文件', video: '视频', audio: '音频', source: '媒体', iframe: '内嵌页' }
|
|
@@ -460,6 +460,8 @@ export function detailOf(it) {
|
|
|
460
460
|
case 'dgmany': return it.what === 'box' ? `一行 ${it.n} 个框(最多 ${it.max} 个):拆成两行,或者合并几个` : `这一层 ${it.n} 个分支(最多 ${it.max} 个):合并几个、往下多分一层,或者拆成两张图`
|
|
461
461
|
case 'dgbar': return `从第 ${it.from} 段起占 ${it.span} 段,可时间轴只有 ${it.cols} 段(--cols):改小 --span / --from,或者加大 --cols 并补上表头`
|
|
462
462
|
case 'dgtext': return `${it.chars} 个字(最好 ≤ ${it.max}):节点写关键词,补充放 <small>,或者拆成下一级`
|
|
463
|
+
case 'dglink': return '这排箭头和上下两层的模块对不上:箭头个数和模块个数一样(空栏放 <i></i>);层里的递进别插 dg-link,改成 <div class="ar-mods seq">(箭头画在空隙里);挨着箭头的层别用 ar-group'
|
|
464
|
+
case 'dgsmall': return `正文约 ${it.px}px,画幅 ${it.vw} 宽:贴进 Word(16 厘米宽)只有约 ${it.pt} 磅,看不清。正文放大到 ${it.need}px 左右(diagram.css 的字整体放大:.dg-page { --dg-scale: … }),或者把画幅改窄;放不下就删减、拆成两张图——加大画幅字一样小`
|
|
463
465
|
default: return ''
|
|
464
466
|
}
|
|
465
467
|
}
|
package/lib/picker.js
CHANGED
|
@@ -3475,8 +3475,9 @@ 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)
|
|
3480
3481
|
|
|
3481
3482
|
issues.sort((x, y) => y.sev - x.sev)
|
|
3482
3483
|
const se0 = se()
|
|
@@ -3638,6 +3639,18 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
3638
3639
|
const span = num(el, '--span', 1)
|
|
3639
3640
|
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
3641
|
}
|
|
3642
|
+
// 架构图两层之间的一排箭头:每个箭头都得落在上下两层的某个模块上(个数对不上、层里塞了占位的横箭头、模块分了组,都会连偏)
|
|
3643
|
+
let off = 0
|
|
3644
|
+
for (const link of document.querySelectorAll('.dg.ar .ar-main > .dg-links > .dg-link')) {
|
|
3645
|
+
if (off >= 3) break
|
|
3646
|
+
const row = link.parentElement
|
|
3647
|
+
const mods = [row.previousElementSibling, row.nextElementSibling]
|
|
3648
|
+
.filter((x) => x && x.classList.contains('ar-layer'))
|
|
3649
|
+
.map((x) => [...x.querySelectorAll(':scope > .ar-mods > :not(.dg-link)')].map((m) => m.getBoundingClientRect()))
|
|
3650
|
+
if (!mods.length || !shown(link)) continue
|
|
3651
|
+
const r = link.getBoundingClientRect(), cx = r.left + r.width / 2
|
|
3652
|
+
if (mods.some((list) => !list.some((m) => cx >= m.left && cx <= m.right))) { add('dglink', link, {}, 2); off++ }
|
|
3653
|
+
}
|
|
3641
3654
|
// 节点字太多:只算节点自己的字,<small> 里的补充不算。汉字算 1 个,字母、数字算半个
|
|
3642
3655
|
const MAX = [['.dg.mm .mm-node', 16], ['.dg.tr .tr-box', 28], ['.dg.rm .rm-bar', 24], ['.dg.ar .ar-mod', 16]]
|
|
3643
3656
|
let long = 0
|
|
@@ -3654,6 +3667,38 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
3654
3667
|
}
|
|
3655
3668
|
}
|
|
3656
3669
|
|
|
3670
|
+
/**
|
|
3671
|
+
* 图表的字偏小:按字数取正文字号的中位数,比画幅宽 ÷ 100 还小就提醒。
|
|
3672
|
+
* 图贴进 Word 会缩到页宽(约 16 厘米 = 453 磅),画幅 1600 宽、正文 14px 只剩 4 磅
|
|
3673
|
+
*/
|
|
3674
|
+
/** SVG 里的字(含 foreignObject 里的)按 viewBox 缩放到屏幕上才是真字号:取屏幕变换的缩放倍数,不在 SVG 里的是 1 */
|
|
3675
|
+
function svgScale(el) {
|
|
3676
|
+
const g = typeof SVGElement === 'function' && el instanceof SVGElement ? el : el.closest && el.closest('foreignObject')
|
|
3677
|
+
const m = g && typeof g.getScreenCTM === 'function' ? g.getScreenCTM() : null
|
|
3678
|
+
const k = m ? Math.sqrt(Math.abs(m.a * m.d - m.b * m.c)) : 1
|
|
3679
|
+
return k > 0 && isFinite(k) ? k : 1
|
|
3680
|
+
}
|
|
3681
|
+
|
|
3682
|
+
function smallTextCheck(add, vw) {
|
|
3683
|
+
const sizes = []
|
|
3684
|
+
let total = 0
|
|
3685
|
+
const tw = document.createTreeWalker(document.body || document.documentElement, NodeFilter.SHOW_TEXT)
|
|
3686
|
+
for (let n = tw.nextNode(); n; n = tw.nextNode()) {
|
|
3687
|
+
const s = n.nodeValue.replace(/\s+/g, '')
|
|
3688
|
+
const el = n.parentElement
|
|
3689
|
+
if (!s || !el || /^(SCRIPT|STYLE|NOSCRIPT|TEMPLATE|TITLE)$/i.test(el.tagName) || hiddenChain(el) || !el.getClientRects().length) continue
|
|
3690
|
+
const fs = parseFloat(getComputedStyle(el).fontSize) * svgScale(el)
|
|
3691
|
+
if (!(fs > 0)) continue
|
|
3692
|
+
sizes.push([fs, s.length])
|
|
3693
|
+
total += s.length
|
|
3694
|
+
}
|
|
3695
|
+
if (total < 20 || !(vw > 0)) return
|
|
3696
|
+
sizes.sort((a, b) => a[0] - b[0])
|
|
3697
|
+
let acc = 0, med = 0
|
|
3698
|
+
for (const [fs, c] of sizes) { acc += c; if (acc * 2 >= total) { med = fs; break } }
|
|
3699
|
+
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)
|
|
3700
|
+
}
|
|
3701
|
+
|
|
3657
3702
|
/**
|
|
3658
3703
|
* 伪元素在屏幕上的框(量不到它自己,按算出来的样式推):
|
|
3659
3704
|
* - 绝对 / 固定定位:算出来的 left / top / 宽高摆进包含块;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
0. **新做一套设计:先问清,先出方向**。
|
|
10
10
|
|
|
11
|
-
-
|
|
11
|
+
- **什么时候跳过**:改已有的设计;做图表(思维导图、路线图、架构图:内容就是需求,不出三个方向,内容没给够只问缺的那部分;但申报书、结题报告那种几块互相支撑的框架图、模式图、技术路线图、架构图,第一次新画时先列「逻辑骨架」请用户确认再画(原文给得再全、带了参考图也要问;改已有的图不用),见 `references/diagram.md`「先理逻辑,确认了再画」);用户说了「直接做」「不用问」;或者需求已经够具体——**说了做什么,又列了要哪几屏(幻灯片列了页数或每页内容)就算够具体**,给谁用、什么风格没说也不问,按场景你来定。这时不问、也不出三个方向,第一句话说清你按什么理解开工(「按运动能量风格做首页、详情、购物车三屏」),直接从第 1 步做全套。只有连做什么都说不清时才问,而且只问缺的那一两项。
|
|
12
12
|
|
|
13
13
|
- **问**:只问最关键的两三个问题,一次问完:给谁用、想要什么感觉(给三个具体选项,从工作台的风格卡里挑最合场景的三个,见下面「风格卡」一节)、有没有必须有的内容或品牌色。有 `ask_user_question` 工具就用它问(带选项),没有就在回复里问完、停下等回答。用户说「你定」就按场景替他定。
|
|
14
14
|
- **用户有默认的品牌设计系统**(这份技能末尾「设计系统」一节写着):感觉已经定了,照那一节做,不问感觉、不推风格卡。
|