foliko 1.1.8 → 1.1.9
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/agents/code-assistant.json +17 -0
- package/.agent/agents/email-assistant.json +14 -0
- package/.agent/agents/file-assistant.json +18 -0
- package/.agent/agents/orchestrator-demo.md +53 -0
- package/.agent/agents/orchestrator.json +7 -0
- package/.agent/agents/poster-expert.md +228 -0
- package/.agent/agents/system-assistant.json +15 -0
- package/.agent/agents/web-assistant.json +12 -0
- package/.agent/data/default.json +5 -404
- package/.agent/data/email/processed-emails.json +1 -0
- package/.agent/data/plugins-state.json +173 -172
- package/.agent/data/scheduler/tasks.json +1 -0
- package/.agent/data/web/web-config.json +5 -0
- package/.agent/mcp_config.json +0 -14
- package/.agent/package.json +8 -0
- package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
- package/.agent/plugins/daytona/README.md +89 -0
- package/.agent/plugins/daytona/index.js +377 -0
- package/.agent/plugins/daytona/package.json +12 -0
- package/.agent/plugins/marknative/README.md +134 -0
- package/.agent/plugins/marknative/fonts.zip +0 -0
- package/.agent/plugins/marknative/index.js +256 -0
- package/.agent/plugins/marknative/package.json +12 -0
- package/.agent/plugins/system-info/index.js +387 -0
- package/.agent/plugins/system-info/package.json +4 -0
- package/.agent/plugins/system-info/test.js +40 -0
- package/.agent/plugins/test-plugin.py +123 -0
- package/.agent/plugins/test_nested_plugin.py +85 -0
- package/.agent/plugins.json +11 -5
- package/.agent/python-scripts/test_sample.py +24 -0
- package/.agent/sessions/cli_default.json +96 -249
- package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +189 -0
- package/.agent/skills/agent-browser/SKILL.md +311 -0
- package/.agent/skills/agent-browser/TEST_PLAN.md +200 -0
- package/.agent/skills/sysinfo/SKILL.md +38 -0
- package/.agent/skills/sysinfo/system-info.sh +130 -0
- package/.agent/skills/workflow/SKILL.md +324 -0
- package/.agent/test-agent.js +35 -0
- package/.agent/weixin.json +6 -0
- package/.agent/workflows/email-digest.json +50 -0
- package/.agent/workflows/file-backup.json +21 -0
- package/.agent/workflows/get-ip-notify.json +32 -0
- package/.agent/workflows/news-aggregator.json +93 -0
- package/.agent/workflows/news-dashboard-v2.json +94 -0
- package/.agent/workflows/notification-batch.json +32 -0
- package/.claude/settings.local.json +9 -1
- package/.env.example +56 -56
- package/README.md +441 -441
- package/cli/src/ui/chat-ui.js +32 -21
- package/foliko_poster.png +0 -0
- package/output/business_poster_final.png +0 -0
- package/output/emoji_test_v2.png +0 -0
- package/output/foliko-ai-launch-poster.png +0 -0
- package/output/foliko-poster.png +0 -0
- package/output/muji_style_poster.png +0 -0
- package/output/new_product_launch.png +0 -0
- package/output/news_poster_625yi_subsidy.png +0 -0
- package/output/tech_future_2026.png +0 -0
- package/output/tech_future_poster.png +0 -0
- package/package.json +1 -2
- package/plugins/default-plugins.js +58 -6
- package/plugins/extension-executor-plugin.js +8 -21
- package/plugins/python-plugin-loader.js +461 -40
- package/plugins/python-plugin-loader.js.bak +856 -0
- package/plugins/subagent-plugin.js +0 -121
- package/plugins/weixin-plugin.js +38 -29
- package/poster.png +0 -0
- package/skills/find-skills/AGENTS.md +162 -162
- package/skills/find-skills/SKILL.md +133 -133
- package/skills/foliko-dev/SKILL.md +6 -0
- package/skills/python-plugin-dev/SKILL.md +124 -2
- package/src/core/agent-chat.js +220 -281
- package/src/core/agent.js +10 -0
- package/src/utils/plugin-helpers.js +22 -4
- package/system.md +1678 -1574
- package/test-scan.js +18 -0
- package/.agent/.shared/ui-ux-pro-max/data/charts.csv +0 -26
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +0 -97
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +0 -101
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +0 -31
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +0 -97
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +0 -24
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +0 -45
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +0 -56
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +0 -51
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +0 -59
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +0 -52
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +0 -54
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +0 -61
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +0 -54
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +0 -51
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +0 -50
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +0 -59
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +0 -58
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +0 -31
- 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 +0 -258
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +0 -1067
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +0 -106
- package/.agent/ARCHITECTURE.md +0 -288
- package/.agent/agents/ambient-agent.md +0 -57
- package/.agent/agents/debugger.md +0 -55
- package/.agent/agents/email-assistant.md +0 -49
- package/.agent/agents/file-manager.md +0 -42
- package/.agent/agents/python-developer.md +0 -60
- package/.agent/agents/scheduler.md +0 -59
- package/.agent/agents/web-developer.md +0 -45
- package/.agent/data/puppeteer-sessions/undefined.json +0 -6
- 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/memory/feedback/mnrdvj5i-ca3dkd.md +0 -9
- package/.agent/memory/feedback/mnre365e-7s4zax.md +0 -9
- package/.agent/memory/feedback/mnre36jn-nkfgmp.md +0 -9
- package/.agent/memory/feedback/mnre3805-kjiq6h.md +0 -9
- package/.agent/memory/feedback/mnsf66kp-b10rcd.md +0 -9
- package/.agent/memory/feedback/mnsi3sz8-p5g2cw.md +0 -9
- package/.agent/memory/feedback/mnsibe47-sv2ni1.md +0 -9
- package/.agent/memory/feedback/mnsic89w-nn228o.md +0 -9
- package/.agent/memory/feedback/mnsj1xe9-x83ba0.md +0 -9
- package/.agent/memory/feedback/mnsj21iv-wnwelx.md +0 -9
- package/.agent/memory/feedback/mnsj2g4a-cog7a2.md +0 -9
- package/.agent/memory/feedback/mnsj4js7-lktjp6.md +0 -9
- package/.agent/memory/feedback/mnsj5d4y-uglwvp.md +0 -9
- package/.agent/memory/feedback/mnslkuo9-uous66.md +0 -24
- package/.agent/memory/feedback/mnsm3vq0-megoil.md +0 -9
- package/.agent/memory/feedback/mnsnn5x2-sxcihd.md +0 -9
- package/.agent/memory/feedback/mnsnq17s-nabrn9.md +0 -9
- package/.agent/memory/feedback/mnsnybet-wz7rn3.md +0 -9
- package/.agent/memory/feedback/mnsrw0s7-7s9e30.md +0 -9
- package/.agent/memory/feedback/mnu5hpnd-tlm16q.md +0 -9
- package/.agent/memory/feedback/mnu60uqe-xuoxp4.md +0 -9
- package/.agent/memory/project/mnqx54u5-loqtoe.md +0 -9
- package/.agent/memory/project/mnqx84cv-mx6dmd.md +0 -9
- package/.agent/memory/project/mnsacuyr-hgtk5n.md +0 -20
- package/.agent/memory/project/mnu5hy2x-bjsg7u.md +0 -9
- package/.agent/memory/reference/mnre3cww-penbo1.md +0 -9
- package/.agent/memory/reference/mns9wn48-luerua.md +0 -14
- package/.agent/memory/reference/mns9yz5c-thc2s0.md +0 -16
- package/.agent/memory/reference/mnsfy4um-910f1o.md +0 -23
- package/.agent/memory/reference/mnsg37dp-lmfj18.md +0 -32
- package/.agent/memory/reference/mnsll60q-0j911u.md +0 -36
- package/.agent/memory/reference/mnsmlb5y-nej31u.md +0 -16
- package/.agent/memory/reference/mnssle72-yrot96.md +0 -9
- package/.agent/memory/user/mnsfuon6-l416q1.md +0 -21
- package/.agent/memory/user/mnsg9kut-95m7rf.md +0 -20
- package/.agent/memory/user/mnu2eo1v-yy6fhe.md +0 -9
- package/.agent/memory/user/mnu2etuo-8u8jk8.md +0 -9
- package/.agent/plugins/poster-plugin/README.md +0 -304
- package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts/Symbola_hint.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221/347/262/227/344/275/223.ttf +0 -0
- package/.agent/plugins/poster-plugin/index.js +0 -13
- package/.agent/plugins/poster-plugin/package.json +0 -29
- package/.agent/plugins/poster-plugin/src/canvas.js +0 -232
- package/.agent/plugins/poster-plugin/src/components/arrow.js +0 -84
- package/.agent/plugins/poster-plugin/src/components/avatar.js +0 -71
- package/.agent/plugins/poster-plugin/src/components/badge.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/barcode.js +0 -123
- package/.agent/plugins/poster-plugin/src/components/bubble.js +0 -154
- package/.agent/plugins/poster-plugin/src/components/button.js +0 -168
- package/.agent/plugins/poster-plugin/src/components/card.js +0 -88
- package/.agent/plugins/poster-plugin/src/components/chart.js +0 -127
- package/.agent/plugins/poster-plugin/src/components/chip.js +0 -88
- package/.agent/plugins/poster-plugin/src/components/columns.js +0 -121
- package/.agent/plugins/poster-plugin/src/components/cta.js +0 -87
- package/.agent/plugins/poster-plugin/src/components/divider.js +0 -55
- package/.agent/plugins/poster-plugin/src/components/feature.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/featureGrid.js +0 -117
- package/.agent/plugins/poster-plugin/src/components/frame.js +0 -230
- package/.agent/plugins/poster-plugin/src/components/grid.js +0 -130
- package/.agent/plugins/poster-plugin/src/components/highlightText.js +0 -145
- package/.agent/plugins/poster-plugin/src/components/icon.js +0 -94
- package/.agent/plugins/poster-plugin/src/components/imageFrame.js +0 -205
- package/.agent/plugins/poster-plugin/src/components/index.js +0 -81
- package/.agent/plugins/poster-plugin/src/components/listItem.js +0 -147
- package/.agent/plugins/poster-plugin/src/components/notification.js +0 -123
- package/.agent/plugins/poster-plugin/src/components/progress.js +0 -79
- package/.agent/plugins/poster-plugin/src/components/progressCircle.js +0 -117
- package/.agent/plugins/poster-plugin/src/components/qrcode.js +0 -74
- package/.agent/plugins/poster-plugin/src/components/quote.js +0 -169
- package/.agent/plugins/poster-plugin/src/components/rating.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/ribbon.js +0 -197
- package/.agent/plugins/poster-plugin/src/components/seal.js +0 -148
- package/.agent/plugins/poster-plugin/src/components/star.js +0 -70
- package/.agent/plugins/poster-plugin/src/components/statCard.js +0 -105
- package/.agent/plugins/poster-plugin/src/components/stepper.js +0 -118
- package/.agent/plugins/poster-plugin/src/components/table.js +0 -167
- package/.agent/plugins/poster-plugin/src/components/tagCloud.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/timeline.js +0 -117
- package/.agent/plugins/poster-plugin/src/components/watermark.js +0 -54
- package/.agent/plugins/poster-plugin/src/composer.js +0 -2314
- package/.agent/plugins/poster-plugin/src/elements/artText.js +0 -69
- package/.agent/plugins/poster-plugin/src/elements/background.js +0 -99
- package/.agent/plugins/poster-plugin/src/elements/circle.js +0 -31
- package/.agent/plugins/poster-plugin/src/elements/image.js +0 -28
- package/.agent/plugins/poster-plugin/src/elements/index.js +0 -28
- package/.agent/plugins/poster-plugin/src/elements/line.js +0 -23
- package/.agent/plugins/poster-plugin/src/elements/polygon.js +0 -63
- package/.agent/plugins/poster-plugin/src/elements/rectangle.js +0 -32
- package/.agent/plugins/poster-plugin/src/elements/richText.js +0 -283
- package/.agent/plugins/poster-plugin/src/elements/svg.js +0 -108
- package/.agent/plugins/poster-plugin/src/elements/text.js +0 -112
- package/.agent/plugins/poster-plugin/src/fonts.js +0 -674
- package/.agent/plugins/poster-plugin/src/index.js +0 -2126
- package/.agent/plugins/poster-plugin/src/presets.js +0 -36
- package/.agent/plugins/poster-plugin/src/templates/business.js +0 -60
- package/.agent/plugins/poster-plugin/src/templates/gradient.js +0 -64
- package/.agent/plugins/poster-plugin/src/templates/index.js +0 -43
- package/.agent/plugins/poster-plugin/src/templates/modern.js +0 -69
- package/.agent/plugins/poster-plugin/src/templates/simple.js +0 -58
- package/.agent/plugins/poster-plugin/src/templates/social.js +0 -62
- package/.agent/plugins/poster-plugin/src/templates/tech.js +0 -84
- package/.agent/plugins/poster-plugin/src/utils/imageLoader.js +0 -84
- package/.agent/plugins/poster-plugin/yarn.lock +0 -837
- package/.agent/plugins/puppeteer-plugin/README.md +0 -147
- package/.agent/plugins/puppeteer-plugin/index.js +0 -1422
- package/.agent/plugins/puppeteer-plugin/package.json +0 -9
- package/.agent/rules/GEMINI.md +0 -273
- package/.agent/rules/allow-rule.md +0 -77
- package/.agent/rules/log-rule.md +0 -83
- package/.agent/rules/security-rule.md +0 -93
- package/.agent/scripts/auto_preview.py +0 -148
- package/.agent/scripts/checklist.py +0 -217
- package/.agent/scripts/session_manager.py +0 -120
- package/.agent/scripts/verify_all.py +0 -327
- package/.agent/skills/api-patterns/SKILL.md +0 -81
- package/.agent/skills/api-patterns/api-style.md +0 -42
- package/.agent/skills/api-patterns/auth.md +0 -24
- package/.agent/skills/api-patterns/documentation.md +0 -26
- package/.agent/skills/api-patterns/graphql.md +0 -41
- package/.agent/skills/api-patterns/rate-limiting.md +0 -31
- package/.agent/skills/api-patterns/response.md +0 -37
- package/.agent/skills/api-patterns/rest.md +0 -40
- package/.agent/skills/api-patterns/scripts/api_validator.py +0 -211
- package/.agent/skills/api-patterns/security-testing.md +0 -122
- package/.agent/skills/api-patterns/trpc.md +0 -41
- package/.agent/skills/api-patterns/versioning.md +0 -22
- package/.agent/skills/app-builder/SKILL.md +0 -75
- package/.agent/skills/app-builder/agent-coordination.md +0 -71
- package/.agent/skills/app-builder/feature-building.md +0 -53
- package/.agent/skills/app-builder/project-detection.md +0 -34
- package/.agent/skills/app-builder/scaffolding.md +0 -118
- package/.agent/skills/app-builder/tech-stack.md +0 -40
- package/.agent/skills/app-builder/templates/SKILL.md +0 -39
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +0 -76
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +0 -92
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +0 -88
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +0 -88
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +0 -83
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +0 -90
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +0 -90
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +0 -122
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +0 -122
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +0 -169
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +0 -134
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +0 -83
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +0 -119
- package/.agent/skills/architecture/SKILL.md +0 -55
- package/.agent/skills/architecture/context-discovery.md +0 -43
- package/.agent/skills/architecture/examples.md +0 -94
- package/.agent/skills/architecture/pattern-selection.md +0 -68
- package/.agent/skills/architecture/patterns-reference.md +0 -50
- package/.agent/skills/architecture/trade-off-analysis.md +0 -77
- package/.agent/skills/clean-code/SKILL.md +0 -201
- package/.agent/skills/doc.md +0 -177
- package/.agent/skills/frontend-design/SKILL.md +0 -418
- package/.agent/skills/frontend-design/animation-guide.md +0 -331
- package/.agent/skills/frontend-design/color-system.md +0 -311
- package/.agent/skills/frontend-design/decision-trees.md +0 -418
- package/.agent/skills/frontend-design/motion-graphics.md +0 -306
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +0 -183
- package/.agent/skills/frontend-design/scripts/ux_audit.py +0 -722
- package/.agent/skills/frontend-design/typography-system.md +0 -345
- package/.agent/skills/frontend-design/ux-psychology.md +0 -1116
- package/.agent/skills/frontend-design/visual-effects.md +0 -383
- package/.agent/skills/i18n-localization/SKILL.md +0 -154
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +0 -241
- package/.agent/skills/mcp-builder/SKILL.md +0 -176
- package/.agent/skills/poster-design/SKILL.md +0 -385
- package/.agent/skills/web-design-guidelines/SKILL.md +0 -57
- package/.agent/workflows/brainstorm.md +0 -113
- package/.agent/workflows/create.md +0 -59
- package/.agent/workflows/debug.md +0 -103
- package/.agent/workflows/deploy.md +0 -176
- package/.agent/workflows/enhance.md +0 -63
- package/.agent/workflows/orchestrate.md +0 -237
- package/.agent/workflows/plan.md +0 -89
- package/.agent/workflows/preview.md +0 -81
- package/.agent/workflows/simple-test.md +0 -42
- package/.agent/workflows/status.md +0 -86
- package/.agent/workflows/structured-orchestrate.md +0 -180
- package/.agent/workflows/test.md +0 -144
- package/.agent/workflows/ui-ux-pro-max.md +0 -296
- package/outputs/emoji-font-showcase.png +0 -0
- package/outputs/foliko-muji-style.png +0 -0
- /package/.agent/plugins/{poster-plugin → marknative}/fonts/SegoeUI Emoji.ttf +0 -0
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 图表组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建图表组件
|
|
9
|
-
*/
|
|
10
|
-
function createChart(project, canvas, params) {
|
|
11
|
-
const {
|
|
12
|
-
type = 'bar',
|
|
13
|
-
x,
|
|
14
|
-
y,
|
|
15
|
-
width,
|
|
16
|
-
height,
|
|
17
|
-
data = [],
|
|
18
|
-
barColor = '#3b82f6',
|
|
19
|
-
showLabels = true,
|
|
20
|
-
showValues = true,
|
|
21
|
-
barGap = 4
|
|
22
|
-
} = params
|
|
23
|
-
|
|
24
|
-
const elements = []
|
|
25
|
-
|
|
26
|
-
if (type === 'bar' && data.length > 0) {
|
|
27
|
-
const maxValue = Math.max(...data.map(d => d.value))
|
|
28
|
-
const barCount = data.length
|
|
29
|
-
const totalGap = barGap * (barCount - 1)
|
|
30
|
-
const barWidth = (width - totalGap) / barCount
|
|
31
|
-
const labelHeight = showLabels ? 24 : 0
|
|
32
|
-
const valueHeight = showValues ? 20 : 0
|
|
33
|
-
const chartHeight = height - labelHeight - valueHeight - 10
|
|
34
|
-
|
|
35
|
-
data.forEach((item, index) => {
|
|
36
|
-
const barHeight = (item.value / maxValue) * chartHeight
|
|
37
|
-
const barX = x + index * (barWidth + barGap)
|
|
38
|
-
const barY = y + height - labelHeight - valueHeight - barHeight - 5
|
|
39
|
-
const color = item.color || barColor
|
|
40
|
-
|
|
41
|
-
const bar = new paper.Path.Rectangle({
|
|
42
|
-
point: [barX, barY],
|
|
43
|
-
size: [barWidth, barHeight],
|
|
44
|
-
radius: [4, 4, 0, 0]
|
|
45
|
-
})
|
|
46
|
-
bar.fillColor = new paper.Color(color)
|
|
47
|
-
if (project && project.activeLayer) {
|
|
48
|
-
project.activeLayer.addChild(bar)
|
|
49
|
-
}
|
|
50
|
-
elements.push({ type: 'path', id: bar.id })
|
|
51
|
-
|
|
52
|
-
if (showValues) {
|
|
53
|
-
const valueText = new paper.PointText({
|
|
54
|
-
point: [barX + barWidth / 2, barY - 8],
|
|
55
|
-
content: String(item.value),
|
|
56
|
-
fontSize: 12,
|
|
57
|
-
fillColor: new paper.Color('#666666'),
|
|
58
|
-
justification: 'center'
|
|
59
|
-
})
|
|
60
|
-
if (project && project.activeLayer) {
|
|
61
|
-
project.activeLayer.addChild(valueText)
|
|
62
|
-
}
|
|
63
|
-
elements.push({ type: 'text', id: valueText.id })
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (showLabels) {
|
|
67
|
-
const labelText = new paper.PointText({
|
|
68
|
-
point: [barX + barWidth / 2, y + height - 8],
|
|
69
|
-
content: item.label || '',
|
|
70
|
-
fontSize: 11,
|
|
71
|
-
fillColor: new paper.Color('#333333'),
|
|
72
|
-
justification: 'center'
|
|
73
|
-
})
|
|
74
|
-
if (project && project.activeLayer) {
|
|
75
|
-
project.activeLayer.addChild(labelText)
|
|
76
|
-
}
|
|
77
|
-
elements.push({ type: 'text', id: labelText.id })
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
} else if (type === 'pie' && data.length > 0) {
|
|
81
|
-
const cx = x + width / 2
|
|
82
|
-
const cy = y + height / 2
|
|
83
|
-
const radius = Math.min(width, height) / 2 - 10
|
|
84
|
-
const total = data.reduce((sum, d) => sum + d.value, 0)
|
|
85
|
-
let currentAngle = -90
|
|
86
|
-
const colors = ['#3b82f6', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899', '#06b6d4', '#84cc16']
|
|
87
|
-
|
|
88
|
-
data.forEach((item, index) => {
|
|
89
|
-
const percentage = item.value / total
|
|
90
|
-
const endAngle = currentAngle + percentage * 360
|
|
91
|
-
const path = new paper.Path()
|
|
92
|
-
path.moveTo(cx, cy)
|
|
93
|
-
path.arc([cx, cy], radius, currentAngle * Math.PI / 180, endAngle * Math.PI / 180)
|
|
94
|
-
path.closePath()
|
|
95
|
-
path.fillColor = new paper.Color(item.color || colors[index % colors.length])
|
|
96
|
-
if (project && project.activeLayer) {
|
|
97
|
-
project.activeLayer.addChild(path)
|
|
98
|
-
}
|
|
99
|
-
elements.push({ type: 'path', id: path.id })
|
|
100
|
-
|
|
101
|
-
if (showLabels && percentage > 0.05) {
|
|
102
|
-
const midAngle = (currentAngle + endAngle) / 2
|
|
103
|
-
const midRad = midAngle * Math.PI / 180
|
|
104
|
-
const labelX = cx + radius * 0.7 * Math.cos(midRad)
|
|
105
|
-
const labelY = cy + radius * 0.7 * Math.sin(midRad)
|
|
106
|
-
const labelText = new paper.PointText({
|
|
107
|
-
point: [labelX, labelY + 4],
|
|
108
|
-
content: `${Math.round(percentage * 100)}%`,
|
|
109
|
-
fontSize: 11,
|
|
110
|
-
fillColor: new paper.Color('#ffffff'),
|
|
111
|
-
justification: 'center',
|
|
112
|
-
fontWeight: 'bold'
|
|
113
|
-
})
|
|
114
|
-
if (project && project.activeLayer) {
|
|
115
|
-
project.activeLayer.addChild(labelText)
|
|
116
|
-
}
|
|
117
|
-
elements.push({ type: 'text', id: labelText.id })
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
currentAngle = endAngle
|
|
121
|
-
})
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return { success: true, elements, type: 'chart' }
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
module.exports = createChart
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chip 标签组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建 Chip 标签组件
|
|
9
|
-
*/
|
|
10
|
-
function createChip(project, canvas, params) {
|
|
11
|
-
const {
|
|
12
|
-
x,
|
|
13
|
-
y,
|
|
14
|
-
text,
|
|
15
|
-
background = '#e0e0e0',
|
|
16
|
-
color = '#333333',
|
|
17
|
-
borderColor,
|
|
18
|
-
fontSize = 12,
|
|
19
|
-
padding = 12,
|
|
20
|
-
radius = 16,
|
|
21
|
-
icon
|
|
22
|
-
} = params
|
|
23
|
-
|
|
24
|
-
const elements = []
|
|
25
|
-
|
|
26
|
-
// 计算尺寸
|
|
27
|
-
const textWidth = text.length * fontSize * 0.6
|
|
28
|
-
const iconWidth = icon ? fontSize : 0
|
|
29
|
-
const totalWidth = padding * 2 + textWidth + iconWidth + 4
|
|
30
|
-
const height = fontSize + padding * 2
|
|
31
|
-
const rectX = x - totalWidth / 2
|
|
32
|
-
const rectY = y - height / 2
|
|
33
|
-
|
|
34
|
-
// 绘制背景
|
|
35
|
-
const bg = new paper.Path.Rectangle({
|
|
36
|
-
point: [rectX, rectY],
|
|
37
|
-
size: [totalWidth, height],
|
|
38
|
-
radius: radius
|
|
39
|
-
})
|
|
40
|
-
bg.fillColor = new paper.Color(background)
|
|
41
|
-
if (borderColor) {
|
|
42
|
-
bg.strokeColor = new paper.Color(borderColor)
|
|
43
|
-
bg.strokeWidth = 1
|
|
44
|
-
}
|
|
45
|
-
if (project && project.activeLayer) {
|
|
46
|
-
project.activeLayer.addChild(bg)
|
|
47
|
-
}
|
|
48
|
-
elements.push({ type: 'path', id: bg.id })
|
|
49
|
-
|
|
50
|
-
// 绘制图标
|
|
51
|
-
if (icon) {
|
|
52
|
-
const iconText = new paper.PointText({
|
|
53
|
-
point: [rectX + padding + iconWidth / 2, y + fontSize / 3],
|
|
54
|
-
content: icon,
|
|
55
|
-
fontSize: fontSize + 2,
|
|
56
|
-
fillColor: new paper.Color(color),
|
|
57
|
-
justification: 'center'
|
|
58
|
-
})
|
|
59
|
-
if (project && project.activeLayer) {
|
|
60
|
-
project.activeLayer.addChild(iconText)
|
|
61
|
-
}
|
|
62
|
-
elements.push({ type: 'text', id: iconText.id })
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 绘制文字
|
|
66
|
-
const textX = icon ? rectX + padding + iconWidth + 4 + textWidth / 2 : x
|
|
67
|
-
const label = new paper.PointText({
|
|
68
|
-
point: [textX, y + fontSize / 3],
|
|
69
|
-
content: text,
|
|
70
|
-
fontSize: fontSize,
|
|
71
|
-
fillColor: new paper.Color(color),
|
|
72
|
-
justification: 'center'
|
|
73
|
-
})
|
|
74
|
-
if (project && project.activeLayer) {
|
|
75
|
-
project.activeLayer.addChild(label)
|
|
76
|
-
}
|
|
77
|
-
elements.push({ type: 'text', id: label.id })
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
success: true,
|
|
81
|
-
elements,
|
|
82
|
-
width: totalWidth,
|
|
83
|
-
height,
|
|
84
|
-
type: 'chip'
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
module.exports = createChip
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 分栏布局组件
|
|
3
|
-
* 支持左右分栏、三栏、四栏等多种布局
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const paper = require('paper')
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 创建分栏布局组件
|
|
10
|
-
*
|
|
11
|
-
* @param {Object} project - Paper.js 项目
|
|
12
|
-
* @param {Object} canvas - 画布对象
|
|
13
|
-
* @param {Object} params - 组件参数
|
|
14
|
-
* @param {number} params.x - 起始X坐标
|
|
15
|
-
* @param {number} params.y - 起始Y坐标
|
|
16
|
-
* @param {number} params.width - 总宽度
|
|
17
|
-
* @param {number} params.height - 总高度
|
|
18
|
-
* @param {number} [params.columns=2] - 列数
|
|
19
|
-
* @param {number} [params.gap=20] - 列间距
|
|
20
|
-
* @param {string} [params.background] - 背景色
|
|
21
|
-
* @param {string} [params.borderColor] - 边框颜色
|
|
22
|
-
* @param {number} [params.borderWidth] - 边框宽度
|
|
23
|
-
* @param {number} [params.radius=0] - 圆角
|
|
24
|
-
* @param {Array} [params.items] - 列内容配置 [{widthRatio, content}]
|
|
25
|
-
* @param {string} [params.direction='horizontal'] - 排列方向: horizontal, vertical
|
|
26
|
-
* @param {string} [params.align='top'] - 垂直对齐: top, center, bottom
|
|
27
|
-
*/
|
|
28
|
-
function createColumns(project, canvas, params) {
|
|
29
|
-
const {
|
|
30
|
-
x,
|
|
31
|
-
y,
|
|
32
|
-
width,
|
|
33
|
-
height,
|
|
34
|
-
columns = 2,
|
|
35
|
-
gap = 20,
|
|
36
|
-
background,
|
|
37
|
-
borderColor,
|
|
38
|
-
borderWidth = 1,
|
|
39
|
-
radius = 0,
|
|
40
|
-
direction = 'horizontal',
|
|
41
|
-
align = 'top'
|
|
42
|
-
} = params
|
|
43
|
-
|
|
44
|
-
const elements = []
|
|
45
|
-
|
|
46
|
-
// 计算每列宽度
|
|
47
|
-
const totalGap = gap * (columns - 1)
|
|
48
|
-
const columnWidth = (width - totalGap) / columns
|
|
49
|
-
|
|
50
|
-
// 绘制背景
|
|
51
|
-
if (background) {
|
|
52
|
-
const bg = new paper.Path.Rectangle({
|
|
53
|
-
point: [x, y],
|
|
54
|
-
size: [width, height],
|
|
55
|
-
radius: radius
|
|
56
|
-
})
|
|
57
|
-
bg.fillColor = new paper.Color(background)
|
|
58
|
-
if (project && project.activeLayer) {
|
|
59
|
-
project.activeLayer.addChild(bg)
|
|
60
|
-
}
|
|
61
|
-
elements.push({ type: 'rectangle', id: bg.id })
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 绘制边框
|
|
65
|
-
if (borderColor && borderWidth > 0) {
|
|
66
|
-
const border = new paper.Path.Rectangle({
|
|
67
|
-
point: [x, y],
|
|
68
|
-
size: [width, height],
|
|
69
|
-
radius: radius
|
|
70
|
-
})
|
|
71
|
-
border.fillColor = new paper.Color('transparent')
|
|
72
|
-
border.strokeColor = new paper.Color(borderColor)
|
|
73
|
-
border.strokeWidth = borderWidth
|
|
74
|
-
if (project && project.activeLayer) {
|
|
75
|
-
project.activeLayer.addChild(border)
|
|
76
|
-
}
|
|
77
|
-
elements.push({ type: 'rectangle', id: border.id })
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// 生成分割线
|
|
81
|
-
for (let i = 1; i < columns; i++) {
|
|
82
|
-
const lineX = x + columnWidth * i + gap * (i - 1) + gap / 2
|
|
83
|
-
const line = new paper.Path.Line({
|
|
84
|
-
from: [lineX, y + 20],
|
|
85
|
-
to: [lineX, y + height - 20]
|
|
86
|
-
})
|
|
87
|
-
line.strokeColor = new paper.Color('#e0e0e0')
|
|
88
|
-
line.strokeWidth = 1
|
|
89
|
-
if (project && project.activeLayer) {
|
|
90
|
-
project.activeLayer.addChild(line)
|
|
91
|
-
}
|
|
92
|
-
elements.push({ type: 'line', id: line.id })
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 返回列位置信息
|
|
96
|
-
const columnPositions = []
|
|
97
|
-
for (let i = 0; i < columns; i++) {
|
|
98
|
-
const colX = x + (columnWidth + gap) * i
|
|
99
|
-
const colY = align === 'center' ? y + (height - height) / 2 : align === 'bottom' ? y + height - height : y
|
|
100
|
-
|
|
101
|
-
columnPositions.push({
|
|
102
|
-
index: i,
|
|
103
|
-
x: colX,
|
|
104
|
-
y: colY,
|
|
105
|
-
width: columnWidth,
|
|
106
|
-
height: height
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
success: true,
|
|
112
|
-
elements,
|
|
113
|
-
columnPositions,
|
|
114
|
-
columnWidth,
|
|
115
|
-
totalWidth: width,
|
|
116
|
-
totalHeight: height,
|
|
117
|
-
type: 'columns'
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
module.exports = createColumns
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CTA(行动号召)按钮组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建 CTA 按钮
|
|
9
|
-
*/
|
|
10
|
-
function createCTA(project, canvas, args) {
|
|
11
|
-
const {
|
|
12
|
-
x = 0, y = 0,
|
|
13
|
-
text = '',
|
|
14
|
-
background = '#007bff',
|
|
15
|
-
color = '#ffffff',
|
|
16
|
-
border,
|
|
17
|
-
fontSize = 20,
|
|
18
|
-
padding = 25,
|
|
19
|
-
radius = 8,
|
|
20
|
-
shadow,
|
|
21
|
-
width: customWidth,
|
|
22
|
-
} = args
|
|
23
|
-
|
|
24
|
-
const elements = []
|
|
25
|
-
|
|
26
|
-
// 确保 text 是字符串
|
|
27
|
-
const textStr = String(text || '')
|
|
28
|
-
// 使用更准确的字符宽度估算:中文约1.0,英文约0.5
|
|
29
|
-
const chineseChars = (textStr.match(/[\u4e00-\u9fa5]/g) || []).length
|
|
30
|
-
const otherChars = textStr.length - chineseChars
|
|
31
|
-
const textWidth = chineseChars * fontSize * 1.0 + otherChars * fontSize * 0.5
|
|
32
|
-
const btnWidth = customWidth || (textWidth + padding * 2)
|
|
33
|
-
const btnHeight = fontSize + padding * 2
|
|
34
|
-
|
|
35
|
-
const btnX = x - btnWidth / 2
|
|
36
|
-
|
|
37
|
-
// 绘制按钮背景
|
|
38
|
-
const button = new paper.Path.Rectangle({
|
|
39
|
-
point: [btnX, y],
|
|
40
|
-
size: [btnWidth, btnHeight],
|
|
41
|
-
radius: radius,
|
|
42
|
-
})
|
|
43
|
-
button.fillColor = new paper.Color(background)
|
|
44
|
-
|
|
45
|
-
if (border) {
|
|
46
|
-
button.strokeColor = new paper.Color(border)
|
|
47
|
-
button.strokeWidth = 1
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (shadow && typeof shadow === 'object') {
|
|
51
|
-
try {
|
|
52
|
-
if (shadow.color) button.shadowColor = new paper.Color(shadow.color)
|
|
53
|
-
button.shadowBlur = shadow.blur || 10
|
|
54
|
-
button.shadowOffset = new paper.Point(shadow.offsetX || 0, shadow.offsetY || 4)
|
|
55
|
-
} catch (e) {
|
|
56
|
-
// 忽略阴影错误
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (project && project.activeLayer) {
|
|
61
|
-
project.activeLayer.addChild(button)
|
|
62
|
-
}
|
|
63
|
-
elements.push({ type: 'rectangle', id: button.id })
|
|
64
|
-
|
|
65
|
-
// 绘制文字
|
|
66
|
-
const buttonText = new paper.PointText({
|
|
67
|
-
point: [x, y + btnHeight / 2 + fontSize / 3],
|
|
68
|
-
content: textStr,
|
|
69
|
-
fontSize: fontSize,
|
|
70
|
-
fillColor: new paper.Color(color),
|
|
71
|
-
justification: 'center',
|
|
72
|
-
})
|
|
73
|
-
if (project && project.activeLayer) {
|
|
74
|
-
project.activeLayer.addChild(buttonText)
|
|
75
|
-
}
|
|
76
|
-
elements.push({ type: 'text', id: buttonText.id })
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
success: true,
|
|
80
|
-
elements,
|
|
81
|
-
width: btnWidth,
|
|
82
|
-
height: btnHeight,
|
|
83
|
-
type: 'cta',
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
module.exports = createCTA
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 分隔线组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建分隔线
|
|
9
|
-
*
|
|
10
|
-
* @param {Object} project - Paper.js 项目
|
|
11
|
-
* @param {Object} canvas - 画布对象
|
|
12
|
-
* @param {Object} args - 组件参数
|
|
13
|
-
* @param {number} args.x - X坐标
|
|
14
|
-
* @param {number} args.y - Y坐标
|
|
15
|
-
* @param {number} args.width - 宽度
|
|
16
|
-
* @param {string} args.color - 颜色
|
|
17
|
-
* @param {number} args.thickness - 厚度
|
|
18
|
-
* @param {string} args.style - 样式: solid, dashed
|
|
19
|
-
* @param {string} args.align - 对齐: left, center, right
|
|
20
|
-
*/
|
|
21
|
-
function createDivider(project, canvas, args) {
|
|
22
|
-
const {
|
|
23
|
-
x, y, width,
|
|
24
|
-
color = '#00d9ff',
|
|
25
|
-
thickness = 1,
|
|
26
|
-
style = 'solid',
|
|
27
|
-
align = 'center',
|
|
28
|
-
} = args
|
|
29
|
-
|
|
30
|
-
let startX = x
|
|
31
|
-
let endX = x + width
|
|
32
|
-
|
|
33
|
-
if (align === 'center') {
|
|
34
|
-
startX = x - width / 2
|
|
35
|
-
endX = x + width / 2
|
|
36
|
-
} else if (align === 'right') {
|
|
37
|
-
startX = x - width
|
|
38
|
-
endX = x
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const line = new paper.Path.Line({
|
|
42
|
-
from: [startX, y],
|
|
43
|
-
to: [endX, y],
|
|
44
|
-
strokeColor: new paper.Color(color),
|
|
45
|
-
strokeWidth: thickness,
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
if (style === 'dashed') {
|
|
49
|
-
line.dashArray = [10, 5]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return { success: true, id: line.id, type: 'line' }
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
module.exports = createDivider
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 特性展示组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建特性展示块
|
|
9
|
-
*
|
|
10
|
-
* @param {Object} project - Paper.js 项目
|
|
11
|
-
* @param {Object} canvas - 画布对象
|
|
12
|
-
* @param {Object} args - 组件参数
|
|
13
|
-
* @param {number} args.x - X坐标
|
|
14
|
-
* @param {number} args.y - Y坐标
|
|
15
|
-
* @param {number} args.width - 总宽度
|
|
16
|
-
* @param {string} args.icon - 图标(emoji)
|
|
17
|
-
* @param {string} args.title - 标题
|
|
18
|
-
* @param {string} args.description - 描述
|
|
19
|
-
* @param {string} args.iconColor - 图标颜色
|
|
20
|
-
* @param {string} args.titleColor - 标题颜色
|
|
21
|
-
* @param {string} args.descColor - 描述颜色
|
|
22
|
-
* @param {number} args.iconSize - 图标大小
|
|
23
|
-
* @param {number} args.titleSize - 标题大小
|
|
24
|
-
* @param {number} args.descSize - 描述大小
|
|
25
|
-
*/
|
|
26
|
-
function createFeature(project, canvas, args) {
|
|
27
|
-
const {
|
|
28
|
-
x, y, width,
|
|
29
|
-
icon,
|
|
30
|
-
title,
|
|
31
|
-
description,
|
|
32
|
-
iconColor = '#007bff',
|
|
33
|
-
titleColor = '#ffffff',
|
|
34
|
-
descColor = '#aaaaaa',
|
|
35
|
-
iconSize = 32,
|
|
36
|
-
titleSize = 20,
|
|
37
|
-
descSize = 14,
|
|
38
|
-
} = args
|
|
39
|
-
|
|
40
|
-
const elements = []
|
|
41
|
-
const padding = 15
|
|
42
|
-
let currentY = y
|
|
43
|
-
|
|
44
|
-
// 绘制图标
|
|
45
|
-
if (icon) {
|
|
46
|
-
const iconText = new paper.PointText({
|
|
47
|
-
point: [x + padding, currentY + iconSize],
|
|
48
|
-
content: icon,
|
|
49
|
-
fontSize: iconSize,
|
|
50
|
-
fillColor: new paper.Color(iconColor),
|
|
51
|
-
justification: 'left',
|
|
52
|
-
})
|
|
53
|
-
elements.push({ type: 'text', id: iconText.id })
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// 绘制标题
|
|
57
|
-
if (title) {
|
|
58
|
-
currentY += icon ? iconSize + 5 : 0
|
|
59
|
-
const titleText = new paper.PointText({
|
|
60
|
-
point: [x + padding, currentY + titleSize],
|
|
61
|
-
content: title,
|
|
62
|
-
fontSize: titleSize,
|
|
63
|
-
fillColor: new paper.Color(titleColor),
|
|
64
|
-
justification: 'left',
|
|
65
|
-
})
|
|
66
|
-
elements.push({ type: 'text', id: titleText.id })
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// 绘制描述
|
|
70
|
-
if (description) {
|
|
71
|
-
currentY += title ? titleSize + 5 : 0
|
|
72
|
-
const descText = new paper.PointText({
|
|
73
|
-
point: [x + padding, currentY + descSize],
|
|
74
|
-
content: description,
|
|
75
|
-
fontSize: descSize,
|
|
76
|
-
fillColor: new paper.Color(descColor),
|
|
77
|
-
justification: 'left',
|
|
78
|
-
})
|
|
79
|
-
elements.push({ type: 'text', id: descText.id })
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return { success: true, elements }
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
module.exports = createFeature
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 特性网格组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建特性网格
|
|
9
|
-
*/
|
|
10
|
-
function createFeatureGrid(project, canvas, args) {
|
|
11
|
-
const {
|
|
12
|
-
x, y,
|
|
13
|
-
columns = 3,
|
|
14
|
-
itemWidth = 200,
|
|
15
|
-
itemHeight = 120,
|
|
16
|
-
gap = 20,
|
|
17
|
-
items = [],
|
|
18
|
-
background = '#1a1a2e',
|
|
19
|
-
borderColor = '#00d9ff',
|
|
20
|
-
radius = 8,
|
|
21
|
-
} = args
|
|
22
|
-
|
|
23
|
-
const elements = []
|
|
24
|
-
|
|
25
|
-
// 确保 items 是数组
|
|
26
|
-
if (!Array.isArray(items)) {
|
|
27
|
-
items = []
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const rows = items.length > 0 ? Math.ceil(items.length / columns) : 0
|
|
31
|
-
|
|
32
|
-
for (let i = 0; i < items.length; i++) {
|
|
33
|
-
const item = items[i]
|
|
34
|
-
const col = i % columns
|
|
35
|
-
const row = Math.floor(i / columns)
|
|
36
|
-
|
|
37
|
-
const itemX = x + col * (itemWidth + gap)
|
|
38
|
-
const itemY = y + row * (itemHeight + gap)
|
|
39
|
-
|
|
40
|
-
// 绘制每个特性的背景
|
|
41
|
-
const bg = new paper.Path.Rectangle({
|
|
42
|
-
point: [itemX, itemY],
|
|
43
|
-
size: [itemWidth, itemHeight],
|
|
44
|
-
radius: radius,
|
|
45
|
-
})
|
|
46
|
-
bg.fillColor = new paper.Color(background)
|
|
47
|
-
bg.strokeColor = new paper.Color(borderColor)
|
|
48
|
-
bg.strokeWidth = 0.5
|
|
49
|
-
bg.opacity = 0.8
|
|
50
|
-
if (project && project.activeLayer) {
|
|
51
|
-
project.activeLayer.addChild(bg)
|
|
52
|
-
}
|
|
53
|
-
elements.push({ type: 'rectangle', id: bg.id })
|
|
54
|
-
|
|
55
|
-
const padding = 15
|
|
56
|
-
let itemYOffset = itemY + padding
|
|
57
|
-
|
|
58
|
-
// 绘制图标
|
|
59
|
-
if (item.icon) {
|
|
60
|
-
const iconText = new paper.PointText({
|
|
61
|
-
point: [itemX + padding, itemYOffset + 24],
|
|
62
|
-
content: item.icon,
|
|
63
|
-
fontSize: 28,
|
|
64
|
-
fillColor: new paper.Color(item.iconColor || '#00ff88'),
|
|
65
|
-
justification: 'left',
|
|
66
|
-
})
|
|
67
|
-
if (project && project.activeLayer) {
|
|
68
|
-
project.activeLayer.addChild(iconText)
|
|
69
|
-
}
|
|
70
|
-
elements.push({ type: 'text', id: iconText.id })
|
|
71
|
-
itemYOffset += 35
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// 绘制标题
|
|
75
|
-
if (item.title) {
|
|
76
|
-
const titleText = new paper.PointText({
|
|
77
|
-
point: [itemX + padding, itemYOffset + 18],
|
|
78
|
-
content: item.title,
|
|
79
|
-
fontSize: 16,
|
|
80
|
-
fillColor: new paper.Color(item.titleColor || '#ffffff'),
|
|
81
|
-
justification: 'left',
|
|
82
|
-
})
|
|
83
|
-
if (project && project.activeLayer) {
|
|
84
|
-
project.activeLayer.addChild(titleText)
|
|
85
|
-
}
|
|
86
|
-
elements.push({ type: 'text', id: titleText.id })
|
|
87
|
-
itemYOffset += 22
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// 绘制描述
|
|
91
|
-
if (item.description) {
|
|
92
|
-
const descText = new paper.PointText({
|
|
93
|
-
point: [itemX + padding, itemYOffset + 14],
|
|
94
|
-
content: item.description,
|
|
95
|
-
fontSize: 12,
|
|
96
|
-
fillColor: new paper.Color(item.descColor || '#888888'),
|
|
97
|
-
justification: 'left',
|
|
98
|
-
})
|
|
99
|
-
if (project && project.activeLayer) {
|
|
100
|
-
project.activeLayer.addChild(descText)
|
|
101
|
-
}
|
|
102
|
-
elements.push({ type: 'text', id: descText.id })
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
success: true,
|
|
108
|
-
elements,
|
|
109
|
-
width: columns * itemWidth + Math.max(0, columns - 1) * gap,
|
|
110
|
-
height: rows * itemHeight + Math.max(0, rows - 1) * gap,
|
|
111
|
-
rows,
|
|
112
|
-
cols: columns,
|
|
113
|
-
type: 'featureGrid',
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
module.exports = createFeatureGrid
|