数据分析ui补充完善,接入数据库
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { IS_TEST_MODE } from '@/ak/config.uts'
|
||||
|
||||
export default {
|
||||
onLoad() {
|
||||
@@ -37,37 +38,23 @@
|
||||
methods: {
|
||||
checkAndRedirect() {
|
||||
console.log('boot: start redirect check')
|
||||
try {
|
||||
const sessionInfo = supa.getSession();
|
||||
if (sessionInfo != null && sessionInfo.user != null) {
|
||||
// 已登录 -> 直接进入消费者端首页
|
||||
console.log('boot: found session, go consumer/index')
|
||||
uni.reLaunch({
|
||||
url: '/pages/mall/consumer/index',
|
||||
success: () => {
|
||||
console.log('boot: redirect to consumer/index success')
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('boot: redirect to consumer/index failed', err)
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('boot: error checking session', e);
|
||||
|
||||
if (IS_TEST_MODE) {
|
||||
// 测试阶段:不做强制重定向,保留你手动输入的 URL / 目标页面
|
||||
return
|
||||
}
|
||||
|
||||
console.log('boot: no session, go login')
|
||||
// 未登录 -> 登录页
|
||||
uni.reLaunch({
|
||||
url: '/pages/user/login',
|
||||
success: () => {
|
||||
console.log('boot: redirect to login success')
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('boot: redirect to login failed', err)
|
||||
try {
|
||||
const sessionInfo = supa.getSession()
|
||||
if (sessionInfo != null && sessionInfo.user != null) {
|
||||
uni.reLaunch({ url: '/pages/mall/consumer/index' })
|
||||
return
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('boot: error checking session', e)
|
||||
}
|
||||
|
||||
uni.reLaunch({ url: '/pages/user/login' })
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -141,6 +141,7 @@
|
||||
<script setup lang="uts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { IS_TEST_MODE } from '@/ak/config.uts'
|
||||
import { getCurrentUser, logout } from '@/utils/store.uts'
|
||||
|
||||
const cssVars = {
|
||||
@@ -171,6 +172,7 @@ const codeCountdown = ref<number>(0)
|
||||
|
||||
onMounted(() => {
|
||||
try {
|
||||
if (IS_TEST_MODE) return
|
||||
const sessionInfo = supa.getSession()
|
||||
if (sessionInfo != null && sessionInfo.user != null) {
|
||||
uni.switchTab({ url: '/pages/mall/consumer/index' })
|
||||
@@ -298,9 +300,11 @@ const handleLogin = async () => {
|
||||
}
|
||||
|
||||
uni.showToast({ title: '登录成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.switchTab({ url: '/pages/mall/consumer/index' })
|
||||
}, 500)
|
||||
if (!IS_TEST_MODE) {
|
||||
setTimeout(() => {
|
||||
uni.switchTab({ url: '/pages/mall/consumer/index' })
|
||||
}, 500)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('登录错误:', err)
|
||||
let msg = '登录失败,请重试'
|
||||
|
||||
Reference in New Issue
Block a user