fix: 我的页按用户决定移除微信一键登录/暂不登录按钮(订阅卡为登录入口);版本号统一 manifest 单一来源(设置页+我的页);登录错误真实原因透出到前端与日志
This commit is contained in:
@@ -219,7 +219,8 @@ const wechatLogin = async () => {
|
||||
uni.showToast({ title: '登录成功', icon: 'success' })
|
||||
setTimeout(() => uni.switchTab({ url: '/pages/index/index' }), 1000)
|
||||
} catch (err) {
|
||||
uni.showToast({ title: '登录失败,请重试', icon: 'none' })
|
||||
const msg = (err && (err.message || err.errMsg)) || ''
|
||||
uni.showToast({ title: msg ? `登录失败:${msg}` : '登录失败,请重试', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -122,22 +122,15 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 登录/退出 -->
|
||||
<!-- 登录入口:统一走上方订阅卡(登录后升级);H5 保留登录/注册快捷按钮 -->
|
||||
<view class="action-row" v-if="!userStore.isLoggedIn">
|
||||
<!-- 小程序:就地微信一键登录,不跳登录页 -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="action-btn primary" :class="{ disabled: loginLoading }" @click="wechatLogin">
|
||||
<text>{{ loginLoading ? '登录中...' : '微信一键登录' }}</text>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<!-- H5:登录页是正常入口(邮箱/用户名登录) -->
|
||||
<!-- #ifdef H5 -->
|
||||
<view class="action-btn primary" @click="goLogin">
|
||||
<text>登录 / 注册</text>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<view class="action-btn ghost" @click="goBrowse">
|
||||
<text>暂不登录,先体验</text>
|
||||
<view class="action-btn ghost" @click="goLogin">
|
||||
<text>去登录,同步点亮进度</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="action-btn logout" v-else @click="handleLogout">
|
||||
@@ -155,8 +148,8 @@ import { useUserStore } from '@/stores/user'
|
||||
import { knowledgeApi, aiChatApi } from '@/utils/api'
|
||||
import { DIMENSIONS } from '@/utils/dimensions'
|
||||
import AppIcon from '@/components/AppIcon.vue'
|
||||
import { APP_VERSION } from '@/utils/version'
|
||||
|
||||
const VERSION = '1.2.0'
|
||||
const SUB_GUEST = '游客 · 点亮进度保存在本机,登录后同步'
|
||||
const SUB_USER = '已点亮 {n} 颗星球 · 连续 {d} 天'
|
||||
const PLAN_FREE = '✦ 免费版'
|
||||
@@ -169,9 +162,8 @@ const collectedCount = ref(0)
|
||||
const stats = ref(null)
|
||||
const byDim = ref({})
|
||||
const quotaInfo = ref(null)
|
||||
const loginLoading = ref(false)
|
||||
|
||||
const versionText = VERSION
|
||||
const versionText = APP_VERSION
|
||||
|
||||
const profileSubText = computed(() => {
|
||||
if (!userStore.isLoggedIn) return SUB_GUEST
|
||||
@@ -269,49 +261,6 @@ async function handleLogout() {
|
||||
|
||||
function goLogin() { uni.navigateTo({ url: '/pages/login/login' }) }
|
||||
|
||||
// 小程序端:我的页就地微信一键登录(登录页保留为账号登录入口)
|
||||
// #ifdef MP-WEIXIN
|
||||
async function wechatLogin() {
|
||||
if (loginLoading.value) return
|
||||
const agreed = uni.getStorageSync('wx_login_agreed')
|
||||
if (!agreed) {
|
||||
uni.showModal({
|
||||
title: '用户协议',
|
||||
content: '登录即表示同意《用户协议》与《隐私政策》',
|
||||
confirmText: '同意并登录',
|
||||
cancelText: '取消',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.setStorageSync('wx_login_agreed', '1')
|
||||
doWechatLogin()
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
doWechatLogin()
|
||||
}
|
||||
|
||||
async function doWechatLogin() {
|
||||
loginLoading.value = true
|
||||
try {
|
||||
const loginRes = await new Promise((resolve, reject) => {
|
||||
uni.login({ success: resolve, fail: reject })
|
||||
})
|
||||
if (!loginRes.code) throw new Error('no code')
|
||||
await userStore.login(loginRes.code, {})
|
||||
uni.showToast({ title: '登录成功', icon: 'success' })
|
||||
// 登录后原地刷新档案数据,无需跳页
|
||||
await userStore.fetchMe()
|
||||
await Promise.all([loadStats(), loadCollected(), loadQuota()])
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '登录失败,请重试', icon: 'none' })
|
||||
} finally {
|
||||
loginLoading.value = false
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
function goBrowse() { uni.switchTab({ url: '/pages/index/index' }) }
|
||||
function goChat() { uni.switchTab({ url: '/pages/chat/chat' }) }
|
||||
function goFavorites() { uni.navigateTo({ url: '/pages/favorites/favorites' }) }
|
||||
function goProgress() { uni.navigateTo({ url: '/pages/progress/progress' }) }
|
||||
|
||||
@@ -59,11 +59,12 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<text class="version">宇之然 AI 维度 v1.0.0</text>
|
||||
<text class="version">宇之然 AI 维度 v{{ appVersion }}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { APP_VERSION as appVersion } from '@/utils/version'
|
||||
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
|
||||
import { ref, onMounted } from 'vue'
|
||||
@@ -123,7 +124,7 @@ function applyTabBarTheme(theme) {
|
||||
function showAbout() {
|
||||
uni.showModal({
|
||||
title: '关于「宇之然AI维度」',
|
||||
content: '宇之然 AI 维度 v1.0.0\n从 5 个维度系统理解人工智能\n© 2026 宇之然',
|
||||
content: `宇之然AI维度 v${appVersion}\n从 5 个维度系统理解人工智能\n© 2026 宇之然`,
|
||||
showCancel: false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// 版本号唯一来源:manifest.json 的 versionName(发布流程改那里,见 docs/版本规则.md)
|
||||
import manifest from '@/manifest.json'
|
||||
|
||||
export const APP_VERSION: string = (manifest as any).versionName || '1.0.0'
|
||||
@@ -151,8 +151,10 @@ router.post('/login', async (req, res) => {
|
||||
}, isNewUser ? '注册成功' : '登录成功')
|
||||
|
||||
} catch (error) {
|
||||
logger.error('登录失败:', error)
|
||||
return ApiResponse.serverError(res, error.message)
|
||||
// 空message的错误也要留下可诊断线索(微信侧errmsg/错误名)
|
||||
const detail = (error && (error.message || error.errmsg)) || (error && error.name) || '未知错误'
|
||||
logger.error('登录失败:', error, '| detail:', detail)
|
||||
return ApiResponse.error(res, detail ? `登录失败:${detail}` : '登录服务异常,请稍后再试', 500)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user