foliko 1.1.7 → 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/poster-expert.md +228 -0
- package/.agent/data/default.json +10 -0
- package/.agent/data/plugins-state.json +1 -1
- package/.agent/mcp_config.json +0 -6
- package/.agent/plugins/test-plugin.py +15 -0
- package/.agent/plugins/test_nested_plugin.py +85 -0
- package/.agent/sessions/cli_default.json +83 -803
- package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +189 -0
- package/.claude/settings.local.json +8 -1
- 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 +2 -2
- package/plugins/default-plugins.js +60 -7
- package/plugins/extension-executor-plugin.js +32 -22
- package/plugins/feishu-plugin.js +2 -2
- 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/telegram-plugin.js +2 -2
- package/plugins/weixin-plugin.js +40 -31
- package/poster.png +0 -0
- 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 +127 -29
- package/src/executors/mcp-executor.js +282 -26
- package/src/utils/plugin-helpers.js +22 -4
- package/system.md +362 -109
- package/test-scan.js +18 -0
- package/.agent/memory/feedback/mnt7jrlt-d67qs7.md +0 -15
- package/.agent/memory/feedback/mnt88ja3-al4fuy.md +0 -9
- package/.agent/plugins/poster-plugin/README.md +0 -304
- package/.agent/plugins/poster-plugin/emojis/rocket.png +0 -1
- package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts/SegoeUI Emoji.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 -224
- 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 -120
- package/.agent/plugins/poster-plugin/src/components/bubble.js +0 -153
- package/.agent/plugins/poster-plugin/src/components/button.js +0 -124
- 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 -107
- 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 -118
- package/.agent/plugins/poster-plugin/src/components/highlightText.js +0 -144
- package/.agent/plugins/poster-plugin/src/components/icon.js +0 -94
- package/.agent/plugins/poster-plugin/src/components/imageFrame.js +0 -155
- 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 -97
- package/.agent/plugins/poster-plugin/src/components/rating.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/ribbon.js +0 -193
- package/.agent/plugins/poster-plugin/src/components/seal.js +0 -146
- 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 -52
- package/.agent/plugins/poster-plugin/src/composer.js +0 -2146
- package/.agent/plugins/poster-plugin/src/elements/artText.js +0 -60
- package/.agent/plugins/poster-plugin/src/elements/background.js +0 -84
- 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 -230
- package/.agent/plugins/poster-plugin/src/elements/svg.js +0 -108
- package/.agent/plugins/poster-plugin/src/elements/text.js +0 -109
- package/.agent/plugins/poster-plugin/src/fonts.js +0 -243
- package/.agent/plugins/poster-plugin/src/index.js +0 -2081
- 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/test-background.svg +0 -1
- package/.agent/plugins/poster-plugin/test-full-poster.svg +0 -2
- package/.agent/plugins/poster-plugin/test-image.png +0 -0
- package/.agent/plugins/poster-plugin/yarn.lock +0 -1007
- package/output/zen_silence.png +0 -0
|
@@ -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 + width, 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
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 时间线组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建时间线
|
|
9
|
-
*/
|
|
10
|
-
function createTimeline(project, canvas, args) {
|
|
11
|
-
const {
|
|
12
|
-
x, y,
|
|
13
|
-
width = 500,
|
|
14
|
-
items = [],
|
|
15
|
-
lineColor = '#e2e8f0',
|
|
16
|
-
dotColor = '#6366f1',
|
|
17
|
-
activeColor = '#22c55e',
|
|
18
|
-
dotSize = 16,
|
|
19
|
-
gap = 60,
|
|
20
|
-
} = args
|
|
21
|
-
|
|
22
|
-
const elements = []
|
|
23
|
-
|
|
24
|
-
// 确保 items 是数组
|
|
25
|
-
if (!Array.isArray(items) || items.length === 0) {
|
|
26
|
-
return { success: true, elements, height: 0, type: 'timeline' }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const centerX = x + 80
|
|
30
|
-
const contentX = x + 120
|
|
31
|
-
|
|
32
|
-
// 绘制主线
|
|
33
|
-
if (items.length > 1) {
|
|
34
|
-
const mainLine = new paper.Path.Line({
|
|
35
|
-
from: [centerX, y + dotSize / 2],
|
|
36
|
-
to: [centerX, y + (items.length - 1) * gap + dotSize / 2],
|
|
37
|
-
strokeColor: new paper.Color(lineColor),
|
|
38
|
-
strokeWidth: 2,
|
|
39
|
-
})
|
|
40
|
-
if (project && project.activeLayer) {
|
|
41
|
-
project.activeLayer.addChild(mainLine)
|
|
42
|
-
}
|
|
43
|
-
elements.push({ type: 'line', id: mainLine.id })
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 绘制每个项目
|
|
47
|
-
for (let i = 0; i < items.length; i++) {
|
|
48
|
-
const item = items[i]
|
|
49
|
-
if (!item) continue
|
|
50
|
-
|
|
51
|
-
const itemY = y + i * gap
|
|
52
|
-
const isActive = item.active !== false
|
|
53
|
-
|
|
54
|
-
// 绘制时间线点
|
|
55
|
-
const dot = new paper.Path.Circle({
|
|
56
|
-
center: [centerX, itemY + dotSize / 2],
|
|
57
|
-
radius: dotSize / 2,
|
|
58
|
-
})
|
|
59
|
-
dot.fillColor = new paper.Color(isActive ? dotColor : lineColor)
|
|
60
|
-
if (project && project.activeLayer) {
|
|
61
|
-
project.activeLayer.addChild(dot)
|
|
62
|
-
}
|
|
63
|
-
elements.push({ type: 'circle', id: dot.id })
|
|
64
|
-
|
|
65
|
-
// 绘制日期
|
|
66
|
-
if (item.date) {
|
|
67
|
-
const dateText = new paper.PointText({
|
|
68
|
-
point: [x + 10, itemY + dotSize / 2 + 5],
|
|
69
|
-
content: item.date,
|
|
70
|
-
fontSize: 12,
|
|
71
|
-
fillColor: new paper.Color('#94a3b8'),
|
|
72
|
-
justification: 'left',
|
|
73
|
-
})
|
|
74
|
-
if (project && project.activeLayer) {
|
|
75
|
-
project.activeLayer.addChild(dateText)
|
|
76
|
-
}
|
|
77
|
-
elements.push({ type: 'text', id: dateText.id })
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// 绘制标题
|
|
81
|
-
const titleText = new paper.PointText({
|
|
82
|
-
point: [contentX, itemY + dotSize / 2 + 5],
|
|
83
|
-
content: item.title || `Event ${i + 1}`,
|
|
84
|
-
fontSize: 16,
|
|
85
|
-
fillColor: new paper.Color(isActive ? '#1e293b' : '#94a3b8'),
|
|
86
|
-
justification: 'left',
|
|
87
|
-
})
|
|
88
|
-
if (project && project.activeLayer) {
|
|
89
|
-
project.activeLayer.addChild(titleText)
|
|
90
|
-
}
|
|
91
|
-
elements.push({ type: 'text', id: titleText.id })
|
|
92
|
-
|
|
93
|
-
// 绘制描述
|
|
94
|
-
if (item.description) {
|
|
95
|
-
const descText = new paper.PointText({
|
|
96
|
-
point: [contentX, itemY + dotSize / 2 + 28],
|
|
97
|
-
content: item.description,
|
|
98
|
-
fontSize: 13,
|
|
99
|
-
fillColor: new paper.Color('#64748b'),
|
|
100
|
-
justification: 'left',
|
|
101
|
-
})
|
|
102
|
-
if (project && project.activeLayer) {
|
|
103
|
-
project.activeLayer.addChild(descText)
|
|
104
|
-
}
|
|
105
|
-
elements.push({ type: 'text', id: descText.id })
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
success: true,
|
|
111
|
-
elements,
|
|
112
|
-
height: items.length * gap,
|
|
113
|
-
type: 'timeline',
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
module.exports = createTimeline
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 水印组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建水印组件
|
|
9
|
-
*/
|
|
10
|
-
function createWatermark(project, canvas, params) {
|
|
11
|
-
const {
|
|
12
|
-
text,
|
|
13
|
-
cx,
|
|
14
|
-
cy,
|
|
15
|
-
color = 'rgba(0,0,0,0.1)',
|
|
16
|
-
fontSize = 48,
|
|
17
|
-
fontFamily = 'sans-serif',
|
|
18
|
-
opacity = 0.1,
|
|
19
|
-
rotation = 0,
|
|
20
|
-
align = 'center'
|
|
21
|
-
} = params
|
|
22
|
-
|
|
23
|
-
const elements = []
|
|
24
|
-
|
|
25
|
-
const label = new paper.PointText({
|
|
26
|
-
point: [cx, cy],
|
|
27
|
-
content: text,
|
|
28
|
-
fontSize: fontSize,
|
|
29
|
-
fontFamily: fontFamily,
|
|
30
|
-
fillColor: new paper.Color(color),
|
|
31
|
-
justification: align,
|
|
32
|
-
opacity: opacity
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
// 应用旋转
|
|
36
|
-
if (rotation !== 0) {
|
|
37
|
-
label.rotate(rotation, new paper.Point(cx, cy))
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (project && project.activeLayer) {
|
|
41
|
-
project.activeLayer.addChild(label)
|
|
42
|
-
}
|
|
43
|
-
elements.push({ type: 'text', id: label.id })
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
success: true,
|
|
47
|
-
elements,
|
|
48
|
-
type: 'watermark'
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
module.exports = createWatermark
|