Skip to content

Commit f3add61

Browse files
committed
feat: 基础搭建完成
0 parents  commit f3add61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+9298
-0
lines changed

.commitlintrc.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/** @type {import("@commitlint/types").UserConfig} */
2+
export default {
3+
extends: ['@commitlint/config-conventional'], // 继承使用常规的 Commit 规范。
4+
rules: {
5+
'type-enum': [
6+
2,
7+
'always',
8+
[
9+
'feat', // 新功能(feature)
10+
'fix', // 修补bug
11+
'docs', // 文档(documentation)
12+
'style', // 格式、样式(不影响代码运行的变动)
13+
'refactor', // 重构(即不是新增功能,也不是修改BUG的代码)
14+
'perf', // 优化相关,比如提升性能、体验
15+
'test', // 添加测试
16+
'ci', // 持续集成修改
17+
'chore', // 构建过程或辅助工具的变动
18+
'revert', // 回滚到上一个版本
19+
'build', // 影响构建系统或外部依赖的更改
20+
/** 以下为自定义,以上(Angular 团队提出的 Conventional Commits 规范,即@commitlint/config-conventional插件配置) */
21+
'workflow', // 工作流改进
22+
'mod', // 不确定分类的修改
23+
'wip', // 开发中
24+
'types', // 类型修改
25+
'release', // 版本发布
26+
],
27+
],
28+
'subject-full-stop': [0, 'never'],
29+
'subject-case': [0, 'never'],
30+
},
31+
};

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# @see: http://editorconfig.org
2+
3+
root = true
4+
5+
[*] # 表示所有文件适用
6+
charset = utf-8 # 设置文件字符集为 utf-8
7+
end_of_line = lf # 控制换行类型(lf | cr | crlf)
8+
insert_final_newline = true # 始终在文件末尾插入一个新行
9+
indent_style = space # 缩进风格(tab | space)
10+
indent_size = 2 # 缩进大小
11+
max_line_length = 100 # 最大行长度
12+
13+
[*.md] # 表示仅 md 文件适用以下规则
14+
insert_final_newline = false # 关闭末尾新行插入
15+
max_line_length = off # 关闭最大行长度限制
16+
trim_trailing_whitespace = false # 关闭末尾空格修剪

.env

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# .env 文件
2+
# 用途: 定义项目的基本环境变量,这些变量在所有环境中都会被加载。
3+
4+
# VITE_MY_APP_PREFIX = my
5+
# 作用:
6+
# VITE_ 前缀的变量会被 Vite 自动注入到客户端代码中,可以通过 import.meta.env.VITE_MY_APP_PREFIX 访问。
7+
# 这些变量在开发环境、生产环境和测试环境中都会生效。
8+
9+
# 项目标题
10+
VITE_APP_TITLE = React-Ts-Template
11+
12+
# 端口号
13+
VITE_APP_PORT = 5173

.env.dev

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 为了防止意外地将一些环境变量泄漏到客户端,只有以 VITE_ 为前缀的变量才会暴露给经过 vite 处理的代码。
2+
# js中通过`import.meta.env.VITE_APP_BASE_API`取值
3+
4+
# 环境
5+
VITE_NODE_ENV = development
6+
7+
# 接口前缀
8+
VITE_API_BASE_URL = '/dev-api'
9+
10+
# 后端服务地址
11+
VITE_SERVER_URL = 'http://localhost:3000'
12+
13+
# 输出路径
14+
VITE_OUT_DIR = dist-dev

.env.pro

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 环境
2+
VITE_NODE_ENV = production
3+
4+
# 接口前缀
5+
VITE_API_BASE_URL = '/pro-api'
6+
7+
# 后端服务地址
8+
VITE_SERVER_URL = 'http://localhost:3000'
9+
10+
# 输出路径
11+
VITE_OUT_DIR = dist-pro

