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,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 图片框组件 - 带装饰边框的图片
|
|
3
|
-
*/
|
|
4
|
-
const createImageFrame = (ctx) => ({
|
|
5
|
-
/**
|
|
6
|
-
* @param {Object} params
|
|
7
|
-
* @param {string} params.src - 图片路径或URL
|
|
8
|
-
* @param {number} params.x - X坐标
|
|
9
|
-
* @param {number} params.y - Y坐标
|
|
10
|
-
* @param {number} params.width - 图片宽度
|
|
11
|
-
* @param {number} params.height - 图片高度
|
|
12
|
-
* @param {string} [params.borderColor='#ffffff'] - 边框颜色
|
|
13
|
-
* @param {number} [params.borderWidth=3] - 边框宽度
|
|
14
|
-
* @param {string} [params.outerColor='#1a1a2e'] - 外边框颜色
|
|
15
|
-
* @param {number} [params.outerWidth=6] - 外边框宽度
|
|
16
|
-
* @param {number} [params.shadowBlur=0] - 阴影模糊
|
|
17
|
-
* @param {number} [params.shadowOffsetX=0] - 阴影X偏移
|
|
18
|
-
* @param {number} [params.shadowOffsetY=0] - 阴影Y偏移
|
|
19
|
-
* @param {string} [params.shadowColor='rgba(0,0,0,0.3)'] - 阴影颜色
|
|
20
|
-
* @param {number} [params.radius=0] - 圆角半径
|
|
21
|
-
* @param {string} [params.overlayColor] - 叠加颜色
|
|
22
|
-
* @param {number} [params.overlayOpacity=0] - 叠加透明度
|
|
23
|
-
* @param {string} [params.fit='cover'] - 图片填充方式: cover, contain, fill
|
|
24
|
-
*/
|
|
25
|
-
async draw({
|
|
26
|
-
src,
|
|
27
|
-
x,
|
|
28
|
-
y,
|
|
29
|
-
width,
|
|
30
|
-
height,
|
|
31
|
-
borderColor = '#ffffff',
|
|
32
|
-
borderWidth = 3,
|
|
33
|
-
outerColor = '#1a1a2e',
|
|
34
|
-
outerWidth = 6,
|
|
35
|
-
shadowBlur = 0,
|
|
36
|
-
shadowOffsetX = 0,
|
|
37
|
-
shadowOffsetY = 0,
|
|
38
|
-
shadowColor = 'rgba(0,0,0,0.3)',
|
|
39
|
-
radius = 0,
|
|
40
|
-
overlayColor,
|
|
41
|
-
overlayOpacity = 0,
|
|
42
|
-
fit = 'cover'
|
|
43
|
-
}) {
|
|
44
|
-
// 绘制外边框(装饰层)
|
|
45
|
-
if (outerWidth > 0) {
|
|
46
|
-
ctx.fillStyle = outerColor
|
|
47
|
-
await _roundRect(ctx, x - outerWidth, y - outerWidth, width + outerWidth * 2, height + outerWidth * 2, radius + outerWidth)
|
|
48
|
-
ctx.fill()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// 绘制内边框
|
|
52
|
-
if (borderWidth > 0) {
|
|
53
|
-
ctx.fillStyle = borderColor
|
|
54
|
-
await _roundRect(ctx, x - borderWidth, y - borderWidth, width + borderWidth * 2, height + borderWidth * 2, radius + borderWidth)
|
|
55
|
-
ctx.fill()
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 绘制阴影
|
|
59
|
-
if (shadowBlur > 0) {
|
|
60
|
-
ctx.shadowColor = shadowColor
|
|
61
|
-
ctx.shadowBlur = shadowBlur
|
|
62
|
-
ctx.shadowOffsetX = shadowOffsetX
|
|
63
|
-
ctx.shadowOffsetY = shadowOffsetY
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// 加载并绘制图片
|
|
67
|
-
const image = await _loadImage(src)
|
|
68
|
-
const imgWidth = image.width
|
|
69
|
-
const imgHeight = image.height
|
|
70
|
-
const imgRatio = imgWidth / imgHeight
|
|
71
|
-
const boxRatio = width / height
|
|
72
|
-
|
|
73
|
-
let drawX = x, drawY = y, drawW = width, drawH = height
|
|
74
|
-
|
|
75
|
-
if (fit === 'cover') {
|
|
76
|
-
if (imgRatio > boxRatio) {
|
|
77
|
-
drawH = height
|
|
78
|
-
drawW = height * imgRatio
|
|
79
|
-
drawX = x - (drawW - width) / 2
|
|
80
|
-
} else {
|
|
81
|
-
drawW = width
|
|
82
|
-
drawH = width / imgRatio
|
|
83
|
-
drawY = y - (drawH - height) / 2
|
|
84
|
-
}
|
|
85
|
-
} else if (fit === 'contain') {
|
|
86
|
-
if (imgRatio > boxRatio) {
|
|
87
|
-
drawW = width
|
|
88
|
-
drawH = width / imgRatio
|
|
89
|
-
drawY = y + (height - drawH) / 2
|
|
90
|
-
} else {
|
|
91
|
-
drawH = height
|
|
92
|
-
drawW = height * imgRatio
|
|
93
|
-
drawX = x + (width - drawW) / 2
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// 裁剪并绘制图片
|
|
98
|
-
ctx.save()
|
|
99
|
-
await _roundRect(ctx, x, y, width, height, radius)
|
|
100
|
-
ctx.clip()
|
|
101
|
-
ctx.drawImage(image, drawX, drawY, drawW, drawH)
|
|
102
|
-
ctx.restore()
|
|
103
|
-
|
|
104
|
-
// 重置阴影
|
|
105
|
-
ctx.shadowColor = 'transparent'
|
|
106
|
-
ctx.shadowBlur = 0
|
|
107
|
-
ctx.shadowOffsetX = 0
|
|
108
|
-
ctx.shadowOffsetY = 0
|
|
109
|
-
|
|
110
|
-
// 叠加颜色
|
|
111
|
-
if (overlayColor && overlayOpacity > 0) {
|
|
112
|
-
ctx.fillStyle = overlayColor
|
|
113
|
-
ctx.globalAlpha = overlayOpacity
|
|
114
|
-
await _roundRect(ctx, x, y, width, height, radius)
|
|
115
|
-
ctx.fill()
|
|
116
|
-
ctx.globalAlpha = 1
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
// 辅助函数:圆角矩形
|
|
122
|
-
async function _roundRect(ctx, x, y, width, height, radius) {
|
|
123
|
-
const r = Math.min(radius, width / 2, height / 2)
|
|
124
|
-
ctx.beginPath()
|
|
125
|
-
ctx.moveTo(x + r, y)
|
|
126
|
-
ctx.lineTo(x + width - r, y)
|
|
127
|
-
ctx.quadraticCurveTo(x + width, y, x + width, y + r)
|
|
128
|
-
ctx.lineTo(x + width, y + height - r)
|
|
129
|
-
ctx.quadraticCurveTo(x + width, y + height, x + width - r, y + height)
|
|
130
|
-
ctx.lineTo(x + r, y + height)
|
|
131
|
-
ctx.quadraticCurveTo(x, y + height, x, y + height - r)
|
|
132
|
-
ctx.lineTo(x, y + r)
|
|
133
|
-
ctx.quadraticCurveTo(x, y, x + r, y)
|
|
134
|
-
ctx.closePath()
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// 辅助函数:加载图片
|
|
138
|
-
async function _loadImage(src) {
|
|
139
|
-
return new Promise((resolve, reject) => {
|
|
140
|
-
const img = new Image()
|
|
141
|
-
img.crossOrigin = 'anonymous'
|
|
142
|
-
img.onload = () => resolve(img)
|
|
143
|
-
img.onerror = (e) => {
|
|
144
|
-
// 尝试 data URL 格式
|
|
145
|
-
if (src.startsWith('data:')) {
|
|
146
|
-
img.src = src
|
|
147
|
-
} else {
|
|
148
|
-
reject(new Error(`Failed to load image: ${src}`))
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
img.src = src
|
|
152
|
-
})
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
module.exports = createImageFrame
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 高级组件模块导出
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const createCard = require('./card')
|
|
6
|
-
const createBadge = require('./badge')
|
|
7
|
-
const createCTA = require('./cta')
|
|
8
|
-
const createFeature = require('./feature')
|
|
9
|
-
const createFeatureGrid = require('./featureGrid')
|
|
10
|
-
const createDivider = require('./divider')
|
|
11
|
-
const createAvatar = require('./avatar')
|
|
12
|
-
const createProgress = require('./progress')
|
|
13
|
-
const createRating = require('./rating')
|
|
14
|
-
const createQuote = require('./quote')
|
|
15
|
-
const createStatCard = require('./statCard')
|
|
16
|
-
const createTagCloud = require('./tagCloud')
|
|
17
|
-
const createStepper = require('./stepper')
|
|
18
|
-
const createTimeline = require('./timeline')
|
|
19
|
-
const { createListItem, createList } = require('./listItem')
|
|
20
|
-
const createNotification = require('./notification')
|
|
21
|
-
const createImageFrame = require('./imageFrame')
|
|
22
|
-
const createColumns = require('./columns')
|
|
23
|
-
const createGrid = require('./grid')
|
|
24
|
-
const createStar = require('./star')
|
|
25
|
-
const createArrow = require('./arrow')
|
|
26
|
-
const createProgressCircle = require('./progressCircle')
|
|
27
|
-
const createChip = require('./chip')
|
|
28
|
-
const createChart = require('./chart')
|
|
29
|
-
const createWatermark = require('./watermark')
|
|
30
|
-
const createTable = require('./table')
|
|
31
|
-
const createButton = require('./button')
|
|
32
|
-
const createIcon = require('./icon')
|
|
33
|
-
const createQRCode = require('./qrcode')
|
|
34
|
-
const createFrame = require('./frame')
|
|
35
|
-
const createBubble = require('./bubble')
|
|
36
|
-
const createRibbon = require('./ribbon')
|
|
37
|
-
const createSeal = require('./seal')
|
|
38
|
-
const createHighlightText = require('./highlightText')
|
|
39
|
-
const createBarcode = require('./barcode')
|
|
40
|
-
|
|
41
|
-
module.exports = {
|
|
42
|
-
// 原有组件
|
|
43
|
-
createCard,
|
|
44
|
-
createBadge,
|
|
45
|
-
createCTA,
|
|
46
|
-
createFeature,
|
|
47
|
-
createFeatureGrid,
|
|
48
|
-
createDivider,
|
|
49
|
-
createAvatar,
|
|
50
|
-
createProgress,
|
|
51
|
-
createRating,
|
|
52
|
-
createQuote,
|
|
53
|
-
createStatCard,
|
|
54
|
-
createTagCloud,
|
|
55
|
-
createStepper,
|
|
56
|
-
createTimeline,
|
|
57
|
-
createListItem,
|
|
58
|
-
createList,
|
|
59
|
-
createNotification,
|
|
60
|
-
createImageFrame,
|
|
61
|
-
createColumns,
|
|
62
|
-
createGrid,
|
|
63
|
-
// 新增组件
|
|
64
|
-
createStar,
|
|
65
|
-
createArrow,
|
|
66
|
-
createProgressCircle,
|
|
67
|
-
createChip,
|
|
68
|
-
createChart,
|
|
69
|
-
createWatermark,
|
|
70
|
-
createTable,
|
|
71
|
-
// 新增设计组件
|
|
72
|
-
createButton,
|
|
73
|
-
createIcon,
|
|
74
|
-
createQRCode,
|
|
75
|
-
createFrame,
|
|
76
|
-
createBubble,
|
|
77
|
-
createRibbon,
|
|
78
|
-
createSeal,
|
|
79
|
-
createHighlightText,
|
|
80
|
-
createBarcode,
|
|
81
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 列表项组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建列表项
|
|
9
|
-
*
|
|
10
|
-
* @param {Object} project - Paper.js 项目
|
|
11
|
-
* @param {Object} canvas - 画布对象
|
|
12
|
-
* @param {Object} args - 组件参数
|
|
13
|
-
* @param {number} args.x - X坐标
|
|
14
|
-
* @param {number} args.y - Y坐标
|
|
15
|
-
* @param {number} args.width - 宽度
|
|
16
|
-
* @param {string} args.icon - 图标
|
|
17
|
-
* @param {string} args.title - 标题
|
|
18
|
-
* @param {string} args.description - 描述
|
|
19
|
-
* @param {string} args.badge - 徽章文字
|
|
20
|
-
* @param {string} args.badgeColor - 徽章颜色
|
|
21
|
-
* @param {string} args.iconColor - 图标颜色
|
|
22
|
-
* @param {string} args.background - 背景色
|
|
23
|
-
* @param {string} args.borderColor - 边框颜色
|
|
24
|
-
* @param {number} args.height - 高度
|
|
25
|
-
* @param {number} args.radius - 圆角半径
|
|
26
|
-
*/
|
|
27
|
-
function createListItem(project, canvas, args) {
|
|
28
|
-
const {
|
|
29
|
-
x = 0,
|
|
30
|
-
y = 0,
|
|
31
|
-
width = 400,
|
|
32
|
-
icon = '→',
|
|
33
|
-
title,
|
|
34
|
-
description,
|
|
35
|
-
badge,
|
|
36
|
-
badgeColor = '#6366f1',
|
|
37
|
-
iconColor = '#6366f1',
|
|
38
|
-
background = '#ffffff',
|
|
39
|
-
borderColor = '#e5e7eb',
|
|
40
|
-
height = 60,
|
|
41
|
-
radius = 8,
|
|
42
|
-
} = args
|
|
43
|
-
|
|
44
|
-
const elements = []
|
|
45
|
-
|
|
46
|
-
// 绘制背景
|
|
47
|
-
const bg = new paper.Path.Rectangle({
|
|
48
|
-
point: [x, y],
|
|
49
|
-
size: [width, height],
|
|
50
|
-
radius: radius,
|
|
51
|
-
})
|
|
52
|
-
bg.fillColor = new paper.Color(background)
|
|
53
|
-
bg.strokeColor = new paper.Color(borderColor)
|
|
54
|
-
bg.strokeWidth = 1
|
|
55
|
-
elements.push({ type: 'rectangle', id: bg.id })
|
|
56
|
-
|
|
57
|
-
// 绘制图标
|
|
58
|
-
const iconText = new paper.PointText({
|
|
59
|
-
point: [x + 15, y + height / 2 + 6],
|
|
60
|
-
content: icon,
|
|
61
|
-
fontSize: 20,
|
|
62
|
-
fillColor: new paper.Color(iconColor),
|
|
63
|
-
justification: 'center',
|
|
64
|
-
})
|
|
65
|
-
elements.push({ type: 'text', id: iconText.id })
|
|
66
|
-
|
|
67
|
-
// 绘制标题
|
|
68
|
-
const titleText = new paper.PointText({
|
|
69
|
-
point: [x + 50, y + height / 2 - 5],
|
|
70
|
-
content: title || 'List Item',
|
|
71
|
-
fontSize: 16,
|
|
72
|
-
fillColor: new paper.Color('#1e293b'),
|
|
73
|
-
justification: 'left',
|
|
74
|
-
})
|
|
75
|
-
elements.push({ type: 'text', id: titleText.id })
|
|
76
|
-
|
|
77
|
-
// 绘制描述
|
|
78
|
-
if (description) {
|
|
79
|
-
const descText = new paper.PointText({
|
|
80
|
-
point: [x + 50, y + height / 2 + 15],
|
|
81
|
-
content: description,
|
|
82
|
-
fontSize: 12,
|
|
83
|
-
fillColor: new paper.Color('#64748b'),
|
|
84
|
-
justification: 'left',
|
|
85
|
-
})
|
|
86
|
-
elements.push({ type: 'text', id: descText.id })
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// 绘制徽章
|
|
90
|
-
if (badge) {
|
|
91
|
-
const badgeWidth = badge.length * 10 + 20
|
|
92
|
-
const badgeX = x + width - badgeWidth - 15
|
|
93
|
-
const badgeY = y + (height - 24) / 2
|
|
94
|
-
|
|
95
|
-
const badgeBg = new paper.Path.Rectangle({
|
|
96
|
-
point: [badgeX, badgeY],
|
|
97
|
-
size: [badgeWidth, 24],
|
|
98
|
-
radius: 12,
|
|
99
|
-
})
|
|
100
|
-
badgeBg.fillColor = new paper.Color(badgeColor)
|
|
101
|
-
elements.push({ type: 'rectangle', id: badgeBg.id })
|
|
102
|
-
|
|
103
|
-
const badgeText = new paper.PointText({
|
|
104
|
-
point: [badgeX + badgeWidth / 2, badgeY + 16],
|
|
105
|
-
content: badge,
|
|
106
|
-
fontSize: 12,
|
|
107
|
-
fillColor: new paper.Color('#ffffff'),
|
|
108
|
-
justification: 'center',
|
|
109
|
-
})
|
|
110
|
-
elements.push({ type: 'text', id: badgeText.id })
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return { success: true, elements, type: 'listItem' }
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* 创建列表(多个列表项)
|
|
118
|
-
*/
|
|
119
|
-
function createList(project, canvas, args) {
|
|
120
|
-
const {
|
|
121
|
-
x = 0, y = 0,
|
|
122
|
-
items = [],
|
|
123
|
-
gap = 10,
|
|
124
|
-
width = 400,
|
|
125
|
-
...rest
|
|
126
|
-
} = args
|
|
127
|
-
|
|
128
|
-
const elements = []
|
|
129
|
-
let currentY = y
|
|
130
|
-
|
|
131
|
-
for (const item of items) {
|
|
132
|
-
const result = createListItem(project, canvas, {
|
|
133
|
-
x, y: currentY, width, ...item, ...rest,
|
|
134
|
-
})
|
|
135
|
-
elements.push(...result.elements)
|
|
136
|
-
currentY += 60 + gap
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
success: true,
|
|
141
|
-
elements,
|
|
142
|
-
height: currentY - y,
|
|
143
|
-
type: 'list',
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
module.exports = { createListItem, createList }
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 通知/提示组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建通知提示
|
|
9
|
-
*
|
|
10
|
-
* @param {Object} project - Paper.js 项目
|
|
11
|
-
* @param {Object} canvas - 画布对象
|
|
12
|
-
* @param {Object} args - 组件参数
|
|
13
|
-
* @param {number} args.x - X坐标
|
|
14
|
-
* @param {number} args.y - Y坐标
|
|
15
|
-
* @param {number} args.width - 宽度
|
|
16
|
-
* @param {string} args.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
|
|
@@ -1,79 +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 {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
|
|
@@ -1,117 +0,0 @@
|
|
|
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
|