dsh-design-studio 0.25.0 → 0.25.1

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/lib/client.js CHANGED
@@ -862,6 +862,12 @@ window.__ModuleLoader__.load({
862
862
  shGh: '投稿要有 GitHub 账号',
863
863
  shTip: '交上去的东西是公开的:别人能看、能拿去用。先查一遍,过了就能投。',
864
864
  shName: '名字',
865
+ shCats: '分类(选 1–2 个)',
866
+ shTags: '标签(可选,最多 8 个)',
867
+ shLang: '设计里的文字',
868
+ shLangZh: '中文',
869
+ shLangEn: '英文',
870
+ shLangBoth: '中英都有',
865
871
  shDesc: '一句话介绍',
866
872
  shDescPh: '比如:街角茶饮店的三屏点单 App',
867
873
  shAgreeOwn: '是我自己(或用设计台)做的,图片都是自己做的或 CC0 / 公有领域',
@@ -1733,6 +1739,12 @@ window.__ModuleLoader__.load({
1733
1739
  shGh: 'You need a GitHub account to submit',
1734
1740
  shTip: 'What you share is public: anyone can see and reuse it. It is checked first; once it passes you can submit it.',
1735
1741
  shName: 'Name',
1742
+ shCats: 'Category (pick 1–2)',
1743
+ shTags: 'Tags (optional, up to 8)',
1744
+ shLang: 'Text in the design',
1745
+ shLangZh: 'Chinese',
1746
+ shLangEn: 'English',
1747
+ shLangBoth: 'Both',
1736
1748
  shDesc: 'One-line description',
1737
1749
  shDescPh: 'e.g. A three-screen ordering app for a corner tea shop',
1738
1750
  shAgreeOwn: 'I made it (or the design studio did); all images are mine or CC0 / public domain',
@@ -2719,6 +2731,11 @@ window.__ModuleLoader__.load({
2719
2731
  .ddp-pack .lic input{flex:none;margin:3px 0 0;accent-color:${ACCENT}}
2720
2732
  .ddp-share .tip.gh{display:flex;align-items:center;gap:6px;margin-bottom:0;color:var(--dsw-alias-label-primary);font-weight:500}
2721
2733
  .ddp-share .tip.gh svg{width:14px;height:14px;flex:none;color:${ACCENT}}
2734
+ .ddp-share .chips{display:flex;flex-wrap:wrap;gap:6px}
2735
+ .ddp-share .chips button{height:26px;padding:0 10px;border:1px solid var(--dsw-alias-separator-primary,rgba(127,127,127,.3));border-radius:13px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;cursor:pointer}
2736
+ .ddp-share .chips button:hover:not(:disabled){color:var(--dsw-alias-label-primary)}
2737
+ .ddp-share .chips button.on{border-color:${ACCENT};background:rgba(77,107,254,.12);color:${ACCENT}}
2738
+ .ddp-share .chips button:disabled{opacity:.45;cursor:default}
2722
2739
  .ddp-share .agree{display:flex;flex-direction:column;gap:2px;margin-top:10px}
2723
2740
  .ddp-share .agree label{display:flex;align-items:flex-start;gap:8px;padding:5px 8px;border-radius:8px;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.5;cursor:pointer}
2724
2741
  .ddp-share .agree label:hover{color:var(--dsw-alias-label-primary)}
@@ -7935,6 +7952,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7935
7952
  const [desc, setDesc] = useState('')
7936
7953
  const [lic, setLic] = useState('CC0-1.0')
7937
7954
  const [agree, setAgree] = useState({})
7955
+ const [cats, setCats] = useState([]) // 分类、标签:从市场词表里选(机器人按同一份词表查)
7956
+ const [tags, setTags] = useState([])
7957
+ const [dlang, setDlang] = useState('') // 设计里的文字是哪种语言
7938
7958
  const [res, setRes] = useState(null)
7939
7959
  const [busy, setBusy] = useState(false)
7940
7960
  const packSeq = useRef(0) // 每次查、每次换作品都加一:晚到的回包对不上就不认(不然 B 的面板会拿到 A 的包去投)
@@ -7950,6 +7970,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7950
7970
  setDesc('')
7951
7971
  setLic('CC0-1.0')
7952
7972
  setAgree({})
7973
+ setCats([])
7974
+ setTags([])
7975
+ setDlang('')
7953
7976
  if (!root) return undefined
7954
7977
  let on = true
7955
7978
  const my = packSeq.current
@@ -7959,18 +7982,25 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7959
7982
  if (!edited.current.title) setTitle(d.title && d.title !== baseName(root) ? d.title : brand || d.title || '')
7960
7983
  if (!edited.current.desc) setDesc(d.description || '')
7961
7984
  if (!edited.current.lic) setLic(d.license === 'CC-BY-4.0' ? 'CC-BY-4.0' : 'CC0-1.0')
7985
+ if (!edited.current.cats) setCats(Array.isArray(d.categories) ? d.categories : [])
7986
+ if (!edited.current.tags) setTags(Array.isArray(d.tags) ? d.tags : [])
7987
+ if (!edited.current.dlang) setDlang(['zh', 'en', 'both'].includes(d.designLang) ? d.designLang : L)
7962
7988
  }, (e) => { if (on && packSeq.current === my) setInfo({ error: e.message }) })
7963
7989
  return () => { on = false }
7964
7990
  }, [root])
7965
7991
  // 预填回来之前不能查(不然用的是没对上这一套的表单)
7966
- const ready = !!root && !!info && !!title.trim() && !!desc.trim() && SHARE_AGREE.every(([k]) => agree[k])
7992
+ const voc = { categories: (info && info.vocab && Array.isArray(info.vocab.categories) && info.vocab.categories) || [], tags: (info && info.vocab && Array.isArray(info.vocab.tags) && info.vocab.tags) || [] }
7993
+ const ready = !!root && !!info && !!title.trim() && !!desc.trim() && (!voc.categories.length || cats.length > 0) && SHARE_AGREE.every(([k]) => agree[k])
7994
+ // 点一下选上、再点取消;选满了别的点不动
7995
+ const toggle = (set, key, max) => (id) => { edited.current[key] = true; set((cur) => (cur.includes(id) ? cur.filter((x) => x !== id) : cur.length < max ? [...cur, id] : cur)) }
7996
+ const chips = (k, list, set, max) => h('div', { key: k + 'c', className: 'chips', role: 'group', 'aria-label': t(k === 'categories' ? 'shCats' : 'shTags') }, ...voc[k].map((x) => h('button', { key: x.id, type: 'button', className: list.includes(x.id) ? 'on' : '', 'aria-pressed': list.includes(x.id), disabled: busy || (!list.includes(x.id) && list.length >= max), onClick: () => toggle(set, k === 'categories' ? 'cats' : 'tags', max)(x.id) }, L === 'en' ? x.en : x.zh)))
7967
7997
  const go = async () => {
7968
7998
  const my = ++packSeq.current
7969
7999
  setBusy(true)
7970
8000
  setRes(null)
7971
8001
  setLost(false)
7972
8002
  let r
7973
- try { r = await post('pack', { session: sid, dir: root, share: true, title: title.trim(), description: desc.trim(), license: lic, agree, lang: L }) } catch (e) { r = { error: e.message } }
8003
+ try { r = await post('pack', { session: sid, dir: root, share: true, title: title.trim(), description: desc.trim(), categories: cats, tags, designLang: dlang || L, license: lic, agree, lang: L }) } catch (e) { r = { error: e.message } }
7974
8004
  if (packSeq.current !== my) return
7975
8005
  setRes(r)
7976
8006
  setBusy(false)
@@ -8075,6 +8105,12 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8075
8105
  h('input', { key: 'ni', className: 'who', value: title, maxLength: 24, disabled: busy, 'aria-label': t('shName'), onChange: (e) => { edited.current.title = true; setTitle(e.target.value) } }),
8076
8106
  h('h4', { key: 'd' }, t('shDesc')),
8077
8107
  h('input', { key: 'di', className: 'who', value: desc, maxLength: 120, disabled: busy, placeholder: t('shDescPh'), 'aria-label': t('shDesc'), onChange: (e) => { edited.current.desc = true; setDesc(e.target.value) } }),
8108
+ voc.categories.length ? h('h4', { key: 'c' }, t('shCats')) : null,
8109
+ voc.categories.length ? chips('categories', cats, setCats, 2) : null,
8110
+ voc.tags.length ? h('h4', { key: 'tg' }, t('shTags')) : null,
8111
+ voc.tags.length ? chips('tags', tags, setTags, 8) : null,
8112
+ h('h4', { key: 'lg' }, t('shLang')),
8113
+ h('div', { key: 'lgc', className: 'chips', role: 'radiogroup', 'aria-label': t('shLang') }, ...[['zh', 'shLangZh'], ['en', 'shLangEn'], ['both', 'shLangBoth']].map(([k, label]) => h('button', { key: k, type: 'button', role: 'radio', 'aria-checked': (dlang || L) === k, className: (dlang || L) === k ? 'on' : '', disabled: busy, onClick: () => { edited.current.dlang = true; setDlang(k) } }, t(label)))),
8078
8114
  h('h4', { key: 'l' }, t('pkLicense')),
8079
8115
  h('div', { key: 'li', className: 'lic' }, ...[['CC0-1.0', 'pkCC0'], ['CC-BY-4.0', 'pkBY']].map(([k, label]) => h('label', { key: k, className: lic === k ? 'on' : '' },
8080
8116
  h('input', { type: 'radio', name: 'ddp-shlic', checked: lic === k, disabled: busy, onChange: () => { edited.current.lic = true; setLic(k) } }), h('span', null, t(label))))),
@@ -419,6 +419,14 @@ export function createMarket({
419
419
  && !isRevoked(e, s))
420
420
  }
421
421
 
422
+ /** 投稿表单用的分类 / 标签词表(目录或自带种子里的;都没有就空着,表单不显示这两栏) */
423
+ function vocab() {
424
+ const c = current()
425
+ const md = c && c.index && c.index.metadata
426
+ const list = (a) => (Array.isArray(a) ? a.filter((x) => x && typeof x.id === 'string' && /^[a-z0-9-]{2,24}$/.test(x.id)).slice(0, 200).map((x) => ({ id: x.id, zh: String(x.zh || x.id).slice(0, 24), en: String(x.en || x.id).slice(0, 40) })) : [])
427
+ return { categories: list(md && md.categories), tags: list(md && md.tags) }
428
+ }
429
+
422
430
  /** 给界面的目录:三类条目 + 词表 + 状态 */
423
431
  function view() {
424
432
  const c = current()
@@ -641,5 +649,5 @@ export function createMarket({
641
649
  return r === base || r.startsWith(base + path.sep) || r.startsWith(path.resolve(stageDir) + path.sep)
642
650
  }
643
651
 
644
- return { fetchPackage, view, refresh, maybeRefresh, abort, entry, thumbFile, stage, shotFile, strictHtml, isStaging, state, url: (e) => e.submission || `${REPO_URL}/tree/main/${e.type === 'system' ? 'systems' : e.type === 'style' ? 'styles' : 'templates'}/${e.id}` }
652
+ return { fetchPackage, view, vocab, refresh, maybeRefresh, abort, entry, thumbFile, stage, shotFile, strictHtml, isStaging, state, url: (e) => e.submission || `${REPO_URL}/tree/main/${e.type === 'system' ? 'systems' : e.type === 'style' ? 'styles' : 'templates'}/${e.id}` }
645
653
  }
@@ -84,7 +84,7 @@ function metaExtra(html) {
84
84
  * 包的清单:有 design.json 就在它的基础上补(屏列表以现在目录里的为准,顺序先照清单),没有就从页面里读出来
85
85
  * screens:listScreens 排好的顶层页面文件名;htmls:文件名 → 内容
86
86
  */
87
- export function buildManifest({ existing = null, screens, htmls, version = '', license = '', author = '', title = '', description = '', shareHash = '' }) {
87
+ export function buildManifest({ existing = null, screens, htmls, version = '', license = '', author = '', title = '', description = '', categories, tags, designLang, shareHash = '' }) {
88
88
  const m = existing && typeof existing === 'object' && !Array.isArray(existing) ? { ...existing } : {}
89
89
  const first = htmls.get(screens[0]) || ''
90
90
  const kinds = screens.map((f) => metaKind(htmls.get(f) || '')).filter(Boolean)
@@ -107,6 +107,9 @@ export function buildManifest({ existing = null, screens, htmls, version = '', l
107
107
  }),
108
108
  }
109
109
  for (const k of ['style', 'categories', 'tags', 'lang', 'dark', 'assets']) if (m[k] !== undefined) out[k] = m[k]
110
+ // 分享表单这次选的分类、标签、语言(传了就以它为准;空列表 = 不要了)
111
+ for (const [k, v] of [['categories', categories], ['tags', tags]]) if (Array.isArray(v)) { if (v.length) out[k] = v; else delete out[k] }
112
+ if (designLang) out.lang = designLang
110
113
  out.license = license || m.license || 'CC0-1.0'
111
114
  // 署名:这次填了名字就用它;没填沿用清单里原来的(从市场装的模板改的,原作者在 derivedFrom 里,不在这)
112
115
  const who = oneLine(author, 40)
@@ -244,7 +247,7 @@ export function stripMeta(buf, ext) {
244
247
  * 打包前的全部步骤。screens:要打进包的屏(顺序就是包里的顺序)
245
248
  * 返回 { ok, errors: [{ code, x, line, msg, sev }], flags, notes: [自动修了什么], skipped, manifest, files: [{ path, data }] }
246
249
  */
247
- export function packDesign(root, { screens, version = '', license = '', author = '', mode = 'zip', lang = 'zh', title = '', description = '', shareHash = '', secrets = [] }) {
250
+ export function packDesign(root, { screens, version = '', license = '', author = '', mode = 'zip', lang = 'zh', title = '', description = '', categories, tags, designLang, shareHash = '', secrets = [] }) {
248
251
  const { files: picked, skipped, tooBig } = collectDesign(root)
249
252
  const notes = []
250
253
  const errors = []
@@ -297,7 +300,7 @@ export function packDesign(root, { screens, version = '', license = '', author =
297
300
  else { skipped.push(f.path); dropped.add(f.path.toLowerCase()); files.splice(i, 1) }
298
301
  }
299
302
  const order = screens.filter((s) => htmls.has(s))
300
- const manifest = buildManifest({ existing, screens: order, htmls, version, license, author, title, description, shareHash })
303
+ const manifest = buildManifest({ existing, screens: order, htmls, version, license, author, title, description, categories, tags, designLang, shareHash })
301
304
  if (dropped.size && Array.isArray(manifest.assets)) manifest.assets = manifest.assets.filter((x) => !(x && typeof x.path === 'string' && dropped.has(String(cleanPath(x.path) || x.path).toLowerCase())))
302
305
  files.unshift({ path: 'design.json', data: Buffer.from(JSON.stringify(manifest, null, 2) + '\n', 'utf8') })
303
306
  const r = checkPack(files, { mode })
@@ -61,7 +61,16 @@ const SVG_ANIM = new Set(['set', 'animate', 'animatetransform', 'animatemotion',
61
61
 
62
62
  // ── 可疑字(只标出来给人看,不直接拒) ────────────────────────────────────────
63
63
  const PHISH = /登录|登陆|密码|验证码|银行卡|身份证|转账|汇款|客服|中奖|领取奖|充值|提现|\b(log ?in|sign ?in|password|passcode|verification code|bank card|credit card|wire transfer|account number|cvv)\b/i
64
- const BRANDS = /微信支付|支付宝|淘宝|天猫|京东|拼多多|抖音|快手|美团|饿了么|小红书|哔哩哔哩|bilibili|微博|知乎|百度|腾讯|阿里巴巴|字节跳动|中国银行|工商银行|建设银行|农业银行|招商银行|交通银行|邮政储蓄|中国移动|中国联通|中国电信|12306|\b(apple|icloud|google|gmail|microsoft|outlook|paypal|amazon|netflix|facebook|instagram|whatsapp|wechat|alipay|taobao|tiktok|steam|binance|coinbase)\b/i
64
+ // 真实品牌(只是初筛提醒,人工审核兜底):日常词(小米、苹果、大众、美的、联想、全家、三星、统一、光明…)不放;
65
+ // 短名会藏在常见词里的(精华为、内蒙牛肉、适宜家庭、完美团队、北京东路…)排除前后字;撞得太多的(盒马、宝马、索尼、安踏)只认全称 / 英文名
66
+ const BRANDS = new RegExp([
67
+ '微信支付|支付宝|淘宝(?![贝藏])|(?<![今每昨明当])天猫(?![咪粮砂])|(?<![北南])京东|拼多多|抖音|快手(?=直播|小店|短视频|视频|主播|账号|号|粉丝|平台|电商|极速版|带货|官方|app|$|[^\u4e00-\u9fff])|(?<![完精甜唯])美团(?![队建圆])|(?<![你我他她们子宝])饿了么|小红书|哔哩哔哩|微博|知乎|(?<![一二两三四五六七八九十几])百度|腾讯|阿里巴巴|字节跳动|网易(?=[云严游新邮考有])|爱奇艺|优酷|飞书|企业微信|携程|飞猪|(?<![休悠])闲鱼|唯品会|苏宁易购|大众点评|高德地图|滴滴出行|12306',
68
+ '中国银行|工商银行|建设银行|农业银行|招商银行|交通银行|邮政储蓄|中国移动|中国联通|中国电信',
69
+ '胖东来|盒马鲜生|山姆会员店|沃尔玛|永辉超市|(?<![合阖])家乐福|大润发|名创优品|优衣库|无印良品|(?<![居室便适皆相合不咸])宜家|屈臣氏|丝芙兰|叮咚买菜',
70
+ '星巴克|瑞幸咖啡|(?<![祥嘉])瑞幸(?![福运])|(?<![欢恭贺道惊双大])喜茶|奈雪的茶|蜜雪冰城|霸王茶姬|茶百道|海底捞(?!针)|麦当劳|肯德基|必胜客|汉堡王|农夫山泉|元气森林|娃哈哈|可口可乐|百事可乐|雀巢|(?<![内启])蒙牛|康师傅|茅台|五粮液|青岛啤酒|三只松鼠|良品铺子',
71
+ '(?<![升精才年荣中风光芳繁奢豪浮京韶清])华为|比亚迪|蔚来|小鹏汽车|理想汽车|特斯拉|大疆|任天堂|迪士尼|耐克|阿迪达斯',
72
+ '\\b(bilibili|apple|icloud|google|gmail|youtube|microsoft|outlook|linkedin|paypal|mastercard|amazon|netflix|spotify|facebook|instagram|whatsapp|twitter|wechat|alipay|taobao|tiktok|steam|binance|coinbase|starbucks|mcdonald\'?s|kfc|coca-?cola|pepsi|nike|adidas|uniqlo|ikea|costco|walmart|samsung|huawei|xiaomi|tesla|disney|airbnb|uber|bmw|sony|luckin)\\b',
73
+ ].join('|'), 'i')
65
74
  const INJECT = /忽略(之前|以上|前面|上面|先前)|无视(之前|以上|前面)|不要理会|你(现在)?是一个|你的新(任务|指令)|系统提示|提示词|\b(ignore (all |any )?(the )?(previous|prior|above|earlier)|disregard (all |the )?(previous|prior|above)|system prompt|you are now|new instructions|developer mode|jailbreak)\b|\b(preview_page|check_design|look_design|handoff_design|compare_design|extract_design_system|show_page|run_command|write_file|edit_file|read_file|ask_user_question|bash|shell)\b|rm -rf|\bsudo\b|\bcurl\s+-|\bwget\s|\|\s*(ba)?sh\b|powershell|chmod\s|\bnpm (i|install)\b|\bpip install\b/i
66
75
  const URLISH = /\bhttps?:\/\/|\bwww\.[a-z0-9-]+\.|\b[a-z0-9-]+\.(com|cn|net|org|io|xyz|top|cc|me|co|app|dev|site|shop|vip|info)\b/i
67
76
  const PERSONAL_MAIL = /@(qq|163|126|yeah|sina|sohu|139|189|foxmail|aliyun|gmail|googlemail|outlook|hotmail|live|msn|yahoo|icloud|me|mac|proton|protonmail)\.(com|cn|net|com\.cn)\b/i
@@ -56,6 +56,7 @@ function manifestTitle(dir) {
56
56
  return t && typeof t === 'object' ? String(t.zh || t.en || '').slice(0, 40) : ''
57
57
  }
58
58
  const TOKEN_RE = /^[0-9a-f]{32}$/
59
+ const DESIGN_LANGS = ['zh', 'en', 'both'] // design.json 的 lang:设计里的文字是哪种语言
59
60
  /** 分享记号 → 目录里的指纹(sha256 前 32 位)和给人看的短号 */
60
61
  export const shareHashOf = (token) => crypto.createHash('sha256').update(String(token)).digest('hex').slice(0, 32)
61
62
  function shareOf(dir) {
@@ -105,7 +106,7 @@ export function describeWork(w) {
105
106
  return { ...base, title: manifestTitle(dir) || product || w.title || path.basename(dir), kind, screens: screens.length, first: screens[0] || '', updated: Math.round(updated || w.updated || w.seen || 0), thumb: sig ? crypto.createHash('sha1').update(sig).digest('hex').slice(0, 10) : '' }
106
107
  }
107
108
 
108
- export function createLibraryRoutes({ admit, readBody, json, tracker, library, inspiration, studio, open, storeLoad, version = '', exported, log = () => {}, thumbDir = THUMB_DIR, downloads = path.join(os.homedir(), 'Downloads'), sessionCwd = async (id) => tracker.cwdOf(id), render = renderPack, github = createGitHub({ log }) }) {
109
+ export function createLibraryRoutes({ admit, readBody, json, tracker, library, inspiration, studio, open, storeLoad, version = '', exported, log = () => {}, thumbDir = THUMB_DIR, downloads = path.join(os.homedir(), 'Downloads'), sessionCwd = async (id) => tracker.cwdOf(id), render = renderPack, github = createGitHub({ log }), vocab = () => ({ categories: [], tags: [] }) }) {
109
110
  const lang = (body) => (body && body.lang === 'en' ? 'en' : 'zh')
110
111
  // 这次运行里「分享到市场」打出来的包(一键投稿只投这些):zip 路径 → { ref, slug, title, license }
111
112
  const shared = new Map()
@@ -210,6 +211,15 @@ export function createLibraryRoutes({ admit, readBody, json, tracker, library, i
210
211
  fs.createReadStream(file).on('error', () => res.end()).pipe(res)
211
212
  }
212
213
 
214
+ // 分类、标签只收词表里有的(机器人按同一份词表查,不在里面会被拒);没传就沿用 design.json 里原来的
215
+ const vocabNow = () => { try { const v = vocab() || {}; return { categories: Array.isArray(v.categories) ? v.categories : [], tags: Array.isArray(v.tags) ? v.tags : [] } } catch { return { categories: [], tags: [] } } }
216
+ function shareMeta(body) {
217
+ const v = vocabNow()
218
+ // 词表拿不到(没联网也没种子):这两栏表单里不显示,design.json 里原来的留着
219
+ const ids = (k, max) => (Array.isArray(body[k]) && v[k].length ? [...new Set(body[k].filter((x) => typeof x === 'string' && v[k].some((y) => y.id === x)))].slice(0, max) : undefined)
220
+ return { categories: ids('categories', 2), tags: ids('tags', 8), designLang: DESIGN_LANGS.includes(body.designLang) ? body.designLang : undefined }
221
+ }
222
+
213
223
  async function pack(req, res) {
214
224
  if (!admit(req, res)) return
215
225
  if (req.method !== 'POST') return json(res, 405, { error: 'method not allowed' })
@@ -226,7 +236,9 @@ export function createLibraryRoutes({ admit, readBody, json, tracker, library, i
226
236
  // 分享向导先要一份预填:名字、介绍、授权、分享过没有
227
237
  if (body.info === true) {
228
238
  const pick = (v) => (v && typeof v === 'object' ? String(v[lang(body)] || v.zh || v.en || '') : '')
229
- return json(res, 200, { title: pick(local && local.title) || manifestTitle(dir) || path.basename(dir), description: pick(local && local.description), license: local && local.license === 'CC-BY-4.0' ? 'CC-BY-4.0' : 'CC0-1.0', share: shareOf(dir), screens: screens.length })
239
+ const v = vocabNow()
240
+ const known = (k, max) => (local && Array.isArray(local[k]) ? local[k].filter((x) => v[k].some((y) => y.id === x)).slice(0, max) : [])
241
+ return json(res, 200, { title: pick(local && local.title) || manifestTitle(dir) || path.basename(dir), description: pick(local && local.description), license: local && local.license === 'CC-BY-4.0' ? 'CC-BY-4.0' : 'CC0-1.0', share: shareOf(dir), screens: screens.length, categories: known('categories', 2), tags: known('tags', 8), designLang: local && DESIGN_LANGS.includes(local.lang) ? local.lang : '', vocab: v })
230
242
  }
231
243
  const license = body.license === 'CC-BY-4.0' ? 'CC-BY-4.0' : 'CC0-1.0'
232
244
  // 分享到市场:四个确认都要勾;分享记号第一次分享时生成,存在作者自己的 design.json 里,包里只带它的指纹
@@ -236,7 +248,7 @@ export function createLibraryRoutes({ admit, readBody, json, tracker, library, i
236
248
  const shareHash = token ? shareHashOf(token) : ''
237
249
  let p
238
250
  try {
239
- p = packDesign(dir, { screens, version, license, author: license === 'CC-BY-4.0' ? String(body.author || '') : '', mode: share ? 'share' : 'zip', lang: lang(body), title: share ? String(body.title || '') : '', description: share ? String(body.description || '') : '', shareHash, secrets: [token, local && local.shareToken].filter(Boolean) })
251
+ p = packDesign(dir, { screens, version, license, author: license === 'CC-BY-4.0' ? String(body.author || '') : '', mode: share ? 'share' : 'zip', lang: lang(body), title: share ? String(body.title || '') : '', description: share ? String(body.description || '') : '', ...(share ? shareMeta(body) : {}), shareHash, secrets: [token, local && local.shareToken].filter(Boolean) })
240
252
  } catch (e) {
241
253
  log(e)
242
254
  return json(res, 500, { error: e.message })
package/lib/index.js CHANGED
@@ -1577,7 +1577,7 @@ export function apply(ctx) {
1577
1577
  } catch (e) { log(e) }
1578
1578
  return known
1579
1579
  }
1580
- const lib = createLibraryRoutes({ admit, readBody, json, tracker, library, inspiration, studio, open, storeLoad: fileStore.load, version: VERSION, exported, log, sessionCwd })
1580
+ const lib = createLibraryRoutes({ admit, readBody, json, tracker, library, inspiration, studio, open, storeLoad: fileStore.load, version: VERSION, exported, log, sessionCwd, vocab: () => market.vocab() })
1581
1581
  // 画布上睡着的屏的缩略图(issue #17)
1582
1582
  const canvasThumbs = createCanvasThumbs({
1583
1583
  tracker,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-design-studio",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test --test-concurrency=1 test/*.mjs"