提交qiming-dev-inject

This commit is contained in:
Codex
2026-06-01 12:53:19 +08:00
parent 96af3b324b
commit 9e9486b7c2
76 changed files with 6397 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
# OS
.DS_Store
Thumbs.db
# Editor
.vscode/
.idea/
*.swp
*.swo
# Node
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View File

@@ -0,0 +1,41 @@
# HTML 静态项目测试
这是一个用于测试 dev-inject 在纯 HTML 静态项目中的注入功能的示例项目。
## 启动项目
### 方式 1: 使用 Python
```bash
python3 -m http.server 3002
```
### 方式 2: 使用 serve
```bash
npx serve -s . -p 3002
```
项目将在 http://localhost:3002 运行。
## 测试步骤
1. 启动项目(任选上述方式之一)
2. 使用 dev-inject 注入监控脚本
3. 点击页面上的按钮触发各种错误类型
4. 在浏览器控制台运行 DevMonitor 命令查看监控信息
## DevMonitor 命令
- `DevMonitor.showPanel()` - 显示监控面板
- `DevMonitor.getStats()` - 获取统计信息
- `DevMonitor.clearErrors()` - 清除错误记录
- `window.__DEV_INJECT__` - 检查注入状态
## 功能特性
- 触发同步错误
- 触发异步错误
- 触发引用错误
- 触发类型错误
- 实时统计错误数据
- 清除错误记录

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML 静态项目 - dev-inject 测试</title>
<!-- DEV-INJECT-START -->
<script data-id="dev-inject-monitor">
(function() {
const remote = "https://testagent.xspaceagi.com/sdk/dev-monitor.js";
const separator = remote.includes('?') ? '&' : '?';
const script = document.createElement('script');
script.src = remote + separator + 't=' + Date.now();
script.dataset.id = 'dev-inject-monitor-script';
script.defer = true;
// 防止重复注入
if (!document.querySelector('[data-id="dev-inject-monitor-script"]')) {
document.head.appendChild(script);
}
})();
</script>
<!-- DEV-INJECT-END -->
</head>
<body>
<h1>HTML 静态项目测试</h1>
<p>测试 dev-inject 在纯 HTML 项目中的注入功能</p>
</body>
</html>

View File

@@ -0,0 +1,17 @@
{
"name": "html-static-test",
"version": "1.0.0",
"description": "纯 HTML 静态项目测试 - dev-inject",
"type": "module",
"scripts": {
"start": "python3 -m http.server 3002",
"serve": "npx serve -s . -p 3002"
},
"keywords": [
"html",
"test",
"dev-inject"
],
"author": "",
"license": "MIT"
}