topfans/frontend/App.vue
2026-05-28 12:00:19 +08:00

87 lines
1.8 KiB
Vue

<script>
import { getGlobalSocket } from '@/utils/socket'
export default {
onLaunch: function() {
console.log('App Launch')
// 不在这里初始化 AI Chat 连接,由各页面自行管理
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
// 关闭所有 WebSocket 连接
this.closeWebSocket()
},
methods: {
initWebSocket() {
const token = uni.getStorageSync('access_token')
if (token) {
console.log('初始化全局 WebSocket 连接')
const globalSocket = getGlobalSocket()
globalSocket.init(token)
}
},
closeWebSocket() {
console.log('关闭全局 WebSocket 连接')
const globalSocket = getGlobalSocket()
globalSocket.closeAll()
}
}
}
</script>
<template>
<view class="app-container">
</view>
</template>
<style>
/*每个页面公共css */
/* 引入 TheMiladiatorRegular 字体 */
@font-face {
font-family: 'TheMiladiatorRegular';
src: url('/static/fonts/The Miladiator Regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
font-display: swap;
}
/* 引入 ZaoZiGongFangJianHei-1 字体 */
@font-face {
font-family: 'ZaoZiGongFangJianHei-1';
src: url('/static/fonts/ZaoZiGongFangJianHei-1.ttf') format('truetype');
font-weight: normal;
font-style: normal;
font-display: swap;
}
/* 圆体 JDLTYuanTiJian.ttf 在部分 Android WebView 上报 OTS/cmap 解析失败,暂不 @font-face 加载,避免控制台告警与渲染异常 */
/* 全局字体设置 */
body {
font-family:
-apple-system,
BlinkMacSystemFont,
'PingFang SC',
'Hiragino Sans GB',
'Microsoft YaHei',
'Noto Sans SC',
sans-serif;
}
/* App 容器 */
.app-container {
width: 100%;
min-height: 100vh;
position: relative;
}
.page-content {
width: 100%;
min-height: 100vh;
}
</style>