188 lines
2.5 KiB
Vue
188 lines
2.5 KiB
Vue
<script>
|
|
import { login, isLoggedIn } from '@/api/auth'
|
|
|
|
export default {
|
|
globalData: {
|
|
loginReady: false,
|
|
loginPromise: null
|
|
},
|
|
|
|
onLaunch: function() {
|
|
console.log('App Launch')
|
|
this.globalData.loginPromise = this.initLogin()
|
|
},
|
|
|
|
onShow: function() {
|
|
console.log('App Show')
|
|
},
|
|
|
|
onHide: function() {
|
|
console.log('App Hide')
|
|
},
|
|
|
|
methods: {
|
|
async initLogin() {
|
|
try {
|
|
if (!isLoggedIn()) {
|
|
console.log('未登录,开始静默登录...')
|
|
await login()
|
|
console.log('静默登录成功')
|
|
} else {
|
|
console.log('已登录')
|
|
}
|
|
this.globalData.loginReady = true
|
|
return true
|
|
} catch (e) {
|
|
console.error('静默登录失败:', e)
|
|
this.globalData.loginReady = true
|
|
return false
|
|
}
|
|
},
|
|
|
|
waitForLogin() {
|
|
return this.globalData.loginPromise
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
page {
|
|
background-color: #0D1F17;
|
|
color: #FFFFFF;
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
font-size: 28rpx;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.container {
|
|
padding: 32rpx;
|
|
min-height: 100vh;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.card {
|
|
background-color: #1A3325;
|
|
border-radius: 24rpx;
|
|
padding: 32rpx;
|
|
margin-bottom: 24rpx;
|
|
}
|
|
|
|
.card-light {
|
|
background-color: #243D2E;
|
|
}
|
|
|
|
.text-primary {
|
|
color: #4ADE80;
|
|
}
|
|
|
|
.text-secondary {
|
|
color: #9CA3AF;
|
|
}
|
|
|
|
.text-muted {
|
|
color: #6B7280;
|
|
}
|
|
|
|
.text-center {
|
|
text-align: center;
|
|
}
|
|
|
|
.text-bold {
|
|
font-weight: 600;
|
|
}
|
|
|
|
.flex {
|
|
display: flex;
|
|
}
|
|
|
|
.flex-center {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.flex-between {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.flex-col {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.flex-1 {
|
|
flex: 1;
|
|
}
|
|
|
|
.gap-sm {
|
|
gap: 16rpx;
|
|
}
|
|
|
|
.gap-md {
|
|
gap: 24rpx;
|
|
}
|
|
|
|
.gap-lg {
|
|
gap: 32rpx;
|
|
}
|
|
|
|
.mt-sm {
|
|
margin-top: 16rpx;
|
|
}
|
|
|
|
.mt-md {
|
|
margin-top: 24rpx;
|
|
}
|
|
|
|
.mt-lg {
|
|
margin-top: 32rpx;
|
|
}
|
|
|
|
.mb-sm {
|
|
margin-bottom: 16rpx;
|
|
}
|
|
|
|
.mb-md {
|
|
margin-bottom: 24rpx;
|
|
}
|
|
|
|
.mb-lg {
|
|
margin-bottom: 32rpx;
|
|
}
|
|
|
|
.btn {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
height: 96rpx;
|
|
border-radius: 48rpx;
|
|
font-size: 32rpx;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.btn-primary {
|
|
background-color: #4ADE80;
|
|
color: #0D1F17;
|
|
}
|
|
|
|
.btn-secondary {
|
|
background-color: #1A3325;
|
|
color: #FFFFFF;
|
|
border: 2rpx solid #374151;
|
|
}
|
|
|
|
.btn-outline {
|
|
background-color: transparent;
|
|
color: #4ADE80;
|
|
border: 2rpx solid #4ADE80;
|
|
}
|
|
|
|
.safe-area-bottom {
|
|
padding-bottom: constant(safe-area-inset-bottom);
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
}
|
|
</style>
|