.env.test

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 环境
2+
VITE_NODE_ENV = test
3+
4+
# 接口前缀
5+
VITE_API_BASE_URL = '/test-api'
6+
7+
# 后端服务地址
8+
VITE_SERVER_URL = 'http://localhost:3000'
9+
10+
# 输出路径
11+
VITE_OUT_DIR = dist-test

.github/workflows/ci.yml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Deploy Pages
2+
3+
# 触发条件,push到master分支或者pull request到master分支
4+
on:
5+
push:
6+
branches: [master]
7+
pull_request:
8+
branches: [master]
9+
10+
# 支持手动在工作流上触发
11+
workflow_dispatch:
12+
13+
# 设置时区
14+
env:
15+
TZ: Asia/Shanghai
16+
17+
# 权限设置
18+
permissions:
19+
# 允许读取仓库内容的权限。
20+
contents: read
21+
# 允许写入 GitHub Pages 的权限。
22+
pages: write
23+
# 允许写入 id-token 的权限。
24+
id-token: write
25+
26+
# 并发控制配置
27+
concurrency:
28+
group: pages
29+
cancel-in-progress: false
30+
31+
# 定义执行任务
32+
jobs:
33+
# 构建任务
34+
build:
35+
runs-on: ubuntu-latest
36+
37+
# node v20 运行
38+
strategy:
39+
matrix:
40+
node-version: [20]
41+
42+
steps:
43+
# 拉取代码
44+
- name: Checkout
45+
uses: actions/checkout@v3
46+
with:
47+
# 保留 Git 信息
48+
fetch-depth: 0
49+
50+
# 设置使用 Node.js 版本
51+
- name: Use Node.js ${{ matrix.node-version }}
52+
uses: actions/setup-node@v3
53+
with:
54+
node-version: ${{ matrix.node-version }}
55+
56+
# 使用 最新的 PNPM
57+
# 你也可以指定为具体的版本
58+
- uses: pnpm/action-setup@v2
59+
name: Install pnpm
60+
with:
61+
version: latest
62+
# version: 9
63+
run_install: false
64+
65+
# 安装依赖
66+
- name: Install dependencies
67+
run: pnpm install --frozen-lockfile
68+
69+
# 构建项目
70+
- name: Build blog project
71+
run: |
72+
echo ${{ github.workspace }}
73+
pnpm run build:pro
74+
75+
# 资源拷贝
76+
- name: Build with Jekyll
77+
uses: actions/jekyll-build-pages@v1
78+
with:
79+
source: ./dist-pro
80+
destination: ./_site
81+
82+
# 上传 _site 的资源,用于后续部署
83+
- name: Upload artifact
84+
uses: actions/upload-pages-artifact@v3
85+
86+
# 部署任务
87+
deploy:
88+
environment:
89+
name: github-pages
90+
url: ${{ steps.deployment.outputs.page_url }}
91+
runs-on: ubuntu-latest
92+
needs: build
93+
steps:
94+
- name: Deploy to GitHub Pages
95+
id: deployment
96+
uses: actions/deploy-pages@v4

.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
/dist*
14+
*.local
15+
16+
# Editor directories and files
17+
.idea
18+
.DS_Store
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?
24+
25+
.stylelintcache
26+
.eslintcache

.husky/commit-msg

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
3+
npx --no -- commitlint --edit

.husky/pre-commit

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
# pnpm run lint:all 全量检查,耗时多
5+
npx lint-staged # 只检查暂存的文件

.npmrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 设置最新的淘宝镜像,加快安装依赖速度
2+
registry = https://registry.npmmirror.com
3+
4+
# 安装依赖时锁定版本号
5+
save-exact = true

.prettierignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules/**
2+
/dist/
3+
/dist*
4+
/public/*
5+
/docs/*
6+
CHANGELOG

.prettierrc.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/** @type {import("prettier").Config} */
2+
export default {
3+
printWidth: 100, // 一行的字符数,如果超过会进行换行,默认为80
4+
tabWidth: 2, // 一个tab代表几个空格数,默认为2
5+
useTabs: false, // 是否使用tab进行缩进,默认为false,表示用空格进行缩减
6+
semi: true, // 行尾是否使用分号
7+
singleQuote: true, // 字符串是否使用单引号,默认为false,使用双引号
8+
quoteProps: 'as-needed', // 对象键值对中的字符串是否需要加引号
9+
bracketSpacing: true, // 对象大括号之间是否有空格,默认为true,效果:{ foo: bar }
10+
trailingComma: 'all', // 是否使用尾逗号,有三个可选值:"none", "es5", "all"
11+
jsxSingleQuote: false, // JSX 中的字符串是否使用单引号
12+
arrowParens: 'always', // 箭头函数参数是否总是使用括号
13+
insertPragma: false, // 是否在文件顶部插入@format注释
14+
requirePragma: false, // 是否仅在文件中有@format注释时才格式化
15+
proseWrap: 'never', // 长文本是否自动换行
16+
htmlWhitespaceSensitivity: 'strict', // HTML中的空白字符敏感度
17+
endOfLine: 'auto', // 文件末尾的换行符
18+
rangeStart: 0, // 格式化的起始位置
19+
// import 顺序自动格式化插件:
20+
plugins: ['@trivago/prettier-plugin-sort-imports'],
21+
importOrderSeparation: true,
22+
importOrderSortSpecifiers: true,
23+
importOrder: [
24+
'^react(.*)$', // React 相关放在最前面
25+
'<THIRD_PARTY_MODULES>', // 其他第三方模块
26+
'^@/components/(.*)$', // 全局组件
27+
'^@/(hooks|store)(.*)$', // 自定义 hooks 和 store 统一分组
28+
'^@/(.*)$', // 其他 @/ 开头的模块
29+
'^[./]', // 当前文件夹和父文件夹的相对导入
30+
],
31+
};

.stylelintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/dist/*
2+
/public/*
3+
public/*
4+
/dist*
5+
index.html

.vscode/extensions.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"recommendations": [
3+
"editorconfig.editorconfig",
4+
"dbaeumer.vscode-eslint",
5+
"esbenp.prettier-vscode",
6+
"stylelint.vscode-stylelint",
7+
"mikestead.dotenv"
8+
]
9+
}

.vscode/settings.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
// 开启自动修复
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll": "never",
5+
"source.fixAll.eslint": "explicit",
6+
"source.fixAll.stylelint": "explicit"
7+
},
8+
// 保存的时候自动格式化
9+
"editor.formatOnSave": true,
10+
// 默认格式化工具选择prettier
11+
"editor.defaultFormatter": "esbenp.prettier-vscode",
12+
// 配置该项,新建文件时默认就是space:2
13+
"editor.tabSize": 2,
14+
// stylelint校验的文件格式
15+
"stylelint.validate": ["css", "scss", "html"],
16+
"[typescriptreact]": {
17+
"editor.defaultFormatter": "esbenp.prettier-vscode"
18+
},
19+
"[typescript]": {
20+
"editor.defaultFormatter": "esbenp.prettier-vscode"
21+
},
22+
"[javascript]": {
23+
"editor.defaultFormatter": "esbenp.prettier-vscode"
24+
},
25+
"[javascriptreact]": {
26+
"editor.defaultFormatter": "esbenp.prettier-vscode"
27+
},
28+
"[json]": {
29+
"editor.defaultFormatter": "esbenp.prettier-vscode"
30+
},
31+
"[html]": {
32+
"editor.defaultFormatter": "esbenp.prettier-vscode"
33+
},
34+
"[css]": {
35+
"editor.defaultFormatter": "esbenp.prettier-vscode"
36+
},
37+
"[scss]": {
38+
"editor.defaultFormatter": "esbenp.prettier-vscode"
39+
},
40+
"[markdown]": {
41+
"editor.defaultFormatter": "esbenp.prettier-vscode"
42+
}
43+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 友人A
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)