Commit 28206b44 by cen Committed by chenwq1

fix: 竖屏布局

1 parent 00f5c1cd
Showing 25 changed files with 447 additions and 104 deletions
...@@ -11,10 +11,8 @@ export default { ...@@ -11,10 +11,8 @@ export default {
onLaunch () { onLaunch () {
// #ifdef APP // #ifdef APP
layoutService.init(); layoutService.init();
const sys = uni.getSystemInfoSync();
// uni.onWindowResize((res) => { console.log(`[App] 当前分辨率:${ sys.screenWidth } x ${ sys.screenHeight}`);
// updateResolutionConfig();
// });
// #endif // #endif
console.log("App Launch"); console.log("App Launch");
...@@ -60,9 +58,24 @@ export default { ...@@ -60,9 +58,24 @@ export default {
}; };
</script> </script>
<style> <style lang="scss">
/* 引入自定义 CSS 工具类 */ /* 引入自定义 CSS 工具类 */
@import url("./common.css"); @import url("./common.css");
/* I18n 布局适配:横竖屏 + 分辨率 */
@import "./adapt/landscape/1080/home-frame.scss";
@import "./adapt/landscape/1920/home-frame.scss";
@import "./adapt/portrait/1080/home-frame.scss";
@import "./adapt/portrait/1920/home-frame.scss";
@import "./adapt/landscape/1080/boutique-index.scss";
@import "./adapt/landscape/1920/boutique-index.scss";
@import "./adapt/portrait/1080/boutique-index.scss";
@import "./adapt/portrait/1920/boutique-index.scss";
@import "./adapt/landscape/1080/login.scss";
@import "./adapt/landscape/1920/login.scss";
@import "./adapt/portrait/1080/login.scss";
@import "./adapt/portrait/1920/login.scss";
@import "./adapt/portrait/1080/account-items.scss";
@import "./adapt/portrait/1920/account-items.scss";
/* 全局默认样式 */ /* 全局默认样式 */
uni-page-body { uni-page-body {
......
/* 精品页 横屏 1080 档位适配
* 目前主要依赖全局 spacing/font/radius 变量,这里预留结构,后续可按需补充页面级变量
*/
.mode-landscape.res-1080 {
/* 示例:可在此处为精品页单独定义变量,例如:
* --boutique-card-height: 200px;
*/
}
/* HomeFrame 横屏 1080 档位适配 */
.home-frame-container.mode-landscape.res-1080 {
/* 对应 layout-vars.uts 中 1024/1174 档的值 */
--l-content-left-width: 605px;
--l-module-box-height: 332px;
--l-tool-box-min-height: 120px;
--l-common-title-height: 60px;
}
/* 登录选择账号页 横屏 1080 档位适配
* 通过 LayoutRoot 上的 .mode-landscape.res-1080 类控制,仅在横屏 1080 档时生效。
*/
.mode-landscape.res-1080 {
/* 示例:可根据登录页设计调整根容器
* .page-container {
* padding: 0 var(--l-spacing-lg);
* }
*/
}
/* 精品页 横屏 1920 档位适配(预留) */
.mode-landscape.res-1920 {
/* 示例:后续可在此定义 1920 档变量 */
}
/* HomeFrame 横屏 1920 档位适配 */
.home-frame-container.mode-landscape.res-1920 {
/* 对应 layout-vars.uts 中 1920 档的值 */
--l-content-left-width: 1134px;
--l-module-box-height: 623px;
--l-tool-box-min-height: 225px;
--l-common-title-height: 113px;
}
/* 登录选择账号页 横屏 1920 档位适配
* 大屏(如 1920 宽度)下,可在此增加更宽松的留白和布局。
*/
.mode-landscape.res-1920 {
/* 示例:后续按实际设计稿补充
* .page-container {
* max-width: 1600px;
* margin: 0 auto;
* }
*/
}
/* 账号选择页 竖屏 1080 档位适配
* 典型手机竖屏场景(如 360 x 800 等宽度归为 1080 档)。
* 通过 .account-page 避免影响其他页面。
*/
.mode-portrait.res-1080 .account-page {
.layout {
padding-top: 48px;
padding-bottom: 24px;
}
.content-box {
top: 120px;
bottom: 48px;
width: 94%;
border-radius: 16px;
}
.step-box {
transform: scale(0.9);
}
/* 竖屏下账号/门店列表:一行一个,撑满宽度 */
.box {
padding: 0 16px;
justify-content: flex-start;
}
.box .items {
width: 100%;
margin-bottom: 16px;
}
}
/* 精品页 竖屏 1080 档位适配
* 使用 LayoutRoot 提供的 mode/res class:
* - .mode-portrait.res-1080
* 可在此范围内定制精品页在竖屏手机上的布局与尺寸。
*/
.mode-portrait.res-1080 {
/* 精品首页竖屏下“开始接待”区域适配,降低高度避免图片拉伸感 */
.start {
height: 96px;
padding-top: 24px;
}
}
/* HomeFrame 竖屏 1080 档位适配
* 注意:数值暂时复用横屏 1080 档,后续可根据你的竖屏设计稿单独调整
*/
.home-frame-container.mode-portrait.res-1080 {
--l-content-left-width: 605px;
--l-module-box-height: 332px;
--l-tool-box-min-height: 120px;
--l-common-title-height: 60px;
}
/* 登录页 竖屏 1080 档位适配(如 360 x 800 等宽度归为 1080 档)
* 通过 .login-page 避免影响其他页面;仅在手机竖屏时生效。
*/
.mode-portrait.res-1080 .login-page {
.layout {
justify-content: flex-start;
align-items: stretch;
padding: 32px 24px;
}
.login {
align-items: stretch;
margin-top: 16px;
max-width: 320px;
margin-left: auto;
margin-right: auto;
}
.login .title {
font-size: 28px;
margin-bottom: 12px;
}
.login .sub-title {
font-size: 14px;
margin: 12px 0 20px;
}
.login .input {
width: 100%;
height: 48px;
border-radius: 24px;
margin-bottom: 16px;
}
.login .btn {
width: 100%;
height: 48px;
margin-top: 8px;
font-size: 18px;
}
.form-footer {
padding-left: 0;
margin-top: 16px;
}
.app-code {
bottom: 12px;
/* 手机端登录页 APP 编码:完全使用固定像素,不参与变量缩放 */
font-size: 10px !important;
line-height: 14px;
left: 50%;
transform: translateX(-50%) scale(0.85);
}
}
/* 账号选择页 竖屏 1920 档位适配(预留)
* 如后续有竖屏大屏需求,可在此补充。
*/
.mode-portrait.res-1920 .account-page {
}
/* 精品页 竖屏 1920 档位适配(预留)
* 当前大屏场景通常为横屏,此处作为扩展占位。
*/
.mode-portrait.res-1920 {
/* 根据后续竖屏大屏设计补充 */
}
/* HomeFrame 竖屏 1920 档位适配
* 注意:数值暂时复用横屏 1920 档,后续可根据你的竖屏设计稿单独调整
*/
.home-frame-container.mode-portrait.res-1920 {
--l-content-left-width: 1134px;
--l-module-box-height: 623px;
--l-tool-box-min-height: 225px;
--l-common-title-height: 113px;
}
/* 登录选择账号页 竖屏 1920 档位适配(预留)
* 如后续有竖屏大屏设备需求,可在此补充。
*/
.mode-portrait.res-1920 {
/* 预留占位,不影响现有布局 */
}
<template> <template>
<view class="left-side left-side-pad"> <!-- 横屏 / Pad:左侧竖向导航(头像 + 场景切换 + 设置) -->
<view v-if="!isPortraitMode"
class="left-side left-side-pad">
<image class="left-side-bg-img" <image class="left-side-bg-img"
mode="aspectFill" mode="aspectFill"
src="/static/images/home/left-bg.png" /> src="/static/images/home/left-bg.png" />
...@@ -35,6 +37,20 @@ ...@@ -35,6 +37,20 @@
<SettingBox :visible="showSetting" <SettingBox :visible="showSetting"
@update:visible="onSettingVisible" /> @update:visible="onSettingVisible" />
</view> </view>
<!-- 竖屏手机:底部 TabBar,仅保留场景 Tab,不显示头像和底部两个按钮 -->
<view v-else
class="left-side left-side-portrait">
<view class="portrait-tabs-row">
<view v-for="(item, index) in tabs"
:key="index"
class="tab-item tab-item-inline"
:class="[tabIndex == index ? 'tabActive' : '']"
@click="onChangeTab(index)">
<text class="tab-label">{{ item.label }}</text>
</view>
</view>
</view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
...@@ -234,6 +250,7 @@ function jumpPersonCenter(): void { ...@@ -234,6 +250,7 @@ function jumpPersonCenter(): void {
padding: var(--l-spacing-sm) var(--l-spacing-md); padding: var(--l-spacing-sm) var(--l-spacing-md);
min-height: 56px; min-height: 56px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
justify-content: center;
} }
.portrait-top-row { .portrait-top-row {
...@@ -255,6 +272,7 @@ function jumpPersonCenter(): void { ...@@ -255,6 +272,7 @@ function jumpPersonCenter(): void {
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
padding: 0 var(--l-spacing-sm); padding: 0 var(--l-spacing-sm);
justify-content: center;
} }
.portrait-tabs-row .tab-item-inline { .portrait-tabs-row .tab-item-inline {
......
<template> <template>
<view class="home-frame-container"> <view class="home-frame-container"
:class="[modeClass, resolutionClass]">
<!-- 首页内容区 --> <!-- 首页内容区 -->
<view v-if="!showDetail" <view v-if="!showDetail"
class="home-content home-content-pad"> class="home-content"
<HomeFrameLeftSide :tab-index="tabIndex" :class="[isPortraitMode ? 'home-content-portrait' : 'home-content-pad']">
:user-info="userInfo"
@change-tab="onChangeTab" /> <!-- 右侧内容:竖屏和横屏共用一套结构,只是顺序不同 -->
<view class="right-side"> <view v-if="isPortraitMode" class="right-side">
<!-- 横屏三卡片布局:轻改等使用 swiperCustom -->
<view v-if="useCardLayout && tabIndex == 0" class="app-content-box right-content show-content-box">
<view class="start" @click="onStartClick">
<image class="start-bg-img"
:mode="isPortraitMode ? 'aspectFill' : 'scaleToFill'"
src="/static/images/home/start-btn.png" />
<view class="start-inner">
<text class="start-text">开始接待</text>
</view>
</view>
<view class="right-content-box flex-row">
<view class="content-left">
<view class="module-box box-class">
<view class="common-title">
<text class="title-text">产品介绍</text>
</view>
<view class="content-box">
<slot v-if="swiperCustom" name="swiperCustom"></slot>
<view v-else class="swiper-placeholder">
<text class="placeholder-text">敬请期待</text>
</view>
</view>
</view>
<view class="tool-box box-class">
<view class="common-title">
<text class="title-text">展业工具</text>
</view>
<view class="content-box">
<Entrance :scene-type="sceneType" />
</view>
</view>
</view>
<view class="content-right box-class">
<view class="common-title">
<text class="title-text">服务中心</text>
</view>
<view class="content-box">
<HomeFrameMessageIndex class="message-box" />
</view>
</view>
</view>
</view>
<!-- 旧版居中布局:权益、二手车等使用 #home -->
<view v-else-if="tabIndex == 0" class="legacy-home-wrap">
<slot name="home"></slot>
</view>
</view>
<view v-else class="right-side">
<!-- 横屏三卡片布局:轻改等使用 swiperCustom --> <!-- 横屏三卡片布局:轻改等使用 swiperCustom -->
<view v-if="useCardLayout && tabIndex == 0" class="app-content-box right-content show-content-box"> <view v-if="useCardLayout && tabIndex == 0" class="app-content-box right-content show-content-box">
<view class="start" @click="onStartClick"> <view class="start" @click="onStartClick">
...@@ -54,6 +104,18 @@ ...@@ -54,6 +104,18 @@
<slot name="home"></slot> <slot name="home"></slot>
</view> </view>
</view> </view>
<!-- 竖屏:底部 TabBar;横屏:左侧栏 -->
<HomeFrameLeftSide v-if="isPortraitMode"
:is-portrait="true"
:tab-index="tabIndex"
:user-info="userInfo"
@change-tab="onChangeTab" />
<HomeFrameLeftSide v-else
:is-portrait="false"
:tab-index="tabIndex"
:user-info="userInfo"
@change-tab="onChangeTab" />
<!-- 底部门店信息:与 right-side 同级,样式与旧项目 store-addr 一致 --> <!-- 底部门店信息:与 right-side 同级,样式与旧项目 store-addr 一致 -->
<!-- <view v-if="showFooter" class="store-addr"> <!-- <view v-if="showFooter" class="store-addr">
<view class="addr-line addr-line-left"></view> <view class="addr-line addr-line-left"></view>
...@@ -74,6 +136,7 @@ ...@@ -74,6 +136,7 @@
import { computed, defineExpose, ref } from "vue"; import { computed, defineExpose, ref } from "vue";
import Entrance from "@/components/Entrance.uvue"; import Entrance from "@/components/Entrance.uvue";
import { layoutService } from "@/services/LayoutService.uts";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
import HomeFrameLeftSide from "./LeftSide.uvue"; import HomeFrameLeftSide from "./LeftSide.uvue";
...@@ -92,6 +155,22 @@ const useCardLayout = computed((): boolean => { ...@@ -92,6 +155,22 @@ const useCardLayout = computed((): boolean => {
return props.swiperCustom === true; return props.swiperCustom === true;
}); });
const modeClass = computed((): string => {
const modeRef = layoutService.getCurrentMode();
const m = modeRef.value;
// pad / desktop 归为横屏,portrait 归为竖屏
return m == "portrait" ? "mode-portrait" : "mode-landscape";
});
const resolutionClass = computed((): string => {
const bucket = layoutService.getResolutionBucket();
return `res-${bucket}`;
});
const isPortraitMode = computed((): boolean => {
return layoutService.isMode("portrait");
});
const showDetail = ref(false); const showDetail = ref(false);
const userInfo = ref<UTSJSONObject>({}); const userInfo = ref<UTSJSONObject>({});
const sceneType = ref<number>(1); const sceneType = ref<number>(1);
...@@ -130,6 +209,7 @@ defineExpose({ ...@@ -130,6 +209,7 @@ defineExpose({
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.home-frame-container { .home-frame-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -152,6 +232,10 @@ defineExpose({ ...@@ -152,6 +232,10 @@ defineExpose({
flex-direction: row; flex-direction: row;
} }
.home-content-portrait {
flex-direction: column;
}
.detail-content { .detail-content {
flex: 1; flex: 1;
width: 100%; width: 100%;
...@@ -166,7 +250,16 @@ defineExpose({ ...@@ -166,7 +250,16 @@ defineExpose({
overflow: hidden; overflow: hidden;
} }
.mode-portrait .right-side {
order: 1;
}
.mode-portrait .left-side-portrait {
order: 2;
}
.app-content-box { .app-content-box {
margin-top: 50px;
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
...@@ -179,7 +272,7 @@ defineExpose({ ...@@ -179,7 +272,7 @@ defineExpose({
/* 与旧项目一致:背景图铺满,文字居中偏上,无渐变遮罩 */ /* 与旧项目一致:背景图铺满,文字居中偏上,无渐变遮罩 */
.start { .start {
height: 126px; height: 86px;
box-sizing: border-box; box-sizing: border-box;
margin-right: 32px; margin-right: 32px;
position: relative; position: relative;
...@@ -216,7 +309,7 @@ defineExpose({ ...@@ -216,7 +309,7 @@ defineExpose({
} }
.start-text { .start-text {
font-size: 36px; font-size: 20px;
font-weight: 600; font-weight: 600;
color: #ffffff; color: #ffffff;
text-align: center; text-align: center;
......
<template> <template>
<view class="layout-root" :style="styleObj"> <view class="layout-root" :class="[modeClass, resolutionClass]" :style="styleObj">
<slot></slot> <slot></slot>
</view> </view>
</template> </template>
...@@ -7,15 +7,28 @@ ...@@ -7,15 +7,28 @@
<script setup lang="uts"> <script setup lang="uts">
import { computed, type Ref } from 'vue' import { computed, type Ref } from 'vue'
import { useLayout } from '@/composables/useLayout' import { useLayout } from '@/composables/useLayout'
import { layoutService } from '@/services/LayoutService.uts'
const layout = useLayout() const layout = useLayout()
const rawCssVars = (layout as UTSJSONObject)['cssVars'] as Ref<UTSJSONObject> | null const rawCssVars = (layout as UTSJSONObject)['cssVars'] as Ref<UTSJSONObject> | null
const styleObj = computed((): UTSJSONObject => { const styleObj = computed((): UTSJSONObject => {
const r = rawCssVars const r = rawCssVars
if (r == null) return {} if (r == null) return {}
const v = r.value const v = r.value
return v != null ? v : {} return v != null ? v : {}
}) })
const modeClass = computed((): string => {
const modeRef = layoutService.getCurrentMode()
const m = modeRef.value
return m == 'portrait' ? 'mode-portrait' : 'mode-landscape'
})
const resolutionClass = computed((): string => {
const bucket = layoutService.getResolutionBucket()
return `res-${bucket}`
})
</script> </script>
<style scoped> <style scoped>
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
} }
}, },
"orientation": [ "orientation": [
"portrait-primary",
"landscape-primary" "landscape-primary"
] ]
} }
...@@ -66,6 +67,7 @@ ...@@ -66,6 +67,7 @@
"default": {} "default": {}
}, },
"orientation": [ "orientation": [
"portrait-primary",
"landscape-primary" "landscape-primary"
], ],
"permissions": [ "permissions": [
...@@ -93,6 +95,7 @@ ...@@ -93,6 +95,7 @@
"icons": {}, "icons": {},
"splashScreens": {}, "splashScreens": {},
"orientation": [ "orientation": [
"portrait-primary",
"landscape-primary" "landscape-primary"
] ]
} }
......
...@@ -82,8 +82,7 @@ ...@@ -82,8 +82,7 @@
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app x", "navigationBarTitleText": "uni-app x",
"navigationBarBackgroundColor": "#F8F8F8", "navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8", "backgroundColor": "#F8F8F8"
"pageOrientation": "landscape"
}, },
"uniIdRouter": {} "uniIdRouter": {}
} }
...@@ -323,13 +323,13 @@ defineExpose({ ...@@ -323,13 +323,13 @@ defineExpose({
.items .name { .items .name {
font-weight: 500; font-weight: 500;
font-size: var(--l-font-base); font-size: 16px;
color: #181a1f; color: #181a1f;
margin-bottom: 6px; margin-bottom: 6px;
} }
.items .text_no { .items .text_no {
font-size: var(--l-font-sm); font-size: 14px;
color: #999ea8; color: #999ea8;
} }
......
<template> <template>
<Layout class="layout"> <layout-root>
<view class="bg"></view>
<view class="login flex-col"> <view class="layout login-page">
<text class="title">登录</text> <view class="bg"></view>
<text class="sub-title">手机号码登录</text> <view class="login flex-col">
<text class="title">登录</text>
<text class="sub-title">手机号码登录</text>
<view class="input"> <view class="input">
<input v-model="mobile" <input v-model="mobile"
auto-blur auto-blur
maxlength="11" maxlength="11"
placeholder="请输入手机号" placeholder="请输入手机号"
type="tel" /> type="tel" />
<view v-if="mobile != ''" <view v-if="mobile != ''"
class="icon" class="icon"
@click="clearMobile"> @click="clearMobile">
<icon color="#000" <icon color="#000"
size="16" size="16"
type="clear"> type="clear">
</icon> </icon>
</view>
</view> </view>
</view>
<view class="input"> <view class="input">
<input v-model="code" <input v-model="code"
auto-blur auto-blur
maxlength="4" maxlength="4"
placeholder="请输入验证码" placeholder="请输入验证码"
type="number" /> type="number" />
<view v-if="code != ''" <view v-if="code != ''"
class="icon" class="icon"
@click="clearCode"> @click="clearCode">
<icon color="#000" <icon color="#000"
size="16" size="16"
type="clear"> type="clear">
</icon> </icon>
</view> </view>
<view class="code-btn" <view class="code-btn"
:class="[count > 0 ? 'code-disabled' : '']" :class="[count > 0 ? 'code-disabled' : '']"
@click="getSmsCode"> @click="getSmsCode">
{{ count > 0 ? `重新发送(${count}s)` : '获取验证码' }} {{ count > 0 ? `重新发送(${count}s)` : '获取验证码' }}
</view>
</view> </view>
</view>
<button class="btn" <button class="btn"
@click="login"> @click="login">
登录 登录
</button> </button>
<view class="form-footer"> <view class="form-footer">
<view class="autoLogin"> <view class="autoLogin">
<radio :checked="readingStatus" <radio :checked="readingStatus"
color="#2C66F7" color="#2C66F7"
@click="toggleReadingStatus"> @click="toggleReadingStatus">
</radio> </radio>
<text @click="toggleReadingStatus">我已阅读并同意</text> <text @click="toggleReadingStatus">我已阅读并同意</text>
<text @click.stop="openPrivacy">《隐私协议》</text> <text @click.stop="openPrivacy">《隐私协议》</text>
</view> </view>
<view class="autoLogin"> <view class="autoLogin">
<radio :checked="noSignIn" <radio :checked="noSignIn"
color="#2C66F7" color="#2C66F7"
@click="toggleNoSignIn"> @click="toggleNoSignIn">
</radio> </radio>
<text @click="toggleNoSignIn">30天内免登录</text> <text @click="toggleNoSignIn">30天内免登录</text>
</view>
</view> </view>
</view> </view>
</view>
<view class="app-code flex"> <view class="app-code flex">
APP编码:{{ deviceId }} APP编码:{{ deviceId }}
<view class="sprite-icon icon-clone" <view class="sprite-icon icon-clone"
@click="copyDeviceId"> @click="copyDeviceId">
</view>
</view> </view>
</view> </view>
</layout-root>
<!-- Test Entry Point -->
<!-- <view class="test-entry" @click="goToTest">
<text>测试入口</text>
</view>
<view class="demo-test" :style="{ paddingLeft: $resState.config.demo.paddingLeft }">
<text :style="{ fontSize: $resState.config.demo.titleFontSize }">Resolution Demo Text</text>
<image mode="widthFix"
:src="$getResImg($resState.config.demo.heroImageSrc)"
:style="{ width: $resState.config.demo.heroImageWidth }">
</image>
</view> -->
</Layout>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
...@@ -94,8 +86,8 @@ import { ref, watch } from "vue"; ...@@ -94,8 +86,8 @@ import { ref, watch } from "vue";
import { apiAutoLogin, apiGetSmsCode, apiSmsLogin } from "@/api/user-api.uts"; import { apiAutoLogin, apiGetSmsCode, apiSmsLogin } from "@/api/user-api.uts";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
// import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
// 手机号正则 // 手机号正则
const phoneRex = /^1([3-9])\d{9}$/; const phoneRex = /^1([3-9])\d{9}$/;
...@@ -370,12 +362,6 @@ function toggleReadingStatus(): void { ...@@ -370,12 +362,6 @@ function toggleReadingStatus(): void {
function toggleNoSignIn(): void { function toggleNoSignIn(): void {
noSignIn.value = !noSignIn.value; noSignIn.value = !noSignIn.value;
} }
function goToTest(): void {
uni.navigateTo({
url: "/pages/test/index"
});
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -118,7 +118,12 @@ class LayoutService { ...@@ -118,7 +118,12 @@ class LayoutService {
* 更新 CSS 变量缓存(遍历 LAYOUT_VARS) * 更新 CSS 变量缓存(遍历 LAYOUT_VARS)
*/ */
private updateCSSVariables(): void { private updateCSSVariables(): void {
const w = this.screenWidth.value // 对于 portrait 模式,使用物理短边参与缩放,避免横屏手机出现非常大的宽度(例如 800x360),
// 造成与 H5 模拟器(390x844)视觉比例差异过大
const sw = this.screenWidth.value
const sh = this.screenHeight.value
const isPortraitMode = this.currentMode.value == 'portrait'
const w = isPortraitMode ? (sw < sh ? sw : sh) : sw
const baseWidth = this.getBaseWidth() const baseWidth = this.getBaseWidth()
const out: UTSJSONObject = {} const out: UTSJSONObject = {}
...@@ -180,6 +185,22 @@ class LayoutService { ...@@ -180,6 +185,22 @@ class LayoutService {
} }
/** /**
* 获取当前分辨率档位(例如 1080 / 1920)
* - 仅用于选择 I18n 适配配置,不追求特别细的区分
*/
getResolutionBucket(): string {
if (!this.initialized.value) {
this.init()
}
const sw = this.screenWidth.value
const sh = this.screenHeight.value
const isPortraitMode = this.currentMode.value == 'portrait'
const w = isPortraitMode ? (sw < sh ? sw : sh) : sw
// 简单两档划分:大于等于 1440 归为 1920,否则归为 1080
return w >= 1440 ? '1920' : '1080'
}
/**
* 是否指定模式 * 是否指定模式
*/ */
isMode(mode: LayoutMode): boolean { isMode(mode: LayoutMode): boolean {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!