foliko 1.0.87 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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 +325 -21
- package/.agent/data/plugins-state.json +194 -162
- package/.agent/data/puppeteer-sessions/undefined.json +6 -0
- package/.agent/mcp_config.json +0 -1
- package/.agent/mcp_config_updated.json +12 -0
- package/.agent/plugins/poster-plugin/README.md +304 -0
- 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//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 +13 -0
- package/.agent/plugins/poster-plugin/package.json +28 -0
- package/.agent/plugins/poster-plugin/src/canvas.js +161 -0
- package/.agent/plugins/poster-plugin/src/components/arrow.js +84 -0
- package/.agent/plugins/poster-plugin/src/components/avatar.js +71 -0
- package/.agent/plugins/poster-plugin/src/components/badge.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/card.js +88 -0
- package/.agent/plugins/poster-plugin/src/components/chart.js +127 -0
- package/.agent/plugins/poster-plugin/src/components/chip.js +88 -0
- package/.agent/plugins/poster-plugin/src/components/columns.js +107 -0
- package/.agent/plugins/poster-plugin/src/components/cta.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/divider.js +55 -0
- package/.agent/plugins/poster-plugin/src/components/feature.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/featureGrid.js +112 -0
- package/.agent/plugins/poster-plugin/src/components/grid.js +118 -0
- package/.agent/plugins/poster-plugin/src/components/imageFrame.js +155 -0
- package/.agent/plugins/poster-plugin/src/components/index.js +62 -0
- package/.agent/plugins/poster-plugin/src/components/listItem.js +146 -0
- package/.agent/plugins/poster-plugin/src/components/notification.js +123 -0
- package/.agent/plugins/poster-plugin/src/components/progress.js +79 -0
- package/.agent/plugins/poster-plugin/src/components/progressCircle.js +117 -0
- package/.agent/plugins/poster-plugin/src/components/quote.js +97 -0
- package/.agent/plugins/poster-plugin/src/components/rating.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/star.js +70 -0
- package/.agent/plugins/poster-plugin/src/components/statCard.js +105 -0
- package/.agent/plugins/poster-plugin/src/components/stepper.js +118 -0
- package/.agent/plugins/poster-plugin/src/components/table.js +159 -0
- package/.agent/plugins/poster-plugin/src/components/tagCloud.js +78 -0
- package/.agent/plugins/poster-plugin/src/components/timeline.js +105 -0
- package/.agent/plugins/poster-plugin/src/components/watermark.js +52 -0
- package/.agent/plugins/poster-plugin/src/composer.js +1904 -0
- package/.agent/plugins/poster-plugin/src/elements/artText.js +60 -0
- package/.agent/plugins/poster-plugin/src/elements/background.js +52 -0
- package/.agent/plugins/poster-plugin/src/elements/circle.js +31 -0
- package/.agent/plugins/poster-plugin/src/elements/image.js +71 -0
- package/.agent/plugins/poster-plugin/src/elements/index.js +26 -0
- package/.agent/plugins/poster-plugin/src/elements/line.js +23 -0
- package/.agent/plugins/poster-plugin/src/elements/polygon.js +63 -0
- package/.agent/plugins/poster-plugin/src/elements/rectangle.js +32 -0
- package/.agent/plugins/poster-plugin/src/elements/svg.js +92 -0
- package/.agent/plugins/poster-plugin/src/elements/text.js +107 -0
- package/.agent/plugins/poster-plugin/src/fonts.js +233 -0
- package/.agent/plugins/poster-plugin/src/index.js +1658 -0
- package/.agent/plugins/poster-plugin/src/presets.js +36 -0
- package/.agent/plugins/poster-plugin/src/templates/business.js +60 -0
- package/.agent/plugins/poster-plugin/src/templates/gradient.js +64 -0
- package/.agent/plugins/poster-plugin/src/templates/index.js +43 -0
- package/.agent/plugins/poster-plugin/src/templates/modern.js +69 -0
- package/.agent/plugins/poster-plugin/src/templates/simple.js +58 -0
- package/.agent/plugins/poster-plugin/src/templates/social.js +62 -0
- package/.agent/plugins/poster-plugin/src/templates/tech.js +84 -0
- package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/index.js +1 -1
- 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 +419 -0
- package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +2195 -0
- 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/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 +20 -8
- package/.env.example +56 -56
- package/CLAUDE.md +144 -108
- package/README.md +441 -441
- package/calc_tokens_weixin.js +81 -0
- package/cli/src/commands/chat.js +2 -1
- package/docs/CONTEXT_DESIGN.md +1596 -0
- package/examples/test-concurrent-chat.js +60 -60
- package/foliko-creative-3.png +0 -0
- package/foliko-creative-4.png +0 -0
- package/foliko-creative-5.png +0 -0
- package/package.json +2 -2
- package/plugins/default-plugins.js +2 -1
- package/plugins/extension-executor-plugin.js +91 -2
- package/plugins/file-system-plugin.js +2 -2
- package/plugins/memory-plugin.js +984 -0
- package/plugins/session-plugin.js +57 -1
- package/plugins/weixin-plugin.js +33 -23
- package/skills/find-skills/AGENTS.md +162 -162
- package/skills/find-skills/SKILL.md +133 -133
- package/skills/poster-guide/SKILL.md +1059 -0
- package/skills/python-plugin-dev/SKILL.md +238 -238
- package/skills/skill-guide/SKILL.md +130 -108
- package/src/capabilities/skill-manager.js +99 -0
- package/src/core/agent-chat.js +620 -141
- package/src/core/agent-context.js +188 -0
- package/src/core/agent.js +6 -2
- package/src/core/context-manager.js +283 -0
- package/src/core/framework.js +264 -3
- package/src/core/plugin-manager.js +79 -2
- package/src/core/request-context.js +98 -0
- package/src/core/session-context.js +341 -0
- package/src/core/session-storage.js +274 -0
- package/src/executors/mcp-executor.js +2 -2
- package/src/utils/index.js +239 -67
- package/src/utils/plugin-helpers.js +17 -0
- package/story-cover-book-v2.png +0 -0
- package/story-cover-japanese-1.png +0 -0
- package/story-cover-japanese-2.png +0 -0
- package/story-cover-japanese-3.png +0 -0
- package/story-cover-moran.png +0 -0
- package/undefined.png +0 -0
- package//346/265/267/346/212/245/346/217/222/344/273/266.md +621 -0
- package/.agent/agents/code-assistant.json +0 -14
- package/.agent/agents/email-assistant.json +0 -14
- package/.agent/agents/file-assistant.json +0 -15
- package/.agent/agents/system-assistant.json +0 -15
- package/.agent/agents/web-assistant.json +0 -12
- package/.agent/data/ambient/goals.json +0 -50
- package/.agent/data/ambient/memories.json +0 -7
- package/.agent/data/scheduler/tasks.json +0 -1
- package/.agent/package.json +0 -8
- package/.agent/plugins/__pycache__/test_plugin.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/index.js +0 -228
- package/.agent/plugins/marknative/package.json +0 -12
- package/.agent/plugins/marknative/update-readme.js +0 -134
- 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/temp-repo/LICENSE +0 -201
- package/.agent/plugins/test_plugin.py +0 -304
- 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/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/examples/test-chat-debug.js +0 -102
- package/examples/test-chat-result.js +0 -76
- package/examples/test-chat-stream-diff.js +0 -63
- /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/README.md +0 -0
- /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/package.json +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
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.type - 类型: success, warning, error, info
|
|
17
|
+
* @param {string} args.title - 标题
|
|
18
|
+
* @param {string} args.message - 消息内容
|
|
19
|
+
* @param {boolean} args.showIcon - 是否显示图标
|
|
20
|
+
* @param {number} args.radius - 圆角半径
|
|
21
|
+
*/
|
|
22
|
+
function createNotification(project, canvas, args) {
|
|
23
|
+
const {
|
|
24
|
+
x, y,
|
|
25
|
+
width = 360,
|
|
26
|
+
type = 'info',
|
|
27
|
+
title,
|
|
28
|
+
message,
|
|
29
|
+
showIcon = true,
|
|
30
|
+
radius = 12,
|
|
31
|
+
} = args
|
|
32
|
+
|
|
33
|
+
// 类型配置
|
|
34
|
+
const config = {
|
|
35
|
+
success: {
|
|
36
|
+
icon: '✓',
|
|
37
|
+
bgColor: '#dcfce7',
|
|
38
|
+
iconColor: '#22c55e',
|
|
39
|
+
borderColor: '#22c55e',
|
|
40
|
+
},
|
|
41
|
+
warning: {
|
|
42
|
+
icon: '⚠',
|
|
43
|
+
bgColor: '#fef9c3',
|
|
44
|
+
iconColor: '#eab308',
|
|
45
|
+
borderColor: '#eab308',
|
|
46
|
+
},
|
|
47
|
+
error: {
|
|
48
|
+
icon: '✕',
|
|
49
|
+
bgColor: '#fee2e2',
|
|
50
|
+
iconColor: '#ef4444',
|
|
51
|
+
borderColor: '#ef4444',
|
|
52
|
+
},
|
|
53
|
+
info: {
|
|
54
|
+
icon: 'ℹ',
|
|
55
|
+
bgColor: '#dbeafe',
|
|
56
|
+
iconColor: '#3b82f6',
|
|
57
|
+
borderColor: '#3b82f6',
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const c = config[type] || config.info
|
|
62
|
+
const padding = 16
|
|
63
|
+
const lineHeight = 22
|
|
64
|
+
const iconSize = 24
|
|
65
|
+
const height = padding * 2 + (title ? lineHeight + 8 : 0) + (message ? lineHeight : 0)
|
|
66
|
+
|
|
67
|
+
const elements = []
|
|
68
|
+
|
|
69
|
+
// 绘制背景
|
|
70
|
+
const bg = new paper.Path.Rectangle({
|
|
71
|
+
point: [x, y],
|
|
72
|
+
size: [width, height],
|
|
73
|
+
radius: radius,
|
|
74
|
+
})
|
|
75
|
+
bg.fillColor = new paper.Color(c.bgColor)
|
|
76
|
+
bg.strokeColor = new paper.Color(c.borderColor)
|
|
77
|
+
bg.strokeWidth = 1
|
|
78
|
+
elements.push({ type: 'rectangle', id: bg.id })
|
|
79
|
+
|
|
80
|
+
// 绘制图标
|
|
81
|
+
if (showIcon) {
|
|
82
|
+
const iconText = new paper.PointText({
|
|
83
|
+
point: [x + padding + iconSize / 2, y + padding + iconSize / 2 + 6],
|
|
84
|
+
content: c.icon,
|
|
85
|
+
fontSize: iconSize,
|
|
86
|
+
fillColor: new paper.Color(c.iconColor),
|
|
87
|
+
justification: 'center',
|
|
88
|
+
})
|
|
89
|
+
elements.push({ type: 'text', id: iconText.id })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const textX = showIcon ? x + padding + iconSize + 12 : x + padding
|
|
93
|
+
let currentY = y + padding
|
|
94
|
+
|
|
95
|
+
// 绘制标题
|
|
96
|
+
if (title) {
|
|
97
|
+
const titleText = new paper.PointText({
|
|
98
|
+
point: [textX, currentY + 18],
|
|
99
|
+
content: title,
|
|
100
|
+
fontSize: 16,
|
|
101
|
+
fillColor: new paper.Color('#1e293b'),
|
|
102
|
+
justification: 'left',
|
|
103
|
+
})
|
|
104
|
+
elements.push({ type: 'text', id: titleText.id })
|
|
105
|
+
currentY += lineHeight + 8
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 绘制消息
|
|
109
|
+
if (message) {
|
|
110
|
+
const msgText = new paper.PointText({
|
|
111
|
+
point: [textX, currentY + 16],
|
|
112
|
+
content: message,
|
|
113
|
+
fontSize: 14,
|
|
114
|
+
fillColor: new paper.Color('#475569'),
|
|
115
|
+
justification: 'left',
|
|
116
|
+
})
|
|
117
|
+
elements.push({ type: 'text', id: msgText.id })
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return { success: true, elements }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
module.exports = createNotification
|
|
@@ -0,0 +1,79 @@
|
|
|
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 {number} args.value - 进度值 0-100
|
|
18
|
+
* @param {string} args.trackColor - 轨道颜色
|
|
19
|
+
* @param {string} args.fillColor - 填充颜色
|
|
20
|
+
* @param {number} args.radius - 圆角半径
|
|
21
|
+
* @param {boolean} args.showLabel - 是否显示标签
|
|
22
|
+
* @param {string} args.label - 标签文字
|
|
23
|
+
*/
|
|
24
|
+
function createProgress(project, canvas, args) {
|
|
25
|
+
const {
|
|
26
|
+
x, y,
|
|
27
|
+
width = 300,
|
|
28
|
+
height = 20,
|
|
29
|
+
value = 50,
|
|
30
|
+
trackColor = '#e0e0e0',
|
|
31
|
+
fillColor = '#6366f1',
|
|
32
|
+
radius = 10,
|
|
33
|
+
showLabel = false,
|
|
34
|
+
label,
|
|
35
|
+
} = args
|
|
36
|
+
|
|
37
|
+
const elements = []
|
|
38
|
+
|
|
39
|
+
// 绘制轨道
|
|
40
|
+
const track = new paper.Path.Rectangle({
|
|
41
|
+
point: [x, y],
|
|
42
|
+
size: [width, height],
|
|
43
|
+
radius: radius,
|
|
44
|
+
})
|
|
45
|
+
track.fillColor = new paper.Color(trackColor)
|
|
46
|
+
elements.push({ type: 'rectangle', id: track.id })
|
|
47
|
+
|
|
48
|
+
// 绘制进度
|
|
49
|
+
const progressWidth = (value / 100) * width
|
|
50
|
+
if (progressWidth > 0) {
|
|
51
|
+
const fill = new paper.Path.Rectangle({
|
|
52
|
+
point: [x, y],
|
|
53
|
+
size: [progressWidth, height],
|
|
54
|
+
radius: radius,
|
|
55
|
+
})
|
|
56
|
+
fill.fillColor = new paper.Color(fillColor)
|
|
57
|
+
elements.push({ type: 'rectangle', id: fill.id })
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 显示标签
|
|
61
|
+
if (showLabel && label) {
|
|
62
|
+
const labelText = new paper.PointText({
|
|
63
|
+
point: [x + width / 2, y - 8],
|
|
64
|
+
content: label,
|
|
65
|
+
fontSize: 14,
|
|
66
|
+
fillColor: new paper.Color('#666666'),
|
|
67
|
+
justification: 'center',
|
|
68
|
+
})
|
|
69
|
+
elements.push({ type: 'text', id: labelText.id })
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
success: true,
|
|
74
|
+
elements,
|
|
75
|
+
value,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = createProgress
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 环形进度条组件
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const paper = require('paper')
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 创建环形进度条组件
|
|
9
|
+
*/
|
|
10
|
+
function createProgressCircle(project, canvas, params) {
|
|
11
|
+
const {
|
|
12
|
+
cx,
|
|
13
|
+
cy,
|
|
14
|
+
radius,
|
|
15
|
+
value,
|
|
16
|
+
strokeWidth = 10,
|
|
17
|
+
trackColor = '#e5e7eb',
|
|
18
|
+
fillColor = '#3b82f6',
|
|
19
|
+
backgroundColor,
|
|
20
|
+
showLabel = true,
|
|
21
|
+
labelColor,
|
|
22
|
+
startAngle = -90
|
|
23
|
+
} = params
|
|
24
|
+
|
|
25
|
+
const elements = []
|
|
26
|
+
|
|
27
|
+
// 绘制背景圆(可选)
|
|
28
|
+
if (backgroundColor) {
|
|
29
|
+
const bgCircle = new paper.Path.Circle({
|
|
30
|
+
center: [cx, cy],
|
|
31
|
+
radius: radius + strokeWidth / 2
|
|
32
|
+
})
|
|
33
|
+
bgCircle.fillColor = new paper.Color(backgroundColor)
|
|
34
|
+
if (project && project.activeLayer) {
|
|
35
|
+
project.activeLayer.addChild(bgCircle)
|
|
36
|
+
}
|
|
37
|
+
elements.push({ type: 'path', id: bgCircle.id })
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 绘制轨道(背景环)
|
|
41
|
+
const trackCircle = new paper.Path.Circle({
|
|
42
|
+
center: [cx, cy],
|
|
43
|
+
radius: radius
|
|
44
|
+
})
|
|
45
|
+
trackCircle.fillColor = null
|
|
46
|
+
trackCircle.strokeColor = new paper.Color(trackColor)
|
|
47
|
+
trackCircle.strokeWidth = strokeWidth
|
|
48
|
+
if (project && project.activeLayer) {
|
|
49
|
+
project.activeLayer.addChild(trackCircle)
|
|
50
|
+
}
|
|
51
|
+
elements.push({ type: 'path', id: trackCircle.id })
|
|
52
|
+
|
|
53
|
+
// 绘制进度弧线
|
|
54
|
+
if (value > 0 && value <= 100) {
|
|
55
|
+
const percentage = value / 100
|
|
56
|
+
const arcAngle = percentage * 360
|
|
57
|
+
|
|
58
|
+
// 转换为弧度
|
|
59
|
+
const startRad = startAngle * Math.PI / 180
|
|
60
|
+
const endRad = (startAngle + arcAngle) * Math.PI / 180
|
|
61
|
+
|
|
62
|
+
// 创建进度弧线路径
|
|
63
|
+
const progressArc = new paper.Path()
|
|
64
|
+
|
|
65
|
+
// 添加起点
|
|
66
|
+
progressArc.moveTo(
|
|
67
|
+
cx + radius * Math.cos(startRad),
|
|
68
|
+
cy + radius * Math.sin(startRad)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
// 添加弧线上的点(用多个点模拟圆弧)
|
|
72
|
+
const segments = 36
|
|
73
|
+
const angleStep = (endRad - startRad) / segments
|
|
74
|
+
for (let i = 1; i <= segments; i++) {
|
|
75
|
+
const angle = startRad + angleStep * i
|
|
76
|
+
progressArc.lineTo(
|
|
77
|
+
cx + radius * Math.cos(angle),
|
|
78
|
+
cy + radius * Math.sin(angle)
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
progressArc.strokeColor = new paper.Color(fillColor)
|
|
83
|
+
progressArc.strokeWidth = strokeWidth
|
|
84
|
+
progressArc.strokeCap = 'round'
|
|
85
|
+
|
|
86
|
+
if (project && project.activeLayer) {
|
|
87
|
+
project.activeLayer.addChild(progressArc)
|
|
88
|
+
}
|
|
89
|
+
elements.push({ type: 'path', id: progressArc.id })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 绘制标签文字
|
|
93
|
+
if (showLabel) {
|
|
94
|
+
const textColor = labelColor || fillColor
|
|
95
|
+
const fontSize = Math.min(Math.max(Math.round(radius * 0.35), 12), 48)
|
|
96
|
+
const label = new paper.PointText({
|
|
97
|
+
point: [cx, cy + fontSize * 0.35],
|
|
98
|
+
content: `${Math.round(value)}%`,
|
|
99
|
+
fontSize: fontSize,
|
|
100
|
+
fillColor: new paper.Color(textColor),
|
|
101
|
+
justification: 'center',
|
|
102
|
+
fontWeight: 'bold'
|
|
103
|
+
})
|
|
104
|
+
if (project && project.activeLayer) {
|
|
105
|
+
project.activeLayer.addChild(label)
|
|
106
|
+
}
|
|
107
|
+
elements.push({ type: 'text', id: label.id })
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
success: true,
|
|
112
|
+
elements,
|
|
113
|
+
type: 'progressCircle'
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
module.exports = createProgressCircle
|
|
@@ -0,0 +1,97 @@
|
|
|
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.text - 引用文字
|
|
17
|
+
* @param {string} args.author - 作者
|
|
18
|
+
* @param {string} args.background - 背景色
|
|
19
|
+
* @param {string} args.borderColor - 左边框颜色
|
|
20
|
+
* @param {number} args.borderWidth - 左边框宽度
|
|
21
|
+
* @param {number} args.padding - 内边距
|
|
22
|
+
* @param {number} args.radius - 圆角半径
|
|
23
|
+
* @param {string} args.textColor - 文字颜色
|
|
24
|
+
* @param {string} args.authorColor - 作者颜色
|
|
25
|
+
* @param {number} args.fontSize - 字体大小
|
|
26
|
+
*/
|
|
27
|
+
function createQuote(project, canvas, args) {
|
|
28
|
+
const {
|
|
29
|
+
x, y,
|
|
30
|
+
width = 400,
|
|
31
|
+
text,
|
|
32
|
+
author,
|
|
33
|
+
background = '#f8fafc',
|
|
34
|
+
borderColor = '#6366f1',
|
|
35
|
+
borderWidth = 4,
|
|
36
|
+
padding = 20,
|
|
37
|
+
radius = 8,
|
|
38
|
+
textColor = '#1e293b',
|
|
39
|
+
authorColor = '#64748b',
|
|
40
|
+
fontSize = 18,
|
|
41
|
+
} = args
|
|
42
|
+
|
|
43
|
+
const elements = []
|
|
44
|
+
|
|
45
|
+
// 绘制背景
|
|
46
|
+
const bg = new paper.Path.Rectangle({
|
|
47
|
+
point: [x, y],
|
|
48
|
+
size: [width, author ? 80 + fontSize * 2 : 40 + fontSize * 1.5],
|
|
49
|
+
radius: radius,
|
|
50
|
+
})
|
|
51
|
+
bg.fillColor = new paper.Color(background)
|
|
52
|
+
elements.push({ type: 'rectangle', id: bg.id })
|
|
53
|
+
|
|
54
|
+
// 绘制左边框
|
|
55
|
+
const border = new paper.Path.Rectangle({
|
|
56
|
+
point: [x, y],
|
|
57
|
+
size: [borderWidth, author ? 80 + fontSize * 2 : 40 + fontSize * 1.5],
|
|
58
|
+
})
|
|
59
|
+
border.fillColor = new paper.Color(borderColor)
|
|
60
|
+
elements.push({ type: 'rectangle', id: border.id })
|
|
61
|
+
|
|
62
|
+
// 绘制引用符号
|
|
63
|
+
const quoteMark = new paper.PointText({
|
|
64
|
+
point: [x + padding + 10, y + padding + fontSize],
|
|
65
|
+
content: '"',
|
|
66
|
+
fontSize: fontSize * 2,
|
|
67
|
+
fillColor: new paper.Color(borderColor),
|
|
68
|
+
justification: 'left',
|
|
69
|
+
})
|
|
70
|
+
elements.push({ type: 'text', id: quoteMark.id })
|
|
71
|
+
|
|
72
|
+
// 绘制引用文字
|
|
73
|
+
const quoteText = new paper.PointText({
|
|
74
|
+
point: [x + padding + 30, y + padding + fontSize * 1.5],
|
|
75
|
+
content: text,
|
|
76
|
+
fontSize: fontSize,
|
|
77
|
+
fillColor: new paper.Color(textColor),
|
|
78
|
+
justification: 'left',
|
|
79
|
+
})
|
|
80
|
+
elements.push({ type: 'text', id: quoteText.id })
|
|
81
|
+
|
|
82
|
+
// 绘制作者
|
|
83
|
+
if (author) {
|
|
84
|
+
const authorText = new paper.PointText({
|
|
85
|
+
point: [x + padding, y + padding + fontSize * 2.5 + 10],
|
|
86
|
+
content: `— ${author}`,
|
|
87
|
+
fontSize: fontSize * 0.8,
|
|
88
|
+
fillColor: new paper.Color(authorColor),
|
|
89
|
+
justification: 'left',
|
|
90
|
+
})
|
|
91
|
+
elements.push({ type: 'text', id: authorText.id })
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return { success: true, elements }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module.exports = createQuote
|
|
@@ -0,0 +1,85 @@
|
|
|
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.value - 评分值 0-5
|
|
16
|
+
* @param {number} args.max - 最大值,默认5
|
|
17
|
+
* @param {number} args.size - 星星大小
|
|
18
|
+
* @param {string} args.filledColor - 填充颜色
|
|
19
|
+
* @param {string} args.emptyColor - 空心颜色
|
|
20
|
+
* @param {number} args.gap - 星星间距
|
|
21
|
+
*/
|
|
22
|
+
function createRating(project, canvas, args) {
|
|
23
|
+
const {
|
|
24
|
+
x, y,
|
|
25
|
+
value = 4,
|
|
26
|
+
max = 5,
|
|
27
|
+
size = 24,
|
|
28
|
+
filledColor = '#fbbf24',
|
|
29
|
+
emptyColor = '#e5e7eb',
|
|
30
|
+
gap = 4,
|
|
31
|
+
} = args
|
|
32
|
+
|
|
33
|
+
const elements = []
|
|
34
|
+
|
|
35
|
+
for (let i = 0; i < max; i++) {
|
|
36
|
+
const starX = x + i * (size + gap)
|
|
37
|
+
const filled = i < Math.floor(value)
|
|
38
|
+
const partial = !filled && i < value
|
|
39
|
+
|
|
40
|
+
// 绘制星星(使用多边形)
|
|
41
|
+
const star = createStar(project, starX + size / 2, y + size / 2, size / 2, size / 4, 5)
|
|
42
|
+
star.fillColor = new paper.Color(partial ? filledColor : emptyColor)
|
|
43
|
+
star.opacity = partial ? value - Math.floor(value) : 1
|
|
44
|
+
elements.push({ type: 'polygon', id: star.id })
|
|
45
|
+
|
|
46
|
+
if (partial) {
|
|
47
|
+
// 半星效果用填充色覆盖一半
|
|
48
|
+
const halfStar = createStar(project, starX + size / 2, y + size / 2, size / 2, size / 4, 5)
|
|
49
|
+
const clipPath = new paper.Path.Rectangle({
|
|
50
|
+
point: [starX, y],
|
|
51
|
+
size: [size / 2, size],
|
|
52
|
+
})
|
|
53
|
+
halfStar.fillColor = new paper.Color(filledColor)
|
|
54
|
+
halfStar.opacity = 1
|
|
55
|
+
elements.push({ type: 'polygon', id: halfStar.id })
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
success: true,
|
|
61
|
+
elements,
|
|
62
|
+
value,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 创建星星形状
|
|
68
|
+
*/
|
|
69
|
+
function createStar(project, cx, cy, outerRadius, innerRadius, points) {
|
|
70
|
+
const star = new paper.Path()
|
|
71
|
+
const step = Math.PI / points
|
|
72
|
+
|
|
73
|
+
for (let i = 0; i < 2 * points; i++) {
|
|
74
|
+
const radius = i % 2 === 0 ? outerRadius : innerRadius
|
|
75
|
+
const angle = i * step - Math.PI / 2
|
|
76
|
+
const x = cx + Math.cos(angle) * radius
|
|
77
|
+
const y = cy + Math.sin(angle) * radius
|
|
78
|
+
star.add(new paper.Point(x, y))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
star.closed = true
|
|
82
|
+
return star
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
module.exports = createRating
|
|
@@ -0,0 +1,70 @@
|
|
|
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: providedInnerRadius,
|
|
19
|
+
outerRadius,
|
|
20
|
+
fill,
|
|
21
|
+
stroke,
|
|
22
|
+
strokeWidth = 1,
|
|
23
|
+
opacity = 1,
|
|
24
|
+
rotation = 0
|
|
25
|
+
} = params
|
|
26
|
+
|
|
27
|
+
// 计算内半径
|
|
28
|
+
const innerRadius = providedInnerRadius || 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 : innerRadius
|
|
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
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|