revert: sync production code to verified test version

This commit is contained in:
stefanfeng
2026-09-16 14:57:37 +08:00
parent e6a4988cf9
commit b3367eedaa
7 changed files with 34 additions and 213 deletions
+1 -6
View File
@@ -1,7 +1,6 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import { getAuthToken } from '@/api'
import { isInUniWebView } from '@/utils/uniapp-bridge'
const routes: RouteRecordRaw[] = [
{
@@ -56,7 +55,7 @@ const routes: RouteRecordRaw[] = [
path: '/token/charge',
name: 'TokenCharge',
component: () => import('@/views/TokenCharge.vue'),
meta: { title: '积分充值', requiresAuth: true, requiresUniWebView: true }
meta: { title: '积分充值', requiresAuth: true }
},
{
path: '/avatar/card',
@@ -134,10 +133,6 @@ const router = createRouter({
router.beforeEach((to, from, next) => {
document.title = to.meta.title as string || '会会数字分身'
if (to.meta.requiresUniWebView && !isInUniWebView()) {
next({ path: '/avatar/manage' })
return
}
const hasLocalSession = Boolean(localStorage.getItem('hh_app_token'))
const hasInjectedSession = Boolean(getAuthToken())
if (to.meta.requiresAuth && !hasLocalSession && !hasInjectedSession) {
+2 -16
View File
@@ -12,10 +12,9 @@ export interface UniLaunchParams {
nickname?: string
avatar?: string
ts?: string
nativeShell?: string
}
const PARAM_KEYS: (keyof UniLaunchParams)[] = ['token', 'userId', 'nickname', 'avatar', 'ts', 'nativeShell']
const PARAM_KEYS: (keyof UniLaunchParams)[] = ['token', 'userId', 'nickname', 'avatar', 'ts']
function readParams(search: string, target: UniLaunchParams): void {
const sp = new URLSearchParams(search)
@@ -25,16 +24,6 @@ function readParams(search: string, target: UniLaunchParams): void {
}
}
function hasNativeShellMarker(): boolean {
const params = getLaunchParams()
if (params.nativeShell === 'uniapp') return true
// Compatibility for already-installed shells. They have always appended a
// timestamp together with the native SSO context, even before the explicit
// nativeShell marker existed.
return Boolean(params.ts && (params.token || params.userId))
}
// 是否运行在 uniapp web-view 环境中
export function isInUniWebView(): boolean {
const runtime = window as any
@@ -51,10 +40,7 @@ export function isInUniWebView(): boolean {
runtime.swan?.webView ||
runtime.tt?.miniProgram
)
// `plus` can be injected after the H5 entry point runs. The native shell
// therefore adds a URL marker while creating its web-view URL, so the
// payment entry does not disappear during that startup window.
return Boolean(runtime.uni?.webView && (isDCloudApp || isMiniProgram || hasNativeShellMarker()))
return Boolean(runtime.uni?.webView && (isDCloudApp || isMiniProgram))
}
// 解析 web-view 加载 URL 时原生注入的参数(token / 会会用户)
@@ -20,7 +20,7 @@
</div>
</section>
<!-- 积分余额条:仅在 uni-app 原生壳内开放充值购买。 -->
<!-- 积分余额条:暂时隐藏,保留完整实现便于后续恢复。 -->
<section v-if="SHOW_POINTS_BALANCE_CARD" class="token-section">
<div class="token-card">
<div class="token-info">
@@ -28,7 +28,7 @@
<span class="token-amount">{{ tokenBalance.toLocaleString() }}</span>
<span class="token-used">累计使用 {{ tokenConsumed.toLocaleString() }}</span>
</div>
<button class="recharge-btn" @click="goToRecharge">充值购买</button>
<button class="recharge-btn" @click="goToRecharge">充值</button>
</div>
</section>
@@ -89,15 +89,14 @@ import { useAvatarStore } from '@/store/avatar'
import { useUserStore } from '@/store/user'
import { createAvatarShareLink } from '@/api'
import { isHuihuiEmbeddedMode } from '@/utils/embed-mode'
import { isInUniWebView } from '@/utils/uniapp-bridge'
const router = useRouter()
const avatarStore = useAvatarStore()
const userStore = useUserStore()
const isEmbedded = isHuihuiEmbeddedMode()
// 充值购买只在 uni-app 原生壳内提供,避免普通 H5 进入支付链路。
const SHOW_POINTS_BALANCE_CARD = isInUniWebView()
// 临时产品开关:余额卡片代码保留,后续改为 true 即可恢复展示。
const SHOW_POINTS_BALANCE_CARD = false
// 当前登录会会用户的资料(头像 / 昵称)
const me = computed(() => userStore.user)