/** * 上传交互卡片模板 */ 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 };