提交 ed467a40 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

Merge branch 'dev' into alpha

......@@ -3,6 +3,23 @@
let firstBackTime = 0
export default {
globalData: {
str: 'default globalData str',
num: 0,
bool: false,
obj: {
str: 'default globalData obj str',
num: 0,
bool: false,
},
null: null as string | null,
arr: [] as number[],
set: new Set<string>(),
map: new Map<string, any>(),
func: (): string => {
return 'globalData func'
}
},
onLaunch: function () {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1000)
......@@ -62,4 +79,4 @@
<style>
/*每个页面公共css */
@import "./common/uni.css";
</style>
\ No newline at end of file
</style>
......@@ -34,11 +34,6 @@
line-height: 20px;
}
.hello-link {
color: #7A7E83;
font-size: 14px;
line-height: 20px;
}
.uni-panel {
margin-bottom: 12px;
......@@ -74,20 +69,6 @@
font-weight: normal;
}
.uni-panel-icon {
margin-left: 15px;
color: #999999;
font-size: 14px;
font-weight: normal;
transform: rotate(0deg);
transition-duration: 0s;
transition-property: transform;
}
.uni-panel-icon-on {
transform: rotate(180deg);
}
.uni-navigate-item {
/* #ifdef H5 */
display: flex;
......@@ -118,10 +99,4 @@
font-size: 14px;
font-weight: normal;
}
.uni-navigate-icon {
margin-left: 15px;
color: #999999;
font-size: 14px;
font-weight: normal;
}
\ No newline at end of file
......@@ -139,10 +139,6 @@
justify-content: center;
}
.uni-textarea-box {
background: #ffffff;
}
.uni-textarea {
padding: 18rpx;
line-height: 1.6;
......
export type ItemType = { value : number; name : string }
\ No newline at end of file
<script lang="uts">
import {type PropType} from 'vue'
export type ItemType = { value : number; name : string }
import { ItemType } from './enum-data'
export default {
emits: ['change'],
......@@ -24,9 +22,9 @@
// @ts-ignore
_change(e : RadioGroupChangeEvent) {
const selected = this.items.find((item: ItemType) : boolean => {
return item.name === e.detail.value
return item.name == e.detail.value
})
if (selected !== null) {
if (selected != null) {
this.current = selected.value
this.$emit('change', this.current)
uni.showToast({
......@@ -46,7 +44,7 @@
</view>
</view>
<view class="uni-list uni-common-pl">
<radio-group @change="_change" class="radio-group">
<radio-group @change="_change">
<radio class="uni-list-cell uni-list-cell-pd radio" v-for="(item, index) in items" :key="item.name"
:class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item.name" :checked="index === current">
{{ item.name }}
......
import { ComponentPublicInstance } from 'vue'
// 查找父组件实例
export function $dispatch(
context : ComponentPublicInstance,
componentName : string,
eventName : string,
...params : any | null
) {
let parent = context.$parent
let name = parent?.$options?.name
while (parent != null && (name == null || componentName != name)) {
parent = parent.$parent
if (parent != null) {
name = parent.$options.name
}
}
if (parent != null) {
parent.$callMethod(eventName, ...params)
}
// 查找父组件实例
export function $dispatch(
context : ComponentPublicInstance,
componentName : string,
eventName : string,
...params : any[]
) {
let parent = context.$parent
let name = parent?.$options?.name
while (parent != null && (name == null || componentName != name)) {
parent = parent.$parent
if (parent != null) {
name = parent.$options.name
}
}
if (parent != null) {
parent.$callMethod(eventName, ...params)
}
}
......@@ -6,7 +6,6 @@
</template>
<script lang="uts">
import { ComponentPublicInstance } from 'vue'
export default {
name: "UniCollapse",
props: {
......@@ -18,7 +17,7 @@
},
data() {
return {
child_nodes: [] as Array < ComponentPublicInstance >
child_nodes: [] as Array<ComponentPublicInstance>
};
},
......
......@@ -7,8 +7,6 @@
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.uniui-back:before {
......
......@@ -20,10 +20,6 @@
background-color: #dd524d;
}
.btn-yellow {
background-color: #f0ad4e;
}
.desc {
padding: 10px;
color: #999999;
......
......@@ -6,7 +6,13 @@ const {
const hbuilderx_version = process.env.HX_Version
const uniTestPlatformInfo = process.env.uniTestPlatformInfo ? process.env.uniTestPlatformInfo.replace(/\s/g,'_') : ''
const folderName = `__image_snapshots__/${hbuilderx_version}/__${uniTestPlatformInfo}__`
const baseFolderName = `__image_snapshots__/base/__${uniTestPlatformInfo}__`
let environment = 'official'
if(hbuilderx_version.includes('dev')){
environment = 'dev'
}else if(hbuilderx_version.includes('alpha')){
environment = 'alpha'
}
const baseFolderName = `__image_snapshots__/base/${environment}/__${uniTestPlatformInfo}__`
expect.extend({
toMatchImageSnapshot: configureToMatchImageSnapshot({
......@@ -16,4 +22,4 @@ expect.extend({
customSnapshotsDir: path.join(__dirname, baseFolderName),
customDiffDir: path.join(__dirname, `${folderName}/`, 'diff'),
}),
});
\ No newline at end of file
});
import App from './App.uvue'
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
import App from './App.uvue'
import { createSSRApp, reactive } from 'vue'
export function createApp() {
const app = createSSRApp(App)
app.config.globalProperties.globalPropertiesStr = 'default string'
app.config.globalProperties.globalPropertiesNum = 0
app.config.globalProperties.globalPropertiesBool = false
app.config.globalProperties.globalPropertiesObj = {
str: 'default globalProperties obj string',
num: 0,
bool: false,
}
app.config.globalProperties.globalPropertiesNull = null as string | null
app.config.globalProperties.globalPropertiesArr = [] as number[]
app.config.globalProperties.globalPropertiesSet = new Set<string>()
app.config.globalProperties.globalPropertiesMap = new Map<string, number>()
app.config.globalProperties.globalPropertiesReactiveObj = reactive({
str: 'default reactive string',
num: 0,
bool: false,
})
app.config.globalProperties.globalPropertiesFn = () : string => {
console.log('this.globalPropertiesStr', this.globalPropertiesStr)
console.log('this.globalPropertiesNum', this.globalPropertiesNum)
return `globalPropertiesStr: ${this.globalPropertiesStr}, globalPropertiesNum: ${this.globalPropertiesNum}`
}
return {
app
}
}
此差异已折叠。
......@@ -57,6 +57,12 @@
] as ItemType[],
current: 0,
}
},
onLoad(){
uni.showActionSheet({
title: "onLoad 调用示例,请手动取消",
itemList:['item1', 'item2'],
})
},
methods: {
radioChange(e : RadioGroupChangeEvent) {
......@@ -82,8 +88,8 @@
if (this.itemContentLarge) {
itemInfo = ['两个黄鹂鸣翠柳,一行白鹭上青天。窗含西岭千秋雪,门泊东吴万里船', '水光潋滟晴方好,山色空蒙雨亦奇。 欲把西湖比西子,淡妆浓抹总相宜', '']
}
}
if (this.itemNumLargeSelect) {
// 大量选项测试,不能超过6个元素 https://uniapp.dcloud.net.cn/api/ui/prompt.html#showactionsheet
itemInfo = []
......
......@@ -216,9 +216,9 @@
let hexChars = "0123456789ABCDEF";
let result = "";
while (num > 0) {
let remainder : Int = num.toInt() % 16;
let remainder = Math.floor(num) % 16;
result = hexChars[remainder] + result;
num = Math.floor(num.toInt() / 16);
num = Math.floor(Math.floor(num) / 16);
}
if (result.length == 1) {
return "0" + result
......
<template>
<view id="snapshot-content">
<page-head id="page-head" title="对本页面根view截图"></page-head>
<page-head title="对本页面根view截图"></page-head>
<view class="uni-padding-wrap">
<text id="text">this is text</text>
<text>this is text</text>
</view>
<button class="uni-btn btn-TakeSnapshot" type="primary" @tap="takeSnapshotClick">
点击截图并替换显示下方图片
</button>
<image style="margin-top: 20px;" :src="snapImage" mode="aspectFit" @longpress="saveToAlbum"></image>
<image style="margin-left:auto;margin-right:auto;margin-top:20px;width:90%;" :src="snapImage" :mode="mode" @longpress="saveToAlbum"></image>
</view>
</template>
......@@ -15,6 +15,7 @@
export default {
data() {
return {
mode: "center",//aspectFit
snapImage: "/static/uni.png"
}
},
......@@ -22,15 +23,16 @@
takeSnapshotClick() {
const view = uni.getElementById('snapshot-content')!
view.takeSnapshot({
success: function (res) {
success: (res) => {
console.log(res.tempFilePath)
this.snapImage = res.tempFilePath
this.mode = 'widthFix'
uni.showToast({
title: '截图成功,路径:' + res.tempFilePath,
icon: "none"
})
},
fail: function (res) {
fail: (res) => {
console.log(res)
uni.showToast({
icon: 'error',
......
......@@ -6,11 +6,11 @@
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v uni-common-mt">
<input class="uni-input uni-input-default" type="text" v-model="realName" name="real-name" id="real-name"
<input class="uni-input" type="text" v-model="realName" name="real-name"
placeholder="姓名" />
</view>
<view class="uni-btn-v uni-common-mt">
<input class="uni-input uni-input-default" type="text" v-model="idCard" name="id-card" id="id-card"
<input class="uni-input" type="text" v-model="idCard" name="id-card"
placeholder="身份证号" />
</view>
<view class="uni-btn-v uni-common-mt">
......@@ -51,7 +51,7 @@
try {
metaInfo = uni.getFacialRecognitionMetaInfo();
} catch (e) {
if (e.message!.indexOf('Failed resolution of') > -1) {
if ((e as Error).message!.indexOf('Failed resolution of') > -1) {
uni.showModal({
title: '提示',
content: '注意:目前uni-app x内使用实人认证功能需要打包自定义基座。',
......@@ -65,7 +65,7 @@
idCard,
metaInfo
})
.then<string>((res : UTSJSONObject) : Promise<string> => {
.then((res : UTSJSONObject) : Promise<string> => {
const certifyId = res['certifyId'] as string
return new Promise((
resolve : (res : string) => void,
......@@ -82,13 +82,13 @@
})
})
})
.then<UTSJSONObject>((certifyId : string) : Promise<UTSJSONObject> => {
.then((certifyId : string) : Promise<UTSJSONObject> => {
return testFacialCo.getAuthResult(certifyId)
})
.then<void>((res : UTSJSONObject) => {
.then((res : UTSJSONObject) => {
console.log('res', res)
})
.catch<void>((err : any | null) => {
.catch((err : any | null) => {
console.error('error', err)
})
}
......
此差异已折叠。
<template>
<scroll-view>
<view>
<button type="primary" @tap="readDirTest" class="btn-read-dir">读取文件夹</button>
<button type="primary" @tap="readFileTest" class="btn-read-file">读取文件</button>
<button type="primary" @tap="rmdirTest" class="btn-remove-dir">删除文件夹</button>
<button type="primary" @tap="unlinkTest" class="btn-unlink-file">删除文件</button>
<button type="primary" @tap="mkdirTest" class="btn-mkdir">创建文件夹</button>
<button type="primary" @tap="writeFileTest" class="btn-write-file">写入文件</button>
<button type="primary" @tap="renameFileTest" class="btn-rename-file">重命名文件</button>
<button type="primary" @tap="copyFileTest" class="btn-copy-file">复制文件</button>
<button type="primary" @tap="accessFileTest" class="btn-access-file">判断文件是否存在</button>
<button type="primary" @tap="getFileInfoTest" class="btn-get-file-info">获取文件信息</button>
</view>
</scroll-view>
</template>
<script>
export default {
data() {
return {
fileListSuccess:[] as string[],
fileListComplete:[] as string[],
accessFileRet:'',
lastFailError:UniError("uni-file-manager",1300000,"mock error"),
lastCompleteError:UniError("uni-file-manager",1300000,"mock error"),
readDir:'a',
readFileRet:"",
writeFileContent:"锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦",
getFileInfoAlgorithm:"md5",
getFileInfoSize:-1,
getFileInfoDigest:"",
unlinkFile:'a/1.txt',
accessFile:'a/1.txt',
writeFile:'a/1.txt',
copyFromFile:'a/1.txt',
copyToFile:'a/2.txt',
renameFromFile:'a/2.txt',
renameToFile:'a/3.txt',
getFileInfoFile:'a/1.txt',
rmDirFile:'a',
mkdirFile:'a',
readFile:'a/1.txt',
recursiveVal:true,
done: false,
writeFileEncoding:"utf-8",
readFileEncoding:"utf-8",
/**
* 待测试的全局环境变量
*/
basePath: uni.env.USER_DATA_PATH,
copyToBasePath: uni.env.USER_DATA_PATH,
globalTempPath:uni.env.TEMP_PATH,
globalRootPath:uni.env.ROOT_PATH,
globalAppResourcePath:uni.env.APP_RESOURCE_PATH,
globalUserDataPath:uni.env.USER_DATA_PATH
}
},
onLoad() {
},
methods: {
getFileInfoTest:function(e:any){
let fileManager = uni.getFileSystemManager()
fileManager.getFileInfo({
filePath:`${this.basePath}${this.getFileInfoFile}`,
digestAlgorithm:this.getFileInfoAlgorithm,
success:function(res:GetFileInfoSuccessResult){
console.log('success',res)
this.getFileInfoSize = res.size
this.getFileInfoDigest = res.digest
},
fail:function(res:any){
console.log('fail',res)
this.lastFailError = res
},
complete:function(res:any){
console.log("complete",res)
this.done = true
if(res instanceof UniError){
this.lastCompleteError = res
}
}
} as GetFileInfoOptions)
},
copyFileTest:function(e:any){
let fileManager = uni.getFileSystemManager()
fileManager.copyFile({
srcPath:`${this.basePath}${this.copyFromFile}`,
destPath:`${this.copyToBasePath}${this.copyToFile}`,
success:function(res:FileManagerSuccessResult){
console.log('success',res)
},
fail:function(res:any){
console.log('fail',res)
this.lastFailError = res
},
complete:function(res:any){
console.log("complete",res)
this.done = true
if(res instanceof UniError){
this.lastCompleteError = res
}
}
} as CopyFileOptions)
},
renameFileTest:function(e:any){
let fileManager = uni.getFileSystemManager()
fileManager.rename({
oldPath:`${this.basePath}${this.renameFromFile}`,
newPath:`${this.basePath}${this.renameToFile}`,
success:function(res:FileManagerSuccessResult){
console.log('success',res)
},
fail:function(res:any){
console.log('fail',res)
this.lastFailError = res
},
complete:function(res:any){
this.done = true
console.log("complete",res)
if(res instanceof UniError){
this.lastCompleteError = res
}
}
} as RenameOptions)
},
readDirTest:function(e:any){
let fileManager = uni.getFileSystemManager()
fileManager.readdir({
dirPath:`${this.basePath}${this.readDir}`,
success:function(res:ReadDirSuccessResult){
console.log("success",res)
this.fileListSuccess = res.files
},
fail:function(res:any){
console.log('fail',res)
this.lastFailError = res
},
complete:function(res:any){
console.log("complete",res)
this.done = true
if(res instanceof ReadDirSuccessResult){
this.fileListComplete = res.files
}
if(res instanceof UniError){
this.lastCompleteError = res
}
}
} as ReadDirOptions)
},
writeFileTest:function(e:any){
let fileManager = uni.getFileSystemManager()
fileManager.writeFile({
filePath:`${this.basePath}${this.writeFile}`,
data:this.writeFileContent,
encoding:this.writeFileEncoding,
success:function(res){
console.log('success',res)
},
fail:function(res){
console.log('fail')
this.lastFailError = res
},
complete:function(res){
this.done = true
console.log("complete")
if(res instanceof UniError){
this.lastCompleteError = res
}
}
} as WriteFileOptions)
},
readFileTest:function(e:any){
let fileManager = uni.getFileSystemManager()
fileManager.readFile({
filePath:`${this.basePath}${this.readFile}`,
encoding:this.readFileEncoding,
success:function(res:ReadFileSuccessResult){
console.log('success',res)
this.readFileRet = res.data
},
fail:function(res:any){
console.log('fail',res)
this.lastFailError = res
},
complete:function(res:any){
console.log("complete",res)
this.done = true
if(res instanceof UniError){
this.lastCompleteError = res
}
}
} as ReadFileOptions)
},
rmdirTest:function(e:any){
let fileManager = uni.getFileSystemManager()
fileManager.rmdir({
dirPath:`${this.basePath}${this.rmDirFile}`,
recursive:this.recursiveVal,
success:function(res:FileManagerSuccessResult){
console.log('success',res)
},
fail:function(res:any){
console.log('fail',res)
this.lastFailError = res
},
complete:function(res:any){
console.log("complete",res)
this.done = true
if(res instanceof UniError){
this.lastCompleteError = res
}
}
} as RmDirOptions)
},
mkdirTest:function(e:any){
// 准备测试数据
let fileManager = uni.getFileSystemManager()
fileManager.mkdir({
dirPath:`${this.basePath}${this.mkdirFile}`,
recursive:this.recursiveVal,
success:function(res:FileManagerSuccessResult){
console.log('success',res)
},
fail:function(res:any){
console.log('fail',res)
this.lastFailError = res
},
complete:function(res:any){
if(res instanceof UniError){
this.lastCompleteError = res
}
this.done = true
console.log("complete",res)
}
} as MkDirOptions)
},
accessFileTest:function(e:any){
this.accessFileRet = ''
let fileManager = uni.getFileSystemManager()
fileManager.access({
path:`${this.basePath}${this.accessFile}`,
success:function(res:FileManagerSuccessResult){
console.log('success',res)
this.accessFileRet = res.errMsg
},
fail:function(res:UniError){
console.log('fail',res)
this.lastFailError = res
},
complete:function(res:any){
if(res instanceof UniError){
this.lastCompleteError = res
}
console.log("complete",res)
this.done = true
}
} as AccessOptions)
},
unlinkTest:function(e:any){
let fileManager = uni.getFileSystemManager()
fileManager.unlink({
filePath:`${this.basePath}${this.unlinkFile}`,
success:function(res:FileManagerSuccessResult){
console.log('success',res)
},
fail:function(res:UniError){
console.log('fail',res)
this.lastFailError = res
},
complete:function(res:any){
if(res instanceof UniError){
this.lastCompleteError = res
}
console.log("complete",res)
this.done = true
}
} as UnLinkOptions)
},
}
}
</script>
<style>
</style>
const PAGE_PATH = '/pages/API/get-app/get-app'
describe('getApp', () => {
it('getApp', async () => {
const page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000)
const oldData = await page.data()
await page.callMethod('_increasetLifeCycleNum')
const newData = await page.data()
expect(newData.lifeCycleNum - oldData.lifeCycleNum).toBe(100)
await page.callMethod('setLifeCycleNum', oldData.lifeCycleNum)
})
})
const PAGE_PATH = '/pages/API/get-app/get-app'
describe('getApp', () => {
let page = null
beforeAll(async () => {
page = await program.navigateTo(PAGE_PATH)
await page.waitFor('view')
})
it('globalData', async () => {
await page.callMethod('getGlobalData')
let data = await page.data()
expect(data.originGlobalData.str).toBe('default globalData str')
expect(data.originGlobalData.num).toBe(0)
expect(data.originGlobalData.bool).toBe(false)
expect(data.originGlobalData.obj).toEqual({
bool: false,
num: 0,
str: 'default globalData obj str'
})
expect(data.originGlobalData.arr).toEqual([])
if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(data.originGlobalData.set).toEqual([])
} else {
expect(data.originGlobalData.set).toEqual({})
}
expect(data.originGlobalData.map).toEqual({})
expect(data.originGlobalDataFuncRes).toBe('globalData func')
await page.callMethod('setGlobalData')
data = await page.data()
expect(data.newGlobalData.str).toBe('new globalData str')
expect(data.newGlobalData.num).toBe(100)
expect(data.newGlobalData.bool).toBe(true)
expect(data.newGlobalData.obj).toEqual({
bool: true,
num: 200,
str: 'new globalData obj str'
})
expect(data.newGlobalData.arr).toEqual([1, 2, 3])
if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(data.newGlobalData.set).toEqual(['a', 'b', 'c'])
} else {
expect(data.originGlobalData.set).toEqual({})
}
if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(data.newGlobalData.map).toEqual({
'a': 1,
'b': 2,
'c': 3
})
} else {
expect(data.originGlobalData.map).toEqual({})
}
expect(data.newGlobalDataFuncRes).toBe('new globalData func')
})
it('method', async () => {
const oldLifeCycleNum = await page.data('lifeCycleNum')
await page.callMethod('_increasetLifeCycleNum')
const newLifeCycleNum = await page.data('lifeCycleNum')
expect(newLifeCycleNum - oldLifeCycleNum).toBe(100)
await page.callMethod('setLifeCycleNum', oldLifeCycleNum)
})
})
\ No newline at end of file
<template>
<view>
<page-head title="getApp"></page-head>
<view class="uni-padding-wrap">
<text>点击按钮调用 App.uvue methods</text>
<text class="margin-top:6px;">increasetLifeCycleNum 方法</text>
<button class="uni-common-mt" @click="_increasetLifeCycleNum">
increase lifeCycleNum
</button>
<text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text>
</view>
</view>
</template>
<script lang="uts">
import { State, state, setLifeCycleNum } from '@/store/index.uts'
export default {
data() {
return {
lifeCycleNum: 0,
}
},
onReady() {
this.lifeCycleNum = state.lifeCycleNum
},
methods: {
_increasetLifeCycleNum: function () {
const app = getApp()
app.increasetLifeCycleNum()
this.lifeCycleNum = state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num: number) {
setLifeCycleNum(num)
},
},
}
</script>
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1;padding-bottom: 20px;">
<!-- #endif -->
<view>
<page-head title="getApp"></page-head>
<view class="uni-padding-wrap">
<button @click="getGlobalData">get globalData</button>
<template v-if="originGlobalData.str.length">
<text class="uni-common-mt bold">初始的 globalData:</text>
<text class="uni-common-mt">globalData string: {{ originGlobalData.str }}</text>
<text class="uni-common-mt">globalData number: {{ originGlobalData.num }}</text>
<text class="uni-common-mt">globalData boolean: {{ originGlobalData.bool }}</text>
<text class="uni-common-mt">globalData object: {{ originGlobalData.obj }}</text>
<text class="uni-common-mt">globalData null: {{ originGlobalData.null }}</text>
<text class="uni-common-mt">globalData array: {{ originGlobalData.arr }}</text>
<text class="uni-common-mt">globalData Set: {{ originGlobalData.set }}</text>
<text class="uni-common-mt">globalData Map: {{ originGlobalData.map }}</text>
<text class="uni-common-mt">globalData func 返回值: {{ originGlobalDataFuncRes }}</text>
</template>
<button @click="setGlobalData" class="uni-common-mt">set globalData</button>
<template v-if="newGlobalData.bool">
<text class="uni-common-mt bold">更新后的 globalData:</text>
<text class="uni-common-mt">globalData string: {{ newGlobalData.str }}</text>
<text class="uni-common-mt">globalData number: {{ newGlobalData.num }}</text>
<text class="uni-common-mt">globalData boolean: {{ newGlobalData.bool }}</text>
<text class="uni-common-mt">globalData object: {{ newGlobalData.obj }}</text>
<text class="uni-common-mt">globalData null: {{ newGlobalData.null }}</text>
<text class="uni-common-mt">globalData array: {{ newGlobalData.arr }}</text>
<text class="uni-common-mt">globalData Set: {{ newGlobalData.set }}</text>
<text class="uni-common-mt">globalData Map: {{ newGlobalData.map }}</text>
<text class="uni-common-mt">globalData func 返回值: {{ newGlobalDataFuncRes }}</text>
</template>
<view class="uni-common-mt hr"></view>
<text class="uni-common-mt">点击按钮调用 App.uvue methods</text>
<text class="margin-top:6px;">increasetLifeCycleNum 方法</text>
<button class="uni-common-mt" @click="_increasetLifeCycleNum">
increase lifeCycleNum
</button>
<text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
type MyGlobalData = {
str : string,
num : number,
bool : boolean,
obj : UTSJSONObject,
null : string | null,
arr : number[],
set : Set<string>,
map : Map<string, any>,
func : () => string
}
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data() {
return {
originGlobalData: {
str: '',
num: 0,
bool: false,
obj: {
str: '',
num: 0,
bool: false
} as UTSJSONObject,
null: null,
arr: [] as number[],
set: new Set<string>(),
map: new Map<string, any>(),
func: () : string => ''
} as MyGlobalData,
originGlobalDataFuncRes: '',
newGlobalData: {
str: '',
num: 0,
bool: false,
obj: {
str: '',
num: 0,
bool: false
} as UTSJSONObject,
null: null,
arr: [] as number[],
set: new Set<string>(),
map: new Map<string, any>(),
func: () : string => ''
} as MyGlobalData,
newGlobalDataFuncRes: '',
lifeCycleNum: 0,
}
},
onReady() {
this.lifeCycleNum = state.lifeCycleNum
},
methods: {
getGlobalData() {
const app = getApp()
this.originGlobalData.str = app.globalData.str
this.originGlobalData.num = app.globalData.num
this.originGlobalData.bool = app.globalData.bool
this.originGlobalData.obj = app.globalData.obj
this.originGlobalData.null = app.globalData.null
this.originGlobalData.arr = app.globalData.arr
this.originGlobalData.set = app.globalData.set
this.originGlobalData.map = app.globalData.map
this.originGlobalData.func = app.globalData.func
this.originGlobalDataFuncRes = this.originGlobalData.func()
},
setGlobalData() {
const app = getApp()
app.globalData.str = 'new globalData str'
app.globalData.num = 100
app.globalData.bool = true
app.globalData.obj = {
str: 'new globalData obj str',
num: 200,
bool: true
}
app.globalData.null = 'not null'
app.globalData.arr = [1, 2, 3]
app.globalData.set = new Set(['a', 'b', 'c'])
app.globalData.map = new Map([
['a', 1],
['b', 2],
['c', 3]
])
app.globalData.func = () : string => {
return 'new globalData func'
}
this.newGlobalData.str = app.globalData.str
this.newGlobalData.num = app.globalData.num
this.newGlobalData.bool = app.globalData.bool
this.newGlobalData.obj = app.globalData.obj
this.newGlobalData.null = app.globalData.null
this.newGlobalData.arr = app.globalData.arr
this.newGlobalData.set = app.globalData.set
this.newGlobalData.map = app.globalData.map
this.newGlobalData.func = app.globalData.func
this.newGlobalDataFuncRes = this.newGlobalData.func()
},
_increasetLifeCycleNum: function () {
const app = getApp()
app.increasetLifeCycleNum()
this.lifeCycleNum = state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num : number) {
setLifeCycleNum(num)
}
},
}
</script>
<style>
.bold {
font-weight: bold;
}
.hr{border-bottom: 1px solid #ccc;}
</style>
......@@ -5,11 +5,11 @@
<view style="background:#FFFFFF; padding:40rpx;">
<view class="uni-center">网络状态</view>
<view v-if="hasNetworkType == false">
<view class="uni-h2 uni-center uni-common-mt">未获取</view>
<view class="uni-center uni-common-mt">未获取</view>
<view class="uni-center uni-common-mt">请点击下面按钮获取网络状态</view>
</view>
<view v-if="hasNetworkType == true">
<view class="uni-h2 uni-center uni-common-mt">{{networkType}}</view>
<view class="uni-center uni-common-mt">{{networkType}}</view>
</view>
</view>
<view class="uni-btn-v uni-common-mt">
......
const PAGE_PATH = '/pages/API/globalProperties/globalProperties'
describe('globalProperties', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
let page = null
beforeAll(async () => {
page = await program.navigateTo(PAGE_PATH)
await page.waitFor(500)
})
it('globalProperties', async () => {
let data = await page.data()
expect(data.myGlobalProperties.str).toBe('default string')
expect(data.myGlobalProperties.num).toBe(0)
expect(data.myGlobalProperties.bool).toBe(false)
expect(data.myGlobalProperties.obj).toEqual({
bool: false,
num: 0,
str: 'default globalProperties obj string'
})
expect(data.myGlobalProperties.arr).toEqual([])
expect(data.myGlobalProperties.set).toEqual([])
expect(data.myGlobalProperties.map).toEqual({})
expect(data.myGlobalProperties.reactiveObj).toEqual({
str: 'default reactive string',
num: 0,
bool: false
})
expect(data.globalPropertiesFnRes).toBe('globalPropertiesStr: default string, globalPropertiesNum: 0')
await page.callMethod('updateGlobalProperties')
data = await page.data()
expect(data.myGlobalProperties.str).toBe('new string')
expect(data.myGlobalProperties.num).toBe(100)
expect(data.myGlobalProperties.bool).toBe(true)
expect(data.myGlobalProperties.obj).toEqual({
bool: true,
num: 100,
str: 'new globalProperties obj string'
})
expect(data.myGlobalProperties.arr).toEqual([1, 2, 3])
expect(data.myGlobalProperties.set).toEqual(['a', 'b', 'c'])
expect(data.myGlobalProperties.map).toEqual({
'a': 1,
'b': 2,
'c': 3
})
expect(data.myGlobalProperties.reactiveObj).toEqual({
str: 'new reactive string',
num: 200,
bool: true
})
expect(data.globalPropertiesFnRes).toBe('globalPropertiesStr: new string, globalPropertiesNum: 100')
})
it('screenshot', async () => {
await page.waitFor(500)
const image = await program.screenshot({
fullPage: true
});
expect(image).toMatchImageSnapshot();
})
} else {
// TODO: web 端暂不支持
it('web', async () => {
expect(1).toBe(1)
})
}
})
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1;padding-bottom: 20px;">
<!-- #endif -->
<view>
<page-head title="getApp"></page-head>
<view class="uni-padding-wrap">
<text class="uni-common-mt">globalProperties string: {{ globalPropertiesStr }}</text>
<text class="uni-common-mt">globalProperties number: {{ globalPropertiesNum }}</text>
<text class="uni-common-mt">globalProperties boolean: {{ globalPropertiesBool }}</text>
<text class="uni-common-mt">globalProperties object: {{ globalPropertiesObj }}</text>
<text class="uni-common-mt">globalProperties null: {{ globalPropertiesNull }}</text>
<text class="uni-common-mt">globalProperties array: {{ globalPropertiesArr }}</text>
<text class="uni-common-mt">globalProperties set: {{ globalPropertiesSet }}</text>
<text class="uni-common-mt">globalProperties map: {{ globalPropertiesMap }}</text>
<text class="uni-common-mt">globalProperties reactiveObj.str: {{ globalPropertiesReactiveObj['str'] }}</text>
<text class="uni-common-mt">globalProperties reactiveObj.num: {{ globalPropertiesReactiveObj['num'] }}</text>
<text class="uni-common-mt">globalProperties reactiveObj.boolean: {{ globalPropertiesReactiveObj['bool'] }}</text>
<text class="uni-common-mt">globalProperties fun 返回值: {{ globalPropertiesFn() }}</text>
<button @click="updateGlobalProperties" class="uni-common-mt">update globalProperties</button>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
type MyGlobalProperties = {
str: string;
num: number;
bool: boolean;
obj: UTSJSONObject;
null: string | null;
arr: number[];
set: Set<string>;
map: Map<string, number>;
reactiveObj: UTSJSONObject;
}
export default {
data() {
return {
myGlobalProperties: {
str: '',
num: 0,
bool: false,
obj: {},
null: null,
arr: [],
set: new Set<string>(),
map: new Map<string, number>(),
reactiveObj: {
str: '',
num: 0,
bool: false,
} as UTSJSONObject,
} as MyGlobalProperties,
globalPropertiesFnRes: '',
bbb: 'my bbb'
}
},
onLoad() {
this.getglobalProperties()
},
methods: {
getglobalProperties() {
this.myGlobalProperties.str = this.globalPropertiesStr
this.myGlobalProperties.num = this.globalPropertiesNum
this.myGlobalProperties.bool = this.globalPropertiesBool
this.myGlobalProperties.obj = this.globalPropertiesObj
this.myGlobalProperties.null = this.globalPropertiesNull
this.myGlobalProperties.arr = this.globalPropertiesArr
this.myGlobalProperties.set = this.globalPropertiesSet
this.myGlobalProperties.map = this.globalPropertiesMap
this.myGlobalProperties.reactiveObj = this.globalPropertiesReactiveObj
this.globalPropertiesFnRes = this.globalPropertiesFn()
},
updateGlobalProperties() {
this.globalPropertiesStr = 'new string'
this.globalPropertiesNum = 100
this.globalPropertiesBool = true
this.globalPropertiesObj = {
str: 'new globalProperties obj string',
num: 100,
bool: true,
}
this.globalPropertiesNull = 'not null'
this.globalPropertiesArr = [1, 2, 3]
this.globalPropertiesSet = new Set(['a', 'b', 'c'])
this.globalPropertiesMap = new Map([['a', 1], ['b', 2], ['c', 3]])
this.globalPropertiesReactiveObj['str'] = 'new reactive string'
this.globalPropertiesReactiveObj['num'] = 200
this.globalPropertiesReactiveObj['bool'] = true
this.getglobalProperties()
}
},
}
</script>
......@@ -12,6 +12,10 @@
</view>
</view>
<view class="uni-list uni-common-pl">
<radio-group @change="radioChange">
<radio class="uni-list-cell uni-list-cell-pd radio" v-for="(item, index) in items" :key="item.value"
:class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item.value"
:checked="index === current">
<radio-group @change="radioChange" class="radio-group">
<radio
class="uni-list-cell uni-list-cell-pd radio"
......@@ -40,6 +44,42 @@
</view>
</template>
<script lang="uts">
type ItemType = {
value : string
name : string
}
export default {
data() {
return {
title: 'loading',
items: [
{
value: 'null',
name: '无标题',
},
{
value: '三秒后自动关闭',
name: '普通标题',
},
{
value: '超长文本内容,测试超出范围-超长文本内容,测试超出范围-三秒后自动关闭',
name: '长标题',
},
] as ItemType[],
current: 0,
maskSelect: false,
titleSelect: "null"
}
},
onLoad(){
uni.showLoading({
title:'onLoad 调用示例,1秒后消失'
})
setTimeout(function() {
uni.hideLoading()
}, 1000);
},
methods: {
type ItemType = {
value : string
name : string
......
......@@ -79,6 +79,12 @@
current: 0
}
},
onLoad(){
uni.showModal({
title: "onLoad 调用示例,请手动取消",
showCancel:false
})
},
methods: {
showCancelChange: function (e : SwitchChangeEvent) {
this.showCancelSelect = e.detail.value
......
......@@ -51,7 +51,7 @@
</template>
<script lang="uts">
import { State, state, setLifeCycleNum } from '@/store/index.uts'
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data() {
......
const PAGE_PATH = '/pages/API/nodes-info/nodes-info'
const RECT_LEFT = 15;
const RECT_WIDTH = 150;
const RECT_HEIGHT = 100;
describe('nodes-info', () => {
let page
beforeAll(async () => {
......@@ -12,7 +16,13 @@ describe('nodes-info', () => {
await btnGetNodeInfo.tap()
await page.waitFor(50)
const data = await page.data()
const data = await page.data()
// TODO 和浏览器的计算存在差异
const nodeInfo = data.nodeInfoList[0]
expect(Math.round(nodeInfo.left)).toBe(RECT_LEFT)
expect(Math.round(nodeInfo.width)).toBe(RECT_WIDTH)
expect(Math.round(nodeInfo.height)).toBe(RECT_HEIGHT)
// android 6 分辨率为 720*1280,需要调整期望数值
if (!process.env.uniTestPlatformInfo.startsWith('android 6')) {
const nodeInfo = data.nodeInfoList[0]
......@@ -29,6 +39,11 @@ describe('nodes-info', () => {
const data = await page.data()
const nodeInfo1 = data.nodeInfoList[0]
expect(Math.round(nodeInfo1.left)).toBe(RECT_LEFT)
expect(nodeInfo1.top > 220).toBe(true)
expect(Math.round(nodeInfo1.width)).toBe(RECT_WIDTH)
expect(Math.round(nodeInfo1.height)).toBe(RECT_HEIGHT)
if (!process.env.uniTestPlatformInfo.startsWith('android 6')) {
const nodeInfo1 = data.nodeInfoList[0]
expect(nodeInfo1.left > 15).toBe(true)
......@@ -36,6 +51,11 @@ describe('nodes-info', () => {
expect(nodeInfo1.width == 150).toBe(true)
expect(nodeInfo1.height == 100).toBe(true)
const nodeInfo2 = data.nodeInfoList[1]
expect(nodeInfo2.left > 200).toBe(true)
expect(nodeInfo2.top > 220).toBe(true)
expect(Math.round(nodeInfo2.width)).toBe(RECT_WIDTH)
expect(Math.round(nodeInfo2.height)).toBe(RECT_HEIGHT)
const nodeInfo2 = data.nodeInfoList[1]
expect(nodeInfo2.left > 200).toBe(true)
expect(nodeInfo2.top > 220).toBe(true)
......@@ -43,4 +63,4 @@ describe('nodes-info', () => {
expect(nodeInfo2.height == 100).toBe(true)
}
})
})
\ No newline at end of file
})
<template>
<view class="uni-padding-wrap">
<view class="page">
<page-head :title="title"></page-head>
<button class="btn btn-get-node-info" @click="getNodeInfo">getNodeInfo</button>
<button class="btn btn-get-all-node-info" @click="getAllNodeInfo">getAllNodeInfo</button>
......@@ -91,6 +91,10 @@
</script>
<style>
.page {
padding: 15px;
}
.btn {
margin-top: 15px;
}
......
......@@ -3,7 +3,7 @@
<!-- 实际开发中,长列表应该使用list-view -->
<view class="uni-padding-wrap uni-common-mt">
<text class="text" v-for="(num,index) in data" :key="index">list - {{num}}</text>
<view class="uni-loadmore" v-if="showLoadMore">{{loadMoreText}}</view>
<view v-if="showLoadMore">{{loadMoreText}}</view>
</view>
</scroll-view>
</template>
......
......@@ -2,7 +2,7 @@
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<image src="/static/uni.png" style="margin: 30rpx 200rpx;height:350rpx;width: 350rpx;"></image>
<image src="/static/uni.png" style="margin: 30rpx 200rpx;height:196px;width:196px;"></image>
<button style="margin: 30rpx;" @click="saveImage">将图片保存到手机相册</button>
<!-- #ifdef APP -->
</scroll-view>
......@@ -39,4 +39,4 @@
</script>
<style>
</style>
\ No newline at end of file
</style>
......@@ -349,13 +349,4 @@ export default {
</script>
<style>
.btn-setstorage {
background-color: #007aff;
color: #ffffff;
}
.button-sp-area {
flex-direction: row;
margin: 0 auto;
}
</style>
......@@ -27,6 +27,14 @@
exeRet: ''
}
},
onLoad(){
uni.showToast({
title:'onLoad 调用示例,1秒后消失'
})
setTimeout(function() {
uni.hideToast()
}, 1000);
},
methods: {
toast1Tap: function () {
uni.showToast({
......
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v uni-common-mt">
<button type="primary" @click="verify(false)">一键登录(半屏)</button>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @click="verify(true)">一键登录(全屏)</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: '一键登录',
univerifyManager: null as UniverifyManager | null
}
},
onLoad() {
this.univerifyManager = uni.getUniverifyManager();
// 预登录
this.univerifyManager?.preLogin({
success() {
console.log("pre login success");
},
fail(err : PreLoginFail) {
console.error("pre login fail => " + JSON.stringify(err));
}
} as PreLoginOptions);
},
methods: {
verify(fullScreen : boolean) {
// 校验预登录是否有效
const isPreLoginValid = this.univerifyManager?.isPreLoginValid() ?? false;
if (isPreLoginValid) {
// 预登录有效,执行登录
this.login(fullScreen);
} else {
// 预登录无效,执行预登录
this.univerifyManager?.preLogin({
success() {
console.log("pre login success");
this.login(fullScreen);
},
fail(err : PreLoginFail) {
console.error("pre login fail => " + JSON.stringify(err));
}
} as PreLoginOptions);
}
},
login(fullScreen : boolean) {
this.univerifyManager?.login({
// 登录页样式
univerifyStyle: {
fullScreen: fullScreen,
backgroundColor: "#FFFFFF",
loginBtnText: "一键登录",
logoPath: "/static/logo.png"
} as UniverifyStyle,
success(res : LoginSuccess) {
console.log("login success => " + JSON.stringify(res));
// 云函数取号
uniCloud.callFunction({
name: 'univerify',
data: {
access_token: res.accessToken, // 客户端一键登录接口返回的access_token
openid: res.openId // 客户端一键登录接口返回的openid
}
}).then(res => {
uni.showModal({
title: '取号成功',
content: res.result.getJSON("res")?.getString("phoneNumber"),
showCancel: false,
success(_) {
// 关闭登录页
this.univerifyManager?.close();
}
});
}).catch(err => {
console.error(JSON.stringify(err));
// 关闭登录页
this.univerifyManager?.close();
});
},
fail(err : LoginFail) {
console.error("login fail => " + err);
uni.showToast({
title: "登录失败",
icon: "error"
});
}
} as LoginOptions);
}
}
}
</script>
<style>
</style>
......@@ -55,13 +55,13 @@
num: 1,
str: 'ABC'
}
}).then<void>(res => {
}).then(res => {
const result = res.result
this.callFunctionResult = result
console.log(JSON.stringify(result))
uni.hideLoading()
this.notify(result['showMessage'] as string, '提示')
}).catch<void>((err : any | null) => {
}).catch((err : any | null) => {
const error = err as UniCloudError
this.callFunctionError = {
errCode: error.errCode,
......@@ -76,4 +76,4 @@
</script>
<style>
</style>
\ No newline at end of file
</style>
......@@ -67,16 +67,15 @@
.add({
num: 1,
tag: 'default-tag',
date: new Date(),
point: new db.Geo.Point(116, 38)
date: new Date()
})
.then<void>(res => {
.then(res => {
uni.hideLoading()
console.log(res)
this.addId = res.id
this.notify(`新增成功,id: ${res.id}`, '提示')
})
.catch<void>((err : any | null) => {
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
......@@ -95,7 +94,7 @@
num: 3,
tag: 'default-tag',
}])
.then<void>((res) => {
.then((res) => {
uni.hideLoading()
console.log(res)
console.log('JSON.stringify(res.inserted)', JSON.stringify(res.inserted))
......@@ -103,7 +102,7 @@
this.batchAddinserted = res.inserted
this.notify(`新增成功条数${res.inserted}, id列表: ${res.ids.join(',')}`, '提示')
})
.catch<void>((err : any | null) => {
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
......@@ -123,13 +122,13 @@
.skip(1)
.limit(2)
.get()
.then<void>(res => {
.then(res => {
uni.hideLoading()
console.log(res)
this.getData = res.data
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
})
.catch<void>((err : any | null) => {
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
......@@ -149,13 +148,13 @@
.skip(1)
.limit(2)
.get()
.then<void>(res => {
.then(res => {
uni.hideLoading()
console.log(res)
this.getWithCommandData = res.data
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
})
.catch<void>((err : any | null) => {
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
......@@ -173,13 +172,13 @@
.update({
num: 4
})
.then<void>(res => {
.then(res => {
uni.hideLoading()
console.log(res)
this.updateUpdated = res.updated
this.notify(`更新成功,更新了${res.updated}条数据`, '提示')
})
.catch<void>((err : any | null) => {
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
......@@ -195,13 +194,13 @@
'tag == "default-tag"'
)
.remove()
.then<void>(res => {
.then(res => {
uni.hideLoading()
console.log(res)
this.removeDeleted = res.deleted
this.notify(`删除成功,删掉了${res.deleted}条数据`, '提示')
})
.catch<void>((err : any | null) => {
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
......@@ -246,11 +245,11 @@
tag: "default-tag"
}])
})
.then<void>((_) : void => {
.then((_) : void => {
uni.hideLoading()
this.notify('数据初始化成功', '提示')
})
.catch<void>((err : any | null) => {
.catch((err : any | null) => {
uni.hideLoading()
console.error(err)
const error = err as UniCloudError
......@@ -270,13 +269,13 @@
.getTemp()
db.collection(local, foreign)
.get()
.then<void>(res => {
.then(res => {
uni.hideLoading()
console.log(res)
this.lookupData = res.data
this.notify(`联表查询成功,取到了${res.data.length}条数据`, '提示')
})
.catch<void>((err : any | null) => {
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
......@@ -287,4 +286,4 @@
</script>
<style>
</style>
\ No newline at end of file
</style>
......@@ -38,7 +38,7 @@
filePath: tempFilePath,
cloudPath: 'test.jpg'
})
.then<void>(function (res) {
.then(function (res) {
uni.hideLoading()
console.log(res)
uni.showModal({
......@@ -46,7 +46,7 @@
showCancel: false
});
})
.catch<void>(function (err : any | null) {
.catch(function (err : any | null) {
uni.hideLoading()
const error = err as UniCloudError
uni.showModal({
......@@ -68,4 +68,4 @@
</script>
<style>
</style>
\ No newline at end of file
</style>
......@@ -63,11 +63,11 @@
})
const title = this.todoTitle
const content = this.todoContent
todo.add(title, content).then<void>((res : UTSJSONObject) : void => {
todo.add(title, content).then((res : UTSJSONObject) : void => {
this.returnTodoTitle = res['title'] as string
this.returnTodoContent = res['content'] as string
this.notify(res['showMessage'] as string, '提示')
}).catch<void>((err : any | null) : void => {
}).catch((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
})
......@@ -78,9 +78,9 @@
retry: true
}
})
todoObj.randomFail().then<void>((res : UTSJSONObject) : void => {
todoObj.randomFail().then((res : UTSJSONObject) : void => {
this.notify(res['showMessage'] as string, '提示')
}).catch<void>((err : any | null) : void => {
}).catch((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
})
......@@ -89,16 +89,16 @@
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
todo.fail().then<void>((res : UTSJSONObject) : void => {
todo.fail().then((res : UTSJSONObject) : void => {
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
console.log('todo.fail: ', res);
}).catch<void>((err : any | null) : void => {
}).catch((err : any | null) : void => {
const error = err as UniCloudError
this.failErrCode = error.errCode as string
console.error(error)
if (this.isUniTest) {
uni.showToast({
title: err.errMsg
title: error.errMsg
})
}
})
......@@ -107,10 +107,10 @@
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
todo.success().then<void>((res : UTSJSONObject) : void => {
todo.success().then((res : UTSJSONObject) : void => {
this.successErrCode = res['errCode'] as number
this.notify(res['showMessage'] as string, '提示')
}).catch<void>((err : any | null) : void => {
}).catch((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
})
......@@ -121,4 +121,4 @@
<style>
</style>
\ No newline at end of file
</style>
......@@ -155,14 +155,6 @@
margin: 20rpx 0;
}
.websocket-room {
height: 40px;
line-height: 40px;
text-align: center;
border-bottom: solid 1px #dddddd;
margin-bottom: 20px;
}
.websocket-msg {
padding: 40px 0px;
text-align: center;
......
<template>
<view style="flex-grow: 1;">
<view class="common" style="background-color: red;z-index: 10;">
<text>z-index: 10</text>
<view>
<view class="common fixed" style="background-color: red;z-index: 10;">
<text>position: fixed</text>
<text>z-index: 10</text>
</view>
<view class="common fixed" style="background-color: green;z-index: 5;top: 175rpx;left: 175rpx;">
<text>position: fixed</text>
<text>z-index: 5</text>
</view>
</view>
<view ref="view" class="common" style="background-color: green;transform: translate(125rpx, -125rpx);z-index: 5;"
@click="changeZIndex(20)">
<text>z-index: {{zIndex}}</text>
<text>点击修改z-index</text>
</view>
<view class="common" style="background-color: blue;transform: translate(250rpx, -250rpx);">
<text>z-index: 0</text>
<view style="top: 500rpx;">
<view class="common" style="background-color: red;z-index: 10;">
<text>z-index: 10</text>
</view>
<view ref="view" class="common" style="background-color: green;z-index: 5;top: -75rpx;left: 175rpx;"
@click="changeZIndex(20)">
<text>z-index: {{zIndex}}</text>
<text>点击修改z-index</text>
</view>
<view class="common" style="background-color: blue;top: -150rpx;left: 350rpx;">
<text>z-index: 0</text>
</view>
</view>
</view>
</template>
......@@ -37,4 +49,8 @@
justify-content: center;
align-items: center;
}
</style>
\ No newline at end of file
.fixed {
position: fixed;
}
</style>
describe('component-native-list-view', () => {
let page
beforeAll(async () => {
//打开list-view测试页
page = await program.reLaunch('/pages/CSS/overflow/overflow')
await page.waitFor("image")
})
//检测overflow设置hidden,visible
it('check_view_overflow', async () => {
const image = await program.screenshot({
fullPage: true,
});
expect(image).toMatchImageSnapshot();
})
})
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1;">
<!-- #endif -->
<text style="font-size: 15px;">overflow=hidden效果 子元素是view</text>
<view class="backgroundview">
<view class="box-hidden">
<view style="width: 50px; height: 150px; background-color: greenyellow;"></view>
</view>
</view>
<text style="font-size: 15px;">overflow=visible效果 子元素是view</text>
<view class="backgroundview">
<view class="box-visible">
<view style="width: 50px; height: 150px; background-color: greenyellow;"></view>
</view>
</view>
<view style="flex-grow: 1">
<text style="font-size: 15px;">overflow=hidden效果 子元素是text</text>
<view class="backgroundview">
<view class="box-hidden">
<text class="text1">ABCDEFG</text>
</view>
</view>
<text style="font-size: 15px;">overflow=visible效果 子元素是text</text>
<view class="backgroundview">
<view class="box-visible">
<text class="text1">ABCDEFG</text>
</view>
</view>
<text style="font-size: 15px;">overflow=hidden效果 子元素是image</text>
<view class="backgroundview">
<view class="box-hidden">
<image style="width: 150px; height: 150px;" src="/static/uni.png"></image>
</view>
</view>
<text style="font-size: 15px;">overflow=visible效果 子元素是image</text>
<view class="backgroundview">
<view class="box-visible">
<image style="width: 150px; height: 150px;" src="/static/uni.png"></image>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
.backgroundview {
width: 300px;
height: 300px;
margin-bottom: 20px;
background-color: white;
justify-content: center;
align-items: center;
}
.box-hidden {
width: 100px;
height: 100px;
border-radius: 20px;
overflow: hidden;
background-color: green;
}
.box-visible {
width: 100px;
height: 100px;
border-radius: 20px;
overflow: visible;
background-color: green;
}
.text1 {
font-size: 50px;
}
</style>
......@@ -4,25 +4,44 @@
<text class="common" style="font-family: cursive">font-family: cursive</text>
<text class="common" style="font-family: AlimamaDaoLiTiTTF">font-family: 阿里妈妈刀隶体-ttf(网络字体下载后生效)</text>
<text class="common" style="font-family: AlimamaDaoLiTiOTF">font-family: 阿里妈妈刀隶体-otf</text>
<!-- <text class="common" style="font-family: AlimamaDaoLiTiWOFF">font-family: 阿里妈妈刀隶体-woff</text>
<text style="font-family: UniFontFamily;">style 加载非 static 目录字体文件:{{uniIcon}}</text>
<!-- <text class="common" style="font-family: AlimamaDaoLiTiWOFF">font-family: 阿里妈妈刀隶体-woff</text>
<text class="common" style="font-family: AlimamaDaoLiTiWOFF2">font-family: 阿里妈妈刀隶体-woff2</text> -->
</view>
</template>
<script lang="uts">
export default {
data() {
return {
uniIcon: '\ue100',
}
}
}
</script>
<style>
.common {
font-size: 20px;
line-height: 40px;
}
@font-face {
font-family: AlimamaDaoLiTiTTF;
src: url('https://native-res.dcloud.net.cn/uni-app-x/static/font/AlimamaDaoLiTi.ttf');
}
@font-face {
font-family: AlimamaDaoLiTiOTF;
src: url('/static/font/AlimamaDaoLiTi.otf');
}
/* @font-face {
@font-face {
font-family: UniFontFamily;
src: url('./uni.ttf');
}
/* @font-face {
font-family: AlimamaDaoLiTiWOFF;
src: url('/static/font/AlimamaDaoLiTi.woff');
}
......@@ -30,4 +49,4 @@
font-family: AlimamaDaoLiTiWOFF2;
src: url('/static/font/AlimamaDaoLiTi.woff2');
} */
</style>
</style>
\ No newline at end of file
<script>
import { type ItemType } from '@/components/enum-data/enum-data.vue'
import { ItemType } from '@/components/enum-data/enum-data'
export default {
data() {
return {
......
......@@ -117,7 +117,7 @@ export default {
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="content nvue">
<view class="content">
<page-head title="组件属性"></page-head>
<boolean-data
:defaultValue="false"
......
<template>
<page-head title="拖拽图标测试相关事件"></page-head>
<view class="container">
<view class="view-box">
<image class="icon" id="icon" src="../image/logo.png" @touchstart="onTouchStart" @touchcancel="onTouchCancel" @touchmove="onTouchMove" @touchend="onTouchEnd"></image>
</view>
</view>
<view v-if="touchEvent !== null">
<text class="title1">touches: </text>
<template v-for="(touch, index) in touchEvent!.touches" :key="index">
<text class="title2">touch[{{ index }}]:</text>
<text>identifier: {{touch.identifier}}</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
</template>
</view>
</template>
<script>
export default {
data() {
return {
move: false,
posX: 0,
posY: 0,
lastX: 0,
lastY: 0,
touchEvent: null as TouchEvent | null,
icon: null as Element | null
}
},
onReady() {
this.icon = uni.getElementById("icon")
},
methods: {
onTouchStart(e: TouchEvent) {
this.touchEvent = e
if(!this.move) {
this.move = true
this.posX = e.touches[0].screenX
this.posY = e.touches[0].screenY
}
},
onTouchMove(e: TouchEvent) {
this.touchEvent = e
let p = e.touches[0]
if(p.screenX == this.lastX && p.screenY == this.lastY){
return
}
let x = p.screenX-this.posX
let y = p.screenY-this.posY
this.lastX = p.screenX
this.lastY = p.screenY
this.icon?.style?.setProperty('transform', 'translate('+x+'px,'+y+'px)')
},
onTouchEnd(e: TouchEvent) {
if(e.touches.length == 0) {
this.resetIcon()
this.touchEvent = null
}
},
onTouchCancel(_: TouchEvent) {
this.resetIcon()
this.touchEvent = null
},
resetIcon() {
this.move = false;
this.posX = 0;
this.posY = 0;
this.icon?.style?.setProperty('transform', 'translate(0px,0px)')
}
}
}
</script>
<style>
.container {
width: 100%;
flex-direction: column;
align-items: center;
}
.view-box {
width: 300px;
height: 300px;
align-items: center;
justify-content: center;
border-style: solid;
}
.icon {
width: 100px;
height: 100px;
}
.msg-text {
margin-bottom: 100px;
}
.title1 {
margin-top: 10px;
font-size: 18px;
}
.title2 {
margin-top: 5px;
font-size: 16px;
}
</style>
describe('component-native-list-view', () => {
let page
beforeAll(async () => {
//打开list-view-multiplex测试页
page = await program.reLaunch('/pages/component/list-view/list-view-multiplex')
await page.waitFor('list-view')
})
//滚动list-view到底部 加载更多 如果异常则直接闪退
it('check_list_item_multiplex', async () => {
await page.callMethod('listViewScrollByY', 5000)
await page.waitFor(400)
await page.callMethod('listViewScrollByY', 100)
})
if (process.env.uniTestPlatformInfo.startsWith('android')) {
let page
beforeAll(async () => {
//打开list-view-multiplex测试页
page = await program.reLaunch('/pages/component/list-view/list-view-multiplex')
await page.waitFor('list-view')
})
//滚动list-view到底部 加载更多 如果异常则直接闪退
it('check_list_item_multiplex', async () => {
await page.callMethod('listViewScrollByY', 5000)
await page.waitFor(400)
await page.callMethod('listViewScrollByY', 100)
})
} else {
// TODO: web 端暂不支持
it('web', async () => {
expect(1).toBe(1)
})
}
})
<template>
<list-view id="listview" style="flex: 1;" show-scrollbar=false @scrolltolower="onScrollTolower">
<list-item v-for="index in item_count" class="item" @click="itemClick(index)">
<list-view id="listview" style="flex: 1;" show-scrollbar=false @scrolltolower="onScrollTolower">
<list-item v-for="index in item_count" class="item">
<text >item-------<text>{{index}}</text></text>
</list-item>
......@@ -19,13 +21,16 @@
},
methods: {
onScrollTolower(_: ScrollToLowerEvent) {
setTimeout(function(){
setTimeout(() => {
this.item_count += 20
}, 300)
},
//用于自动化测试
listViewScrollByY(y : number) {
this.listViewElement?.scrollBy(0, y)
},
itemClick(index: number) {
console.log("itemTextClick---"+index)
}
}
}
......
......@@ -110,7 +110,7 @@ export default {
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="content nvue">
<view class="content">
<page-head title="组件属性"></page-head>
<boolean-data
:defaultValue="false"
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
static/uni.png

4.1 KB | W: | H:

static/uni.png

4.2 KB | W: | H:

static/uni.png
static/uni.png
static/uni.png
static/uni.png
  • 2-up
  • Swipe
  • Onion skin
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册