bug-extractor-plugin 0.1.0

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/README.md ADDED
@@ -0,0 +1,192 @@
1
+ # 嵌入式自动化 Bug 提取插件
2
+
3
+ 一个可嵌入各业务子系统的 Bug 自动提取插件,支持自动捕获接口错误、截图标注、多格式导出。
4
+
5
+ ## 功能特性
6
+
7
+ - 🎯 **自动捕获接口错误** - 自动拦截 HTTP 请求错误,无需修改业务代码
8
+ - 📸 **截图标注** - 自动截图 + 手动标注(矩形、箭头、文字、马赛克)
9
+ - 📤 **多格式导出** - 支持 JSON / Markdown / CSV / Word / PDF 五种格式
10
+ - 🔄 **批量导出** - 支持多选 Bug 一键导出
11
+ - 🌐 **双模式接入** - 支持 npm 包和 iframe 两种接入方式
12
+ - 🎨 **Vue 3 + TypeScript** - 现代化技术栈,类型安全
13
+
14
+ ## 技术栈
15
+
16
+ - **框架**: Vue 3.4+ (Composition API)
17
+ - **语言**: TypeScript 5.3+
18
+ - **构建**: Vite 5.0+
19
+ - **UI**: Element Plus 2.5+
20
+ - **截图**: html-to-image
21
+ - **导出**: docx / jspdf
22
+
23
+ ## 快速开始
24
+
25
+ ### 安装
26
+
27
+ ```bash
28
+ npm install @bug-extractor/plugin
29
+ ```
30
+
31
+ ### Vue 3 项目接入
32
+
33
+ ```typescript
34
+ // main.ts
35
+ import { createApp } from 'vue'
36
+ import BugExtractor from '@bug-extractor/plugin'
37
+ import App from './App.vue'
38
+
39
+ const app = createApp(App)
40
+
41
+ // 初始化插件
42
+ BugExtractor.init({
43
+ system: 'BDC',
44
+ autoScreenshot: true,
45
+ screenshotOptions: { delay: 800 },
46
+ ignore: {
47
+ urls: ['/api/heartbeat'],
48
+ statusCodes: [401, 403],
49
+ },
50
+ })
51
+
52
+ // 注册插件
53
+ app.use(BugExtractor.VuePlugin)
54
+ app.mount('#app')
55
+ ```
56
+
57
+ ```vue
58
+ <!-- App.vue -->
59
+ <template>
60
+ <div id="app">
61
+ <router-view />
62
+ <BugExtractorToolbar />
63
+ </div>
64
+ </template>
65
+
66
+ <script setup lang="ts">
67
+ import { BugExtractorToolbar } from '@bug-extractor/plugin'
68
+ </script>
69
+ ```
70
+
71
+ ### iframe 模式接入
72
+
73
+ ```html
74
+ <!-- 宿主 HTML -->
75
+ <script src="https://plugin.example.com/bug-extractor-host.js"></script>
76
+
77
+ <script>
78
+ // 注册截图钩子
79
+ window.BugExtractorScreenshot = async () => {
80
+ const { toJpeg } = await import('html-to-image');
81
+ return await toJpeg(document.body, { quality: 0.6 });
82
+ };
83
+
84
+ // 初始化插件
85
+ const adapter = new window.BugExtractor.IframeHostAdapter({
86
+ system: 'BDC',
87
+ pluginUrl: '//plugin.example.com/extractor.html',
88
+ });
89
+
90
+ adapter.init('//plugin.example.com/extractor.html', (bug) => {
91
+ console.log('捕获到 Bug:', bug);
92
+ });
93
+ </script>
94
+ ```
95
+
96
+ ## 配置选项
97
+
98
+ ```typescript
99
+ interface BugExtractorConfig {
100
+ // 系统标识
101
+ system: string;
102
+
103
+ // 是否启用自动截图
104
+ autoScreenshot?: boolean;
105
+
106
+ // 截图配置
107
+ screenshotOptions?: {
108
+ quality?: number; // 图片质量 0-1
109
+ maxSize?: number; // 最大文件大小(字节)
110
+ delay?: number; // 延迟截图时间(毫秒)
111
+ showFlash?: boolean; // 是否显示截图提示
112
+ };
113
+
114
+ // 忽略规则
115
+ ignore?: {
116
+ urls?: (string | RegExp)[]; // 忽略的 URL
117
+ statusCodes?: number[]; // 忽略的状态码
118
+ businessCodes?: string[]; // 忽略的业务错误码
119
+ methods?: string[]; // 忽略的请求方法
120
+ filter?: (error: any) => boolean; // 自定义过滤函数
121
+ };
122
+
123
+ // 回调函数
124
+ onBugCaptured?: (bug: BugReport) => void;
125
+ }
126
+ ```
127
+
128
+ ## 导出格式
129
+
130
+ | 格式 | 用途 | 特点 |
131
+ |------|------|------|
132
+ | JSON | 标准数据 | 适合系统对接 |
133
+ | Markdown | 文档报告 | 适合 Git 归档 |
134
+ | CSV | 表格数据 | 适合 Excel 分析 |
135
+ | Word | 可编辑文档 | 适合协作打印 |
136
+ | PDF | 只读文档 | 适合归档提交 |
137
+
138
+ ## 开发
139
+
140
+ ```bash
141
+ # 安装依赖
142
+ npm install
143
+
144
+ # 启动开发服务器
145
+ npm run dev
146
+
147
+ # 构建库文件
148
+ npm run build:lib
149
+
150
+ # 运行测试
151
+ npm run test
152
+
153
+ # 运行测试(带覆盖率)
154
+ npm run test:coverage
155
+
156
+ # 类型检查
157
+ npm run type-check
158
+ ```
159
+
160
+ ## 目录结构
161
+
162
+ ```
163
+ bug-extractor-plugin/
164
+ ├── src/ # 演示应用
165
+ ├── packages/ # 核心代码
166
+ │ ├── core/ # 核心逻辑层(纯 TS)
167
+ │ │ ├── interceptors/ # HTTP 拦截器
168
+ │ │ ├── services/ # 核心服务
169
+ │ │ └── exporters/ # 导出器
170
+ │ ├── ui/ # UI 组件层(Vue 3)
171
+ │ │ └── components/ # Vue 组件
172
+ │ ├── adapters/ # 适配层
173
+ │ │ ├── npm-adapter.ts
174
+ │ │ └── iframe-adapter.ts
175
+ │ └── types/ # 类型定义
176
+ ├── tests/ # 测试文件
177
+ │ ├── unit/ # 单元测试
178
+ │ └── e2e/ # E2E 测试
179
+ └── docs/ # 文档
180
+ ```
181
+
182
+ ## 浏览器支持
183
+
184
+ - Chrome >= 80
185
+ - Firefox >= 78
186
+ - Safari >= 13
187
+ - Edge >= 80
188
+ - 国产信创浏览器(基于 Chromium)
189
+
190
+ ## License
191
+
192
+ MIT
@@ -0,0 +1,32 @@
1
+ import { B as r, a as s, b as t, C as o, E as i, d as p, F as n, H as l, I as c, J as E, M as d, N as g, P as x, S, W as v, e as m, f as u, h as b, i as f, j as A, k as B, l as C, o as h, s as I, m as P, t as k, n as F, p as H } from "./index-iouTpRcq.js";
2
+ export {
3
+ r as BugBuilderService,
4
+ s as BugDialog,
5
+ t as BugStoreService,
6
+ o as CsvExporter,
7
+ i as ErrorClassifier,
8
+ p as ExportService,
9
+ n as FloatingToolbar,
10
+ l as HttpInterceptor,
11
+ c as IframeAdapter,
12
+ E as JsonExporter,
13
+ d as MarkdownExporter,
14
+ g as NpmAdapter,
15
+ x as PdfExporter,
16
+ S as ScreenshotService,
17
+ v as WordExporter,
18
+ m as bindEvents,
19
+ u as clearElement,
20
+ b as createAdapter,
21
+ f as createAutoAdapter,
22
+ A as createElement,
23
+ B as debounce,
24
+ C as getExportService,
25
+ h as on,
26
+ I as setPosition,
27
+ P as setVisible,
28
+ k as throttle,
29
+ F as toggleClass,
30
+ H as transition
31
+ };
32
+ //# sourceMappingURL=bug-extractor.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bug-extractor.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}