diff --git a/pages/API/get-app-base-info/get-app-base-info.uvue b/pages/API/get-app-base-info/get-app-base-info.uvue index f181af48e6f3b4d83c16267973621fa1c867f493..e51cee92a5e25584564c614b5a87030dd82bcb24 100644 --- a/pages/API/get-app-base-info/get-app-base-info.uvue +++ b/pages/API/get-app-base-info/get-app-base-info.uvue @@ -35,8 +35,16 @@ methods: { getAppBaseInfo: function () { const res = uni.getAppBaseInfo(); + 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); + }); + this.items = [] as Item[]; - for(const key in res){ + keys.sort().forEach( key => { const value = res[key]; if(value != null){ const item = { @@ -45,7 +53,8 @@ } as Item; this.items.push(item); } - } + }); + } } } diff --git a/pages/API/get-device-info/get-device-info.uvue b/pages/API/get-device-info/get-device-info.uvue index 91a7755548d67ce67c757d695b54d9de66c5bf99..72f0b557a1c597f32f749d55b3704420d692bdac 100644 --- a/pages/API/get-device-info/get-device-info.uvue +++ b/pages/API/get-device-info/get-device-info.uvue @@ -51,17 +51,25 @@ const res = uni.getDeviceInfo(); // 获取像素比, 供截图对比使用 setDevicePixelRatio(res.devicePixelRatio !== null ? parseFloat(res.devicePixelRatio!) : 1) - 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); + } + }); } } } diff --git a/pages/API/get-system-info/get-system-info.uvue b/pages/API/get-system-info/get-system-info.uvue index 598c25f1de3b72952073d69e588304ff76ad2fad..f1115d1dfc7bf3264d5a23ab1a0d1abf6ac8dfe0 100644 --- a/pages/API/get-system-info/get-system-info.uvue +++ b/pages/API/get-system-info/get-system-info.uvue @@ -51,33 +51,47 @@ getSystemInfo: function () { uni.getSystemInfo({ success: (res) => { - 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); + } + }); }, }) }, getSystemInfoSync: function () { this.items = [] as Item[]; - const res = uni.getSystemInfoSync() - 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); - } - } + const res = uni.getSystemInfoSync() + 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_getSystemInfo() : GetSystemInfoResult {