feat(革命日): 优化代码和样式

This commit is contained in:
hzj 2025-11-05 16:34:45 +08:00
parent d3a657e5a0
commit b989beccba
2 changed files with 46 additions and 179 deletions

View File

@ -136,11 +136,20 @@
v-show="rankingShow" v-show="rankingShow"
style="position: relative; width: 90%; left: 50%; transform: translateX(-50%)" style="position: relative; width: 90%; left: 50%; transform: translateX(-50%)"
> >
<div> <div
style="
position: absolute;
inset: 2;
background: radial-gradient(50% 50% at 50% 50%, #10614b 0%, #053126 100%);
z-index: 1;
"
></div>
<div style="position: relative; z-index: 1">
<!-- 前三名 --> <!-- 前三名 -->
<div style="position: relative"> <div style="position: relative">
<!-- 头像框 -->
<img :src="images.RankingMain" alt="" width="100%" style="display: block" /> <img :src="images.RankingMain" alt="" width="100%" style="display: block" />
<!-- 前3名 --> <!-- 用户信息 -->
<div style="position: absolute; inset: 0; padding: 18% 5% 2%"> <div style="position: absolute; inset: 0; padding: 18% 5% 2%">
<div style="margin-top: 3%"> <div style="margin-top: 3%">
<!-- 第一 --> <!-- 第一 -->
@ -349,7 +358,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 0 5%; padding: 2% 5% 0;
" "
> >
<div <div
@ -362,7 +371,8 @@
:src="myRanking.userAvatar || ''" :src="myRanking.userAvatar || ''"
alt="" alt=""
style=" style="
width: 30%; display: block;
width: 25%;
aspect-ratio: 1/1; aspect-ratio: 1/1;
border-radius: 50%; border-radius: 50%;
object-fit: cover; object-fit: cover;
@ -371,7 +381,7 @@
@error="defaultAvatarUrl" @error="defaultAvatarUrl"
/> />
<!-- 名称 --> <!-- 名称 -->
<div style="display: flex; flex-direction: column; width: calc(70% - 24px - 20%)"> <div style="display: flex; flex-direction: column; width: calc(75% - 24px - 20%)">
<div <div
style=" style="
color: #fff; color: #fff;
@ -502,19 +512,7 @@
</template> </template>
<script setup> <script setup>
import { import { isInApp, viewUserInfo } from '@/utils/appBridge.js'
connectApplication,
parseAccessOrigin,
parseHeader,
setHttpHeaders,
isInApp,
viewUserInfo,
} from '@/utils/appBridge.js'
import {
appConnectionManager,
isAppConnected,
getAppHeaderInfo,
} from '@/utils/appConnectionManager.js'
import { computed, onMounted, onUnmounted, ref } from 'vue' import { computed, onMounted, onUnmounted, ref } from 'vue'
import itemCenter from '@/components/WeeklyStar/itemCenter.vue' import itemCenter from '@/components/WeeklyStar/itemCenter.vue'
import TopUser from '../RevolutionUnityDay/topUser.vue' import TopUser from '../RevolutionUnityDay/topUser.vue'
@ -528,7 +526,7 @@ import {
getMyWeekStarRanking, getMyWeekStarRanking,
getHistoryTopOne, getHistoryTopOne,
} from '@/api/weeklyStar.js' } from '@/api/weeklyStar.js'
import { getWeekTopList, getThisWeekRewardsAndGifts } from '@/api/topList.js' import { connectToApp } from '@/utils/appConnector.js'
// vite // vite
const imageModules = import.meta.glob('@/assets/images/Activities/revolution/*.{png,jpg,svg}', { const imageModules = import.meta.glob('@/assets/images/Activities/revolution/*.{png,jpg,svg}', {
@ -542,126 +540,6 @@ const images = Object.fromEntries(
}) })
) )
const appConnected = ref(false)
const headerInfo = ref({})
/**
* 连接APP并获取认证信息优化版 - 仅专注连接
*/
const connectToApp = async () => {
console.group('🔗 APP Connection Process')
console.debug('🚀 Starting APP connection...')
try {
// APP
if (!isInApp()) {
console.debug('🌐 Browser environment detected')
appConnected.value = true
console.groupEnd()
//
getUserInfo()
return { success: true, environment: 'browser' }
}
//
if (isAppConnected()) {
console.debug('✅ APP already connected and valid')
appConnected.value = true
// 使
const cachedHeaderInfo = getAppHeaderInfo()
if (cachedHeaderInfo) {
headerInfo.value = cachedHeaderInfo
console.debug('🔧 Using cached HTTP headers')
}
console.groupEnd()
//
getUserInfo()
return { success: true, environment: 'app', fromCache: true }
}
//
if (appConnectionManager.isConnecting()) {
console.debug('⏳ Connection already in progress, waiting...')
await appConnectionManager.getConnectionPromise()
appConnected.value = true
console.debug('✅ Connected via existing process')
console.groupEnd()
//
getUserInfo()
return { success: true, environment: 'app', fromCache: true }
}
// APP
console.debug('📱 Establishing new APP connection...')
const connectionResult = await new Promise((resolve, reject) => {
const connectionPromise = new Promise((connectResolve, connectReject) => {
connectApplication(async (access) => {
try {
const result = parseAccessOrigin(access)
if (result.success) {
//
headerInfo.value = parseHeader(result.data)
// HTTP
console.debug('🔧 Setting HTTP headers...')
await setHttpHeaders(headerInfo.value)
//
appConnected.value = true
appConnectionManager.setConnected(headerInfo.value)
console.debug('🎉 APP connection established successfully')
connectResolve({ success: true, environment: 'app', fromCache: false })
} else {
console.error('❌ Failed to parse access origin:', result.error)
appConnectionManager.reset()
connectReject(new Error(result.error))
}
} catch (error) {
console.error('❌ Connection process failed:', error)
appConnectionManager.reset()
connectReject(error)
}
})
})
//
appConnectionManager.setConnecting(connectionPromise)
connectionPromise.then(resolve).catch(reject)
})
console.debug('✅ Connection completed successfully')
console.groupEnd()
//
getUserInfo()
return connectionResult
} catch (error) {
console.error('❌ Connection failed:', error)
appConnected.value = false
console.groupEnd()
//
if (error.message && error.message.includes('parse access')) {
// router.push({ path: '/not_app', query: { message: error.message } })
}
return { success: false, error: error.message }
}
}
const userInfo = ref({}) const userInfo = ref({})
const isInAppEnvironment = ref(false) // APP const isInAppEnvironment = ref(false) // APP
@ -806,7 +684,7 @@ const resetPage = () => {
historyIndex.value = 0 // historyIndex.value = 0 //
updatePageData() // initData() //
} }
// //
@ -869,28 +747,6 @@ const getMyThisWeekRanking = async () => {
} }
} }
//
// const getThisWeekRewards = async () => {
// const resThisWeekRewardsAndGifts = await getThisWeekRewardsAndGifts()
// console.log('resThisWeekRewardsAndGifts:', resThisWeekRewardsAndGifts)
// if (resThisWeekRewardsAndGifts.status && resThisWeekRewardsAndGifts.body) {
// rewardsList.value = [
// {
// rankRange: '1',
// rewards: resThisWeekRewardsAndGifts.body.butOneRewards || [],
// },
// {
// rankRange: '2',
// rewards: resThisWeekRewardsAndGifts.body.butTwoRewards || [],
// },
// {
// rankRange: '3',
// rewards: resThisWeekRewardsAndGifts.body.butThreeRewards || [],
// },
// ]
// }
// }
// //
const getThisWeekGifts = async () => { const getThisWeekGifts = async () => {
const resThisWeekGifts = await getWeekGifts('THIS_WEEK') const resThisWeekGifts = await getWeekGifts('THIS_WEEK')
@ -910,7 +766,8 @@ const getThisWeekRewards = async () => {
} }
// //
const updatePageData = () => { const initData = () => {
getUserInfo()
getThisWeekRanking() // getThisWeekRanking() //
getHistoryRankingTop1() // top1 getHistoryRankingTop1() // top1
getThisWeekRewards() // getThisWeekRewards() //
@ -932,16 +789,22 @@ const observer = new IntersectionObserver((entries) => {
}) })
}) })
// 使APP
const connectToAppHandler = async () => {
await connectToApp(() => {
//
initData() //
})
}
// //
onMounted(() => { onMounted(() => {
connectToApp() connectToAppHandler()
isInAppEnvironment.value = isInApp() isInAppEnvironment.value = isInApp()
getCountdown() getCountdown()
timer = setInterval(getCountdown, 1000) // timer = setInterval(getCountdown, 1000) //
updatePageData() //
// //
if (RankingLoadmore.value) { if (RankingLoadmore.value) {
observer.observe(RankingLoadmore.value) observer.observe(RankingLoadmore.value)

View File

@ -60,6 +60,7 @@
</div> </div>
<div <div
style=" style="
width: 60%;
border-radius: 40px; border-radius: 40px;
border: 0.64px solid #ffdf36; border: 0.64px solid #ffdf36;
background: linear-gradient( background: linear-gradient(
@ -76,7 +77,6 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
" "
:style="{ width: isTopOne ? '60%' : '50%' }"
> >
<img <img
src="/src/assets/icon/coin.png" src="/src/assets/icon/coin.png"
@ -147,30 +147,34 @@ const defaultAvatarUrl = (e) => {
} }
.top1Text { .top1Text {
font-size: 12px; font-size: 0.8em;
} }
.text { .text {
font-size: 10px; font-size: 0.6em;
}
@media screen and (max-width: 360px) {
* {
font-size: 10px;
}
}
@media screen and (min-width: 360px) {
* {
font-size: 16px;
}
} }
@media screen and (min-width: 768px) { @media screen and (min-width: 768px) {
.top1Text { * {
font-size: 24px; font-size: 24px;
} }
.text {
font-size: 20px;
}
} }
@media screen and (min-width: 1024px) { @media screen and (min-width: 1024px) {
.top1Text { * {
font-size: 32px; font-size: 32px;
} }
.text {
font-size: 28px;
}
} }
</style> </style>