dsh-design-studio 0.25.0 → 0.25.2
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 +43 -2
- package/lib/gallery/market.js +9 -1
- package/lib/gallery/pack.js +6 -3
- package/lib/gallery/policy.js +10 -1
- package/lib/gallery/routes.js +15 -3
- package/lib/index.js +1 -1
- package/lib/styles.js +24 -6
- package/package.json +1 -1
- package/skills/ui-design/SKILL.md +1 -1
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)}
|
|
@@ -3794,10 +3811,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
3794
3811
|
// 「北欧风」「清新风:首页…」「中国风的界面」算说了风格;先去掉「通风」「台风」「新风系统」「风控」「风景」这类不是风格的词
|
|
3795
3812
|
const NOT_STYLE_FENG = /通风|台风|新风(系统|机|量)|风险|风控|风景|风扇|风味|风暴|风光|风速|风向|风筝|风铃|风车|吹风|防风|挡风|避风|屏风|旋风|狂风|微风|寒风|疾风|顺风|逆风|作风|中风|风湿|风水/g
|
|
3796
3813
|
const SAID_STYLE = /风格|配色|色调|主色|色系|[红橙黄绿青蓝紫粉黑白灰棕金银米]色|蓝白|黑白|黑金|红白|绿白|深色|浅色|暗色|亮色|[^\s。,,、::;;((]风|\b(style|styled|aesthetic|vibe|palette|colou?r scheme|look and feel|dark|light)\b/i
|
|
3814
|
+
// 像申报书、开题 / 结题报告那种图就不附风格卡(默认用 diagram.css 的「申报书炫酷样式」);模型调 pick_style 时卡和这条一起给,由模型照原话判断。规则和 lib/styles.js 的 isProposal 一样
|
|
3815
|
+
const PROPOSAL = /申报|课题|开题|结题|基金|申请书|教学成果|育人模式|人才培养方案|研究框架|研究思路|\b(grant|research|thesis) proposals?\b|\bgrant applications?\b/i
|
|
3816
|
+
const DIAGRAM_WORD = /图|路线|框架|架构|\b(diagrams?|roadmaps?|frameworks?|charts?)\b/i
|
|
3817
|
+
const isProposal = (s, kind) => PROPOSAL.test(s) && (kind === 'diagram' || (!kind && DIAGRAM_WORD.test(s)))
|
|
3797
3818
|
function autoStyle(text, kind) {
|
|
3798
3819
|
const s = String(text || '')
|
|
3799
3820
|
if (!s.trim()) return null
|
|
3800
3821
|
if (kind === 'dshplugin' || kind === 'framed') return null // DSH 插件默认用 DSH 自己的样子(外框的 --dsh-* 变量),不替它挑风格卡
|
|
3822
|
+
if (isProposal(s, kind)) return null // 申报书那种图默认用炫酷样式,不挑风格卡
|
|
3801
3823
|
const said = s.replace(NOT_STYLE_FENG, ' ')
|
|
3802
3824
|
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
|
|
3803
3825
|
const by = (id) => STYLES.find((x) => x.id === id) || null
|
|
@@ -7935,6 +7957,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7935
7957
|
const [desc, setDesc] = useState('')
|
|
7936
7958
|
const [lic, setLic] = useState('CC0-1.0')
|
|
7937
7959
|
const [agree, setAgree] = useState({})
|
|
7960
|
+
const [cats, setCats] = useState([]) // 分类、标签:从市场词表里选(机器人按同一份词表查)
|
|
7961
|
+
const [tags, setTags] = useState([])
|
|
7962
|
+
const [dlang, setDlang] = useState('') // 设计里的文字是哪种语言
|
|
7938
7963
|
const [res, setRes] = useState(null)
|
|
7939
7964
|
const [busy, setBusy] = useState(false)
|
|
7940
7965
|
const packSeq = useRef(0) // 每次查、每次换作品都加一:晚到的回包对不上就不认(不然 B 的面板会拿到 A 的包去投)
|
|
@@ -7950,6 +7975,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7950
7975
|
setDesc('')
|
|
7951
7976
|
setLic('CC0-1.0')
|
|
7952
7977
|
setAgree({})
|
|
7978
|
+
setCats([])
|
|
7979
|
+
setTags([])
|
|
7980
|
+
setDlang('')
|
|
7953
7981
|
if (!root) return undefined
|
|
7954
7982
|
let on = true
|
|
7955
7983
|
const my = packSeq.current
|
|
@@ -7959,18 +7987,25 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7959
7987
|
if (!edited.current.title) setTitle(d.title && d.title !== baseName(root) ? d.title : brand || d.title || '')
|
|
7960
7988
|
if (!edited.current.desc) setDesc(d.description || '')
|
|
7961
7989
|
if (!edited.current.lic) setLic(d.license === 'CC-BY-4.0' ? 'CC-BY-4.0' : 'CC0-1.0')
|
|
7990
|
+
if (!edited.current.cats) setCats(Array.isArray(d.categories) ? d.categories : [])
|
|
7991
|
+
if (!edited.current.tags) setTags(Array.isArray(d.tags) ? d.tags : [])
|
|
7992
|
+
if (!edited.current.dlang) setDlang(['zh', 'en', 'both'].includes(d.designLang) ? d.designLang : L)
|
|
7962
7993
|
}, (e) => { if (on && packSeq.current === my) setInfo({ error: e.message }) })
|
|
7963
7994
|
return () => { on = false }
|
|
7964
7995
|
}, [root])
|
|
7965
7996
|
// 预填回来之前不能查(不然用的是没对上这一套的表单)
|
|
7966
|
-
const
|
|
7997
|
+
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) || [] }
|
|
7998
|
+
const ready = !!root && !!info && !!title.trim() && !!desc.trim() && (!voc.categories.length || cats.length > 0) && SHARE_AGREE.every(([k]) => agree[k])
|
|
7999
|
+
// 点一下选上、再点取消;选满了别的点不动
|
|
8000
|
+
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)) }
|
|
8001
|
+
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
8002
|
const go = async () => {
|
|
7968
8003
|
const my = ++packSeq.current
|
|
7969
8004
|
setBusy(true)
|
|
7970
8005
|
setRes(null)
|
|
7971
8006
|
setLost(false)
|
|
7972
8007
|
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 } }
|
|
8008
|
+
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
8009
|
if (packSeq.current !== my) return
|
|
7975
8010
|
setRes(r)
|
|
7976
8011
|
setBusy(false)
|
|
@@ -8075,6 +8110,12 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8075
8110
|
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
8111
|
h('h4', { key: 'd' }, t('shDesc')),
|
|
8077
8112
|
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) } }),
|
|
8113
|
+
voc.categories.length ? h('h4', { key: 'c' }, t('shCats')) : null,
|
|
8114
|
+
voc.categories.length ? chips('categories', cats, setCats, 2) : null,
|
|
8115
|
+
voc.tags.length ? h('h4', { key: 'tg' }, t('shTags')) : null,
|
|
8116
|
+
voc.tags.length ? chips('tags', tags, setTags, 8) : null,
|
|
8117
|
+
h('h4', { key: 'lg' }, t('shLang')),
|
|
8118
|
+
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
8119
|
h('h4', { key: 'l' }, t('pkLicense')),
|
|
8079
8120
|
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
8121
|
h('input', { type: 'radio', name: 'ddp-shlic', checked: lic === k, disabled: busy, onChange: () => { edited.current.lic = true; setLic(k) } }), h('span', null, t(label))))),
|
package/lib/gallery/market.js
CHANGED
|
@@ -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
|
}
|
package/lib/gallery/pack.js
CHANGED
|
@@ -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 })
|
package/lib/gallery/policy.js
CHANGED
|
@@ -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
|
-
|
|
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
|
package/lib/gallery/routes.js
CHANGED
|
@@ -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
|
-
|
|
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/lib/styles.js
CHANGED
|
@@ -134,10 +134,20 @@ export const AUTO_SPREAD = ['minimal', 'editorial', 'playful', 'fresh', 'tech',
|
|
|
134
134
|
// 「北欧风」「清新风:首页…」「中国风的界面」算说了风格;先去掉「通风」「台风」「新风系统」「风控」「风景」这类不是风格的词
|
|
135
135
|
export const NOT_STYLE_FENG = /通风|台风|新风(系统|机|量)|风险|风控|风景|风扇|风味|风暴|风光|风速|风向|风筝|风铃|风车|吹风|防风|挡风|避风|屏风|旋风|狂风|微风|寒风|疾风|顺风|逆风|作风|中风|风湿|风水/g
|
|
136
136
|
export const SAID_STYLE = /风格|配色|色调|主色|色系|[红橙黄绿青蓝紫粉黑白灰棕金银米]色|蓝白|黑白|黑金|红白|绿白|深色|浅色|暗色|亮色|[^\s。,,、::;;((]风|\b(style|styled|aesthetic|vibe|palette|colou?r scheme|look and feel|dark|light)\b/i
|
|
137
|
+
// 申报书、开题 / 结题报告那种图:默认用 diagram.css 的「申报书炫酷样式」fx-*,不按题材挑风格卡(不然「社区阅读推广」会被「阅读」挑成杂志风)。
|
|
138
|
+
// 这里只粗看「像不像」:像就首页不附卡,模型调 pick_style 时卡和「申报书图用炫酷样式」一起给,由模型照原话判断(「个税申报流程图」照用卡),猜错也只是多调一次
|
|
139
|
+
export const PROPOSAL = /申报|课题|开题|结题|基金|申请书|教学成果|育人模式|人才培养方案|研究框架|研究思路|\b(grant|research|thesis) proposals?\b|\bgrant applications?\b/i
|
|
140
|
+
export const DIAGRAM_WORD = /图|路线|框架|架构|\b(diagrams?|roadmaps?|frameworks?|charts?)\b/i
|
|
141
|
+
/** 像不像申报书那种图:类型选了「图表」,或者没选类型、话里说了要画图 */
|
|
142
|
+
export function isProposal(text, kind) {
|
|
143
|
+
const s = String(text || '')
|
|
144
|
+
return PROPOSAL.test(s) && (kind === 'diagram' || (!kind && DIAGRAM_WORD.test(s)))
|
|
145
|
+
}
|
|
137
146
|
export function autoStyle(text, kind) {
|
|
138
147
|
const s = String(text || '')
|
|
139
148
|
if (!s.trim()) return null
|
|
140
149
|
if (kind === 'dshplugin' || kind === 'framed') return null // DSH 插件默认用 DSH 自己的样子(外框的 --dsh-* 变量),不替它挑风格卡
|
|
150
|
+
if (isProposal(s, kind)) return null // 申报书那种图默认用炫酷样式,不挑风格卡
|
|
141
151
|
const said = s.replace(NOT_STYLE_FENG, ' ')
|
|
142
152
|
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
|
|
143
153
|
return topicStyle(s, kind)
|
|
@@ -188,17 +198,25 @@ export function pickStyles(subject, kind, count = 1) {
|
|
|
188
198
|
return out
|
|
189
199
|
}
|
|
190
200
|
|
|
201
|
+
// 像申报书那种图时 pick_style 回复的开头:卡照给,由模型照原话判断用不用
|
|
202
|
+
const PROPOSAL_NOTE = {
|
|
203
|
+
zh: '先看用户要的是什么图:申报书、开题报告、结题报告、教学成果奖、人才培养方案里的框架图、模式图、路线图(技术路线图、研究流程图、研究框架图、育人模式图这类)不用下面的风格卡,默认用申报书炫酷样式——照 references/diagram.md「申报书炫酷样式 fx-*」做(部件都在 diagram.css 里,深浅色、导出、字号都调好了);这时别把下面卡的配色和字体写进 tokens.css,开工第一句说用的是「申报书炫酷样式」。用户要素净、黑白印刷、投期刊论文就照用户的;用户定了风格或配色,定了的那部分照用户的。别的(报告里的统计图、讲申请或审核手续怎么办的流程图,或者网页、海报、幻灯片)照下面的风格卡做。',
|
|
204
|
+
en: `First check what the user wants: a framework, model or roadmap diagram for a grant / research proposal, a research project's opening or final report, a teaching-achievement award or a training program (research roadmap, research workflow, research framework and the like) does not use the style card below; use the proposal style by default: follow references/diagram.md, section "申报书炫酷样式 fx-*" (the parts are in diagram.css, with light/dark, export and font sizes already tuned). In that case do not copy the card's colors and fonts into tokens.css, and say in your first sentence that you are using the proposal style. If the user wants it plain, black-and-white for print, or for a journal paper, follow the user; if the user already named a style or colors, keep what they named. Anything else (data charts in a report, flowcharts of an application or review procedure, or a web page, poster or slides) uses the style card below.`,
|
|
205
|
+
}
|
|
206
|
+
|
|
191
207
|
/** pick_style 工具的返回文字 */
|
|
192
208
|
export function pickStyleText(subject, kind, count = 1) {
|
|
193
209
|
const en = !/[一-鿿]/.test(String(subject))
|
|
210
|
+
const head = isProposal(subject, kind) ? (en ? PROPOSAL_NOTE.en : PROPOSAL_NOTE.zh) + '\n\n' : '' // 像申报书那种图:先说清什么时候不用卡,卡照给
|
|
211
|
+
const els = head ? (en ? 'For the kinds that use the card' : '照卡做的那类') : (en ? 'Otherwise' : '否则') // 有开头那段时,收尾只管照卡做的那类,别和开头打架
|
|
194
212
|
const list = pickStyles(subject, kind, count)
|
|
195
213
|
const cards = list.map((x, i) => (list.length > 1 ? `${en ? 'Direction' : '方向'} ${'ABC'[i]}: ` : '') + cardText(x, en)).join('\n\n')
|
|
196
214
|
if (list.length > 1) {
|
|
197
|
-
return en
|
|
198
|
-
? `${cards}\n\nIf the user already chose a specific style or colors, follow them and do not use these cards.
|
|
199
|
-
: `${cards}\n\n
|
|
215
|
+
return head + (en
|
|
216
|
+
? `${cards}\n\nIf the user already chose a specific style or colors, follow them and do not use these cards. ${els}: each direction keeps its own colors and fonts: write the variables inside that page's own <style>. Create the shared tokens.css only after the user has chosen. Do not swap them for a beige or cream look. Say briefly what style each direction is.`
|
|
217
|
+
: `${cards}\n\n用户已经定了具体风格或配色的话,照用户的来,不用这些卡。${els}:每个方向用各自的配色和字体,变量写在各自页面的 <style> 里;用户挑定以后再建公共的 tokens.css。别换成米色、奶油底。用一两句话说清每个方向是什么风格。`)
|
|
200
218
|
}
|
|
201
|
-
return en
|
|
202
|
-
? `${cards}\n\nIf the user already chose a specific style or colors, follow them and do not use this card.
|
|
203
|
-
: `${cards}\n\n
|
|
219
|
+
return head + (en
|
|
220
|
+
? `${cards}\n\nIf the user already chose a specific style or colors, follow them and do not use this card. ${els}: put these colors and fonts into tokens.css first and build the whole set with them. Do not swap them for a beige or cream look. In your first sentence, tell the user which style you are using; it is easy to change if they do not like it.`
|
|
221
|
+
: `${cards}\n\n用户已经定了具体风格或配色的话,照用户的来,不用这张卡。${els}:先把这些配色和字体定进 tokens.css,整套照它做,别换成米色、奶油底。第一句话告诉用户用的是哪个风格,不喜欢可以换。`)
|
|
204
222
|
}
|
package/package.json
CHANGED
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
|
|
165
165
|
## 风格卡
|
|
166
166
|
|
|
167
|
-
用户没定具体风格时(消息里没有〔风格〕,也没说具体的风格或配色;只说「你定」「帮我推荐一个」「出几个风格挑」都算没定),**开工前先调 `pick_style`**:`subject` 写用户的原话,`kind` 写类型;要先出三个方向时 `count` 填 3,每个方向一张,变量写在各自页面里,用户挑定后才建 tokens.css;只做一套就照返回的配色和字体定进 tokens.css
|
|
167
|
+
用户没定具体风格时(消息里没有〔风格〕,也没说具体的风格或配色;只说「你定」「帮我推荐一个」「出几个风格挑」都算没定),**开工前先调 `pick_style`**:`subject` 写用户的原话,`kind` 写类型;要先出三个方向时 `count` 填 3,每个方向一张,变量写在各自页面里,用户挑定后才建 tokens.css;只做一套就照返回的配色和字体定进 tokens.css。开工第一句点名(「风格:运动能量」)。别跳过它自己定,自己定基本都会落回米色。申报书、开题 / 结题报告里的框架图、模式图、路线图例外:不挑风格卡,默认用 `references/diagram.md` 的「申报书炫酷样式」;报告里的统计图照常调 `pick_style`。
|
|
168
168
|
|
|
169
169
|
下面这张表是换卡用的:用户说不喜欢,就按题材另挑一张。**换卡也先按题材往下挑,别先想米色**:米色暖调的四张(温暖手作、奶油风、日系原木、中式雅致)只在用户点名,或题材离不开(手作、烘焙、茶馆、书店)时才用;民宿、餐饮、电商、SaaS、金融、运动、活动这些题材都有更合适的卡。
|
|
170
170
|
|