feat(M1.3): 构建工具配置 (v0.0.3)

- 安装 npm 依赖 (Vue 3, Vite, @crxjs/vite-plugin)
- 配置 vite.config.js 支持 Chrome Extension
- 创建基础入口文件 (background, content, popup, options)
- 配置构建输出到 dist/ 目录
- 添加占位图标文件
This commit is contained in:
李岩岩 2026-02-10 09:25:54 +08:00
parent f6f3fca1c4
commit 0995811155
18 changed files with 5141 additions and 13 deletions

10
README.md Normal file
View File

@ -0,0 +1,10 @@
### ai对话常用语句
继续任务M1.3,如果你的上下文不够了,记得提醒我新开对话。
M1.2验收通过,提交代码。
继续开发沙拉查词项目,请先阅读 docs/README.md要求。
实现 M3.3,遵循 docs/README.md 要求。

12
assets/icons/icon16.png Normal file
View File

@ -0,0 +1,12 @@
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz
AAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAFUSURB
VDiNpZM9SwNBEIafJQQLwcJCG1sLwcJCG8HKQhArwU5tf4C1v2AbtbHQylZ8rCxsLPwAg+AD+oFg
YyM2IigY8XnPze1eEg58zM7MPsy53J1zROQqUAtwTlVrHnADjAGbQNPdR8BGwG9APdAGToGJmS2a
2V1cN7NTd78OfAI3ZvZsZqOJGFR1DpgG3oGHAPeBqruvuXuzG1DVJ+AGmAcO3X0tBvLANXALjLj7
cgyo6jFwAMwDT+6+GQO5DlwCL8C4u5/EgKoeArPAs7tvxEAGwAVwBoy6+30M5Pp/Ap4E3tw9D+SB
C+AIGHH3hxjI9T8DXgJn7r6ZB3L9T4FTYOi3XyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/
LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLy
D7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/
LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLy
D7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/
LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLyD7X/LyLy

View File

@ -7,7 +7,7 @@
## 版本速查 ## 版本速查
### 当前版本 ### 当前版本
`0.0.2` → 下一目标 `0.0.3` ([M1.3](./M1.md)) `0.0.3` → 下一目标 `0.0.4` ([M1.4](./M1.md))
### 模块版本范围 ### 模块版本范围

View File

@ -64,9 +64,9 @@ M11.10完成 → 1.0.0 (正式发布)
## 当前状态 ## 当前状态
**当前版本**: `0.0.2` **当前版本**: `0.0.3`
**当前进度**: 2/97 (2%) **当前进度**: 3/97 (3%)
**下一任务**: [M1.3 构建工具配置](./M1.md#m13-构建工具配置--目标版本-0003) **下一任务**: [M1.4 模块间通信工具](./M1.md#m14-模块间通信工具--目标版本-0004)
--- ---

View File

@ -19,7 +19,7 @@
|------|------|------|------|------| |------|------|------|------|------|
| M1.1 | 0.0.1 | 项目初始化 | ✅ | 2026-02-09 | | M1.1 | 0.0.1 | 项目初始化 | ✅ | 2026-02-09 |
| M1.2 | 0.0.2 | Manifest V3 配置 | ✅ | 2026-02-09 | | M1.2 | 0.0.2 | Manifest V3 配置 | ✅ | 2026-02-09 |
| M1.3 | 0.0.3 | 构建工具配置 | ⬜ | - | | M1.3 | 0.0.3 | 构建工具配置 | ✅ | 2026-02-09 |
| M1.4 | 0.0.4 | 模块间通信工具 | ⬜ | - | | M1.4 | 0.0.4 | 模块间通信工具 | ⬜ | - |
| M1.5 | 0.0.5 | 开发环境验证 | ⬜ | - | | M1.5 | 0.0.5 | 开发环境验证 | ⬜ | - |

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 3, "manifest_version": 3,
"name": "沙拉查词", "name": "沙拉查词",
"version": "0.0.2", "version": "0.0.3",
"description": "聚合词典划词翻译", "description": "聚合词典划词翻译",
"permissions": [ "permissions": [
"storage", "storage",
@ -29,15 +29,15 @@
"default_popup": "src/popup/index.html", "default_popup": "src/popup/index.html",
"default_title": "沙拉查词", "default_title": "沙拉查词",
"default_icon": { "default_icon": {
"16": "assets/icons/icon16.png", "16": "icons/icon16.png",
"48": "assets/icons/icon48.png", "48": "icons/icon48.png",
"128": "assets/icons/icon128.png" "128": "icons/icon128.png"
} }
}, },
"icons": { "icons": {
"16": "assets/icons/icon16.png", "16": "icons/icon16.png",
"48": "assets/icons/icon48.png", "48": "icons/icon48.png",
"128": "assets/icons/icon128.png" "128": "icons/icon128.png"
}, },
"options_page": "src/options/index.html" "options_page": "src/options/index.html"
} }

