<script setup lang="uts">
|
import { developmentLoginBypassEnabled, isApiConfigured } from './config/api.uts'
|
import { initializeDevelopmentApiBaseUrl } from './config/development-server.uts'
|
import { loginWithDevelopmentSession } from './services/auth.uts'
|
import { resolveApiUrl } from './services/http.uts'
|
|
/**
|
* 行楷字体(古典艺术行楷简,5.1MB)放在服务器 `/uploads/fonts/gudian-xingkai.ttf`:
|
* 包体主包上限 2MB,完整字体不能进包,所以启动时动态加载;加载失败时页面仍用包内子集/系统字体。
|
* `global: true` 只在 app.uvue 里调用才全局生效(微信小程序基础库 2.10+)。
|
*/
|
const loadCalligraphyFont = () => {
|
if (!isApiConfigured()) return
|
uni.loadFontFace({
|
family: 'FoodCalligraphyFull',
|
source: 'url("' + resolveApiUrl('/uploads/fonts/gudian-xingkai.ttf') + '")',
|
global: true,
|
success: () => { console.log('Calligraphy font loaded') },
|
fail: (error: any) => { console.warn('Calligraphy font load failed: ' + JSON.stringify(error)) }
|
})
|
}
|
|
// #ifdef APP-ANDROID || APP-HARMONY
|
let firstBackTime = 0
|
// #endif
|
|
onLaunch(() => {
|
console.log('App Launch')
|
// 先把服务端地址解析好:开发环境探测本机局域网 IP,换网后不必改代码重新编译。
|
initializeDevelopmentApiBaseUrl()
|
loadCalligraphyFont()
|
if (developmentLoginBypassEnabled) {
|
loginWithDevelopmentSession(() => {}, (error) => {
|
console.warn('Development session initialization failed: ' + error.code)
|
})
|
}
|
})
|
|
onAppShow(() => {
|
console.log('App Show')
|
})
|
|
onAppHide(() => {
|
console.log('App Hide')
|
})
|
|
// #ifdef APP-ANDROID || APP-HARMONY
|
onLastPageBackPress(() => {
|
console.log('App LastPageBackPress')
|
if (firstBackTime == 0) {
|
uni.showToast({
|
title: '再按一次退出应用',
|
position: 'bottom',
|
})
|
firstBackTime = Date.now()
|
setTimeout(() => {
|
firstBackTime = 0
|
}, 2000)
|
} else if (Date.now() - firstBackTime < 2000) {
|
firstBackTime = Date.now()
|
uni.exit()
|
}
|
})
|
|
onExit(() => {
|
console.log('App Exit')
|
})
|
// #endif
|
</script>
|
|
<style>
|
/* #ifdef WEB || MP-WEIXIN */
|
/* 统一隐藏页面和滚动容器的滚动条,保留滑动、下拉刷新与触底加载。 */
|
::-webkit-scrollbar {
|
display: none;
|
width: 0;
|
height: 0;
|
}
|
/* #endif */
|
|
page {
|
background-color: #F6F7FB;
|
color: #1E293B;
|
font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
|
}
|
|
/* 每个页面公共布局 */
|
.uni-row {
|
flex-direction: row;
|
}
|
|
.uni-column {
|
flex-direction: column;
|
}
|
|
/* 全局统一人才端自定义导航左上返回箭头,位置按登录页原型 */
|
.nav-row .back-button,
|
.nav-row .back {
|
display: flex !important;
|
width: 80rpx !important;
|
height: 80rpx !important;
|
margin-left: 0 !important;
|
position: relative !important;
|
left: auto !important;
|
top: auto !important;
|
border-radius: 10rpx !important;
|
background-color: transparent !important;
|
box-shadow: none !important;
|
justify-content: center !important;
|
align-items: center !important;
|
}
|
|
.custom-nav .nav-row,
|
.page-header .nav-row {
|
padding-left: 18rpx !important;
|
}
|
|
.nav-row .back-button image,
|
.nav-row .back image {
|
width: 44rpx !important;
|
height: 44rpx !important;
|
}
|
|
.custom-nav.is-solid .back-button {
|
background-color: transparent !important;
|
}
|
|
/*
|
* 专题页的大标题/菜名用行楷:优先用 App.uvue 动态加载的服务器字体(FoodCalligraphyFull),
|
* 没加载出来或缺少字符时回退到包内子集(FoodCalligraphy)与系统字体。
|
*/
|
.dish-name,
|
.scene-name {
|
font-family: 'FoodCalligraphyFull', 'FoodCalligraphy' !important;
|
}
|
|
.nav-row .back-button-active {
|
opacity: .55;
|
}
|
</style>
|