From 37928b4298db12277a61ecbd72c2c88ad10bf208 Mon Sep 17 00:00:00 2001 From: wangzhitong Date: Mon, 25 Mar 2024 20:06:04 +0800 Subject: [PATCH] =?UTF-8?q?get-window-info=20=E7=A4=BA=E4=BE=8B=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/get-window-info/get-window-info.uvue | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/pages/API/get-window-info/get-window-info.uvue b/pages/API/get-window-info/get-window-info.uvue index 728f33a1..0a739a0c 100644 --- a/pages/API/get-window-info/get-window-info.uvue +++ b/pages/API/get-window-info/get-window-info.uvue @@ -42,17 +42,25 @@ const res = uni.getWindowInfo(); // 获取状态栏+导航栏高度, 供截图对比使用 setStatusBarHeight(res.statusBarHeight); - this.items = [] as Item[]; - for (const key in res) { - const value = res[key]; - if (value != null) { - const item = { - label: key, - value: "" + ((typeof value == "object") ? JSON.stringify(value) : value) - } as Item; - this.items.push(item); - } - } + this.items = [] as Item[]; + + const res_str = JSON.stringify(res); + const res_obj = JSON.parseObject(res_str); + const res_map = res_obj!.toMap(); + let keys = [] as string[] + res_map.forEach((_, key) => { + keys.push(key); + }); + keys.sort().forEach( key => { + const value = res[key]; + if(value != null){ + const item = { + label: key, + value: "" + ((typeof value == "object")? JSON.stringify(value) : value) + } as Item; + this.items.push(item); + } + }); }, //自动化测试例专用 jest_getWindowInfo() : GetWindowInfoResult { -- GitLab