Skip to content

Commit 4e649c8

Browse files
authored
Create dev-guide.md
1 parent 209c366 commit 4e649c8

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

doc/dev-guide.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# 开发指南
2+
3+
## 1. 相关技术和工具
4+
5+
使用到的技术栈有:
6+
7+
* [webpack](https://github.com/webpack/webpack) + [TypeScript](https://github.com/microsoft/TypeScript)
8+
* [Vue3 (Composition API)](https://vuejs.org/api/#:~:text=defineCustomElement()-,Composition%20API,-setup())
9+
* [sass](https://github.com/sass/sass)
10+
* [Element Plus](https://element-plus.gitee.io/)
11+
* [echarts](https://github.com/apache/echarts)
12+
13+
以及 [Chrome Extension 开发文档](https://developer.chrome.com/docs/webstore/),目前 manifest 的版本为 V2,V3 正在迁移中 (对应分支 [mv3](https://github.com/sheepzh/timer/tree/mv3))
14+
15+
还集成了一些免费的开源工具:
16+
17+
* 单元测试工具 [jest](https://jestjs.io/docs/getting-started)
18+
* 单元测试覆盖率 [Codecov](https://app.codecov.io/gh/sheepzh/timer)
19+
* 集成测试套件 [Travis CI](https://app.travis-ci.com/github/sheepzh/timer)
20+
21+
## 2. 开发步骤
22+
23+
1. fork 自己的仓库
24+
2. 安装依赖
25+
```shell
26+
npm install
27+
# or
28+
yarn install
29+
```
30+
3. 创建对应的需求分支
31+
4. code
32+
5. run 开发环境
33+
首先执行命令
34+
```shell
35+
npm run dev
36+
# or
37+
yarn run dev
38+
```
39+
40+
项目根目录下会输出两个文件夹,dist_dev 和 firefox_dev。
41+
42+
然后根据测试浏览器的不同导入不同的文件夹到浏览器中:
43+
44+
* Chrome 和 Edge 导入 dist_dev 文件夹
45+
* Firefox 导入 firefox_dev 文件夹下的 manifest.json 文件。
46+
6. 运行单元测试
47+
```shell
48+
npm run test
49+
# or
50+
yarn run test
51+
```
52+
7. 提交代码,并 PR 主仓库的 main 分支
53+
54+
## 3. 应用架构设计
55+
56+
> todo
57+
58+
## 4. 目录结构
59+
60+
```plain
61+
project
62+
| package.json
63+
| jest.config.ts # jest 配置
64+
│ tsconfig.json # TypeScript 配置
65+
| global.d.ts # 命名空间声明
66+
| .travis.yml # 集成测试任务配置
67+
│ README.md
68+
69+
└───doc # 文档目录
70+
71+
└───public # 静态资源目录
72+
| | app.html # 后台页主界面
73+
| | popup.html # 弹窗页主界面
74+
| |
75+
| └───images # 图片资源
76+
| | icon.png # 扩展图标
77+
|
78+
└───src # 代码
79+
| | manifest.ts # 扩展的声明文件
80+
| | package.ts # ../package.json 的声明文件
81+
| └───api # HTTP api
82+
| |
83+
| └───app # 后台页应用,一个 vue 单页应用
84+
| |
85+
| └───popup # 扩展图标弹窗页应用,也是个 vue 单页应用
86+
| |
87+
| └───background # 扩展的后台服务,负责协调数据交互
88+
| |
89+
| └───content-script # 注入到用户页面里的脚本
90+
| |
91+
| └───service # 服务层
92+
| |
93+
| └───database # 数据访问层
94+
| |
95+
| └───entity # 业务数据抽象
96+
| |
97+
| └───util # 工具包
98+
| |
99+
| └───common # 公共功能
100+
|
101+
└───test # 单测,主要测试业务逻辑
102+
| └───__mock__
103+
| | | storage.ts # mock chrome.storage
104+
| |
105+
| └───database # database 单测
106+
| |
107+
| └───entity # entity 单测
108+
| |
109+
| └───service # service 单测
110+
| |
111+
| └───util # util 单测
112+
|
113+
└───types # 补充声明
114+
|
115+
└───webpack # webpack 打包配置
116+
| webpack.common.ts # 基础配置
117+
| webpack.dev.ts # 开发环境配置
118+
| webpack.prod.ts # 生产配置
119+
120+
```

0 commit comments

Comments
 (0)