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,148 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 印章组件 - 印章效果
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
const { getFontFallbackChain, validateFont } = require('../fonts')
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 创建印章
|
|
10
|
-
*/
|
|
11
|
-
function createSeal(project, args) {
|
|
12
|
-
const {
|
|
13
|
-
x = 0,
|
|
14
|
-
y = 0,
|
|
15
|
-
size = 100,
|
|
16
|
-
text = '印章',
|
|
17
|
-
fontSize = 24,
|
|
18
|
-
fontFamily,
|
|
19
|
-
color = '#e74c3c',
|
|
20
|
-
borderColor,
|
|
21
|
-
style = 'circle', // circle, square, star, hexagon
|
|
22
|
-
borderWidth = 3,
|
|
23
|
-
opacity = 1,
|
|
24
|
-
} = args
|
|
25
|
-
|
|
26
|
-
const items = []
|
|
27
|
-
const centerX = x + size / 2
|
|
28
|
-
const centerY = y + size / 2
|
|
29
|
-
|
|
30
|
-
// 印章边框
|
|
31
|
-
let border
|
|
32
|
-
switch (style) {
|
|
33
|
-
case 'circle':
|
|
34
|
-
border = new paper.Path.Circle({
|
|
35
|
-
center: [centerX, centerY],
|
|
36
|
-
radius: size / 2 - borderWidth,
|
|
37
|
-
})
|
|
38
|
-
break
|
|
39
|
-
case 'square':
|
|
40
|
-
const squareSize = size - borderWidth * 2
|
|
41
|
-
border = new paper.Path.Rectangle({
|
|
42
|
-
point: [x + borderWidth, y + borderWidth],
|
|
43
|
-
size: [squareSize, squareSize],
|
|
44
|
-
radius: 4,
|
|
45
|
-
})
|
|
46
|
-
break
|
|
47
|
-
case 'star':
|
|
48
|
-
border = createStarPath(centerX, centerY, size / 2 - borderWidth, size / 2 - borderWidth - 10, 5)
|
|
49
|
-
break
|
|
50
|
-
case 'hexagon':
|
|
51
|
-
border = createPolygonPath(centerX, centerY, size / 2 - borderWidth, 6)
|
|
52
|
-
break
|
|
53
|
-
default:
|
|
54
|
-
border = new paper.Path.Circle({
|
|
55
|
-
center: [centerX, centerY],
|
|
56
|
-
radius: size / 2 - borderWidth,
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
border.strokeColor = new paper.Color(color)
|
|
61
|
-
border.strokeWidth = borderWidth
|
|
62
|
-
border.fillColor = null
|
|
63
|
-
if (opacity !== 1) border.opacity = opacity
|
|
64
|
-
items.push(border)
|
|
65
|
-
|
|
66
|
-
// 内边框
|
|
67
|
-
const innerBorder = border.clone()
|
|
68
|
-
innerBorder.scale(0.85, 0.85, new paper.Point(centerX, centerY))
|
|
69
|
-
innerBorder.strokeWidth = 1
|
|
70
|
-
if (opacity !== 1) innerBorder.opacity = opacity
|
|
71
|
-
items.push(innerBorder)
|
|
72
|
-
|
|
73
|
-
// 文字
|
|
74
|
-
const mainFont = getFontFallbackChain(fontFamily, text).join(', ')
|
|
75
|
-
const textItem = new paper.PointText({
|
|
76
|
-
point: [centerX, centerY + fontSize / 3],
|
|
77
|
-
content: text,
|
|
78
|
-
fontSize,
|
|
79
|
-
fontFamily: mainFont,
|
|
80
|
-
fillColor: new paper.Color(color),
|
|
81
|
-
justification: 'center',
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
if (opacity !== 1) textItem.opacity = opacity
|
|
85
|
-
items.push(textItem)
|
|
86
|
-
|
|
87
|
-
// 顶部文字(如果适用)
|
|
88
|
-
const topText = new paper.PointText({
|
|
89
|
-
point: [centerX, centerY - size / 4],
|
|
90
|
-
content: '★',
|
|
91
|
-
fontSize: 16,
|
|
92
|
-
fontFamily: mainFont,
|
|
93
|
-
fillColor: new paper.Color(color),
|
|
94
|
-
justification: 'center',
|
|
95
|
-
})
|
|
96
|
-
if (opacity !== 1) topText.opacity = opacity
|
|
97
|
-
items.push(topText)
|
|
98
|
-
|
|
99
|
-
// 底部星星装饰
|
|
100
|
-
const bottomStar = new paper.PointText({
|
|
101
|
-
point: [centerX, centerY + size / 3],
|
|
102
|
-
content: '★ ★ ★',
|
|
103
|
-
fontSize: 12,
|
|
104
|
-
fontFamily: mainFont,
|
|
105
|
-
fillColor: new paper.Color(color),
|
|
106
|
-
justification: 'center',
|
|
107
|
-
letterSpacing: 8,
|
|
108
|
-
})
|
|
109
|
-
if (opacity !== 1) bottomStar.opacity = opacity
|
|
110
|
-
items.push(bottomStar)
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
success: true,
|
|
114
|
-
type: 'seal',
|
|
115
|
-
items: items.map(i => i.id),
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* 创建五角星路径
|
|
121
|
-
*/
|
|
122
|
-
function createStarPath(cx, cy, outerR, innerR, points) {
|
|
123
|
-
const path = new paper.Path()
|
|
124
|
-
const angleStep = Math.PI / points
|
|
125
|
-
|
|
126
|
-
for (let i = 0; i < points * 2; i++) {
|
|
127
|
-
const r = i % 2 === 0 ? outerR : innerR
|
|
128
|
-
const angle = i * angleStep - Math.PI / 2
|
|
129
|
-
path.add(new paper.Point(cx + r * Math.cos(angle), cy + r * Math.sin(angle)))
|
|
130
|
-
}
|
|
131
|
-
path.closed = true
|
|
132
|
-
return path
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* 创建多边形路径
|
|
137
|
-
*/
|
|
138
|
-
function createPolygonPath(cx, cy, radius, sides) {
|
|
139
|
-
const path = new paper.Path()
|
|
140
|
-
for (let i = 0; i < sides; i++) {
|
|
141
|
-
const angle = (i * 2 * Math.PI / sides) - Math.PI / 2
|
|
142
|
-
path.add(new paper.Point(cx + radius * Math.cos(angle), cy + radius * Math.sin(angle)))
|
|
143
|
-
}
|
|
144
|
-
path.closed = true
|
|
145
|
-
return path
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
module.exports = createSeal
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 星形组件 - 支持多角星形
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建星形组件
|
|
9
|
-
* @param {Object} project - Paper.js 项目
|
|
10
|
-
* @param {Object} canvas - 画布对象
|
|
11
|
-
* @param {Object} params - 组件参数
|
|
12
|
-
*/
|
|
13
|
-
function createStar(project, canvas, params) {
|
|
14
|
-
const {
|
|
15
|
-
cx,
|
|
16
|
-
cy,
|
|
17
|
-
points = 5,
|
|
18
|
-
innerRadius,
|
|
19
|
-
outerRadius,
|
|
20
|
-
fill,
|
|
21
|
-
stroke,
|
|
22
|
-
strokeWidth = 1,
|
|
23
|
-
opacity = 1,
|
|
24
|
-
rotation = 0
|
|
25
|
-
} = params
|
|
26
|
-
|
|
27
|
-
// 计算内半径
|
|
28
|
-
const actualInnerRadius = innerRadius || outerRadius * 0.4
|
|
29
|
-
|
|
30
|
-
// 创建星形路径
|
|
31
|
-
const path = new paper.Path()
|
|
32
|
-
const angleStep = Math.PI / points
|
|
33
|
-
|
|
34
|
-
for (let i = 0; i < points * 2; i++) {
|
|
35
|
-
const radius = i % 2 === 0 ? outerRadius : actualInnerRadius
|
|
36
|
-
const angle = i * angleStep - Math.PI / 2 + (rotation * Math.PI / 180)
|
|
37
|
-
const x = cx + radius * Math.cos(angle)
|
|
38
|
-
const y = cy + radius * Math.sin(angle)
|
|
39
|
-
|
|
40
|
-
if (i === 0) {
|
|
41
|
-
path.moveTo(x, y)
|
|
42
|
-
} else {
|
|
43
|
-
path.lineTo(x, y)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
path.closePath()
|
|
47
|
-
|
|
48
|
-
// 设置样式
|
|
49
|
-
if (fill) {
|
|
50
|
-
path.fillColor = new paper.Color(fill)
|
|
51
|
-
}
|
|
52
|
-
if (stroke) {
|
|
53
|
-
path.strokeColor = new paper.Color(stroke)
|
|
54
|
-
path.strokeWidth = strokeWidth
|
|
55
|
-
}
|
|
56
|
-
path.opacity = opacity
|
|
57
|
-
|
|
58
|
-
// 关键:将元素添加到活动层
|
|
59
|
-
if (project && project.activeLayer) {
|
|
60
|
-
project.activeLayer.addChild(path)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
success: true,
|
|
65
|
-
elements: [{ type: 'path', id: path.id }],
|
|
66
|
-
type: 'star'
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
module.exports = createStar
|
|
@@ -1,105 +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 {number} args.height - 高度
|
|
17
|
-
* @param {string} args.label - 标签
|
|
18
|
-
* @param {string} args.value - 数值
|
|
19
|
-
* @param {string} args.change - 变化值(如 "+12.5%")
|
|
20
|
-
* @param {boolean} args.positive - 变化是否为正
|
|
21
|
-
* @param {string} args.icon - 图标
|
|
22
|
-
* @param {string} args.iconColor - 图标颜色
|
|
23
|
-
* @param {string} args.background - 背景色
|
|
24
|
-
* @param {string} args.border - 边框颜色
|
|
25
|
-
* @param {number} args.radius - 圆角半径
|
|
26
|
-
*/
|
|
27
|
-
function createStatCard(project, canvas, args) {
|
|
28
|
-
const {
|
|
29
|
-
x, y,
|
|
30
|
-
width = 200,
|
|
31
|
-
height = 120,
|
|
32
|
-
label = 'Total Users',
|
|
33
|
-
value = '10,000',
|
|
34
|
-
change,
|
|
35
|
-
positive = true,
|
|
36
|
-
icon,
|
|
37
|
-
iconColor = '#6366f1',
|
|
38
|
-
background = '#ffffff',
|
|
39
|
-
border = '#e5e7eb',
|
|
40
|
-
radius = 12,
|
|
41
|
-
} = args
|
|
42
|
-
|
|
43
|
-
const elements = []
|
|
44
|
-
|
|
45
|
-
// 绘制背景
|
|
46
|
-
const bg = new paper.Path.Rectangle({
|
|
47
|
-
point: [x, y],
|
|
48
|
-
size: [width, height],
|
|
49
|
-
radius: radius,
|
|
50
|
-
})
|
|
51
|
-
bg.fillColor = new paper.Color(background)
|
|
52
|
-
bg.strokeColor = new paper.Color(border)
|
|
53
|
-
bg.strokeWidth = 1
|
|
54
|
-
elements.push({ type: 'rectangle', id: bg.id })
|
|
55
|
-
|
|
56
|
-
// 绘制图标
|
|
57
|
-
if (icon) {
|
|
58
|
-
const iconText = new paper.PointText({
|
|
59
|
-
point: [x + 20, y + 35],
|
|
60
|
-
content: icon,
|
|
61
|
-
fontSize: 24,
|
|
62
|
-
fillColor: new paper.Color(iconColor),
|
|
63
|
-
justification: 'left',
|
|
64
|
-
})
|
|
65
|
-
elements.push({ type: 'text', id: iconText.id })
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// 绘制标签
|
|
69
|
-
const labelText = new paper.PointText({
|
|
70
|
-
point: [x + 20, y + 50 + (icon ? 10 : 0)],
|
|
71
|
-
content: label,
|
|
72
|
-
fontSize: 14,
|
|
73
|
-
fillColor: new paper.Color('#64748b'),
|
|
74
|
-
justification: 'left',
|
|
75
|
-
})
|
|
76
|
-
elements.push({ type: 'text', id: labelText.id })
|
|
77
|
-
|
|
78
|
-
// 绘制数值
|
|
79
|
-
const valueText = new paper.PointText({
|
|
80
|
-
point: [x + 20, y + 75 + (icon ? 10 : 0)],
|
|
81
|
-
content: value,
|
|
82
|
-
fontSize: 28,
|
|
83
|
-
fillColor: new paper.Color('#1e293b'),
|
|
84
|
-
justification: 'left',
|
|
85
|
-
})
|
|
86
|
-
elements.push({ type: 'text', id: valueText.id })
|
|
87
|
-
|
|
88
|
-
// 绘制变化值
|
|
89
|
-
if (change) {
|
|
90
|
-
const changeColor = positive ? '#22c55e' : '#ef4444'
|
|
91
|
-
const changeIcon = positive ? '↑' : '↓'
|
|
92
|
-
const changeText = new paper.PointText({
|
|
93
|
-
point: [x + 20, y + 95 + (icon ? 10 : 0)],
|
|
94
|
-
content: `${changeIcon} ${change}`,
|
|
95
|
-
fontSize: 14,
|
|
96
|
-
fillColor: new paper.Color(changeColor),
|
|
97
|
-
justification: 'left',
|
|
98
|
-
})
|
|
99
|
-
elements.push({ type: 'text', id: changeText.id })
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return { success: true, elements }
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
module.exports = createStatCard
|
|
@@ -1,118 +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 {Array} args.steps - 步骤数组 [{title, description}]
|
|
17
|
-
* @param {number} args.currentStep - 当前步骤(从0开始)
|
|
18
|
-
* @param {string} args.activeColor - 激活颜色
|
|
19
|
-
* @param {string} args.inactiveColor - 未激活颜色
|
|
20
|
-
* @param {string} args.completedColor - 已完成颜色
|
|
21
|
-
* @param {number} args.circleSize - 圆圈大小
|
|
22
|
-
*/
|
|
23
|
-
function createStepper(project, canvas, args) {
|
|
24
|
-
const {
|
|
25
|
-
x, y,
|
|
26
|
-
width = 600,
|
|
27
|
-
steps = [],
|
|
28
|
-
currentStep = 0,
|
|
29
|
-
activeColor = '#6366f1',
|
|
30
|
-
inactiveColor = '#e5e7eb',
|
|
31
|
-
completedColor = '#22c55e',
|
|
32
|
-
circleSize = 40,
|
|
33
|
-
} = args
|
|
34
|
-
|
|
35
|
-
const elements = []
|
|
36
|
-
const stepWidth = steps.length > 1 ? width / (steps.length - 1) : width
|
|
37
|
-
const lineY = y + circleSize / 2
|
|
38
|
-
|
|
39
|
-
// 绘制连接线
|
|
40
|
-
if (steps.length > 1) {
|
|
41
|
-
const line = new paper.Path.Line({
|
|
42
|
-
from: [x + circleSize / 2, lineY],
|
|
43
|
-
to: [x + width - circleSize / 2, lineY],
|
|
44
|
-
strokeColor: new paper.Color(inactiveColor),
|
|
45
|
-
strokeWidth: 2,
|
|
46
|
-
})
|
|
47
|
-
elements.push({ type: 'line', id: line.id })
|
|
48
|
-
|
|
49
|
-
// 绘制已完成部分的覆盖线
|
|
50
|
-
if (currentStep > 0) {
|
|
51
|
-
const completedLine = new paper.Path.Line({
|
|
52
|
-
from: [x + circleSize / 2, lineY],
|
|
53
|
-
to: [x + circleSize / 2 + (currentStep) * stepWidth, lineY],
|
|
54
|
-
strokeColor: new paper.Color(completedColor),
|
|
55
|
-
strokeWidth: 2,
|
|
56
|
-
})
|
|
57
|
-
elements.push({ type: 'line', id: completedLine.id })
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// 绘制每个步骤
|
|
62
|
-
for (let i = 0; i < steps.length; i++) {
|
|
63
|
-
const stepX = steps.length > 1 ? x + i * stepWidth : x
|
|
64
|
-
const step = steps[i]
|
|
65
|
-
let color = inactiveColor
|
|
66
|
-
|
|
67
|
-
if (i < currentStep) {
|
|
68
|
-
color = completedColor
|
|
69
|
-
} else if (i === currentStep) {
|
|
70
|
-
color = activeColor
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// 绘制圆圈
|
|
74
|
-
const circle = new paper.Path.Circle({
|
|
75
|
-
center: [stepX + circleSize / 2, lineY],
|
|
76
|
-
radius: circleSize / 2,
|
|
77
|
-
})
|
|
78
|
-
circle.fillColor = new paper.Color(color)
|
|
79
|
-
elements.push({ type: 'circle', id: circle.id })
|
|
80
|
-
|
|
81
|
-
// 绘制步骤编号或勾选
|
|
82
|
-
const icon = i < currentStep ? '✓' : String(i + 1)
|
|
83
|
-
const iconText = new paper.PointText({
|
|
84
|
-
point: [stepX + circleSize / 2, lineY + circleSize / 6],
|
|
85
|
-
content: icon,
|
|
86
|
-
fontSize: 16,
|
|
87
|
-
fillColor: new paper.Color('#ffffff'),
|
|
88
|
-
justification: 'center',
|
|
89
|
-
})
|
|
90
|
-
elements.push({ type: 'text', id: iconText.id })
|
|
91
|
-
|
|
92
|
-
// 绘制标题
|
|
93
|
-
const titleText = new paper.PointText({
|
|
94
|
-
point: [stepX + circleSize / 2, y + circleSize + 20],
|
|
95
|
-
content: step.title || `Step ${i + 1}`,
|
|
96
|
-
fontSize: 14,
|
|
97
|
-
fillColor: new paper.Color(i <= currentStep ? '#1e293b' : '#94a3b8'),
|
|
98
|
-
justification: 'center',
|
|
99
|
-
})
|
|
100
|
-
elements.push({ type: 'text', id: titleText.id })
|
|
101
|
-
|
|
102
|
-
// 绘制描述
|
|
103
|
-
if (step.description) {
|
|
104
|
-
const descText = new paper.PointText({
|
|
105
|
-
point: [stepX + circleSize / 2, y + circleSize + 38],
|
|
106
|
-
content: step.description,
|
|
107
|
-
fontSize: 11,
|
|
108
|
-
fillColor: new paper.Color('#94a3b8'),
|
|
109
|
-
justification: 'center',
|
|
110
|
-
})
|
|
111
|
-
elements.push({ type: 'text', id: descText.id })
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return { success: true, elements }
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
module.exports = createStepper
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 表格组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建表格组件
|
|
9
|
-
*/
|
|
10
|
-
function createTable(project, canvas, params) {
|
|
11
|
-
const {
|
|
12
|
-
x,
|
|
13
|
-
y,
|
|
14
|
-
width,
|
|
15
|
-
columns,
|
|
16
|
-
rows,
|
|
17
|
-
rowHeight = 36,
|
|
18
|
-
headerBg = '#f0f0f0',
|
|
19
|
-
headerColor = '#333333',
|
|
20
|
-
borderColor = '#e0e0e0',
|
|
21
|
-
cellColor = '#333333',
|
|
22
|
-
fontSize = 12,
|
|
23
|
-
headerFontSize = 13,
|
|
24
|
-
striped = true,
|
|
25
|
-
stripeColor = '#fafafa'
|
|
26
|
-
} = params
|
|
27
|
-
|
|
28
|
-
const elements = []
|
|
29
|
-
|
|
30
|
-
// 确保 columns 是数组且不为空
|
|
31
|
-
if (!Array.isArray(columns) || columns.length === 0) {
|
|
32
|
-
return { success: true, elements, type: 'table' }
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 确保 rows 是数组
|
|
36
|
-
if (!Array.isArray(rows)) {
|
|
37
|
-
rows = []
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 确保 width 有默认值
|
|
41
|
-
const tableWidth = width || 400
|
|
42
|
-
const totalHeight = rowHeight * (rows.length + 1)
|
|
43
|
-
|
|
44
|
-
// 绘制外边框
|
|
45
|
-
const outerBorder = new paper.Path.Rectangle({
|
|
46
|
-
point: [x, y],
|
|
47
|
-
size: [tableWidth, totalHeight]
|
|
48
|
-
})
|
|
49
|
-
outerBorder.fillColor = new paper.Color('transparent')
|
|
50
|
-
outerBorder.strokeColor = new paper.Color(borderColor)
|
|
51
|
-
outerBorder.strokeWidth = 1
|
|
52
|
-
if (project && project.activeLayer) {
|
|
53
|
-
project.activeLayer.addChild(outerBorder)
|
|
54
|
-
}
|
|
55
|
-
elements.push({ type: 'path', id: outerBorder.id })
|
|
56
|
-
|
|
57
|
-
// 绘制表头背景
|
|
58
|
-
const headerBgRect = new paper.Path.Rectangle({
|
|
59
|
-
point: [x, y],
|
|
60
|
-
size: [tableWidth, rowHeight]
|
|
61
|
-
})
|
|
62
|
-
headerBgRect.fillColor = new paper.Color(headerBg)
|
|
63
|
-
headerBgRect.strokeColor = new paper.Color(borderColor)
|
|
64
|
-
headerBgRect.strokeWidth = 0.5
|
|
65
|
-
if (project && project.activeLayer) {
|
|
66
|
-
project.activeLayer.addChild(headerBgRect)
|
|
67
|
-
}
|
|
68
|
-
elements.push({ type: 'path', id: headerBgRect.id })
|
|
69
|
-
|
|
70
|
-
// 绘制表头
|
|
71
|
-
let currentX = x
|
|
72
|
-
columns.forEach((col, index) => {
|
|
73
|
-
const colWidth = col.width || (tableWidth / columns.length)
|
|
74
|
-
|
|
75
|
-
// 列分隔线
|
|
76
|
-
if (index > 0) {
|
|
77
|
-
const line = new paper.Path.Line({
|
|
78
|
-
from: [currentX, y],
|
|
79
|
-
to: [currentX, y + totalHeight]
|
|
80
|
-
})
|
|
81
|
-
line.strokeColor = new paper.Color(borderColor)
|
|
82
|
-
line.strokeWidth = 0.5
|
|
83
|
-
if (project && project.activeLayer) {
|
|
84
|
-
project.activeLayer.addChild(line)
|
|
85
|
-
}
|
|
86
|
-
elements.push({ type: 'line', id: line.id })
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// 表头文字
|
|
90
|
-
const headerText = new paper.PointText({
|
|
91
|
-
point: [currentX + colWidth / 2, y + rowHeight / 2 + fontSize / 3],
|
|
92
|
-
content: col.title || '',
|
|
93
|
-
fontSize: headerFontSize,
|
|
94
|
-
fillColor: new paper.Color(headerColor),
|
|
95
|
-
justification: col.align || 'center',
|
|
96
|
-
fontWeight: 'bold'
|
|
97
|
-
})
|
|
98
|
-
if (project && project.activeLayer) {
|
|
99
|
-
project.activeLayer.addChild(headerText)
|
|
100
|
-
}
|
|
101
|
-
elements.push({ type: 'text', id: headerText.id })
|
|
102
|
-
|
|
103
|
-
currentX += colWidth
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
// 绘制数据行
|
|
107
|
-
rows.forEach((row, rowIndex) => {
|
|
108
|
-
const rowY = y + rowHeight * (rowIndex + 1)
|
|
109
|
-
|
|
110
|
-
// 斑马纹背景
|
|
111
|
-
if (striped && rowIndex % 2 === 1) {
|
|
112
|
-
const stripeBg = new paper.Path.Rectangle({
|
|
113
|
-
point: [x, rowY],
|
|
114
|
-
size: [tableWidth, rowHeight]
|
|
115
|
-
})
|
|
116
|
-
stripeBg.fillColor = new paper.Color(stripeColor)
|
|
117
|
-
stripeBg.strokeColor = new paper.Color(borderColor)
|
|
118
|
-
stripeBg.strokeWidth = 0.5
|
|
119
|
-
if (project && project.activeLayer) {
|
|
120
|
-
project.activeLayer.addChild(stripeBg)
|
|
121
|
-
}
|
|
122
|
-
elements.push({ type: 'path', id: stripeBg.id })
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// 行分隔线
|
|
126
|
-
const rowLine = new paper.Path.Line({
|
|
127
|
-
from: [x, rowY],
|
|
128
|
-
to: [x + tableWidth, rowY]
|
|
129
|
-
})
|
|
130
|
-
rowLine.strokeColor = new paper.Color(borderColor)
|
|
131
|
-
rowLine.strokeWidth = 0.5
|
|
132
|
-
if (project && project.activeLayer) {
|
|
133
|
-
project.activeLayer.addChild(rowLine)
|
|
134
|
-
}
|
|
135
|
-
elements.push({ type: 'line', id: rowLine.id })
|
|
136
|
-
|
|
137
|
-
// 单元格
|
|
138
|
-
let cellX = x
|
|
139
|
-
columns.forEach((col, colIndex) => {
|
|
140
|
-
const colWidth = col.width || (tableWidth / columns.length)
|
|
141
|
-
const cellValue = row[colIndex] || ''
|
|
142
|
-
const cellText = new paper.PointText({
|
|
143
|
-
point: [cellX + colWidth / 2, rowY + rowHeight / 2 + fontSize / 3],
|
|
144
|
-
content: String(cellValue),
|
|
145
|
-
fontSize: fontSize,
|
|
146
|
-
fillColor: new paper.Color(cellColor),
|
|
147
|
-
justification: col.align || 'center'
|
|
148
|
-
})
|
|
149
|
-
if (project && project.activeLayer) {
|
|
150
|
-
project.activeLayer.addChild(cellText)
|
|
151
|
-
}
|
|
152
|
-
elements.push({ type: 'text', id: cellText.id })
|
|
153
|
-
|
|
154
|
-
cellX += colWidth
|
|
155
|
-
})
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
success: true,
|
|
160
|
-
elements,
|
|
161
|
-
width: tableWidth,
|
|
162
|
-
height: totalHeight,
|
|
163
|
-
type: 'table'
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
module.exports = createTable
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 标签云组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建标签云
|
|
9
|
-
*/
|
|
10
|
-
function createTagCloud(project, canvas, args) {
|
|
11
|
-
const {
|
|
12
|
-
x = 0,
|
|
13
|
-
y = 0,
|
|
14
|
-
tags = [],
|
|
15
|
-
fontSize = 14,
|
|
16
|
-
padding = 12,
|
|
17
|
-
gap = 10,
|
|
18
|
-
maxWidth = 400,
|
|
19
|
-
} = args
|
|
20
|
-
|
|
21
|
-
const elements = []
|
|
22
|
-
|
|
23
|
-
// 确保 tags 是数组
|
|
24
|
-
if (!Array.isArray(tags) || tags.length === 0) {
|
|
25
|
-
return { success: true, elements, height: 0, type: 'tagCloud' }
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let currentX = x
|
|
29
|
-
let currentY = y
|
|
30
|
-
let rowHeight = 0
|
|
31
|
-
|
|
32
|
-
for (const tag of tags) {
|
|
33
|
-
// 确保 tag.text 是字符串
|
|
34
|
-
const tagText = String(tag.text || '')
|
|
35
|
-
if (!tagText) continue
|
|
36
|
-
|
|
37
|
-
const textWidth = tagText.length * fontSize * 0.6
|
|
38
|
-
const tagWidth = textWidth + padding * 2
|
|
39
|
-
const tagHeight = fontSize + padding * 2
|
|
40
|
-
|
|
41
|
-
// 换行处理
|
|
42
|
-
if (currentX + tagWidth > x + maxWidth && currentX > x) {
|
|
43
|
-
currentX = x
|
|
44
|
-
currentY += rowHeight + gap
|
|
45
|
-
rowHeight = 0
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 绘制标签背景
|
|
49
|
-
const tagBg = new paper.Path.Rectangle({
|
|
50
|
-
point: [currentX, currentY],
|
|
51
|
-
size: [tagWidth, tagHeight],
|
|
52
|
-
radius: tagHeight / 2,
|
|
53
|
-
})
|
|
54
|
-
tagBg.fillColor = new paper.Color(tag.bgColor || '#e0e7ff')
|
|
55
|
-
if (project && project.activeLayer) {
|
|
56
|
-
project.activeLayer.addChild(tagBg)
|
|
57
|
-
}
|
|
58
|
-
elements.push({ type: 'rectangle', id: tagBg.id })
|
|
59
|
-
|
|
60
|
-
// 绘制标签文字
|
|
61
|
-
const tagTextEl = new paper.PointText({
|
|
62
|
-
point: [currentX + tagWidth / 2, currentY + tagHeight / 2 + fontSize / 3],
|
|
63
|
-
content: tagText,
|
|
64
|
-
fontSize: fontSize,
|
|
65
|
-
fillColor: new paper.Color(tag.color || '#4338ca'),
|
|
66
|
-
justification: 'center',
|
|
67
|
-
})
|
|
68
|
-
if (project && project.activeLayer) {
|
|
69
|
-
project.activeLayer.addChild(tagTextEl)
|
|
70
|
-
}
|
|
71
|
-
elements.push({ type: 'text', id: tagTextEl.id })
|
|
72
|
-
|
|
73
|
-
currentX += tagWidth + gap
|
|
74
|
-
rowHeight = Math.max(rowHeight, tagHeight)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
success: true,
|
|
79
|
-
elements,
|
|
80
|
-
height: currentY - y + rowHeight,
|
|
81
|
-
type: 'tagCloud',
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
module.exports = createTagCloud
|