Skip to content

Commit

Permalink
style(project): eslint fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
chansee97 committed Jun 16, 2023
1 parent 0449e25 commit 9b60bb7
Show file tree
Hide file tree
Showing 30 changed files with 64 additions and 43 deletions.
1 change: 1 addition & 0 deletions build/config/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ProxyOptions } from 'vite'

/**
* @description: 生成vite代理字段
* @param {*} env - 环境变量配置
Expand Down
5 changes: 3 additions & 2 deletions build/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { PluginOption } from 'vite'
import UnoCSS from '@unocss/vite'
import UnoCSS from '@unocss/vite'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
import vue from './vue'
import compress from './compress'
import visualizer from './visualizer'
import unplugin from './unplugin'
import mock from './mock'

// import { viteMockServe } from 'vite-plugin-mock' // https://github.com/vbenjs/vite-plugin-mock/blob/main/README.zh_CN.md

/**
Expand All @@ -14,7 +15,7 @@ import mock from './mock'
* @return {*}
*/
export function setVitePlugins(env: ImportMetaEnv) {
const plugins: PluginOption[] = [...vue, UnoCSS(), ...unplugin,mock, vueSetupExtend()]
const plugins: PluginOption[] = [...vue, UnoCSS(), ...unplugin, mock, vueSetupExtend()]
// 是否压缩
if (env.VITE_COMPRESS_OPEN === 'Y')
plugins.push(compress(env))
Expand Down
2 changes: 1 addition & 1 deletion build/plugins/unplugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' // https://github.c

export default [
AutoImport({
imports: ['vue', 'vue-router','pinia'],
imports: ['vue', 'vue-router', 'pinia'],
include: [
/\.[tj]sx?$/,
/\.vue$/,
Expand Down
7 changes: 5 additions & 2 deletions build/plugins/vue.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx' // https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx

import vueJsx from '@vitejs/plugin-vue-jsx'

// https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx
import VueDevTools from 'vite-plugin-vue-devtools' // https://github.com/webfansplz/vite-plugin-vue-devtools

const plugins = [vue(), vueJsx(),VueDevTools()]
const plugins = [vue(), vueJsx(), VueDevTools()]

export default plugins
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"dev:prod": "vite --mode production",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"lint": "eslint . --fix",
"lint": "eslint --fix",
"prepare": "husky install",
"commit": "cz",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md"
Expand Down Expand Up @@ -78,12 +78,12 @@
"@types/mockjs": "^1.0.7",
"@types/node": "^20.3.1",
"@types/qs": "^6.9.7",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"commitizen": "^4.2.6",
"cz-conventional-changelog": "^3.3.0",
"cz-customizable": "^7.0.0",
"eslint": "^8.36.0",
"eslint": "^8.42.0",
"husky": "^8.0.3",
"less": "^4.1.3",
"lint-staged": "^13.1.0",
Expand Down
8 changes: 5 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { GlobalThemeOverrides } from 'naive-ui'
import { dateZhCN, useOsTheme, zhCN } from 'naive-ui'
import { useAppStore } from './store'
import themeConfig from './theme.json';
import themeConfig from './theme.json'
const locale = zhCN
const dateLocale = dateZhCN
Expand All @@ -14,8 +14,10 @@ const themeOverrides: GlobalThemeOverrides = {} || themeConfig
</script>

<template>
<n-config-provider class="wh-full" :theme="appStore.darkTheme" :locale="locale" :date-locale="dateLocale"
:theme-overrides="themeOverrides">
<n-config-provider
class="wh-full" :theme="appStore.darkTheme" :locale="locale" :date-locale="dateLocale"
:theme-overrides="themeOverrides"
>
<naive-provider><router-view /></naive-provider>
</n-config-provider>
</template>
1 change: 1 addition & 0 deletions src/components/common/DarkModeSwitch.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { useAppStore } from '@/store'
const appStore = useAppStore()
</script>

Expand Down
1 change: 1 addition & 0 deletions src/components/common/appLoading.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { useAppInfo } from '@/hooks'
const { title } = useAppInfo()
</script>

Expand Down
4 changes: 3 additions & 1 deletion src/components/custom/QRCode.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script setup lang="ts">
import vueQr from 'vue-qr/src/packages/vue-qr.vue' // https://www.npmjs.com/package/vue-qr
import vueQr from 'vue-qr/src/packages/vue-qr.vue'
// https://www.npmjs.com/package/vue-qr
const props = withDefaults(
defineProps<{
text?: string
Expand Down
1 change: 1 addition & 0 deletions src/config/service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** 默认实例的Aixos配置 */
import type { AxiosRequestConfig } from 'axios'

export const DEFAULT_AXIOS_OPTIONS: AxiosRequestConfig = {
// 请求超时时间,默认15秒
timeout: 15 * 1000,
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export function usePermission() {
let has = role === 'super'
if (!has) {
if (isArray(permission))
has = (permission as Auth.RoleType[]).includes(role)
has = (permission).includes(role)

if (isString(permission))
has = (permission as Auth.RoleType) === role
has = (permission) === role
}
return has
}
Expand Down
1 change: 1 addition & 0 deletions src/layouts/components/header/FullScreen.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import HeaderButton from '../common/HeaderButton.vue'
import { useAppStore } from '@/store'
const appStore = useAppStore()
</script>

Expand Down
3 changes: 2 additions & 1 deletion src/layouts/components/header/Github.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import HeaderButton from '../common/HeaderButton.vue'
const toMyGithub = () => {
function toMyGithub() {
window.open('https://github.com/iam-see')
}
</script>
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/components/header/Reload.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<script setup lang="ts">
import HeaderButton from '../common/HeaderButton.vue'
import { useAppStore } from '@/store'
const appStore = useAppStore()
const loading = ref(false)
const handleReload = () => {
function handleReload() {
loading.value = true
appStore.reloadPage()
setTimeout(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/components/header/Search.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import HeaderButton from '../common/HeaderButton.vue'
const handleSearch = () => {
function handleSearch() {
window.$message.success('施工中...')
}
</script>
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/components/header/Setting.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script setup lang="ts">
import HeaderButton from '../common/HeaderButton.vue'
import { useAppStore } from '@/store'
const appStore = useAppStore()
const drawerActive = ref(false)
const openSetting = () => {
function openSetting() {
drawerActive.value = !drawerActive.value
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/header/UserCenter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const options = [
icon: renderIcon('icon-park-outline:logout'),
},
]
const handleSelect = (key: string | number) => {
function handleSelect(key: string | number) {
if (key === 'loginOut') {
window.$dialog.info({
title: '退出登录',
Expand Down
1 change: 1 addition & 0 deletions src/layouts/components/sider/Logo.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { useAppStore } from '@/store'
import { useAppInfo, useAppRouter } from '@/hooks'
const { name } = useAppInfo()
const { toRoot } = useAppRouter()
const appStore = useAppStore()
Expand Down
3 changes: 1 addition & 2 deletions src/router/guard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Router } from 'vue-router'
import { createPermissionGuard } from './permission'
import { useRouteStore, useTabStore } from '@/store'


const title = import.meta.env.VITE_APP_TITLE

export function setupRouterGuard(router: Router) {
Expand All @@ -18,7 +17,7 @@ export function setupRouterGuard(router: Router) {
await createPermissionGuard(to, from, next)
})

router.beforeResolve(async (to) => {
router.beforeResolve((to) => {
const routeStore = useRouteStore()
const tabStore = useTabStore()
// 设置菜单高亮
Expand Down
2 changes: 1 addition & 1 deletion src/service/api/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export function fetchUserInfo(params: any) {
return mockRequest.get<Auth.UserInfo>('/getUserInfo', { params })
}
export function fetchUserRoutes(params: { userId: number }) {
return mockRequest.post<any>('/getUserRoutes', params)
return mockRequest.post<AppRoute.Route[]>('/getUserRoutes', params)
}
6 changes: 4 additions & 2 deletions src/store/modules/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import type { MenuOption } from 'naive-ui'
import { RouterLink } from 'vue-router'
import { h } from 'vue'
Expand Down Expand Up @@ -80,7 +79,7 @@ export const useRouteStore = defineStore('route-store', {
createMenus(userRoutes: AppRoute.Route[]) {
this.userRoutes = userRoutes

let resultMenus = JSON.parse(JSON.stringify(userRoutes))
let resultMenus: AppRoute.Route[] = JSON.parse(JSON.stringify(userRoutes))
resultMenus = this.removeHiddenRoutes(resultMenus)
this.menus = this.transformAuthRoutesToMenus(resultMenus)
},
Expand Down Expand Up @@ -157,6 +156,9 @@ export const useRouteStore = defineStore('route-store', {
const { data: routes } = await fetchUserRoutes({
userId: userInfo.userId,
})

if (!routes)
return
// 根据用户返回的路由表来生成真实路由
const appRoutes = await createDynamicRoutes(routes)
// 生成侧边菜单
Expand Down
8 changes: 4 additions & 4 deletions src/typings/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
interface Window {
$loadingBar?: import('naive-ui').LoadingBarApiInjection;
$dialog?: import('naive-ui').DialogApiInjection;
$message?: import('naive-ui').MessageApiInjection;
$notification?: import('naive-ui').NotificationApiInjection;
$loadingBar?: import('naive-ui').LoadingBarApi;
$dialog?: import('naive-ui').DialogApi;
$message?: import('naive-ui').MessageApi;
$notification?: import('naive-ui').NotificationApi;
}

declare const AMap: any;
Expand Down
2 changes: 1 addition & 1 deletion src/typings/route.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ declare namespace AppRoute {
/* 嵌套外链 */
herf?: string;
/** 当前路由需要选中的菜单项(用于跳转至不在左侧菜单显示的路由且需要高亮某个菜单的情况) */
activeMenu?: RouteKey;
activeMenu?: string;
}
}
2 changes: 1 addition & 1 deletion src/views/list/commonList/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const initialModel = {
const model = ref({ ...initialModel })
const formRef = ref<FormInst | null>()
const sendMail = (id: number) => {
function sendMail(id: number) {
window.$message.success(`用户id:${id}`)
}
const columns: DataTableColumns = [
Expand Down
1 change: 1 addition & 0 deletions src/views/plugin/editor/md/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import MdEditor from 'md-editor-v3'
import 'md-editor-v3/lib/style.css'
// https://github.com/imzbf/md-editor-v3/blob/dev/README-CN.md
const text = ref('# Hello Editor')
Expand Down
2 changes: 1 addition & 1 deletion src/views/plugin/editor/rich/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ onBeforeUnmount(() => {
editor.destroy()
})
const handleCreated = (editor: string) => {
function handleCreated(editor: string) {
editorRef.value = editor // 记录 editor 实例,重要!
}
</script>
Expand Down
20 changes: 10 additions & 10 deletions src/views/test/test1/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ import {
} from '@/service'
const msg = ref()
const pinter = () => {
function pinter() {
msg.value = import.meta.env
}
const get = () => {
function get() {
fetachGet({ a: 112211 }).then((res) => {
msg.value = res
})
}
const delete2 = () => {
function delete2() {
fetachDelete().then((res) => {
msg.value = res
})
}
const post = () => {
function post() {
const params = {
data: '2022-2-2',
data1: [],
Expand All @@ -48,7 +48,7 @@ function formPost() {
msg.value = res
})
}
const put = () => {
function put() {
const params = {
data: '2022-2-2',
}
Expand All @@ -58,30 +58,30 @@ const put = () => {
}
// 测试请求失败
const failedRequest = () => {
function failedRequest() {
testFailedRequest().then((res) => {
msg.value = res
})
}
// 测试业务失败
const failedResponse = () => {
function failedResponse() {
testFailedResponse().then((res) => {
msg.value = res
})
}
// 测试业务失败无提示
const failedResponse_NT = () => {
function failedResponse_NT() {
testFailedResponse_NT().then((res) => {
msg.value = res
})
}
// 测试刷新token
const updataToken = () => {
function updataToken() {
testUpdataToken().then((res) => {
msg.value = res
})
}
const mock = () => {
function mock() {
fetchMock().then((res) => {
msg.value = res
})
Expand Down
1 change: 1 addition & 0 deletions src/views/test/test2/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { useAppRouter } from '@/hooks'
const { routerPush } = useAppRouter()
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/views/test/test3/test4/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
const testMsg = () => {
function testMsg() {
window.$message.error('Once upon a time you dressed so fine')
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion unocss.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { presetUno,presetAttributify,defineConfig } from 'unocss' // https://github.com/unocss/unocss
import { defineConfig, presetAttributify, presetUno } from 'unocss' // https://github.com/unocss/unocss

export default defineConfig({
presets: [presetUno({ dark: 'class' }), presetAttributify()],
Expand Down

0 comments on commit 9b60bb7

Please sign in to comment.