4998
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "salad-dict", "name": "salad-dict",
"version": "0.0.2", "version": "0.0.3",
"description": "聚合词典划词翻译", "description": "聚合词典划词翻译",
"private": true, "private": true,
"type": "module", "type": "module",

BIN
public/icons/icon128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

BIN
public/icons/icon16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

BIN
public/icons/icon48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

14
src/background/index.js Normal file
View File

@ -0,0 +1,14 @@
// Background Service Worker
console.log('[SaladDict] Background service worker started')
// 监听安装事件
chrome.runtime.onInstalled.addListener((details) => {
console.log('[SaladDict] Extension installed:', details.reason)
})
// 监听消息
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
console.log('[SaladDict] Message received:', message)
sendResponse({ pong: true })
return true
})

11
src/content/index.js Normal file
View File

@ -0,0 +1,11 @@
// Content Script
console.log('[SaladDict] Content script loaded')
// 简单的 ping 测试
chrome.runtime.sendMessage({ type: 'PING' }, (response) => {
if (chrome.runtime.lastError) {
console.error('[SaladDict] Ping failed:', chrome.runtime.lastError)
} else {
console.log('[SaladDict] Ping success:', response)
}
})

25
src/options/index.html Normal file
View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>沙拉查词设置</title>
<style>
body {
margin: 0;
padding: 24px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
h1 {
margin: 0 0 24px 0;
font-size: 24px;
color: #333;
}
</style>
</head>
<body>
<h1>沙拉查词设置</h1>
<p>设置页面占位</p>
<script type="module" src="./index.js"></script>
</body>
</html>

6
src/options/index.js Normal file
View File

@ -0,0 +1,6 @@
// Options entry
console.log('[SaladDict] Options page loaded')
document.addEventListener('DOMContentLoaded', () => {
console.log('[SaladDict] Options DOM ready')
})

27
src/popup/index.html Normal file
View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>沙拉查词</title>
<style>
body {
margin: 0;
padding: 16px;
width: 400px;
min-height: 300px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
h1 {
margin: 0 0 16px 0;
font-size: 18px;
color: #333;
}
</style>
</head>
<body>
<h1>沙拉查词</h1>
<p>Popup 页面占位</p>
<script type="module" src="./index.js"></script>
</body>
</html>

6
src/popup/index.js Normal file
View File

@ -0,0 +1,6 @@
// Popup entry
console.log('[SaladDict] Popup opened')
document.addEventListener('DOMContentLoaded', () => {
console.log('[SaladDict] Popup DOM ready')
})

19
vite.config.js Normal file
View File

@ -0,0 +1,19 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { crx } from '@crxjs/vite-plugin'
import manifest from './manifest.json' with { type: 'json' }
export default defineConfig({
plugins: [
vue(),
crx({ manifest })
],
build: {
rollupOptions: {
input: {
popup: 'src/popup/index.html',
options: 'src/options/index.html'
}
}
}
})