Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
6ddaf958
U
uni-app
项目概览
DCloud
/
uni-app
14 天 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6ddaf958
编写于
6月 17, 2024
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: build
上级
4b876204
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
23 deletion
+49
-23
packages/uni-app-harmony/dist/uni.api.ets
packages/uni-app-harmony/dist/uni.api.ets
+48
-22
packages/uni-app-harmony/dist/uni.runtime.esm.js
packages/uni-app-harmony/dist/uni.runtime.esm.js
+1
-1
未找到文件。
packages/uni-app-harmony/dist/uni.api.ets
浏览文件 @
6ddaf958
...
...
@@ -27,6 +27,8 @@ import { getEnv, Emitter as Emitter2 } from "../../../resources/rawfile/uni-app/
import { getRealPath as getRealPath1 } from "../../../resources/rawfile/uni-app/uni-app-harmony-framework-dev";
import { getRealPath as getRealPath2, Emitter as Emitter1 } from "../../../resources/rawfile/uni-app/uni-app-harmony-framework-dev";
import { getRealPath } from "../../../resources/rawfile/uni-app/uni-app-harmony-framework-dev";
import harmonyWindowType from '@ohos.window';
import harmonyWindowType1 from '@ohos.window';
import http1 from '@ohos.net.http';
import http2 from '@ohos.net.http';
import { isPlainObject, Emitter } from "../../../resources/rawfile/uni-app/uni-app-harmony-framework-dev";
...
...
@@ -466,30 +468,48 @@ export function initUniExtApi(APP_ID: string) {
};
const internalGetWindowInfo = (): GetWindowInfoResult =>{
const pixelRatio = vp2px(1);
const avoidArea: harmonyWindowType.AvoidArea = UTSHarmony2.getAvoidArea();
const windowStage: harmonyWindowType.WindowStage = UTSHarmony2.getWindowStage();
let topRect: harmonyWindowType.Rect = {
top: 0,
left: 0,
width: 0,
height: 136
};
let bottomRect: harmonyWindowType.Rect = {
top: 0,
left: 0,
width: 0,
height: 98
};
if (windowStage) {
const mainWindow = windowStage.getMainWindowSync();
topRect = mainWindow.getWindowAvoidArea(harmonyWindowType.AvoidAreaType.TYPE_SYSTEM).topRect;
bottomRect = mainWindow.getWindowAvoidArea(harmonyWindowType.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect;
}
const defaultDisplay = display.getDefaultDisplaySync();
const currentPage: ESObject = getCurrentPage();
const navigationBarHeight = currentPage
.$page.meta.navigationBar.type === 'default' ? 56
: 0;
const tabBarHeight = currentPage.$.__isTabBar ? 50 : 0;
const navigationBarHeight = currentPage
&& currentPage.$page.meta.navigationBar.type === 'default' ? 58
: 0;
const tabBarHeight = currentPage
&& currentPage
.$.__isTabBar ? 50 : 0;
const screenWidth = px2vp(defaultDisplay.width);
const screenHeight = px2vp(defaultDisplay.height);
const safeAreaTopSize = px2vp(avoidArea.topRect.top + avoidArea.topRect.height) + navigationBarHeight;
const safeAreaBottomSize = px2vp(avoidArea.bottomRect.height) + tabBarHeight;
const safeAreaLeftSize = px2vp(avoidArea.leftRect.left + avoidArea.leftRect.width);
const safeAreaRightSize = px2vp(avoidArea.rightRect.width);
const statusBarHeight = px2vp(topRect.top + topRect.height);
const safeAreaTopSize = statusBarHeight + navigationBarHeight;
const safeAreaBottomSize = px2vp(bottomRect.height) + tabBarHeight;
const safeAreaInsets: SafeAreaInsets = {
top:
safeAreaTopSize
,
right:
safeAreaRightSize
,
bottom:
safeAreaBottomSize
,
left:
safeAreaLeftSize
top:
0
,
right:
0
,
bottom:
0
,
left:
0
};
const windowWidth = screenWidth - 0 - 0;
const windowHeight = screenHeight - safeAreaTopSize - safeAreaBottomSize;
const safeArea: SafeArea = {
top:
safeAreaInsets.top
,
right:
screenWidth - safeAreaRightSize
,
bottom:
screenHeight - safeAreaBottomSize
,
left:
safeAreaInsets.left
,
width:
screenWidth - safeAreaLeftSize - safeAreaRightSize
,
height:
screenHeight - safeAreaTopSize - safeAreaBottomSize
top:
0
,
right:
windowWidth
,
bottom:
windowHeight
,
left:
0
,
width:
windowWidth
,
height:
windowHeight
};
return {
pixelRatio,
...
...
@@ -502,7 +522,7 @@ export function initUniExtApi(APP_ID: string) {
windowHeight: safeArea.height,
safeAreaInsets,
safeArea,
statusBarHeight
: safeAreaTopSize
statusBarHeight
};
};
const getWindowInfo: GetWindowInfo = defineSyncApi<GetWindowInfoResult>(API_GET_WINDOW_INFO, (): GetWindowInfoResult =>{
...
...
@@ -2175,11 +2195,17 @@ export function initUniExtApi(APP_ID: string) {
type Rpx2px = (number: number) => number;
const API_RPX2PX = 'rpx2px';
const EPS = 1e-4;
const test = (type: harmonyWindowType1.AvoidAreaType)=>{};
test(harmonyWindowType1.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);
const rpx2px: Rpx2px = defineSyncApi<number>(API_RPX2PX, (number: number): number =>{
const windowStage: harmonyWindowType.WindowStage = UTSHarmony3.getWindowStage();
const mainWindow: harmonyWindowType.Window = windowStage.getMainWindowSync();
const windowWidthInPx: number = mainWindow.getWindowProperties().windowRect.width;
const windowWidthInVp: number = px2vp(windowWidthInPx);
const windowStage: harmonyWindowType1.WindowStage = UTSHarmony3.getWindowStage();
let windowWidthInVp: number = 384;
let windowWidthInPx: number = 1344;
if (windowStage) {
const mainWindow: harmonyWindowType1.Window = windowStage.getMainWindowSync();
windowWidthInPx = mainWindow.getWindowProperties().windowRect.width;
windowWidthInVp = px2vp(windowWidthInPx);
}
let result = (number / 750) * windowWidthInVp;
if (result < 0) {
result = -result;
...
...
packages/uni-app-harmony/dist/uni.runtime.esm.js
浏览文件 @
6ddaf958
...
...
@@ -10453,7 +10453,7 @@ class CanvasContext {
const c2d = canvas.getContext('2d')
c2d.font = font
return c2d.measureText(text).width || 0
})(
${
JSON
.
stringify
(
text
)}
,
${
JSON
.
stringify
(
font
)}
)`
).
then
(
res
=>
{
})(
${
JSON
.
stringify
(
text
)}
,
${
JSON
.
stringify
(
font
)}
)`
).
then
(
(
res
)
=>
{
callback
(
new
TextMetrics
(
parseFloat
(
res
)));
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录