Skip to content

Commit 96dae5b

Browse files
authored
Merge pull request #2 from CQUPTMirror/zhouhang
feat: 功能优化与代码重构
2 parents 0372fec + 4f332e6 commit 96dae5b

Some content is hidden

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

68 files changed

+8632
-4669
lines changed

.eslintrc.js

Lines changed: 0 additions & 82 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local.json
1313
npm-debug.log*
1414
yarn-debug.log*
1515
yarn-error.log*
16+
pnpm-debug.log*
1617

1718
# Editor directories and files
1819
.idea
@@ -22,3 +23,6 @@ yarn-error.log*
2223
*.njsproj
2324
*.sln
2425
*.sw?
26+
27+
# pnpm specific files
28+
.pnpm-store/

.npmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
shamefully-hoist=true
2+
strict-peer-dependencies=false
3+
auto-install-peers=true

docs/theme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 主题切换功能说明
2+
3+
## 功能概述
4+
该主题切换系统支持亮色/暗色模式,具有以下特性:
5+
- 自动跟随系统主题
6+
- 根据时间自动切换(晚6点到早6点自动切换为暗色模式)
7+
- 支持手动切换并记住用户偏好
8+
9+
## 使用方法

env.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference types="vite/client" />
2+
3+
declare module '*.vue' {
4+
import type { DefineComponent } from 'vue'
5+
6+
const component: DefineComponent<unknown, unknown, any>
7+
export default component
8+
}

eslint.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import antfu from '@antfu/eslint-config'
2+
3+
export default antfu({
4+
// 启用 TypeScript 支持
5+
typescript: true,
6+
// 启用 Vue 支持
7+
vue: true,
8+
// 启用 JSON 支持
9+
jsonc: true,
10+
// 启用 YAML 支持
11+
yaml: true,
12+
// 覆盖一些规则
13+
})

index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5+
<script>
6+
(function() {
7+
try {
8+
const savedTheme = localStorage.getItem('theme-preference')
9+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
10+
const hour = new Date().getHours()
11+
const isNight = hour >= 18 || hour < 6
12+
13+
const shouldBeDark = savedTheme
14+
? JSON.parse(savedTheme)
15+
: prefersDark || isNight
16+
17+
if (shouldBeDark)
18+
document.documentElement.classList.add('dark')
19+
} catch (e) {}
20+
})()
21+
</script>
522
<link rel="icon" href="/favicon.ico" />
623
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
724
<title>重庆邮电大学开源镜像站 | CQUPT OpenSource Mirror</title>

