mirror of
https://github.com/xiangshu233/vue3-vant4-mobile.git
synced 2025-08-08 03:02:05 +08:00
fix: correct function name typos from WidthOut to WithOut
- Fixed spelling error in useRouteStoreWidthOut -> useRouteStoreWithOut - Fixed spelling error in useUserStoreWidthOut -> useUserStoreWithOut - Updated all imports and usage across affected files - Improved code semantic correctness and consistency
This commit is contained in:
parent
b2bd636e92
commit
bf941ba71e
@ -4,14 +4,14 @@ import { createRouter, createWebHashHistory } from 'vue-router'
|
|||||||
import { createRouterGuards } from './router-guards'
|
import { createRouterGuards } from './router-guards'
|
||||||
import routeModuleList from './modules'
|
import routeModuleList from './modules'
|
||||||
import { ErrorPageRoute, LoginRoute, RootRoute } from '@/router/base'
|
import { ErrorPageRoute, LoginRoute, RootRoute } from '@/router/base'
|
||||||
import { useRouteStoreWidthOut } from '@/store/modules/route'
|
import { useRouteStoreWithOut } from '@/store/modules/route'
|
||||||
|
|
||||||
// 菜单
|
// 菜单
|
||||||
|
|
||||||
// 普通路由
|
// 普通路由
|
||||||
export const constantRouter: RouteRecordRaw[] = [LoginRoute, RootRoute, ErrorPageRoute]
|
export const constantRouter: RouteRecordRaw[] = [LoginRoute, RootRoute, ErrorPageRoute]
|
||||||
|
|
||||||
const routeStore = useRouteStoreWidthOut()
|
const routeStore = useRouteStoreWithOut()
|
||||||
|
|
||||||
routeStore.setMenus(routeModuleList)
|
routeStore.setMenus(routeModuleList)
|
||||||
routeStore.setRouters(constantRouter.concat(routeModuleList))
|
routeStore.setRouters(constantRouter.concat(routeModuleList))
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import type { Router } from 'vue-router'
|
import type { Router } from 'vue-router'
|
||||||
import { isNavigationFailure } from 'vue-router'
|
import { isNavigationFailure } from 'vue-router'
|
||||||
import NProgress from 'nprogress'
|
import NProgress from 'nprogress'
|
||||||
import { useRouteStoreWidthOut } from '@/store/modules/route'
|
import { useRouteStoreWithOut } from '@/store/modules/route'
|
||||||
import { useUserStoreWidthOut } from '@/store/modules/user'
|
import { useUserStoreWithOut } from '@/store/modules/user'
|
||||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||||
import { storage } from '@/utils/Storage'
|
import { storage } from '@/utils/Storage'
|
||||||
import { PageEnum } from '@/enums/pageEnum'
|
import { PageEnum } from '@/enums/pageEnum'
|
||||||
@ -19,7 +19,7 @@ export function createRouterGuards(router: Router) {
|
|||||||
// to: 即将要进入的目标
|
// to: 即将要进入的目标
|
||||||
// from: 当前导航正要离开的路由
|
// from: 当前导航正要离开的路由
|
||||||
NProgress.start()
|
NProgress.start()
|
||||||
const userStore = useUserStoreWidthOut()
|
const userStore = useUserStoreWithOut()
|
||||||
|
|
||||||
if (from.path === LOGIN_PATH && to.name === PageEnum.ERROR_PAGE_NAME) {
|
if (from.path === LOGIN_PATH && to.name === PageEnum.ERROR_PAGE_NAME) {
|
||||||
next(PageEnum.BASE_HOME)
|
next(PageEnum.BASE_HOME)
|
||||||
@ -63,7 +63,7 @@ export function createRouterGuards(router: Router) {
|
|||||||
console.warn('failed navigation', failure)
|
console.warn('failed navigation', failure)
|
||||||
}
|
}
|
||||||
|
|
||||||
const routeStore = useRouteStoreWidthOut()
|
const routeStore = useRouteStoreWithOut()
|
||||||
// 在这里设置需要缓存的组件名称
|
// 在这里设置需要缓存的组件名称
|
||||||
const keepAliveComponents = routeStore.keepAliveComponents
|
const keepAliveComponents = routeStore.keepAliveComponents
|
||||||
// 获取当前组件名
|
// 获取当前组件名
|
||||||
|
@ -35,6 +35,6 @@ export const useRouteStore = defineStore({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Need to be used outside the setup
|
// Need to be used outside the setup
|
||||||
export function useRouteStoreWidthOut() {
|
export function useRouteStoreWithOut() {
|
||||||
return useRouteStore(store)
|
return useRouteStore(store)
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,6 @@ export const useUserStore = defineStore({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Need to be used outside the setup
|
// Need to be used outside the setup
|
||||||
export function useUserStoreWidthOut() {
|
export function useUserStoreWithOut() {
|
||||||
return useUserStore(store)
|
return useUserStore(store)
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import { isString } from '@/utils/is/'
|
|||||||
import { deepMerge, isUrl } from '@/utils'
|
import { deepMerge, isUrl } from '@/utils'
|
||||||
import { setObjToUrlParams } from '@/utils/urlUtils'
|
import { setObjToUrlParams } from '@/utils/urlUtils'
|
||||||
|
|
||||||
import { useUserStoreWidthOut } from '@/store/modules/user'
|
import { useUserStoreWithOut } from '@/store/modules/user'
|
||||||
|
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { storage } from '@/utils/Storage'
|
import { storage } from '@/utils/Storage'
|
||||||
@ -186,7 +186,7 @@ const transform: AxiosTransform = {
|
|||||||
*/
|
*/
|
||||||
requestInterceptors: (config, options) => {
|
requestInterceptors: (config, options) => {
|
||||||
// 请求之前处理config
|
// 请求之前处理config
|
||||||
const userStore = useUserStoreWidthOut()
|
const userStore = useUserStoreWithOut()
|
||||||
const token = userStore.getToken
|
const token = userStore.getToken
|
||||||
if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
|
if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
|
||||||
// jwt token
|
// jwt token
|
||||||
|
Loading…
x
Reference in New Issue
Block a user