chore: 优化ts配置,更新版本,types解决。

main
NoahLan 1 year ago
parent 2b97f0fe9d
commit ee84f695e9

@ -5,7 +5,7 @@
"scripts": {
"build": "vite build",
"build:ssg": "vite-ssg build",
"dev": "vite --port 3333 --open",
"dev": "vite --port 3333",
"lint": "eslint .",
"preview": "vite preview",
"preview-https": "serve dist",
@ -18,65 +18,65 @@
"sizecheck": "npx vite-bundle-visualizer"
},
"dependencies": {
"@unhead/vue": "^1.1.27",
"@unocss/reset": "^0.52.2",
"@vueuse/core": "^10.1.2",
"@vueuse/head": "^1.1.26",
"@unhead/vue": "^1.7.4",
"@unocss/reset": "^0.55.7",
"@vueuse/core": "^10.4.1",
"@vueuse/head": "^2.0.0",
"nprogress": "^0.2.0",
"pinia": "^2.1.3",
"pinia": "^2.1.6",
"vue": "^3.3.4",
"vue-demi": "^0.14.5",
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.1"
"vue-demi": "^0.14.6",
"vue-i18n": "^9.4.1",
"vue-router": "^4.2.4"
},
"devDependencies": {
"@antfu/eslint-config": "^0.39.3",
"@iconify-json/carbon": "^1.1.16",
"@intlify/unplugin-vue-i18n": "^0.10.0",
"@antfu/eslint-config": "^0.43.0",
"@iconify-json/carbon": "^1.1.21",
"@intlify/unplugin-vue-i18n": "^1.2.0",
"@types/markdown-it-link-attributes": "^3.0.1",
"@types/nprogress": "^0.2.0",
"@types/qs": "^6.9.7",
"@unocss/eslint-config": "^0.52.2",
"@vitejs/plugin-vue": "^4.2.3",
"@unocss/eslint-config": "^0.55.7",
"@vitejs/plugin-vue": "^4.3.4",
"@vue-macros/reactivity-transform": "^0.3.9",
"@vue-macros/short-vmodel": "^1.2.8",
"@vue-macros/volar": "^0.9.8",
"@vue/test-utils": "^2.3.2",
"critters": "^0.0.16",
"@vue-macros/volar": "^0.14.3",
"@vue/test-utils": "^2.4.1",
"critters": "^0.0.20",
"cross-env": "^7.0.3",
"cypress": "^12.12.0",
"cypress-vite": "^1.4.0",
"eslint": "^8.41.0",
"eslint-plugin-cypress": "^2.13.3",
"cypress": "^13.2.0",
"cypress-vite": "^1.4.2",
"eslint": "^8.49.0",
"eslint-plugin-cypress": "^2.15.1",
"https-localhost": "^4.7.1",
"lint-staged": "^13.2.2",
"lint-staged": "^14.0.1",
"markdown-it-link-attributes": "^4.0.1",
"markdown-it-shiki": "^0.9.0",
"naive-ui": "^2.34.4",
"pnpm": "^8.5.1",
"shiki": "^0.14.2",
"simple-git-hooks": "^2.8.1",
"taze": "^0.10.1",
"typescript": "^5.0.4",
"unocss": "^0.52.2",
"unplugin-auto-import": "^0.16.2",
"unplugin-vue-components": "^0.24.1",
"unplugin-vue-macros": "^2.1.7",
"vite": "^4.3.8",
"vite-bundle-visualizer": "^0.7.0",
"vite-plugin-inspect": "^0.7.28",
"vite-plugin-pages": "^0.30.1",
"vite-plugin-pwa": "^0.15.0",
"pnpm": "^8.7.6",
"shiki": "^0.14.4",
"simple-git-hooks": "^2.9.0",
"taze": "^0.11.2",
"typescript": "^5.2.2",
"unocss": "^0.55.7",
"unplugin-auto-import": "^0.16.6",
"unplugin-vue-components": "^0.25.2",
"unplugin-vue-macros": "^2.5.1",
"unplugin-vue-markdown": "^0.24.3",
"vite": "^4.4.9",
"vite-bundle-visualizer": "^0.10.0",
"vite-plugin-inspect": "^0.7.38",
"vite-plugin-pages": "^0.31.0",
"vite-plugin-pwa": "^0.16.5",
"vite-plugin-vue-component-preview": "^1.1.6",
"vite-plugin-vue-devtools": "^0.0.16",
"vite-plugin-vue-devtools": "^1.0.0-rc.4",
"vite-plugin-vue-layouts": "^0.8.0",
"vite-plugin-vue-markdown": "^0.23.5",
"vite-plugin-webfont-dl": "^3.7.4",
"vite-ssg": "^0.22.2",
"vite-plugin-webfont-dl": "^3.7.6",
"vite-ssg": "^0.23.2",
"vite-ssg-sitemap": "^0.5.1",
"vitest": "^0.31.1",
"vue-request": "^2.0.1",
"vue-tsc": "^1.6.5"
"vitest": "^0.34.4",
"vue-request": "^2.0.3",
"vue-tsc": "^1.8.11"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"

File diff suppressed because it is too large Load Diff

@ -41,29 +41,14 @@ const themeOverrides: GlobalThemeOverrides = {
</script>
<template>
<n-config-provider
class="h-full w-full"
:theme="theme"
:theme-overrides="themeOverrides"
:locale="zhCN"
:date-locale="dateZhCN"
>
<n-config-provider class="h-full w-full" :theme="theme" :theme-overrides="themeOverrides" :locale="zhCN"
:date-locale="dateZhCN">
<n-loading-bar-provider>
<n-message-provider>
<n-notification-provider>
<n-dialog-provider>
<n-watermark
content="TODO 水印"
cross
fullscreen
:font-size="12"
:line-height="16"
:width="384"
:height="384"
:x-offset="12"
:y-offset="60"
:rotate="-15"
/>
<n-watermark content="TODO 水印" cross fullscreen :font-size="12" :line-height="16" :width="384" :height="384"
:x-offset="12" :y-offset="60" :rotate="-15" />
<RouterView />
</n-dialog-provider>
</n-notification-provider>

30
src/api/api.d.ts vendored

@ -1,9 +1,25 @@
interface Pagination {
size?: number
current?: number
total?: number
}
declare namespace API {
// 分页模型
interface Pagination {
size?: number
current?: number
total?: number
}
// 时间模型
interface TimeInfo {
createdAt?: string
updatedAt?: string
}
// 基础ID
interface BaseID {
id?: string
}
interface BaseID {
id?: string
// 验证码请求
interface CaptchaReq {
captchaId: string
captcha: string
}
}

61
src/api/auth.d.ts vendored

@ -0,0 +1,61 @@
declare namespace API {
// OAuth 登录请求(网页登录)
interface OauthLoginReq {
// 服务提供商名称
provider: string
}
// OAuth 登录返回登录页(网页登录)
interface OauthLoginResp {
// 提供商登录地址
AuthUrl: string
}
// OAuth Code 登录请求
interface OauthLoginByCodeReq {
code: string
provider: string
}
// OAuth 手机号登录请求
interface OauthLoginByPhoneCodeReq {
authCode?: string
code: string
provider: string
}
// 登录请求
type LoginReq = Partial<CaptchaReq> & {
// 登录主体(用户名/邮箱/手机号码)| 作用于验证码时,不支持用户名
subject: string
// 登录凭证
credentials: string
// 当前登录平台
platform: string
}
// 登录Token信息
interface LoginTokenInfo {
uid: string
token_type: string
access_token: string
expires_at: Number
scope: string
}
// 登录返回
interface LoginResp {
twoFactorType: string
token: LoginTokenInfo
}
// 注册请求
type RegisterReq = Partial<CaptchaReq> & Partial<{
username: string
email: string
phoneNumber: string
code: string
}> & {
credentials: string
}
}

@ -1,7 +1,55 @@
import { defHttp } from '~/utils/http'
export function login() {
defHttp.post({
// 密码登录
export function login(data: API.LoginReq) {
defHttp.post<API.LoginResp>({
url: '/api/auth/login',
})
method: 'POST',
data
}, { withToken: false })
}
// 验证码登录手机x邮箱
export function loginByCode(data: API.LoginReq) {
defHttp.post<API.LoginResp>({
url: '/api/auth/login/byCode',
method: 'POST',
data
}, { withToken: false })
}
// Oauth 第三方登录获取登录地址通常针对PC网页登录APP端自行获取code
export function oauthLogin(params: API.OauthLoginReq) {
defHttp.post<API.OauthLoginResp>({
url: '/api/auth/oauth/login',
method: 'GET',
params
}, { withToken: false })
}
// Oauth 第三方登录客户端自行获取code进行登录
export function oauthLoginByCode(data: API.OauthLoginByCodeReq) {
defHttp.post<API.LoginResp>({
url: '/api/auth/oauth/login/byCode',
method: 'POST',
data
}, { withToken: false })
}
// Oauth 第三方登录客户端获取换取手机号的code进行登录
export function oauthLoginByPhone(data: API.OauthLoginByPhoneCodeReq) {
defHttp.post<API.LoginResp>({
url: '/api/auth/oauth/login/byPhone',
method: 'POST',
data
}, { withToken: false })
}
// 用户注册
export function register(data: API.RegisterReq) {
defHttp.post<API.BaseID>({
url: '/api/auth/register',
method: 'POST',
data
}, { withToken: false })
}

@ -1,6 +1,7 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
declare global {
@ -50,9 +51,14 @@ declare global {
const isReactive: typeof import('vue')['isReactive']
const isReadonly: typeof import('vue')['isReadonly']
const isRef: typeof import('vue')['isRef']
const login: typeof import('./api/auth/auth')['login']
const loginByCode: typeof import('./api/auth/auth')['loginByCode']
const makeDestructurable: typeof import('@vueuse/core')['makeDestructurable']
const markRaw: typeof import('vue')['markRaw']
const nextTick: typeof import('vue')['nextTick']
const oauthLogin: typeof import('./api/auth/auth')['oauthLogin']
const oauthLoginByCode: typeof import('./api/auth/auth')['oauthLoginByCode']
const oauthLoginByPhone: typeof import('./api/auth/auth')['oauthLoginByPhone']
const onActivated: typeof import('vue')['onActivated']
const onBeforeMount: typeof import('vue')['onBeforeMount']
const onBeforeRouteLeave: typeof import('vue-router')['onBeforeRouteLeave']
@ -88,6 +94,7 @@ declare global {
const refDefault: typeof import('@vueuse/core')['refDefault']
const refThrottled: typeof import('@vueuse/core')['refThrottled']
const refWithControl: typeof import('@vueuse/core')['refWithControl']
const register: typeof import('./api/auth/auth')['register']
const resolveComponent: typeof import('vue')['resolveComponent']
const resolveRef: typeof import('@vueuse/core')['resolveRef']
const resolveUnref: typeof import('@vueuse/core')['resolveUnref']
@ -307,7 +314,7 @@ declare global {
// for type re-export
declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode } from 'vue'
export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
}
// for vue template auto import
import { UnwrapRef } from 'vue'
@ -346,7 +353,6 @@ declare module 'vue' {
readonly defineComponent: UnwrapRef<typeof import('vue')['defineComponent']>
readonly eagerComputed: UnwrapRef<typeof import('@vueuse/core')['eagerComputed']>
readonly effectScope: UnwrapRef<typeof import('vue')['effectScope']>
readonly envD: UnwrapRef<typeof import('./types/env.d')['default']>
readonly extendRef: UnwrapRef<typeof import('@vueuse/core')['extendRef']>
readonly getCurrentInstance: UnwrapRef<typeof import('vue')['getCurrentInstance']>
readonly getCurrentScope: UnwrapRef<typeof import('vue')['getCurrentScope']>
@ -359,9 +365,14 @@ declare module 'vue' {
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
readonly isReadonly: UnwrapRef<typeof import('vue')['isReadonly']>
readonly isRef: UnwrapRef<typeof import('vue')['isRef']>
readonly login: UnwrapRef<typeof import('./api/auth/auth')['login']>
readonly loginByCode: UnwrapRef<typeof import('./api/auth/auth')['loginByCode']>
readonly makeDestructurable: UnwrapRef<typeof import('@vueuse/core')['makeDestructurable']>
readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']>
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
readonly oauthLogin: UnwrapRef<typeof import('./api/auth/auth')['oauthLogin']>
readonly oauthLoginByCode: UnwrapRef<typeof import('./api/auth/auth')['oauthLoginByCode']>
readonly oauthLoginByPhone: UnwrapRef<typeof import('./api/auth/auth')['oauthLoginByPhone']>
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
readonly onBeforeMount: UnwrapRef<typeof import('vue')['onBeforeMount']>
readonly onBeforeRouteLeave: UnwrapRef<typeof import('vue-router')['onBeforeRouteLeave']>
@ -397,6 +408,7 @@ declare module 'vue' {
readonly refDefault: UnwrapRef<typeof import('@vueuse/core')['refDefault']>
readonly refThrottled: UnwrapRef<typeof import('@vueuse/core')['refThrottled']>
readonly refWithControl: UnwrapRef<typeof import('@vueuse/core')['refWithControl']>
readonly register: UnwrapRef<typeof import('./api/auth/auth')['register']>
readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
readonly resolveRef: UnwrapRef<typeof import('@vueuse/core')['resolveRef']>
readonly resolveUnref: UnwrapRef<typeof import('@vueuse/core')['resolveUnref']>
@ -649,7 +661,6 @@ declare module '@vue/runtime-core' {
readonly defineComponent: UnwrapRef<typeof import('vue')['defineComponent']>
readonly eagerComputed: UnwrapRef<typeof import('@vueuse/core')['eagerComputed']>
readonly effectScope: UnwrapRef<typeof import('vue')['effectScope']>
readonly envD: UnwrapRef<typeof import('./types/env.d')['default']>
readonly extendRef: UnwrapRef<typeof import('@vueuse/core')['extendRef']>
readonly getCurrentInstance: UnwrapRef<typeof import('vue')['getCurrentInstance']>
readonly getCurrentScope: UnwrapRef<typeof import('vue')['getCurrentScope']>
@ -662,9 +673,14 @@ declare module '@vue/runtime-core' {
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
readonly isReadonly: UnwrapRef<typeof import('vue')['isReadonly']>
readonly isRef: UnwrapRef<typeof import('vue')['isRef']>
readonly login: UnwrapRef<typeof import('./api/auth/auth')['login']>
readonly loginByCode: UnwrapRef<typeof import('./api/auth/auth')['loginByCode']>
readonly makeDestructurable: UnwrapRef<typeof import('@vueuse/core')['makeDestructurable']>
readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']>
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
readonly oauthLogin: UnwrapRef<typeof import('./api/auth/auth')['oauthLogin']>
readonly oauthLoginByCode: UnwrapRef<typeof import('./api/auth/auth')['oauthLoginByCode']>
readonly oauthLoginByPhone: UnwrapRef<typeof import('./api/auth/auth')['oauthLoginByPhone']>
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
readonly onBeforeMount: UnwrapRef<typeof import('vue')['onBeforeMount']>
readonly onBeforeRouteLeave: UnwrapRef<typeof import('vue-router')['onBeforeRouteLeave']>
@ -700,6 +716,7 @@ declare module '@vue/runtime-core' {
readonly refDefault: UnwrapRef<typeof import('@vueuse/core')['refDefault']>
readonly refThrottled: UnwrapRef<typeof import('@vueuse/core')['refThrottled']>
readonly refWithControl: UnwrapRef<typeof import('@vueuse/core')['refWithControl']>
readonly register: UnwrapRef<typeof import('./api/auth/auth')['register']>
readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
readonly resolveRef: UnwrapRef<typeof import('@vueuse/core')['resolveRef']>
readonly resolveUnref: UnwrapRef<typeof import('@vueuse/core')['resolveUnref']>

@ -3,11 +3,9 @@
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'
export {}
declare module '@vue/runtime-core' {
declare module 'vue' {
export interface GlobalComponents {
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDialogProvider: typeof import('naive-ui')['NDialogProvider']

@ -18,9 +18,3 @@ interface ImportMetaEnv {
}
interface ImportMeta {readonly env: ImportMetaEnv}
declare module "*.vue" {
import type { DefineComponent } from "vue"
const component: DefineComponent<{}, {}, any>
export default component
}

@ -23,7 +23,8 @@
"vite-plugin-vue-component-preview/client",
"vite-plugin-vue-layouts/client",
"vite-plugin-pwa/client",
"unplugin-vue-macros/macros-global"
"unplugin-vue-macros/macros-global",
"naive-ui",
],
"paths": {
"~/*": ["src/*"],
@ -38,10 +39,9 @@
]
},
"exclude": ["dist", "node_modules", "cypress"],
"include": [
"src/**/*",
"src/**/*.d.ts",
"src/types/**/*.d.ts",
"src/**/types/**/*.d.ts"
]
// "include": [
// // "src/**/*",
// // "src/types/**/*.d.ts",
// // "src/**/types/**/*.d.ts"
// ]
}

@ -6,20 +6,20 @@ import generateSitemap from 'vite-ssg-sitemap'
import Layouts from 'vite-plugin-vue-layouts'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import Markdown from 'vite-plugin-vue-markdown'
import { VitePWA } from 'vite-plugin-pwa'
import Markdown from 'unplugin-vue-markdown/vite'
import VueMacros from 'unplugin-vue-macros/vite'
import VueI18n from '@intlify/unplugin-vue-i18n/vite'
import { VitePWA } from 'vite-plugin-pwa'
import VueDevTools from 'vite-plugin-vue-devtools'
import LinkAttributes from 'markdown-it-link-attributes'
import Unocss from 'unocss/vite'
import Shiki from 'markdown-it-shiki'
import WebfontDownload from 'vite-plugin-webfont-dl'
// custom
import { transformShortVmodel } from '@vue-macros/short-vmodel'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
// @ts-expect-error failed to resolve types
import VueMacros from 'unplugin-vue-macros/vite'
import WebfontDownload from 'vite-plugin-webfont-dl'
export default defineConfig({
resolve: {
alias: {
@ -76,6 +76,7 @@ export default defineConfig({
'src/composables',
'src/stores',
'src/types',
'src/api',
'src/api/**',
],
vueTemplate: true,

Loading…
Cancel
Save