foliko 1.1.7 → 1.1.8
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/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/.agent/ARCHITECTURE.md +288 -0
- package/.agent/agents/ambient-agent.md +57 -0
- package/.agent/agents/debugger.md +55 -0
- package/.agent/agents/email-assistant.md +49 -0
- package/.agent/agents/file-manager.md +42 -0
- package/.agent/agents/python-developer.md +60 -0
- package/.agent/agents/scheduler.md +59 -0
- package/.agent/agents/web-developer.md +45 -0
- package/.agent/data/default.json +412 -3
- package/.agent/data/plugins-state.json +172 -173
- package/.agent/data/puppeteer-sessions/undefined.json +6 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775618677512.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619073340.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619097536.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619209388.jpg +0 -0
- package/.agent/mcp_config.json +11 -3
- package/.agent/memory/feedback/mnrdvj5i-ca3dkd.md +9 -0
- package/.agent/memory/feedback/mnre365e-7s4zax.md +9 -0
- package/.agent/memory/feedback/mnre36jn-nkfgmp.md +9 -0
- package/.agent/memory/feedback/mnre3805-kjiq6h.md +9 -0
- package/.agent/memory/feedback/mnsf66kp-b10rcd.md +9 -0
- package/.agent/memory/feedback/mnsi3sz8-p5g2cw.md +9 -0
- package/.agent/memory/feedback/mnsibe47-sv2ni1.md +9 -0
- package/.agent/memory/feedback/mnsic89w-nn228o.md +9 -0
- package/.agent/memory/feedback/mnsj1xe9-x83ba0.md +9 -0
- package/.agent/memory/feedback/mnsj21iv-wnwelx.md +9 -0
- package/.agent/memory/feedback/mnsj2g4a-cog7a2.md +9 -0
- package/.agent/memory/feedback/mnsj4js7-lktjp6.md +9 -0
- package/.agent/memory/feedback/mnsj5d4y-uglwvp.md +9 -0
- package/.agent/memory/feedback/mnslkuo9-uous66.md +24 -0
- package/.agent/memory/feedback/mnsm3vq0-megoil.md +9 -0
- package/.agent/memory/feedback/mnsnn5x2-sxcihd.md +9 -0
- package/.agent/memory/feedback/mnsnq17s-nabrn9.md +9 -0
- package/.agent/memory/feedback/mnsnybet-wz7rn3.md +9 -0
- package/.agent/memory/feedback/mnsrw0s7-7s9e30.md +9 -0
- package/.agent/memory/feedback/mnu5hpnd-tlm16q.md +9 -0
- package/.agent/memory/feedback/mnu60uqe-xuoxp4.md +9 -0
- package/.agent/memory/project/mnqx54u5-loqtoe.md +9 -0
- package/.agent/memory/project/mnqx84cv-mx6dmd.md +9 -0
- package/.agent/memory/project/mnsacuyr-hgtk5n.md +20 -0
- package/.agent/memory/project/mnu5hy2x-bjsg7u.md +9 -0
- package/.agent/memory/reference/mnre3cww-penbo1.md +9 -0
- package/.agent/memory/reference/mns9wn48-luerua.md +14 -0
- package/.agent/memory/reference/mns9yz5c-thc2s0.md +16 -0
- package/.agent/memory/reference/mnsfy4um-910f1o.md +23 -0
- package/.agent/memory/reference/mnsg37dp-lmfj18.md +32 -0
- package/.agent/memory/reference/mnsll60q-0j911u.md +36 -0
- package/.agent/memory/reference/mnsmlb5y-nej31u.md +16 -0
- package/.agent/memory/reference/mnssle72-yrot96.md +9 -0
- package/.agent/memory/user/mnsfuon6-l416q1.md +21 -0
- package/.agent/memory/user/mnsg9kut-95m7rf.md +20 -0
- package/.agent/memory/user/mnu2eo1v-yy6fhe.md +9 -0
- package/.agent/memory/user/mnu2etuo-8u8jk8.md +9 -0
- package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts/Symbola_hint.ttf +0 -0
- package/.agent/plugins/poster-plugin/package.json +3 -3
- package/.agent/plugins/poster-plugin/src/canvas.js +8 -0
- package/.agent/plugins/poster-plugin/src/components/barcode.js +5 -2
- package/.agent/plugins/poster-plugin/src/components/bubble.js +3 -2
- package/.agent/plugins/poster-plugin/src/components/button.js +74 -30
- package/.agent/plugins/poster-plugin/src/components/columns.js +97 -83
- package/.agent/plugins/poster-plugin/src/components/grid.js +104 -92
- package/.agent/plugins/poster-plugin/src/components/highlightText.js +2 -1
- package/.agent/plugins/poster-plugin/src/components/imageFrame.js +143 -93
- package/.agent/plugins/poster-plugin/src/components/quote.js +85 -13
- package/.agent/plugins/poster-plugin/src/components/ribbon.js +13 -9
- package/.agent/plugins/poster-plugin/src/components/seal.js +5 -3
- package/.agent/plugins/poster-plugin/src/components/star.js +3 -3
- package/.agent/plugins/poster-plugin/src/components/table.js +1 -1
- package/.agent/plugins/poster-plugin/src/components/watermark.js +4 -2
- package/.agent/plugins/poster-plugin/src/composer.js +181 -13
- package/.agent/plugins/poster-plugin/src/elements/artText.js +16 -7
- package/.agent/plugins/poster-plugin/src/elements/background.js +20 -5
- package/.agent/plugins/poster-plugin/src/elements/richText.js +160 -107
- package/.agent/plugins/poster-plugin/src/elements/text.js +48 -45
- package/.agent/plugins/poster-plugin/src/fonts.js +556 -125
- package/.agent/plugins/poster-plugin/src/index.js +46 -1
- package/.agent/plugins/poster-plugin/yarn.lock +186 -356
- package/.agent/plugins/puppeteer-plugin/README.md +147 -0
- package/.agent/plugins/puppeteer-plugin/index.js +1422 -0
- package/.agent/plugins/puppeteer-plugin/package.json +9 -0
- package/.agent/plugins.json +5 -11
- package/.agent/rules/GEMINI.md +273 -0
- package/.agent/rules/allow-rule.md +77 -0
- package/.agent/rules/log-rule.md +83 -0
- package/.agent/rules/security-rule.md +93 -0
- package/.agent/scripts/auto_preview.py +148 -0
- package/.agent/scripts/checklist.py +217 -0
- package/.agent/scripts/session_manager.py +120 -0
- package/.agent/scripts/verify_all.py +327 -0
- package/.agent/sessions/cli_default.json +122 -689
- package/.agent/skills/api-patterns/SKILL.md +81 -0
- package/.agent/skills/api-patterns/api-style.md +42 -0
- package/.agent/skills/api-patterns/auth.md +24 -0
- package/.agent/skills/api-patterns/documentation.md +26 -0
- package/.agent/skills/api-patterns/graphql.md +41 -0
- package/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/response.md +37 -0
- package/.agent/skills/api-patterns/rest.md +40 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/api-patterns/security-testing.md +122 -0
- package/.agent/skills/api-patterns/trpc.md +41 -0
- package/.agent/skills/api-patterns/versioning.md +22 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +40 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/.agent/skills/architecture/SKILL.md +55 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/clean-code/SKILL.md +201 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/frontend-design/SKILL.md +418 -0
- package/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/color-system.md +311 -0
- package/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/.agent/skills/frontend-design/typography-system.md +345 -0
- package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/poster-design/SKILL.md +385 -0
- package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/.agent/workflows/brainstorm.md +113 -0
- package/.agent/workflows/create.md +59 -0
- package/.agent/workflows/debug.md +103 -0
- package/.agent/workflows/deploy.md +176 -0
- package/.agent/workflows/enhance.md +63 -0
- package/.agent/workflows/orchestrate.md +237 -0
- package/.agent/workflows/plan.md +89 -0
- package/.agent/workflows/preview.md +81 -0
- package/.agent/workflows/simple-test.md +42 -0
- package/.agent/workflows/status.md +86 -0
- package/.agent/workflows/structured-orchestrate.md +180 -0
- package/.agent/workflows/test.md +144 -0
- package/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/.claude/settings.local.json +1 -2
- package/.env.example +56 -56
- package/README.md +441 -441
- package/output/foliko-poster.png +0 -0
- package/outputs/emoji-font-showcase.png +0 -0
- package/outputs/foliko-muji-style.png +0 -0
- package/package.json +3 -2
- package/plugins/default-plugins.js +2 -1
- package/plugins/extension-executor-plugin.js +24 -1
- package/plugins/feishu-plugin.js +2 -2
- package/plugins/telegram-plugin.js +2 -2
- package/plugins/weixin-plugin.js +2 -2
- package/skills/find-skills/AGENTS.md +162 -162
- package/skills/find-skills/SKILL.md +133 -133
- package/src/core/agent.js +117 -29
- package/src/executors/mcp-executor.js +282 -26
- package/system.md +719 -570
- package/.agent/agents/code-assistant.json +0 -17
- package/.agent/agents/email-assistant.json +0 -14
- package/.agent/agents/file-assistant.json +0 -18
- package/.agent/agents/orchestrator-demo.md +0 -53
- package/.agent/agents/orchestrator.json +0 -7
- package/.agent/agents/system-assistant.json +0 -15
- package/.agent/agents/web-assistant.json +0 -12
- package/.agent/data/email/processed-emails.json +0 -1
- package/.agent/data/scheduler/tasks.json +0 -1
- package/.agent/data/web/web-config.json +0 -5
- package/.agent/memory/feedback/mnt7jrlt-d67qs7.md +0 -15
- package/.agent/memory/feedback/mnt88ja3-al4fuy.md +0 -9
- package/.agent/package.json +0 -8
- package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
- package/.agent/plugins/daytona/README.md +0 -89
- package/.agent/plugins/daytona/index.js +0 -377
- package/.agent/plugins/daytona/package.json +0 -12
- package/.agent/plugins/marknative/README.md +0 -134
- package/.agent/plugins/marknative/fonts/SegoeUI Emoji.ttf +0 -0
- package/.agent/plugins/marknative/fonts.zip +0 -0
- package/.agent/plugins/marknative/index.js +0 -256
- package/.agent/plugins/marknative/package.json +0 -12
- package/.agent/plugins/poster-plugin/emojis/rocket.png +0 -1
- package/.agent/plugins/poster-plugin/test-background.svg +0 -1
- package/.agent/plugins/poster-plugin/test-full-poster.svg +0 -2
- package/.agent/plugins/poster-plugin/test-image.png +0 -0
- package/.agent/plugins/system-info/index.js +0 -387
- package/.agent/plugins/system-info/package.json +0 -4
- package/.agent/plugins/system-info/test.js +0 -40
- package/.agent/plugins/test-plugin.py +0 -108
- package/.agent/python-scripts/test_sample.py +0 -24
- package/.agent/skills/agent-browser/SKILL.md +0 -311
- package/.agent/skills/agent-browser/TEST_PLAN.md +0 -200
- package/.agent/skills/sysinfo/SKILL.md +0 -38
- package/.agent/skills/sysinfo/system-info.sh +0 -130
- package/.agent/skills/workflow/SKILL.md +0 -324
- package/.agent/test-agent.js +0 -35
- package/.agent/weixin.json +0 -6
- package/.agent/workflows/email-digest.json +0 -50
- package/.agent/workflows/file-backup.json +0 -21
- package/.agent/workflows/get-ip-notify.json +0 -32
- package/.agent/workflows/news-aggregator.json +0 -93
- package/.agent/workflows/news-dashboard-v2.json +0 -94
- package/.agent/workflows/notification-batch.json +0 -32
- package/output/zen_silence.png +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnsnq17s-nabrn9"
|
|
3
|
+
name: "【避免指南】避免在未创建画布时调用get_poster_canvas_info"
|
|
4
|
+
type: "feedback"
|
|
5
|
+
project: "null"
|
|
6
|
+
tags: [error, avoid, poster:get_poster_canvas_info]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
【下次这样做】使用poster插件时,在调用get_poster_canvas_info之前,必须先调用create_poster_canvas创建画布。例如:ext_call({plugin: 'poster', tool: 'create_poster_canvas', args: {preset: 'social'}})。错误原因:No canvas created表示画布不存在,无法获取信息。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnsnybet-wz7rn3"
|
|
3
|
+
name: "避免在导出海报前未创建画布"
|
|
4
|
+
type: "feedback"
|
|
5
|
+
project: "null"
|
|
6
|
+
tags: [error, avoid, poster, export_poster_canvas]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
【下次这样做】在调用 poster:export_poster_canvas 之前必须先调用 poster:create_poster_canvas 创建画布。错误原因:直接调用导出工具时,画布不存在,导致报错 "No canvas created"。正确顺序:1) create_poster_canvas 创建画布 → 2) 添加海报元素(背景、文字、图片等)→ 3) export_poster_canvas 导出图片。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnsrw0s7-7s9e30"
|
|
3
|
+
name: "【避免指南】海报制作前必须先创建画布"
|
|
4
|
+
type: "feedback"
|
|
5
|
+
project: "null"
|
|
6
|
+
tags: [error, avoid, poster, workflow]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
【下次这样做】使用 poster 插件添加元素(如文字、图片等)前,必须先调用 create_poster_canvas 创建画布。错误原因:在未创建画布的情况下直接添加元素,导致插件无法定位目标画布。正确流程:1. 调用 create_poster_canvas 创建画布;2. 调用 add_poster_* 系列函数添加元素;3. 调用 export_poster_canvas 导出海报。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnu5hpnd-tlm16q"
|
|
3
|
+
name: "布局文字比例问题反馈"
|
|
4
|
+
type: "feedback"
|
|
5
|
+
project: "null"
|
|
6
|
+
tags: [海报, 布局, 文字比例, 重制]
|
|
7
|
+
created: "2026-04-11"
|
|
8
|
+
---
|
|
9
|
+
用户反馈之前的布局和文字比例不正确,需要重新制作。Why:布局和文字比例是海报视觉传达的核心要素,比例失调会影响信息传达效果。How to apply:下次制作海报时,先确定整体布局结构,确保文字大小与画布比例协调,标题、副标题、正文的层级比例要分明(建议标题占15-20%,副标题10-15%,正文内容保持足够留白)。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnu60uqe-xuoxp4"
|
|
3
|
+
name: "避免调用不存在的海报组件工具"
|
|
4
|
+
type: "feedback"
|
|
5
|
+
project: "null"
|
|
6
|
+
tags: [error, avoid, poster, barcode]
|
|
7
|
+
created: "2026-04-11"
|
|
8
|
+
---
|
|
9
|
+
【下次这样做】在调用海报插件工具前,先使用 list_poster_components 列出所有可用的组件类型,确认目标工具存在后再调用。错误原因:调用了不存在的工具 add_poster_barcode,可能是误以为存在该功能但实际该工具不在插件支持范围内。建议:使用 compose_poster 或 generate_poster 等已确认存在的工具来实现海报生成需求。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnqx54u5-loqtoe"
|
|
3
|
+
name: "FOLIKO项目核心信息与设计规范"
|
|
4
|
+
type: "project"
|
|
5
|
+
project: "FOLIKO"
|
|
6
|
+
tags: [核心特性, 设计规范, 项目路径, 用户偏好]
|
|
7
|
+
created: "2026-04-09"
|
|
8
|
+
---
|
|
9
|
+
FOLIKO项目核心特性为:插件化架构、多模型支持、流式实时响应。项目路径位于 D:\code\vb-agent\。项目视觉设计规范为:暗色科技风+赛博朋克霓虹(深蓝黑底+青绿渐变+紫色点缀),用户偏好精美且让AI自主决定的设计。Why: 明确项目核心卖点与视觉品牌基调,确保后续内容生成的一致性;记录用户偏好以优化交互体验。How to apply: 涉及FOLIKO的宣传、UI设计时,必须体现三大核心特性,并沿用科技风霓虹配色;对用户采取“直接出精美方案、少问细节”的交互策略。
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnsacuyr-hgtk5n"
|
|
3
|
+
name: "Zod复杂类型schema解析修复"
|
|
4
|
+
type: "project"
|
|
5
|
+
project: "foliko-agent"
|
|
6
|
+
tags: [zod, schema, extension-tools, parameter-table, bugfix]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
agent.js 的 `_fallbackSchemaToText` 方法需要递归处理复杂 Zod 类型(如 `ZodOptional`、`ZodUnion`、`ZodArray` 等)。
|
|
10
|
+
|
|
11
|
+
问题场景:.agent/plugins 下的自定义扩展插件使用复杂 schema(如 `z.union([...])` 或 `z.optional()`)时,`zodSchemaToTable` 无法正确解析,导致显示 "Type: ZodObject" 而非参数表格。
|
|
12
|
+
|
|
13
|
+
解决方案:实现 `_extractFieldType(validator)` 方法,递归检查 `_def.innerType`、`_def.types` 等属性,正确提取字段类型名称。
|
|
14
|
+
|
|
15
|
+
关键代码模式:
|
|
16
|
+
- `ZodOptional` -> 检查 `validator._def.innerType`
|
|
17
|
+
- `ZodUnion` -> 检查 `validator._def.types`
|
|
18
|
+
- `ZodArray` -> 检查 `validator._def.type`
|
|
19
|
+
|
|
20
|
+
参考文件:agent.js 的 `_fallbackSchemaToText` 方法。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnre3cww-penbo1"
|
|
3
|
+
name: "ext_call 参数约束"
|
|
4
|
+
type: "reference"
|
|
5
|
+
project: "null"
|
|
6
|
+
tags: [ext_call, 参数验证, 插件开发]
|
|
7
|
+
created: "2026-04-09"
|
|
8
|
+
---
|
|
9
|
+
ext_call 调用时参数类型有约束:text 参数不能为数字或 null(需要字符串);settle 参数不能为数组(需要字符串如 'USDT')。Why:参数类型错误会导致调用失败,影响插件功能。How to apply:调用前确保参数类型符合规范,字符串参数用 .toLowerCase() 前需确认类型。
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mns9wn48-luerua"
|
|
3
|
+
name: "zodSchemaToTable fallback 机制缺失"
|
|
4
|
+
type: "reference"
|
|
5
|
+
project: "foliko-framework"
|
|
6
|
+
tags: [bug-fix, agent-js, extension-tools, schema-parsing]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
在 `agent.js` 的 `_buildExtensionToolsDescription()` 方法中,当 `zodSchemaToTable(tool.inputSchema)` 无法正确解析 schema(返回 `Type: ZodObject` 或 null)时,应该提供一个 fallback 机制,遍历 `tool.inputSchema.shape` 或 `tool.inputSchema.properties` 来手动构建参数表格,而不是直接显示 "参数信息不可用"。
|
|
10
|
+
|
|
11
|
+
**如何应用**:
|
|
12
|
+
1. 在 agent.js 中添加一个辅助函数 `buildFallbackSchemaTable(schema)`,尝试从 `schema.shape` 或 `schema.properties` 提取参数信息
|
|
13
|
+
2. 在 zodSchemaToTable 返回无效结果时调用此 fallback
|
|
14
|
+
3. 显示参数名、类型、描述(如果有的话)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mns9yz5c-thc2s0"
|
|
3
|
+
name: "agent.js 遗漏 version 字段输出"
|
|
4
|
+
type: "reference"
|
|
5
|
+
project: "null"
|
|
6
|
+
tags: [bug, agent.js, extension-executor, 缺陷修复]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
在 agent.js 的 _buildExtensionToolsDescription 方法中,调用 getExtensions() 后遍历扩展时,输出了 name 和 description,但遗漏了 version 字段。
|
|
10
|
+
|
|
11
|
+
**问题代码位置:** agent.js 第 267 行附近
|
|
12
|
+
**正确做法:** 应添加版本信息输出,例如:sections.push(`**版本:** ${ext.version || '1.0.0'}`, '');
|
|
13
|
+
|
|
14
|
+
**涉及文件:**
|
|
15
|
+
- extension-executor-plugin.js: getExtensions() 方法返回正确结构
|
|
16
|
+
- agent.js: _buildExtensionToolsDescription 方法输出不完整
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnsfy4um-910f1o"
|
|
3
|
+
name: "复古杂志风海报设计规范"
|
|
4
|
+
type: "reference"
|
|
5
|
+
project: "null"
|
|
6
|
+
tags: [海报设计, 复古风格, 杂志风]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
复古杂志风海报设计规范:
|
|
10
|
+
|
|
11
|
+
**Why(为什么重要)**:用户在多次设计中明确选择了复古杂志风格,这表明这可能是一个常用的设计偏好。记录设计规范可以快速复用于未来类似需求。
|
|
12
|
+
|
|
13
|
+
**How to apply(如何使用)**:
|
|
14
|
+
1. 背景:米白色 #F8F6F3
|
|
15
|
+
2. 主色:纯黑 #1A1A1A
|
|
16
|
+
3. 字体:中文用系统默认衬线/无衬线,英文用 Georgia 或 Times New Roman
|
|
17
|
+
4. 布局特点:
|
|
18
|
+
- 左侧粗黑竖线装饰(strokeWidth: 6-8)
|
|
19
|
+
- 超大标题字体(fontSize: 80-120)
|
|
20
|
+
- 粗黑分隔线(strokeWidth: 2-4)
|
|
21
|
+
- 多区块内容排版
|
|
22
|
+
- 可添加斜体英文作为装饰
|
|
23
|
+
5. 风格关键词:极简、复古、杂志感、留白、粗边框分割
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnsg37dp-lmfj18"
|
|
3
|
+
name: "樟木头收容遣送站历史资料"
|
|
4
|
+
type: "reference"
|
|
5
|
+
project: "null"
|
|
6
|
+
tags: [历史, 收容遣送, 樟木头, 无印风格]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
# 樟木头收容遣送站历史资料
|
|
10
|
+
|
|
11
|
+
## 基本信息
|
|
12
|
+
- **成立时间**:1969年
|
|
13
|
+
- **地理位置**:广东省东莞市樟木头镇
|
|
14
|
+
- **设立目的**:安置因各种原因流入城市的无合法身份人员
|
|
15
|
+
|
|
16
|
+
## 收容遣送制度背景
|
|
17
|
+
- 1951年:内务部出台《城市流浪乞讨人员收容遣送办法》
|
|
18
|
+
- 1982年:国务院发布《城市流浪乞讨人员收收容遣送方法》
|
|
19
|
+
- 收容对象:无合法身份、无正当职业、无正当居所人员(即"三无人员")
|
|
20
|
+
|
|
21
|
+
## "名声"
|
|
22
|
+
樟木头收容遣送站曾被称为"二里头"——专收"不该出生的人"。2000年前后,多名被收容者在收容遣送站内非正常死亡,其中最著名的是1998年湖南青年刘二涛案。
|
|
23
|
+
|
|
24
|
+
## 终结
|
|
25
|
+
2003年,大学生孙志刚在广州市收容救治站被殴打致死,引发社会强烈反响。2003年6月20日,温家宝签署国务院令,公布《城市生活无着的流浪乞讨人员救助管理办法》,同年8月1日起正式实施,废止了已实行50余年的收容遣送制度。
|
|
26
|
+
|
|
27
|
+
## 亲历者回忆
|
|
28
|
+
> "樟木头给我的最深印象不是别的,是那里的厕所。进去之后,必须把身上的钱和物品全部掏出来,放在一个托盘里,由管理人员统一保管。"
|
|
29
|
+
> — — 亲历者口述
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
*资料来源:根据相关历史文献整理*
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnsll60q-0j911u"
|
|
3
|
+
name: "Paper.js API: Point 和 Size 参数规范"
|
|
4
|
+
type: "reference"
|
|
5
|
+
project: "foliko-poster-plugin"
|
|
6
|
+
tags: [paper.js, bug-fix, api-usage, poster-plugin]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
**Paper.js 创建图形时 point/size 参数必须使用对象而非数组**
|
|
10
|
+
|
|
11
|
+
**Why 重要:**
|
|
12
|
+
- Paper.js 中 Path.Rectangle、PointText 等图形构造函数的 `point` 参数需要是 `paper.Point` 对象,不是 `[x, y]` 数组
|
|
13
|
+
- `size` 参数需要是 `paper.Size` 对象,不是 `[width, height]` 数组
|
|
14
|
+
- 错误用法不会报错,但图形不会正确渲染
|
|
15
|
+
|
|
16
|
+
**How to apply:**
|
|
17
|
+
```javascript
|
|
18
|
+
// ✅ 正确写法
|
|
19
|
+
new paper.Path.Rectangle({
|
|
20
|
+
point: new paper.Point(x, y),
|
|
21
|
+
size: new paper.Size(width, height)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
new paper.PointText({
|
|
25
|
+
point: new paper.Point(x, y),
|
|
26
|
+
content: 'text'
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// ❌ 错误写法(不会报错但无效)
|
|
30
|
+
new paper.Path.Rectangle({
|
|
31
|
+
point: [x, y],
|
|
32
|
+
size: [width, height]
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**涉及文件:** `.agent/plugins/poster-plugin/components/button.js`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnsmlb5y-nej31u"
|
|
3
|
+
name: "poster 插件参数传递修复"
|
|
4
|
+
type: "reference"
|
|
5
|
+
project: "foliko-poster-plugin"
|
|
6
|
+
tags: [poster, bug-fix, createButton, 参数传递]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
poster 插件组件(如 createButton)调用时注意参数顺序,不要多传内部对象(如 canvas)。
|
|
10
|
+
|
|
11
|
+
**Why**:在 poster 插件中,add_poster_button 等工具调用 createButton 时,如果多传了 canvas 对象作为第一个参数,会导致参数错位,后续参数的坐标、尺寸等数值被当作 canvas 对象处理,最终生成超大错误尺寸的 SVG。
|
|
12
|
+
|
|
13
|
+
**How to apply**:
|
|
14
|
+
- 工具入口层(如 index.js)应直接传递 args 给 createButton:`createButton(project, args)`
|
|
15
|
+
- createButton 内部会自己获取 canvas:`const canvas = this._canvasManager.getCanvas()`
|
|
16
|
+
- 不要在工具入口层传递 canvas 对象
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnssle72-yrot96"
|
|
3
|
+
name: "无印风格历史记录书页模板"
|
|
4
|
+
type: "reference"
|
|
5
|
+
project: "海报设计"
|
|
6
|
+
tags: [无印风格, 极简设计, 历史记录, 书页布局]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
无印风格海报设计规范:采用9:16比例,大量留白,浅灰白背景(#F5F5F5)配合纯黑文字(#1A1A1A),使用微软雅黑字体。布局层次:标题区→副标题→时间线→基本信息网格→亲历者引用块→总结→页底。几何线条分隔,小圆点标记时间节点。
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnsfuon6-l416q1"
|
|
3
|
+
name: "用户海报风格偏好"
|
|
4
|
+
type: "user"
|
|
5
|
+
project: "null"
|
|
6
|
+
tags: [海报设计, 风格偏好, 樟木头历史]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
## 用户海报设计风格偏好
|
|
10
|
+
|
|
11
|
+
### Why (为什么重要)
|
|
12
|
+
用户制作了一个关于「樟木头收容遣送制度」的历史话题海报,倾向使用复古杂志风、极简几何风或国潮山水风。需要在后续设计任务中参考这些风格建议。
|
|
13
|
+
|
|
14
|
+
### How to apply (如何使用)
|
|
15
|
+
当用户再次请求海报设计时:
|
|
16
|
+
1. 先检查记忆中是否有相关偏好
|
|
17
|
+
2. 根据主题选择合适风格:
|
|
18
|
+
- 严肃历史/新闻纪实 → 复古杂志风(留白+衬线+高级感)
|
|
19
|
+
- 中国传统文化 → 国潮山水风(水墨+传统纹样)
|
|
20
|
+
- 简洁有力 → 极简几何风(莫兰迪色系)
|
|
21
|
+
3. 询问用户确认风格后再开始设计
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "mnsg9kut-95m7rf"
|
|
3
|
+
name: "海报设计偏好"
|
|
4
|
+
type: "user"
|
|
5
|
+
project: "null"
|
|
6
|
+
tags: [poster, design, layout, font]
|
|
7
|
+
created: "2026-04-10"
|
|
8
|
+
---
|
|
9
|
+
用户有明确的海报设计偏好:
|
|
10
|
+
|
|
11
|
+
**Why(为什么重要):**
|
|
12
|
+
- 用户明确指定了8层布局结构(标题→副标题→时间线→基本信息→亲历者回忆×2→总结→页底),这表明用户习惯于详细规划海报内容层级
|
|
13
|
+
- 用户偏好特定字体:微软雅黑
|
|
14
|
+
- 用户曾设计历史记录类海报(樟木头收容遣送制度),风格偏向严肃、记录性质
|
|
15
|
+
|
|
16
|
+
**How to apply(如何使用):**
|
|
17
|
+
- 当用户说「重新设计海报」时,应主动询问或参考此布局结构
|
|
18
|
+
- 字体统一使用「微软雅黑」
|
|
19
|
+
- 历史/纪念类海报可参考深色背景+金色点缀的风格
|
|
20
|
+
- 8层布局结构:标题、副标题、时间线、基本信息、亲历者回忆①、亲历者回忆②、总结、页底
|
|
Binary file
|
|
Binary file
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
"description": "海报/Banner 设计插件 - 基于 Paper.js 实现,支持 35 个组件",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"canvas": "
|
|
7
|
+
"canvas": "npm:@napi-rs/canvas@latest",
|
|
8
8
|
"fontkit": "^2.0.4",
|
|
9
9
|
"jsdom": "^16.2.2",
|
|
10
10
|
"paper": "^0.12.18",
|
|
11
11
|
"qrcode": "^1.5.4"
|
|
12
12
|
},
|
|
13
13
|
"overrides": {
|
|
14
|
-
"canvas": "
|
|
14
|
+
"canvas": "npm:@napi-rs/canvas@latest"
|
|
15
15
|
},
|
|
16
16
|
"resolutions": {
|
|
17
|
-
"**/canvas": "
|
|
17
|
+
"**/canvas": "npm:@napi-rs/canvas@latest"
|
|
18
18
|
},
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "MIT",
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
const paper = require('paper')
|
|
6
6
|
const PRESETS = require('./presets')
|
|
7
|
+
const fonts = require('./fonts')
|
|
7
8
|
const fs = require('fs')
|
|
8
9
|
const path = require('path')
|
|
9
10
|
|
|
@@ -49,6 +50,13 @@ class CanvasManager {
|
|
|
49
50
|
this._width = w
|
|
50
51
|
this._height = h
|
|
51
52
|
|
|
53
|
+
// 初始化字体系统
|
|
54
|
+
if (typeof fonts.init === 'function') {
|
|
55
|
+
fonts.init()
|
|
56
|
+
} else if (typeof fonts.initFonts === 'function') {
|
|
57
|
+
fonts.initFonts()
|
|
58
|
+
}
|
|
59
|
+
|
|
52
60
|
// 添加背景
|
|
53
61
|
if (background) {
|
|
54
62
|
if (typeof background === 'string' && path.isAbsolute(background)) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
const paper = require('paper')
|
|
6
6
|
const { loadImageAsRaster, downloadImage } = require('../utils/imageLoader')
|
|
7
|
+
const { getFontFallbackChain, validateFont } = require('../fonts')
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* 创建条形码
|
|
@@ -33,11 +34,12 @@ async function createBarcode(project, args) {
|
|
|
33
34
|
|
|
34
35
|
// 文字
|
|
35
36
|
if (showText) {
|
|
37
|
+
const barcodeFont = getFontFallbackChain('monospace', content).join(', ')
|
|
36
38
|
const textItem = new paper.PointText({
|
|
37
39
|
point: [x + width / 2, y + height + fontSize + 5],
|
|
38
40
|
content: content,
|
|
39
41
|
fontSize,
|
|
40
|
-
fontFamily:
|
|
42
|
+
fontFamily: barcodeFont,
|
|
41
43
|
fillColor: new paper.Color(textColor),
|
|
42
44
|
justification: 'center',
|
|
43
45
|
})
|
|
@@ -98,11 +100,12 @@ function createSimpleBarcode(project, args) {
|
|
|
98
100
|
|
|
99
101
|
// 文字
|
|
100
102
|
if (showText) {
|
|
103
|
+
const simpleBarcodeFont = getFontFallbackChain('monospace', content).join(', ')
|
|
101
104
|
const textItem = new paper.PointText({
|
|
102
105
|
point: [x + width / 2, y + barHeight + fontSize + 3],
|
|
103
106
|
content: content,
|
|
104
107
|
fontSize,
|
|
105
|
-
fontFamily:
|
|
108
|
+
fontFamily: simpleBarcodeFont,
|
|
106
109
|
fillColor: new paper.Color(textColor),
|
|
107
110
|
justification: 'center',
|
|
108
111
|
})
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
const paper = require('paper')
|
|
6
|
+
const { getFontFallbackChain, validateFont } = require('../fonts')
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* 创建对话气泡
|
|
@@ -115,7 +116,7 @@ function createBubble(project, args) {
|
|
|
115
116
|
point: [bubbleX + padding, bubbleY + bubbleHeight / 2 + fontSize / 3],
|
|
116
117
|
content: text,
|
|
117
118
|
fontSize,
|
|
118
|
-
fontFamily: fontFamily
|
|
119
|
+
fontFamily: getFontFallbackChain(fontFamily, text).join(', '),
|
|
119
120
|
fillColor: new paper.Color(color),
|
|
120
121
|
justification: tailPosition === 'left' ? 'left' : tailPosition === 'right' ? 'right' : 'center',
|
|
121
122
|
})
|
|
@@ -130,7 +131,7 @@ function createBubble(project, args) {
|
|
|
130
131
|
let currentLine = ''
|
|
131
132
|
for (const char of text) {
|
|
132
133
|
currentLine += char
|
|
133
|
-
const testText = new paper.PointText({ content: currentLine, fontSize, fontFamily: fontFamily
|
|
134
|
+
const testText = new paper.PointText({ content: currentLine, fontSize, fontFamily: getFontFallbackChain(fontFamily, currentLine).join(', ') })
|
|
134
135
|
if (testText.bounds.width > maxTextWidth) {
|
|
135
136
|
lines.push(currentLine.slice(0, -1))
|
|
136
137
|
currentLine = char
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
const paper = require('paper')
|
|
6
6
|
const { loadImageAsRaster } = require('../utils/imageLoader')
|
|
7
|
+
const { getFontFallbackChain, validateFont } = require('../fonts')
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* 创建按钮
|
|
@@ -12,7 +13,7 @@ async function createButton(project, args) {
|
|
|
12
13
|
const {
|
|
13
14
|
x = 0,
|
|
14
15
|
y = 0,
|
|
15
|
-
width
|
|
16
|
+
width: customWidth, // 重命名为 customWidth
|
|
16
17
|
height = 60,
|
|
17
18
|
text = '按钮',
|
|
18
19
|
fontSize = 24,
|
|
@@ -27,24 +28,37 @@ async function createButton(project, args) {
|
|
|
27
28
|
icon,
|
|
28
29
|
iconPosition = 'left',
|
|
29
30
|
opacity = 1,
|
|
31
|
+
padding = 30, // 内边距
|
|
30
32
|
} = args
|
|
31
33
|
|
|
34
|
+
// 使用字符数估算文本宽度(参考 CTA 组件的方式)
|
|
35
|
+
const textStr = String(text || '')
|
|
36
|
+
const chineseChars = (textStr.match(/[\u4e00-\u9fa5]/g) || []).length
|
|
37
|
+
const otherChars = textStr.length - chineseChars
|
|
38
|
+
// 中文约1.0倍,英文/数字约0.5倍字体大小
|
|
39
|
+
const textWidth = chineseChars * fontSize * 1.0 + otherChars * fontSize * 0.5
|
|
40
|
+
|
|
41
|
+
// 图标宽度
|
|
42
|
+
const iconWidth = icon ? Math.min(height * 0.5, fontSize) + 8 : 0
|
|
43
|
+
|
|
44
|
+
// 计算最终宽度:如果没有指定宽度,则根据内容计算
|
|
45
|
+
const finalWidth = customWidth || (textWidth + padding * 2 + iconWidth)
|
|
46
|
+
|
|
32
47
|
// 创建按钮背景
|
|
33
|
-
const
|
|
48
|
+
const bg = new paper.Path.Rectangle({
|
|
34
49
|
point: [x, y],
|
|
35
|
-
size: [
|
|
50
|
+
size: [finalWidth, height],
|
|
36
51
|
radius: radius,
|
|
37
|
-
}
|
|
52
|
+
})
|
|
38
53
|
|
|
54
|
+
// 边框
|
|
39
55
|
if (borderColor) {
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
bg.strokeColor = new paper.Color(borderColor)
|
|
57
|
+
bg.strokeWidth = borderWidth
|
|
42
58
|
}
|
|
43
59
|
|
|
44
|
-
const bg = new paper.Path.Rectangle(bgOptions)
|
|
45
|
-
|
|
46
60
|
// 渐变或纯色填充
|
|
47
|
-
if (gradient && gradient.colors && gradient.colors.length >
|
|
61
|
+
if (gradient && gradient.colors && gradient.colors.length > 1) {
|
|
48
62
|
const colors = gradient.colors.map(c => new paper.Color(c))
|
|
49
63
|
bg.fillColor = new paper.Color({
|
|
50
64
|
gradient: { stops: colors },
|
|
@@ -56,68 +70,98 @@ async function createButton(project, args) {
|
|
|
56
70
|
}
|
|
57
71
|
|
|
58
72
|
// 阴影
|
|
59
|
-
if (shadow) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
73
|
+
if (shadow && typeof shadow === 'object') {
|
|
74
|
+
try {
|
|
75
|
+
if (shadow.color) bg.shadowColor = new paper.Color(shadow.color)
|
|
76
|
+
bg.shadowBlur = shadow.blur || 10
|
|
77
|
+
bg.shadowOffset = new paper.Point(shadow.offsetX || 0, shadow.offsetY || 4)
|
|
78
|
+
} catch (e) {
|
|
79
|
+
// 忽略阴影错误
|
|
80
|
+
}
|
|
63
81
|
}
|
|
64
82
|
|
|
65
83
|
if (opacity !== 1) {
|
|
66
84
|
bg.opacity = opacity
|
|
67
85
|
}
|
|
68
86
|
|
|
69
|
-
|
|
70
|
-
|
|
87
|
+
if (project && project.activeLayer) {
|
|
88
|
+
project.activeLayer.addChild(bg)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const elements = [{ type: 'rectangle', id: bg.id }]
|
|
92
|
+
|
|
93
|
+
// 文字居中 x 坐标
|
|
94
|
+
const textX = x + finalWidth / 2
|
|
71
95
|
|
|
72
96
|
// 添加图标
|
|
73
97
|
if (icon) {
|
|
74
|
-
const iconSize = Math.min(height * 0.5,
|
|
75
|
-
const
|
|
98
|
+
const iconSize = Math.min(height * 0.5, fontSize)
|
|
99
|
+
const iconY = y + height / 2 + iconSize / 3
|
|
76
100
|
|
|
77
101
|
if (icon.startsWith('http') || icon.startsWith('data:')) {
|
|
78
102
|
// URL图片图标
|
|
103
|
+
const iconX = iconPosition === 'left'
|
|
104
|
+
? x + padding
|
|
105
|
+
: x + finalWidth - padding - iconSize
|
|
106
|
+
|
|
79
107
|
const { raster } = await loadImageAsRaster(project, icon, {
|
|
80
108
|
x: iconX,
|
|
81
109
|
y: y + (height - iconSize) / 2,
|
|
82
110
|
width: iconSize,
|
|
83
111
|
height: iconSize
|
|
84
112
|
}, opacity)
|
|
85
|
-
|
|
113
|
+
|
|
114
|
+
if (project && project.activeLayer) {
|
|
115
|
+
project.activeLayer.addChild(raster)
|
|
116
|
+
}
|
|
117
|
+
elements.push({ type: 'raster', id: raster.id })
|
|
86
118
|
} else {
|
|
87
119
|
// Emoji 或文本图标
|
|
120
|
+
const iconX = iconPosition === 'left'
|
|
121
|
+
? x + padding + iconSize / 2
|
|
122
|
+
: x + finalWidth - padding - iconSize / 2
|
|
123
|
+
|
|
88
124
|
const iconText = new paper.PointText({
|
|
89
|
-
point: [iconX
|
|
125
|
+
point: [iconX, iconY],
|
|
90
126
|
content: icon,
|
|
91
127
|
fontSize: iconSize,
|
|
92
128
|
justification: 'center',
|
|
93
129
|
})
|
|
94
130
|
if (opacity !== 1) iconText.opacity = opacity
|
|
95
|
-
|
|
131
|
+
|
|
132
|
+
if (project && project.activeLayer) {
|
|
133
|
+
project.activeLayer.addChild(iconText)
|
|
134
|
+
}
|
|
135
|
+
elements.push({ type: 'text', id: iconText.id })
|
|
96
136
|
}
|
|
97
|
-
|
|
98
|
-
textX = iconPosition === 'left' ? x + width / 2 + 25 : x + width / 2 - 25
|
|
99
137
|
}
|
|
100
138
|
|
|
101
139
|
// 添加文字
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
140
|
+
const textY = y + height / 2 + fontSize / 3
|
|
141
|
+
const buttonText = new paper.PointText({
|
|
142
|
+
point: [textX, textY],
|
|
143
|
+
content: textStr,
|
|
144
|
+
fontSize: fontSize,
|
|
145
|
+
fontFamily: getFontFallbackChain(fontFamily, textStr).join(', '),
|
|
107
146
|
fillColor: new paper.Color(color),
|
|
108
147
|
justification: 'center',
|
|
109
148
|
})
|
|
110
149
|
|
|
111
150
|
if (opacity !== 1) {
|
|
112
|
-
|
|
151
|
+
buttonText.opacity = opacity
|
|
113
152
|
}
|
|
114
153
|
|
|
115
|
-
|
|
154
|
+
if (project && project.activeLayer) {
|
|
155
|
+
project.activeLayer.addChild(buttonText)
|
|
156
|
+
}
|
|
157
|
+
elements.push({ type: 'text', id: buttonText.id })
|
|
116
158
|
|
|
117
159
|
return {
|
|
118
160
|
success: true,
|
|
119
161
|
type: 'button',
|
|
120
|
-
|
|
162
|
+
elements,
|
|
163
|
+
width: finalWidth,
|
|
164
|
+
height: height,
|
|
121
165
|
}
|
|
122
166
|
}
|
|
123
167
|
|