remove dependence @tanstack/vue-query

This commit is contained in:
KUN1007 2023-06-14 19:18:27 +08:00
parent 87d4949bbb
commit 37b5b33170
5 changed files with 25 additions and 119 deletions

View file

@ -21,7 +21,6 @@
"shinnku", "shinnku",
"signin", "signin",
"sina", "sina",
"tanstack",
"tencent", "tencent",
"Upvotes", "Upvotes",
"VARCHAR", "VARCHAR",

View file

@ -18,7 +18,6 @@
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"@tanstack/vue-query": "^4.29.11",
"@wangeditor/editor": "^5.1.23", "@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "^5.1.12", "@wangeditor/editor-for-vue": "^5.1.12",
"animate.css": "^4.1.1", "animate.css": "^4.1.1",

View file

@ -5,9 +5,6 @@ settings:
excludeLinksFromLockfile: false excludeLinksFromLockfile: false
dependencies: dependencies:
'@tanstack/vue-query':
specifier: ^4.29.11
version: 4.29.11(vue@3.3.4)
'@wangeditor/editor': '@wangeditor/editor':
specifier: ^5.1.23 specifier: ^5.1.23
version: 5.1.23 version: 5.1.23
@ -41,8 +38,8 @@ devDependencies:
specifier: ^4.1.1 specifier: ^4.1.1
version: 4.1.1(vue@3.3.4) version: 4.1.1(vue@3.3.4)
'@types/node': '@types/node':
specifier: ^20.2.5 specifier: ^20.3.1
version: 20.2.5 version: 20.3.1
'@vitejs/plugin-vue': '@vitejs/plugin-vue':
specifier: ^4.2.3 specifier: ^4.2.3
version: 4.2.3(vite@4.3.9)(vue@3.3.4) version: 4.2.3(vite@4.3.9)(vue@3.3.4)
@ -50,17 +47,17 @@ devDependencies:
specifier: ^7.0.3 specifier: ^7.0.3
version: 7.0.3 version: 7.0.3
rollup-plugin-visualizer: rollup-plugin-visualizer:
specifier: ^5.9.0 specifier: ^5.9.2
version: 5.9.0 version: 5.9.2
sass: sass:
specifier: ^1.62.1 specifier: ^1.63.3
version: 1.62.1 version: 1.63.4
typescript: typescript:
specifier: ^5.1.3 specifier: ^5.1.3
version: 5.1.3 version: 5.1.3
vite: vite:
specifier: ^4.3.9 specifier: ^4.3.9
version: 4.3.9(@types/node@20.2.5)(sass@1.62.1) version: 4.3.9(@types/node@20.3.1)(sass@1.63.4)
vite-plugin-mock: vite-plugin-mock:
specifier: ^3.0.0 specifier: ^3.0.0
version: 3.0.0(esbuild@0.17.19)(mockjs@1.1.0)(vite@4.3.9) version: 3.0.0(esbuild@0.17.19)(mockjs@1.1.0)(vite@4.3.9)
@ -373,33 +370,6 @@ packages:
fastq: 1.15.0 fastq: 1.15.0
dev: true dev: true
/@tanstack/match-sorter-utils@8.8.4:
resolution: {integrity: sha512-rKH8LjZiszWEvmi01NR72QWZ8m4xmXre0OOwlRGnjU01Eqz/QnN+cqpty2PJ0efHblq09+KilvyR7lsbzmXVEw==}
engines: {node: '>=12'}
dependencies:
remove-accents: 0.4.2
dev: false
/@tanstack/query-core@4.29.11:
resolution: {integrity: sha512-8C+hF6SFAb/TlFZyS9FItgNwrw4PMa7YeX+KQYe2ZAiEz6uzg6yIr+QBzPkUwZ/L0bXvGd1sufTm3wotoz+GwQ==}
dev: false
/@tanstack/vue-query@4.29.11(vue@3.3.4):
resolution: {integrity: sha512-HxaACzKQv3zlDyu2QHirMQpDNszdsQ+0vZqCzjDf1hkhQNYS+98Ofy4SvnKjSfUBsmNDc88YkZDo78eJh638jA==}
peerDependencies:
'@vue/composition-api': ^1.1.2
vue: ^2.5.0 || ^3.0.0
peerDependenciesMeta:
'@vue/composition-api':
optional: true
dependencies:
'@tanstack/match-sorter-utils': 8.8.4
'@tanstack/query-core': 4.29.11
'@vue/devtools-api': 6.5.0
vue: 3.3.4
vue-demi: 0.13.11(vue@3.3.4)
dev: false
/@transloadit/prettier-bytes@0.0.7: /@transloadit/prettier-bytes@0.0.7:
resolution: {integrity: sha512-VeJbUb0wEKbcwaSlj5n+LscBl9IPgLPkHVGBkh00cztv6X4L/TJXK58LzFuBKX7/GAfiGhIwH67YTLTlzvIzBA==} resolution: {integrity: sha512-VeJbUb0wEKbcwaSlj5n+LscBl9IPgLPkHVGBkh00cztv6X4L/TJXK58LzFuBKX7/GAfiGhIwH67YTLTlzvIzBA==}
dev: false dev: false
@ -412,8 +382,8 @@ packages:
resolution: {integrity: sha512-OCxXz6hEaJOVpRwuJMiVY5a6LtJcih+br9gwB/Q8ooOBikvk5FpBQ31OlNimXo3EqKha1Z7PFBni+q9m+8NCWg==} resolution: {integrity: sha512-OCxXz6hEaJOVpRwuJMiVY5a6LtJcih+br9gwB/Q8ooOBikvk5FpBQ31OlNimXo3EqKha1Z7PFBni+q9m+8NCWg==}
dev: true dev: true
/@types/node@20.2.5: /@types/node@20.3.1:
resolution: {integrity: sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ==} resolution: {integrity: sha512-EhcH/wvidPy1WeML3TtYFGR83UzjxeWRen9V402T8aUGYsCHOmfoisV3ZSg03gAFIbLq8TnWOJ0f4cALtnSEUg==}
dev: true dev: true
/@uppy/companion-client@2.2.2: /@uppy/companion-client@2.2.2:
@ -464,7 +434,7 @@ packages:
vite: ^4.0.0 vite: ^4.0.0
vue: ^3.2.25 vue: ^3.2.25
dependencies: dependencies:
vite: 4.3.9(@types/node@20.2.5)(sass@1.62.1) vite: 4.3.9(@types/node@20.3.1)(sass@1.63.4)
vue: 3.3.4 vue: 3.3.4
dev: true dev: true
@ -1396,10 +1366,6 @@ packages:
resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==}
dev: false dev: false
/remove-accents@0.4.2:
resolution: {integrity: sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA==}
dev: false
/require-directory@2.1.1: /require-directory@2.1.1:
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
@ -1410,8 +1376,8 @@ packages:
engines: {iojs: '>=1.0.0', node: '>=0.10.0'} engines: {iojs: '>=1.0.0', node: '>=0.10.0'}
dev: true dev: true
/rollup-plugin-visualizer@5.9.0: /rollup-plugin-visualizer@5.9.2:
resolution: {integrity: sha512-bbDOv47+Bw4C/cgs0czZqfm8L82xOZssk4ayZjG40y9zbXclNk7YikrZTDao6p7+HDiGxrN0b65SgZiVm9k1Cg==} resolution: {integrity: sha512-waHktD5mlWrYFrhOLbti4YgQCn1uR24nYsNuXxg7LkPH8KdTXVWR9DNY1WU0QqokyMixVXJS4J04HNrVTMP01A==}
engines: {node: '>=14'} engines: {node: '>=14'}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
@ -1440,8 +1406,8 @@ packages:
queue-microtask: 1.2.3 queue-microtask: 1.2.3
dev: true dev: true
/sass@1.62.1: /sass@1.63.4:
resolution: {integrity: sha512-NHpxIzN29MXvWiuswfc1W3I0N8SXBd8UR26WntmDlRYf0bSADnwnOjsyMZ3lMezSlArD33Vs3YFhp7dWvL770A==} resolution: {integrity: sha512-Sx/+weUmK+oiIlI+9sdD0wZHsqpbgQg8wSwSnGBjwb5GwqFhYNwwnI+UWZtLjKvKyFlKkatRK235qQ3mokyPoQ==}
engines: {node: '>=14.0.0'} engines: {node: '>=14.0.0'}
hasBin: true hasBin: true
dependencies: dependencies:
@ -1591,13 +1557,13 @@ packages:
mockjs: 1.1.0 mockjs: 1.1.0
path-to-regexp: 6.2.1 path-to-regexp: 6.2.1
picocolors: 1.0.0 picocolors: 1.0.0
vite: 4.3.9(@types/node@20.2.5)(sass@1.62.1) vite: 4.3.9(@types/node@20.3.1)(sass@1.63.4)
transitivePeerDependencies: transitivePeerDependencies:
- esbuild - esbuild
- supports-color - supports-color
dev: true dev: true
/vite@4.3.9(@types/node@20.2.5)(sass@1.62.1): /vite@4.3.9(@types/node@20.3.1)(sass@1.63.4):
resolution: {integrity: sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==} resolution: {integrity: sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==}
engines: {node: ^14.18.0 || >=16.0.0} engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true hasBin: true
@ -1622,30 +1588,15 @@ packages:
terser: terser:
optional: true optional: true
dependencies: dependencies:
'@types/node': 20.2.5 '@types/node': 20.3.1
esbuild: 0.17.19 esbuild: 0.17.19
postcss: 8.4.24 postcss: 8.4.24
rollup: 3.23.1 rollup: 3.23.1
sass: 1.62.1 sass: 1.63.4
optionalDependencies: optionalDependencies:
fsevents: 2.3.2 fsevents: 2.3.2
dev: true dev: true
/vue-demi@0.13.11(vue@3.3.4):
resolution: {integrity: sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
peerDependencies:
'@vue/composition-api': ^1.0.0-rc.1
vue: ^3.0.0-0 || ^2.6.0
peerDependenciesMeta:
'@vue/composition-api':
optional: true
dependencies:
vue: 3.3.4
dev: false
/vue-demi@0.14.5(vue@3.3.4): /vue-demi@0.14.5(vue@3.3.4):
resolution: {integrity: sha512-o9NUVpl/YlsGJ7t+xuqJKx8EBGf1quRhCiT6D/J0pfwmk9zUwYkC7yrF4SZCe6fETvSM3UNL2edcbYrSyc4QHA==} resolution: {integrity: sha512-o9NUVpl/YlsGJ7t+xuqJKx8EBGf1quRhCiT6D/J0pfwmk9zUwYkC7yrF4SZCe6fETvSM3UNL2edcbYrSyc4QHA==}
engines: {node: '>=12'} engines: {node: '>=12'}

View file

@ -10,8 +10,6 @@ import 'animate.css'
import i18n from '@/language/i18n' import i18n from '@/language/i18n'
// 引入路由守卫 // 引入路由守卫
import { setupRouterGuard } from '@/router/guard' import { setupRouterGuard } from '@/router/guard'
// 引入 TanStack Query V4
import { VueQueryPlugin } from '@tanstack/vue-query'
// 引入 Pinia // 引入 Pinia
import { setupPinia } from '@/store/index' import { setupPinia } from '@/store/index'
// 引入样式 // 引入样式
@ -25,4 +23,4 @@ setupPinia(app)
// 使用路由守卫 // 使用路由守卫
setupRouterGuard(router) setupRouterGuard(router)
app.use(router).use(i18n).use(VueQueryPlugin).mount('#app') app.use(router).use(i18n).mount('#app')

View file

@ -1,7 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive } from 'vue' import { ref, reactive } from 'vue'
import { useKUNGalgamerStore } from '@/store/modules/kungalgamer' import { useKUNGalgamerStore } from '@/store/modules/kungalgamer'
import { useMutation } from '@tanstack/vue-query'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { fetchPost } from '@/utils/request' import { fetchPost } from '@/utils/request'
import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue' import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue'
@ -19,24 +18,24 @@ const useStore = useKUNGalgamerStore()
const router = useRouter() const router = useRouter()
// //
const loginMutation = useMutation(async (data: any) => { const login = async (data: any) => {
const res: Response = await fetchPost('http://127.0.0.1:10007/api/login', { const res: Response = await fetchPost('http://127.0.0.1:10007/api/login', {
method: 'POST', method: 'POST',
body: JSON.stringify(data), body: JSON.stringify(data),
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
}) })
return await res.json() return await res.json()
}) }
// //
const registerMutation = useMutation(async (data: any) => { const register = async (data: any) => {
const res: Response = await fetchPost('http://127.0.0.1:10007/api/register', { const res: Response = await fetchPost('http://127.0.0.1:10007/api/register', {
method: 'POST', method: 'POST',
body: JSON.stringify(data), body: JSON.stringify(data),
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
}) })
return await res.json() return await res.json()
}) }
// //
const handleClickSignIn = () => { const handleClickSignIn = () => {
@ -48,49 +47,9 @@ const handleClickRegister = () => {
isShowPanel.value = 'right-panel-active' isShowPanel.value = 'right-panel-active'
} }
const handleLogin = () => { const handleLogin = () => {}
const { email, password } = loginForm
if (email && password) {
loginMutation.mutate(
{ email, password },
{
onSuccess: (response: any) => {
if (response.success) {
const token = response.token
useStore.setToken(token)
router.push({ path: '/' })
} else {
console.log('登录失败:', response.error)
}
},
}
)
} else {
console.log('请输入有效的邮箱和密码')
}
}
const handleRegister = () => { const handleRegister = () => {}
const { username, email, password, verificationCode } = loginForm
if (username && email && password && verificationCode) {
registerMutation.mutate(
{ username, email, password, verificationCode },
{
onSuccess: (response: any) => {
if (response.success) {
console.log('注册成功')
//
} else {
console.log('注册失败:', response.error)
//
}
},
}
)
} else {
console.log('请填写完整的注册信息')
}
}
</script> </script>
<template> <template>