更新:访客模式可以查看图书首页
This commit is contained in:
22
App.vue
22
App.vue
@@ -3,31 +3,9 @@
|
||||
import update from "@/uni_modules/uni-upgrade-center-app/utils/check-update";
|
||||
|
||||
// #endif
|
||||
import { useUserStore } from '@/stores/user'
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
const userStore = useUserStore()
|
||||
console.log('App Launch')
|
||||
// 保存原生 switchTab 方法
|
||||
const originalSwitchTab = uni.switchTab;
|
||||
uni.switchTab = (options) => {
|
||||
if (options.url.includes('/pages/book/index') && !uni.getStorageSync('token')) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请先登录后访问该页面',
|
||||
confirmText: '去登录',
|
||||
success: (res) => {
|
||||
console.log(res, 'res');
|
||||
if (res.confirm) uni.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
});
|
||||
}
|
||||
});
|
||||
return; // 拦截跳转
|
||||
}
|
||||
// 已登录/非拦截页 → 执行原生跳转
|
||||
originalSwitchTab.call(uni, options);
|
||||
}
|
||||
// 检测自动更新
|
||||
// #ifdef APP-PLUS
|
||||
update();
|
||||
|
||||
Reference in New Issue
Block a user