feat: 登录页自动跳过 — 已登录用户不再看到登录界面
This commit is contained in:
@ -6,7 +6,12 @@
|
||||
<text class="version">{{ appVersion }}</text>
|
||||
</view>
|
||||
|
||||
<view class="form">
|
||||
<!-- 检查中:防止登录页闪烁 -->
|
||||
<view v-if="checking" class="checking">
|
||||
<text class="checking-icon">⏳</text>
|
||||
</view>
|
||||
|
||||
<view v-else class="form">
|
||||
<input v-model="username" class="input" placeholder="用户名" />
|
||||
<input v-model="password" class="input" type="password" placeholder="密码" />
|
||||
<button class="login-btn" @tap="handleLogin" :disabled="loading">
|
||||
@ -21,9 +26,21 @@
|
||||
import { ref, onMounted } from "vue";
|
||||
import { post } from "../../utils/request";
|
||||
|
||||
// 🚀 动态版本号 — 热更新后自动变化
|
||||
// 🚀 动态版本号 + 自动跳过登录(已登录用户)
|
||||
const appVersion = ref("T1.0.2");
|
||||
const checking = ref(true);
|
||||
|
||||
onMounted(() => {
|
||||
// 1. 自动跳过:如果已有 token + user,直接进首页
|
||||
const token = uni.getStorageSync("access_token") || uni.getStorageSync("refresh_token");
|
||||
const user = uni.getStorageSync("user");
|
||||
if (token && user) {
|
||||
uni.switchTab({ url: "/pages/scan/index" });
|
||||
return; // 不展示登录页
|
||||
}
|
||||
checking.value = false;
|
||||
|
||||
// 2. 动态版本号
|
||||
try {
|
||||
const v = uni.getSystemInfoSync().appWgtVersion || uni.getSystemInfoSync().appVersion;
|
||||
if (v) appVersion.value = v.startsWith("T") ? v : "T" + v;
|
||||
@ -74,4 +91,6 @@ async function handleLogin() {
|
||||
.login-btn { width: 100%; height: 48px; background: #2563EB; color: #fff; border: none; border-radius: 10px; font-size: 16px; font-weight: 700; line-height: 48px; }
|
||||
.login-btn[disabled] { opacity: 0.6; }
|
||||
.error { display: block; text-align: center; color: #dc2626; font-size: 13px; margin-top: 12px; }
|
||||
.checking { display: flex; align-items: center; justify-content: center; }
|
||||
.checking-icon { font-size: 40px; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user