Initial commit: 七牛云上传飞书机器人
功能: - 飞书交互卡片支持 - 七牛云文件上传 - 自动 CDN 刷新 - 多存储桶配置 - 跨平台部署(Linux/macOS/Windows) - Docker 支持
This commit is contained in:
230
src/cards/upload-card.js
Normal file
230
src/cards/upload-card.js
Normal file
@@ -0,0 +1,230 @@
|
||||
/**
|
||||
* 上传交互卡片模板
|
||||
*/
|
||||
|
||||
class UploadCard {
|
||||
static create() {
|
||||
return {
|
||||
"config": {
|
||||
"wide_screen_mode": true
|
||||
},
|
||||
"header": {
|
||||
"template": "blue",
|
||||
"title": {
|
||||
"content": "🍙 七牛云上传助手",
|
||||
"tag": "plain_text"
|
||||
}
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"tag": "div",
|
||||
"text": {
|
||||
"content": "**📤 快速上传文件到七牛云**\n\n支持指定路径、多存储桶、自动 CDN 刷新",
|
||||
"tag": "lark_md"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "hr"
|
||||
},
|
||||
{
|
||||
"tag": "div",
|
||||
"text": {
|
||||
"content": "**💡 使用方式**\n\n• 直接发送文件给我\n• 或使用命令:`/upload [路径] [存储桶]`\n• 支持 `--original` 使用原文件名",
|
||||
"tag": "lark_md"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "hr"
|
||||
},
|
||||
{
|
||||
"tag": "action",
|
||||
"actions": [
|
||||
{
|
||||
"tag": "button",
|
||||
"text": {
|
||||
"content": "📎 选择文件上传",
|
||||
"tag": "plain_text"
|
||||
},
|
||||
"type": "primary",
|
||||
"value": {
|
||||
"action": "upload_file",
|
||||
"type": "upload"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "button",
|
||||
"text": {
|
||||
"content": "⚙️ 配置",
|
||||
"tag": "plain_text"
|
||||
},
|
||||
"type": "default",
|
||||
"value": {
|
||||
"action": "config",
|
||||
"type": "config"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "button",
|
||||
"text": {
|
||||
"content": "❓ 帮助",
|
||||
"tag": "plain_text"
|
||||
},
|
||||
"type": "default",
|
||||
"value": {
|
||||
"action": "help",
|
||||
"type": "help"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
static createUploading(fileName) {
|
||||
return {
|
||||
"config": {
|
||||
"wide_screen_mode": true
|
||||
},
|
||||
"header": {
|
||||
"template": "blue",
|
||||
"title": {
|
||||
"content": "📤 上传中...",
|
||||
"tag": "plain_text"
|
||||
}
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"tag": "div",
|
||||
"text": {
|
||||
"content": `**文件:** ${fileName}\n\n正在上传到七牛云,请稍候...`,
|
||||
"tag": "lark_md"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "progress_bar",
|
||||
"tag": "div",
|
||||
"text": {
|
||||
"content": "上传进度",
|
||||
"tag": "plain_text"
|
||||
},
|
||||
"value": 50,
|
||||
"color": "blue"
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
static createSuccess(result) {
|
||||
return {
|
||||
"config": {
|
||||
"wide_screen_mode": true
|
||||
},
|
||||
"header": {
|
||||
"template": "green",
|
||||
"title": {
|
||||
"content": "✅ 上传成功",
|
||||
"tag": "plain_text"
|
||||
}
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"tag": "div",
|
||||
"text": {
|
||||
"content": `**📦 文件:** ${result.key}\n\n` +
|
||||
`**🔗 链接:** [点击查看](${result.url})\n\n` +
|
||||
`**🪣 存储桶:** ${result.bucket || 'default'}`,
|
||||
"tag": "lark_md"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "hr"
|
||||
},
|
||||
{
|
||||
"tag": "action",
|
||||
"actions": [
|
||||
{
|
||||
"tag": "button",
|
||||
"text": {
|
||||
"content": "🔗 复制链接",
|
||||
"tag": "plain_text"
|
||||
},
|
||||
"type": "default",
|
||||
"value": {
|
||||
"action": "copy_link",
|
||||
"url": result.url
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "button",
|
||||
"text": {
|
||||
"content": "📤 继续上传",
|
||||
"tag": "plain_text"
|
||||
},
|
||||
"type": "primary",
|
||||
"value": {
|
||||
"action": "upload_file",
|
||||
"type": "upload"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
static createError(error) {
|
||||
return {
|
||||
"config": {
|
||||
"wide_screen_mode": true
|
||||
},
|
||||
"header": {
|
||||
"template": "red",
|
||||
"title": {
|
||||
"content": "❌ 上传失败",
|
||||
"tag": "plain_text"
|
||||
}
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"tag": "div",
|
||||
"text": {
|
||||
"content": `**错误信息:**\n${error.message}\n\n请检查配置或联系管理员。`,
|
||||
"tag": "lark_md"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "action",
|
||||
"actions": [
|
||||
{
|
||||
"tag": "button",
|
||||
"text": {
|
||||
"content": "🔄 重试",
|
||||
"tag": "plain_text"
|
||||
},
|
||||
"type": "primary",
|
||||
"value": {
|
||||
"action": "upload_file",
|
||||
"type": "upload"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "button",
|
||||
"text": {
|
||||
"content": "⚙️ 检查配置",
|
||||
"tag": "plain_text"
|
||||
},
|
||||
"type": "default",
|
||||
"value": {
|
||||
"action": "config",
|
||||
"type": "config"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { UploadCard };
|
||||
Reference in New Issue
Block a user