dsh-design-studio 1.0.2 → 1.1.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
@@ -42,6 +42,7 @@ If DSH can't reach the npm registry, it falls back to a mirror in China. To upda
42
42
  - **Click to edit:** click an element or drag over an area, and a small chip lands in the input (hover it for details); just add how to change it. Markup, style changes, style cards and check lists land as chips too, not walls of text. The model still gets the full location and styles. Changed spots flash in the preview. You can also draw circles, arrows and notes right on the page and hand the marked-up screenshot to the model, or copy it to paste elsewhere. Adjust style can apply a change to every screen at once, and when you edit a design by hand in the sidebar, the model is told before its next step so it won't undo your edits.
43
43
  - **Open what you have:** home + › Open HTML… picks an HTML file, or drop an HTML file or folder onto the sidebar (desktop app); you can also type a path or a dev-server port.
44
44
  - **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.
45
+ - **Clickable prototypes:** back arrows marked `data-back` go back to wherever you came from; the different looks of one page (empty list, with data, paid) are states in one file instead of extra screens, switchable next to the screen name on the canvas, and checked and exported state by state. The design check also points out a shared part that is styled differently on different screens (#30).
45
46
  - **Versions and compare:** every turn is saved; drag a slider to compare, and go back to any version.
46
47
  - **Export and share:** Export makes showcase images, PDF and PowerPoint (links between screens still work), and designs with hundreds of screens export in full (up to 1000). Share has a clickable HTML demo that opens with a double-click (device frame included, ready to send to a client), a temporary public link (beta; opens in WeChat or any browser, closes after 2 hours), and 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.
47
48
  - **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.
package/README.md CHANGED
@@ -42,6 +42,7 @@
42
42
  - **点一下就改**:点元素或框一块区域,输入框里出现一个小标签(悬停看详情),你只要补一句怎么改;标注、调样式、风格、体检清单这些放进输入框的也都是小标签,不再是一大段字;发出去模型拿到完整的位置和样式。改过的地方在预览里闪一下。也能直接在页面上画圈、画箭头、写字,拼成一张图交给模型,或者复制下来贴到别处。调样式可以「各屏一起改」;你在右侧栏亲手改过的地方,模型下一步会先知道,不会改回去。
43
43
  - **打开已有的页面**:首页输入框左边的「+」→「打开 HTML…」选一个,或把 HTML 文件 / 文件夹拖进右侧栏就能预览(桌面版);也能输路径或开发服务器端口。
44
44
  - **设计体检**:一键查文字溢出、对比度不够、按钮太小、字太小,问题直接标在页面上;模型做完也会自己查一遍再改。
45
+ - **点得动的原型**:返回按钮写上 `data-back` 就「从哪来回哪去」;同一个页面的几种样子(空列表 / 有数据 / 已付款)写成状态,不用另做一屏,画布上屏名旁边就能切,体检、导出每个状态都算;共用部件在各屏写得不一样时,体检会提醒(#30)。
45
46
  - **版本和对比**:每轮自动存一版,左右拖动对比,随时回到任意一版。
46
47
  - **导出和分享**:标题栏「导出」出展示图、PDF、PPT(屏和屏之间的跳转照样能点),几百屏的设计也全部导出(最多 1000 屏);「分享」里有双击就能开的 HTML 演示(带外壳、点得动,发给客户直接看)、临时公网链接(实验,微信里点开就能看,2 小时自动关),扫码在手机上按真机尺寸看。页面比默认画幅大的幻灯片、海报,画幅自动跟页面走;也可以在类型后面跟 `宽x高` 指定,比如 `<meta name="dsh-design" content="slides 1440x810">`。导出选项里可以选版面(16:9、4:3、A3 横向、自定义)、每页取景(一屏、整页、指定高度)和每页拼 2 屏;有内容会被裁时,导出前先给一张清单,可以一键按内容改画幅。
47
48
  - **图表**:思维导图、技术路线图(申报书、开题报告那种)、产品路线图、系统架构图。连线、分叉、箭头自动排好,改字、加节点自己重排;配色跟着设计风格走,导出高清 PNG 或 PDF 贴进 Word / PPT。申报书、结题报告的框架图先帮你理清「哪个问题对应哪项内容」请你确认再画,版块之间画出带关系词的箭头;默认是立体渐变的「申报书炫酷样式」,也能照你给的参考图画。
package/lib/canvthumb.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 画布上睡着的屏的缩略图(issue #17):屏多时画布只挂离镜头近的 LIVE_MAX 屏,别的屏先放一张无头浏览器截的图,挪近了再换成真页面。
3
3
  *
4
- * GET scrthumb ?session=&root=&key=&w=&h=&dark= → JPEG(取不到 404 / 503,页面上照旧显示「挪近就加载」)。响应头:
4
+ * GET scrthumb ?session=&root=&key=&w=&h=&dark=&state= → JPEG(state:一页多状态 #30,画布上这屏切到的状态)(取不到 404 / 503,页面上照旧显示「挪近就加载」)。响应头:
5
5
  * X-Dsh-Title 页面标题;X-Dsh-Thumb 这张图的名字(同一张页面就不换);X-Dsh-Recheck 目录没在监听(改了不会通知)时,过几秒再来要
6
6
  * GET verthumb ?session=&n=&key=&w=&h=&dark= → 旧版本里某一屏的 JPEG(1.0 版本面板的卡片)。存下的版本不会再变,按「版本号 + 存的时间」缓存,不用看文件
7
7
  *
@@ -17,6 +17,7 @@ import fs from 'node:fs'
17
17
  import os from 'node:os'
18
18
  import path from 'node:path'
19
19
  import { prepare } from './look.js'
20
+ import { STATE_RE, withState } from './states.js'
20
21
 
21
22
  export const THUMB_DIR = path.join(os.homedir(), '.dsh', 'cache', 'dsh-design-studio', 'canvas')
22
23
  const WIDTH = 480 // 截出来最宽多少像素:睡着的屏都是缩得很小的时候看的
@@ -211,7 +212,7 @@ export function createCanvasThumbs({ tracker, browser, trust = () => '', strictR
211
212
 
212
213
  /** 这屏的缩略图 { file, title }(要截就排队)。onLeave 交出「这个请求不等了」的回调 */
213
214
  function thumb(o, onLeave) {
214
- const id = sha1([path.resolve(o.root), o.key, o.w, o.h, o.dark ? 1 : 0, ...(o.v ? [`v${o.v}@${o.at}`] : [])].join('\0')).slice(0, 20)
215
+ const id = sha1([path.resolve(o.root), o.key, o.w, o.h, o.dark ? 1 : 0, ...(o.v ? [`v${o.v}@${o.at}`] : []), ...(o.state ? [`s:${o.state}`] : [])].join('\0')).slice(0, 20)
215
216
  const stamp = o.v ? 'v' : stampOf(o) // 文件没了这里就抛
216
217
  const file = path.join(dir, `${id}-${stamp}.jpg`)
217
218
  if (fs.existsSync(file)) return Promise.resolve({ file, title: titleOf(file) })
@@ -249,6 +250,7 @@ export function createCanvasThumbs({ tracker, browser, trust = () => '', strictR
249
250
  if (t.root !== root) return json(res, 404, { error: 'design changed' })
250
251
  const sc = (snap.screens || []).find((x) => x.key === key)
251
252
  if (!sc || !HTML_RE.test(key)) return json(res, 404, { error: 'no such screen' })
253
+ const state = STATE_RE.test(q.get('state') || '') ? q.get('state') : ''
252
254
  const b = browser()
253
255
  if (!b || !b.available()) return json(res, 503, { error: 'no browser' })
254
256
  let got
@@ -256,7 +258,7 @@ export function createCanvasThumbs({ tracker, browser, trust = () => '', strictR
256
258
  try {
257
259
  // 先整张读进来再回:拿到路径和读之间,这张可能刚被同一屏的新图顶掉删了,那就再要一次(这回给的是新的)
258
260
  for (let i = 0; i < 2 && !buf; i++) {
259
- got = await thumb({ root: t.root, key, url: sc.url, w, h, dark: q.get('dark') === '1' }, (leave) => res.on('close', leave))
261
+ got = await thumb({ root: t.root, key, url: state ? withState(sc.url, state) : sc.url, state, w, h, dark: q.get('dark') === '1' }, (leave) => res.on('close', leave))
260
262
  try { buf = await fs.promises.readFile(got.file) } catch (e) { if (e.code !== 'ENOENT') throw e }
261
263
  }
262
264
  } catch (e) {