utsiOS.vue 4.5 KB
Newer Older
lizhongyi_'s avatar
lizhongyi_ 已提交
1
<template>
lizhongyi_'s avatar
lizhongyi_ 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
	<view>
		<button @click="testCurrentVC">获取当前UIViewController</button>
		<view class="result" :style="resultStyle(currentVCResult.passed)"> 测试结果 -- {{formatResult(currentVCResult.passed)}}</view>
		<button @click="testKeyWindow">获取当前app的keyWindow</button>
		<view class="result" :style="resultStyle(keyWindowResult.passed)"> 测试结果 -- {{formatResult(keyWindowResult.passed)}}</view>
		<button @click="testColorConvert">将字符串色值转换为UIColor</button>
		<view class="result">
			<p v-for="item in colorConvertResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
		</view>
		<button @click="testResourcePath">资源路径转换</button>
		<view class="result" :style="resultStyle(resourcePathResult.passed)"> {{resourcePathResult.key}}: {{resourcePathResult.value}} -- {{formatResult(resourcePathResult.passed)}}</view>
		<button @click="testDeviceInfo">获取设备信息</button>
		<view class="result">
			<p v-for="item in deviceInfoResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
		</view>
		<button @click="testAppInfo">获取App信息相关api</button>
		<view class="result">
			<p v-for="item in appInfoResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
		</view>
		<button @click="testSystemSetting">获取系统设置</button>
		<view class="result" :style="resultStyle(systemSettingResult.passed)"> {{systemSettingResult.key}}: {{systemSettingResult.value}} -- {{formatResult(systemSettingResult.passed)}}</view>
		<button @click="testTypeof">typeof</button>
		<view class="result">
			<p v-for="item in typeofResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
		</view>
		<button @click="testDataConvert">数据转换</button>
		<view class="result">
			<p v-for="item in dataConvertResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
		</view>
		<button @click="testAll">test all</button>
	</view>
lizhongyi_'s avatar
lizhongyi_ 已提交
33 34 35
</template>

<script>
lizhongyi_'s avatar
lizhongyi_ 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48
 import {
   getCurrentVCTest,
   getKeyWindowTest,
   colorWithStringTest,
   getResourcePathTest,
   getDeviceInfoTest,
   getAppInfoTest,
   getSystemSettingTest,
   tepeofTest,   
   dataConvertTest,
 } from "@/uni_modules/uts-platform-api"


lizhongyi_'s avatar
lizhongyi_ 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
	export default {
		data() {
			return {
				title: "UTSiOS test",
				currentVCResult: {},
				keyWindowResult: {},
				colorConvertResult: [],
				resourcePathResult: {},
				deviceInfoResult: [],
				appInfoResult: [],
				systemSettingResult: {},
				typeofResult: [],
				dataConvertResult: []
			}
		},
		
		methods: {
			
			formatResult(res) {
				if (res == null) {
					return "";
				}
				return res ? "测试通过": "测试失败"
			},
			
			resultStyle(res) {
				
				if (res == null) {
					return {
						color: "#333333"
					}
				}
				let color =  res ? "#00ff00" : "#ff0000";
				return {
					color: color
				}
			},
			
			testCurrentVC() {
				this.currentVCResult = getCurrentVCTest();
			},
			
			testKeyWindow() {
				this.keyWindowResult = getKeyWindowTest();
			},
			
			testColorConvert() {
				let array = colorWithStringTest();
				this.colorConvertResult = array.map((value) => {
					return JSON.parse(value)
				})
			},
			
			testResourcePath() {
				this.resourcePathResult = getResourcePathTest("/static/logo.png");
			},
			
			testDeviceInfo() {
				let array = getDeviceInfoTest();
				this.deviceInfoResult = array.map((value) => {
					return JSON.parse(value)
				})
			},
			
			testAppInfo() {
				let array = getAppInfoTest();
				this.appInfoResult = array.map((value) => {
					return JSON.parse(value)
				})
			}, 
			
			testSystemSetting() {
				this.systemSettingResult = getSystemSettingTest();
			},
			
			testTypeof() {
				let array = tepeofTest();
				this.typeofResult = array.map((value) => {
					return JSON.parse(value)
				})
			},
			
			testDataConvert() {
				let array = dataConvertTest();
				this.dataConvertResult = array.map((value) => {
					return JSON.parse(value)
				})
			},
			
			testAll() {
				this.testCurrentVC();
				this.testKeyWindow();
				this.testColorConvert();
				this.testResourcePath();
				this.testDeviceInfo();
				this.testAppInfo();
				this.testSystemSetting();
				this.testTypeof();
				this.testDataConvert();
			}
		}
	}
	
lizhongyi_'s avatar
lizhongyi_ 已提交
152 153
</script>

lizhongyi_'s avatar
lizhongyi_ 已提交
154 155 156 157 158 159 160 161 162 163
<style scoped>
	.result {
		text-align: left;
		padding-left: 20px;
		padding-right: 20px;
		max-width: 100%;
		overflow: auto;
		overflow-wrap: normal;
	}
	
lizhongyi_'s avatar
lizhongyi_ 已提交
164
</style>