feat(login): wip 登录系统

This commit is contained in:
feige996
2025-08-18 22:01:55 +08:00
parent e8478c9d43
commit 6aa4bc3472
5 changed files with 19 additions and 10 deletions

View File

@@ -1,8 +1,6 @@
<script setup lang="ts">
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
import { navigateToInterceptor } from '@/router/interceptor'
import { tabbarStore } from './tabbar/store'
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
onLaunch((options) => {
@@ -12,9 +10,6 @@ onLaunch((options) => {
const gotoPath = options?.path || ''
navigateToInterceptor.invoke({ url: gotoPath })
// 处理直接进入路由非首页时tabbarIndex 不正确的问题
tabbarStore.setAutoCurIdx(gotoPath)
})
onShow((options) => {
console.log('App Show', options)

View File

@@ -17,6 +17,12 @@ import RequestComp from './components/request.vue'
// testOxlint('oxlint')
console.log('about')
function toLogin() {
uni.navigateTo({
url: `/pages/login/login?redirect=${encodeURIComponent('/pages/about/about')}`,
})
}
function gotoAlova() {
uni.navigateTo({
url: '/pages/about/alova',
@@ -51,6 +57,9 @@ onReady(() => {
<view class="my-2 text-center">
<image src="/static/images/avatar.jpg" class="h-100px w-100px" />
</view>
<button class="mt-4 w-40 text-center" @click="toLogin">
点击去登录页
</button>
<RequestComp />
<view class="mb-6 h-1px bg-#eee" />
<view class="text-center">

View File

@@ -5,6 +5,7 @@
* 我这里应为大部分都可以随便进入,所以使用黑名单
*/
import { useUserStore } from '@/store'
import { tabbarStore } from '@/tabbar/store'
import { getLastPage } from '@/utils'
import { EXCLUDE_LIST, LOGIN_PAGE_LIST } from '../login/config'
@@ -14,6 +15,9 @@ export const navigateToInterceptor = {
// 增加对相对路径的处理BY 网友 @ideal
invoke({ url }: { url: string }) {
console.log(url) // /pages/route-interceptor/index?name=feige&age=30
if (url === undefined) {
return
}
let path = url.split('?')[0]
// 处理相对路径
@@ -24,6 +28,9 @@ export const navigateToInterceptor = {
path = `${baseDir}/${path}`
}
// 处理直接进入路由非首页时tabbarIndex 不正确的问题
tabbarStore.setAutoCurIdx(path)
if (LOGIN_PAGE_LIST.includes(path)) {
console.log('000')
return
@@ -34,8 +41,6 @@ export const navigateToInterceptor = {
return
}
// tabbarStore.restorePrevIdx()
console.log('拦截器中得到的 path:', path, userStore.hasLogin)
if ([...EXCLUDE_LIST, ...LOGIN_PAGE_LIST].includes(path)) {

View File

@@ -20,7 +20,7 @@ export const TABBAR_STRATEGY_MAP = {
// 如果是使用 NO_TABBAR(0)nativeTabbarList 和 customTabbarList 都不生效(里面的配置不用管)
// 如果是使用 NATIVE_TABBAR(1),只需要配置 nativeTabbarListcustomTabbarList 不生效
// 如果是使用 CUSTOM_TABBAR(2,3),只需要配置 customTabbarListnativeTabbarList 不生效
export const selectedTabbarStrategy = TABBAR_STRATEGY_MAP.NATIVE_TABBAR
export const selectedTabbarStrategy = TABBAR_STRATEGY_MAP.CUSTOM_TABBAR_WITH_CACHE
type NativeTabBarItem = TabBar['list'][0]
// TODO: 2/3. 使用 NATIVE_TABBAR 时,更新下面的 tabbar 配置

View File

@@ -33,8 +33,8 @@ export const tabbarStore = reactive({
uni.setStorageSync('app-tabbar-index', idx)
},
setAutoCurIdx(path: string) {
const index = tabbarList.findIndex(item => item.pagePath === path)
// console.log('index:', index, path)
const index = tabbarList.findIndex(item => item.path === path)
console.log('index:', index, path)
// console.log('tabbarList:', tabbarList)
if (index === -1) {
this.setCurIdx(0)