Implement login functionality and UI updates across the application. Added silent login process in App.vue, updated styles for various components, and integrated smoke record dialog. Enhanced onboarding and profile pages with improved layouts and user experience. Updated manifest and configuration files for deployment. Added easycom configuration for component auto-import.

This commit is contained in:
nepiedg
2026-01-25 14:48:20 +08:00
parent c883ae7b17
commit 661f39dfd7
24 changed files with 4569 additions and 572 deletions
+56
View File
@@ -0,0 +1,56 @@
import { ref } from 'vue'
import { login, isLoggedIn } from '@/api/auth'
const loginReady = ref(false)
let loginPromise = null
export function useLogin() {
async function waitForLogin() {
if (loginReady.value) {
return true
}
if (loginPromise) {
return loginPromise
}
const app = getApp()
if (app && app.globalData && app.globalData.loginPromise) {
loginPromise = app.globalData.loginPromise
const result = await loginPromise
loginReady.value = true
return result
}
loginPromise = doLogin()
return loginPromise
}
async function doLogin() {
try {
if (!isLoggedIn()) {
await login()
}
loginReady.value = true
return true
} catch (e) {
console.error('登录失败:', e)
loginReady.value = true
return false
}
}
async function ensureLogin() {
if (isLoggedIn()) {
loginReady.value = true
return true
}
return waitForLogin()
}
return {
loginReady,
waitForLogin,
ensureLogin
}
}