package.json

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,66 @@
11
{
22
"name": "template-vue3",
3-
"description": "A template of vue3",
3+
"type": "module",
44
"version": "0.0.0",
5+
"description": "A template of vue3",
56
"scripts": {
67
"dev": "vite",
7-
"build": "vue-tsc --noEmit --skipLibCheck && vite build",
8-
"only-build": "vite build",
9-
"serve": "vite preview",
10-
"commit": "git-cz"
8+
"build": "pnpm vue-tsc --noEmit && pnpm vite build",
9+
"preview": "pnpm vite preview",
10+
"lint": "eslint . --cache",
11+
"format": "prettier --write ."
1112
},
1213
"dependencies": {
13-
"ant-design-vue": "^2.1.6",
14-
"axios": "^0.21.1",
15-
"js-cookie": "^2.2.1",
16-
"sass": "^1.34.0",
17-
"vue": "3.0.11",
18-
"vue-router": "^4.0.5",
19-
"vuex": "^4.0.0"
14+
"@unocss/reset": "^0.58.5",
15+
"@vueuse/core": "^10.7.2",
16+
"ant-design-vue": "^4.0.0",
17+
"axios": "^1.6.7",
18+
"js-cookie": "^3.0.5",
19+
"naive-ui": "^2.40.1",
20+
"pinia": "^2.1.7",
21+
"sass": "^1.71.0",
22+
"vue": "^3.4.19",
23+
"vue-router": "^4.2.5"
2024
},
2125
"devDependencies": {
22-
"@commitlint/cli": "^8.2.0",
23-
"@commitlint/config-conventional": "^8.2.0",
24-
"@soerenmartius/vue3-clipboard": "^0.1.2",
25-
"@types/js-cookie": "^2.2.6",
26-
"@types/node": "^14.14.41",
27-
"@typescript-eslint/eslint-plugin": "^4.19.0",
28-
"@typescript-eslint/parser": "^4.19.0",
29-
"@vitejs/plugin-legacy": "^1.3.1",
30-
"@vitejs/plugin-vue": "^1.1.5",
31-
"@vitejs/plugin-vue-jsx": "^1.1.2",
32-
"@vue/compiler-sfc": "^3.0.11",
33-
"@vue/eslint-config-standard": "^4.0.0",
34-
"@vue/eslint-config-typescript": "^4.0.0",
35-
"@vueuse/core": "^4.8.3",
36-
"body-parser": "^1.19.0",
37-
"commitizen": "^4.2.3",
38-
"conventional-changelog-cli": "^2.1.1",
39-
"cross-env": "^7.0.3",
40-
"dotenv": "^8.2.0",
41-
"eslint": "^7.22.0",
42-
"eslint-config-airbnb-base": "^14.2.1",
43-
"eslint-config-prettier": "^8.1.0",
44-
"eslint-plugin-import": "^2.22.1",
45-
"eslint-plugin-prettier": "^3.3.1",
46-
"eslint-plugin-vue": "^7.8.0",
47-
"lint-staged": "^10.5.4",
48-
"stylelint": "^13.12.0",
49-
"stylelint-config-standard": "^21.0.0",
50-
"stylelint-order": "^4.1.0",
51-
"typescript": "^4.1.3",
52-
"vite": "^2.1.0",
53-
"vue-eslint-parser": "^7.6.0",
54-
"vue-tsc": "^0.0.8",
55-
"yorkie": "^2.0.0"
26+
"@antfu/eslint-config": "^2.8.0",
27+
"@commitlint/cli": "^18.6.1",
28+
"@commitlint/config-conventional": "^18.6.2",
29+
"@iconify-json/carbon": "^1.2.4",
30+
"@iconify-json/devicon": "^1.2.5",
31+
"@iconify-json/file-icons": "^1.2.0",
32+
"@iconify-json/logos": "^1.2.3",
33+
"@iconify-json/ri": "^1.2.3",
34+
"@iconify-json/simple-icons": "^1.2.11",
35+
"@iconify/utils": "^2.1.33",
36+
"@types/js-cookie": "^3.0.6",
37+
"@types/node": "^20.11.24",
38+
"@typescript-eslint/eslint-plugin": "^7.0.2",
39+
"@typescript-eslint/parser": "^7.0.2",
40+
"@unocss/preset-attributify": "^0.58.9",
41+
"@unocss/preset-icons": "^0.58.9",
42+
"@unocss/preset-uno": "^0.58.9",
43+
"@vitejs/plugin-vue": "^5.0.4",
44+
"@vitejs/plugin-vue-jsx": "^3.1.0",
45+
"@vue/eslint-config-typescript": "^12.0.0",
46+
"eslint": "^8.57.0",
47+
"eslint-config-prettier": "^9.1.0",
48+
"eslint-plugin-vue": "^9.21.1",
49+
"lint-staged": "^15.2.2",
50+
"prettier": "^3.2.5",
51+
"typescript": "^5.3.3",
52+
"unocss": "^0.58.9",
53+
"vite": "^5.1.3",
54+
"vue-tsc": "^1.8.27"
5655
},
5756
"gitHooks": {
5857
"pre-commit": "lint-staged",
5958
"commit-msg": "commitlint -e"
6059
},
61-
"config": {
62-
"commitizen": {
63-
"path": "cz-conventional-changelog"
64-
}
65-
},
6660
"lint-staged": {
67-
"*.{js,vue,ts}": [
68-
"eslint --ext .ts,.vue,.tsx src",
69-
"git add"
61+
"*.{js,vue,ts,tsx}": [
62+
"eslint --fix",
63+
"prettier --write"
7064
]
7165
}
7266
}

0 commit comments

Comments
 (0)