dsh-design-studio 0.21.0 → 0.23.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
@@ -44,6 +44,7 @@ If DSH can't reach the npm registry, it falls back to a mirror in China. To upda
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
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
@@ -44,6 +44,7 @@
44
44
  - **版本和对比**:每轮自动存一版,左右拖动对比,随时回到任意一版。
45
45
  - **导出和手机上看**:导出展示图、PDF、PPT(屏和屏之间的跳转照样能点);扫码在手机上按真机尺寸看。页面比默认画幅大的幻灯片、海报,画幅自动跟页面走;也可以在类型后面跟 `宽x高` 指定,比如 `<meta name="dsh-design" content="slides 1440x810">`。导出选项里可以选版面(16:9、4:3、A3 横向、自定义)、每页取景(一屏、整页、指定高度)和每页拼 2 屏;有内容会被裁时,导出前先给一张清单,可以一键按内容改画幅。
46
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/browser.js CHANGED
@@ -11,7 +11,7 @@ import os from 'node:os'
11
11
  import path from 'node:path'
12
12
  import { spawn, execFile } from 'node:child_process'
13
13
 
14
- const IDLE_MS = 90000 // 闲置多久关掉
14
+ const IDLE_MS = 30000 // 闲置多久关掉(#21:原来 90 秒,活动监视器里 Chrome Helper 挂太久;再开一次约 1 秒)
15
15
  const CALL_MS = 30000 // 一条指令最多等多久
16
16
  const CLOSE_MS = 600 // 让浏览器自己关,最多等多久再强杀
17
17
  const LOAD_MS = 15000 // 页面载入最多等多久(到点照样往下走:有个图一直载不完也能量)
@@ -54,7 +54,7 @@ const PREFIX = 'dsh-design-browser-'
54
54
  const STALE_MS = 3600 * 1000 // 一小时没动过的临时用户目录:上回没删掉的(DSH 被强退、插件进程直接退出)
55
55
  let swept = false
56
56
 
57
- /** 清掉以前留下的临时用户目录(每个进程只扫一次;正在用的浏览器闲置 90 秒就关,不会一小时不动) */
57
+ /** 清掉以前留下的临时用户目录(每个进程只扫一次;正在用的浏览器闲置 30 秒就关,不会一小时不动) */
58
58
  function sweep(dir = os.tmpdir(), now = Date.now()) {
59
59
  if (swept) return
60
60
  swept = true
@@ -210,9 +210,9 @@ export function createBrowser({ bin = findBrowser(), log = () => {}, idleMs = ID
210
210
  stop()
211
211
  }
212
212
 
213
- const touch = () => {
213
+ const touch = (ms = idleMs) => {
214
214
  clearTimeout(idle)
215
- if (!open) idle = setTimeout(() => { if (!open) stop() }, idleMs)
215
+ if (!open) idle = setTimeout(() => { if (!open) stop() }, ms)
216
216
  }
217
217
 
218
218
  /**
@@ -223,7 +223,7 @@ export function createBrowser({ bin = findBrowser(), log = () => {}, idleMs = ID
223
223
  * allow(网址):给了就只让它说行的页面载入(主页面、iframe,连跳转、脚本改地址都算),别的拦下,记在 page.blocked
224
224
  * offline:断网渲染(设计库的检查):所有请求(样式、图片、字体、接口 …)只放行和页面同源的,别的一律拦下,记在 page.blocked
225
225
  */
226
- async function withPage({ url, w, h, scale = 1, dark = false, allow = null, offline = false }, fn) {
226
+ async function withPage({ url, w, h, scale = 1, dark = false, allow = null, offline = false, linger = idleMs }, fn) {
227
227
  if (dead) throw new Error('browser closed')
228
228
  if (open >= MAX_PAGES) await new Promise((r) => queue.push(r))
229
229
  if (dead) throw new Error('browser closed')
@@ -317,7 +317,7 @@ export function createBrowser({ bin = findBrowser(), log = () => {}, idleMs = ID
317
317
  open--
318
318
  const next = queue.shift()
319
319
  if (next) next()
320
- touch()
320
+ touch(Math.min(linger, idleMs)) // 后台活(画布缩略图)可以要求早点关
321
321
  }
322
322
  }
323
323
 
package/lib/canvthumb.js CHANGED
@@ -172,7 +172,7 @@ export function createCanvasThumbs({ tracker, browser, trust = () => '', strictR
172
172
  const b = browser()
173
173
  if (!b || !b.available()) throw new Error('no browser')
174
174
  let title = ''
175
- const jpg = await b.withPage({ url: o.url, w: o.w, h: o.h, scale: Math.min(1, WIDTH / o.w), dark: o.dark, offline: strictRoot(o.root) }, async (page) => {
175
+ const jpg = await b.withPage({ url: o.url, w: o.w, h: o.h, scale: Math.min(1, WIDTH / o.w), dark: o.dark, offline: strictRoot(o.root), linger: 10000 }, async (page) => {
176
176
  const { info } = await prepare(page, o.dark)
177
177
  title = cut(String((info && info.title) || '').replace(/\s+/g, ' ').trim(), 80)
178
178
  return page.shot({ quality: 72 })