We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5765c92 commit 2c456d0Copy full SHA for 2c456d0
.eslintrc.js
@@ -21,8 +21,6 @@ module.exports = {
21
'import/namespace': [2, { allowComputed: true }],
22
'import/no-named-as-default-member': 'off',
23
'import/no-unresolved': 'off',
24
- '@typescript-eslint/consistent-type-imports': 'off',
25
- '@typescript-eslint/no-unused-vars': 'off',
26
// enUS: all rules docs https://eslint.org/docs/rules/
27
// zhCN: 所有规则文档 https://eslint.bootcss.com/docs/rules/
28
// 基础规则 全部 ES 项目通用
@@ -35,6 +33,12 @@ module.exports = {
35
33
'no-unused-vars': ['off'],
36
34
// 强制在代码块中开括号前和闭括号后有空格
37
'block-spacing': ['error', 'always'],
38
- 'object-curly-spacing': ['error', 'always']
+ 'object-curly-spacing': ['error', 'always'],
+ /* typescript */
+ '@typescript-eslint/ban-ts-ignore': 'off',
39
+ '@typescript-eslint/no-var-requires': 'off',
40
+ '@typescript-eslint/no-explicit-any': 'off',
41
+ '@typescript-eslint/consistent-type-imports': 'off',
42
+ '@typescript-eslint/no-unused-vars': 'off',
43
},
44
}
components.d.ts
@@ -6,8 +6,13 @@ import '@vue/runtime-core'
6
declare module '@vue/runtime-core' {
7
export interface GlobalComponents {
8
VanButton: typeof import('vant/es')['Button']
9
+ VanCell: typeof import('vant/es')['Cell']
10
+ VanCellGroup: typeof import('vant/es')['CellGroup']
11
VanConfigProvider: typeof import('vant/es')['ConfigProvider']
12
+ VanIcon: typeof import('vant/es')['Icon']
13
+ VanNavBar: typeof import('vant/es')['NavBar']
14
VanSwitch: typeof import('vant/es')['Switch']
15
+ VanTag: typeof import('vant/es')['Tag']
16
17
18
src/App.vue
@@ -1,26 +1,30 @@
1
<template>
2
<van-config-provider :theme="theme">
3
- <van-switch v-model="checked" />
4
<router-view />
5
</van-config-provider>
</template>
<script setup lang="ts">
-import { ref, watch } from 'vue'
+import { ref, computed, watch } from 'vue'
import type { ConfigProviderTheme } from 'vant'
+import { localStorage } from '@/utils/local-storage'
+import { useStore } from '@/stores'
-const theme = ref<ConfigProviderTheme>('light')
-const checked = ref<boolean>(false)
+const store = useStore()
+const res = localStorage.get('theme')
+const theme = ref<ConfigProviderTheme>(res)
+const mode = computed(() => store.mode)
-watch(checked,() => {
- if(checked.value) {
+watch(mode, (val) => {
19
+ if(val === 'dark') {
20
theme.value = 'dark'
document.querySelector('html')
- .setAttribute('data-theme', 'data-theme-dark')
+ .setAttribute('data-theme', 'dark')
} else {
theme.value = 'light'
- .setAttribute('data-theme', 'data-theme-light')
+ .setAttribute('data-theme', 'light')
-})
+}, { immediate: true })
29
+
30
</script>
src/api/dashboard/workplace.ts src/api/index.tssrc/api/dashboard/workplace.ts renamed to src/api/index.ts
@@ -1,5 +1,5 @@
-import request from '@/utils/request'
-
-export async function queryProjectNotice(): Promise<any> {
- return request('/project/notice')
+import request from '@/utils/request'
+export async function queryProjectNotice(): Promise<any> {
+ return request('/project/notice')
src/app.less
@@ -13,7 +13,7 @@ body {
box-sizing: border-box;
-[data-theme='data-theme-dark'] {
+[data-theme='dark'] {
&,
* {
color-scheme: dark !important;
src/router/index.ts
@@ -1,30 +1,34 @@
+// https://router.vuejs.org/zh/
import { createRouter, createWebHistory } from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
NProgress.configure({ showSpinner: true })
// 导入路由组件
-import Dashboard from '../views/dashboard/analysis/index.vue'
-import Workplace from '../views/dashboard/workplace/index.vue'
+import mian from '@/views/index.vue'
+import mock from '@/views/mock/index.vue'
// 定义路由,每个路由都需要映射到一个组件
const routes = [
{
path: '/',
- name: 'dashboard',
- component: Dashboard
+ name: 'main',
+ component: mian
}, {
- path: '/workplace',
- name: 'workplace',
- component: Workplace
+ path: '/mock',
+ name: 'mock',
+ component: mock
]
// 创建路由实例并传递 `routes` 配置
const router = createRouter({
history: createWebHistory(),
- routes
+ routes,
+ scrollBehavior() {
+ // 始终滚动到顶部
+ return { top: 0 }
31
+ },
32
})
router.beforeEach((_to, _from, next) => {
src/stores/index.ts
@@ -0,0 +1,8 @@
+import { defineStore } from 'pinia'
+export const useStore = defineStore({
+ id: 'index',
+ state: () => ({
+ mode: 'light'
+ })
+})
src/store/mutation-type.ts src/stores/mutation-type.tssrc/store/mutation-type.ts renamed to src/stores/mutation-type.ts
src/utils/request.ts
@@ -2,7 +2,7 @@ import type { AxiosRequestConfig, AxiosError } from 'axios'
import axios, { AxiosResponse } from 'axios'
import type { ResponseBody } from '@/api/typing'
import { localStorage } from '@/utils/local-storage'
-import { STORAGE_TOKEN_KEY } from '@/store/mutation-type'
+import { STORAGE_TOKEN_KEY } from '@/stores/mutation-type'
import { Notify } from 'vant'
// 这里是用于设定请求后端时,所用的 Token KEY
src/views/dashboard/analysis/index.vue
0 commit comments