提交 95edcade 编写于 作者: DCloud-yyl's avatar DCloud-yyl

Merge branch 'dev' into alpha

# Conflicts:
#	pages/API/get-file-system-manager/get-file-system-manager.test.js
#	pages/API/get-file-system-manager/get-file-system-manager.uvue
...@@ -19,8 +19,8 @@ export function createApp() { ...@@ -19,8 +19,8 @@ export function createApp() {
str: 'default reactive string', str: 'default reactive string',
num: 0, num: 0,
bool: false, bool: false,
}) } as UTSJSONObject)
app.config.globalProperties.globalPropertiesFn = () : string => { app.config.globalProperties.globalPropertiesFn = function () : string {
console.log('this.globalPropertiesStr', this.globalPropertiesStr) console.log('this.globalPropertiesStr', this.globalPropertiesStr)
console.log('this.globalPropertiesNum', this.globalPropertiesNum) console.log('this.globalPropertiesNum', this.globalPropertiesNum)
return `globalPropertiesStr: ${this.globalPropertiesStr}, globalPropertiesNum: ${this.globalPropertiesNum}` return `globalPropertiesStr: ${this.globalPropertiesStr}, globalPropertiesNum: ${this.globalPropertiesNum}`
......
...@@ -344,13 +344,14 @@ ...@@ -344,13 +344,14 @@
"navigationBarTitleText": "数据存储" "navigationBarTitleText": "数据存储"
} }
}, },
// #ifndef WEB
{ {
"path": "pages/API/get-file-system-manager/get-file-system-manager", "path": "pages/API/get-file-system-manager/get-file-system-manager",
"style": { "style": {
"navigationBarTitleText": "沙盒文件管理" "navigationBarTitleText": "文件管理"
} }
}, },
// #endif
{ {
"path": "pages/API/action-sheet/action-sheet", "path": "pages/API/action-sheet/action-sheet",
"style": { "style": {
...@@ -543,6 +544,7 @@ ...@@ -543,6 +544,7 @@
"navigationBarTitleText": "get-window-info" "navigationBarTitleText": "get-window-info"
} }
}, },
// #ifndef WEB
{ {
"path": "pages/API/facial-recognition-verify/facial-recognition-verify", "path": "pages/API/facial-recognition-verify/facial-recognition-verify",
"style": { "style": {
...@@ -550,6 +552,7 @@ ...@@ -550,6 +552,7 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
// #endif
{ {
"path": "pages/API/element-takesnapshot/element-takesnapshot", "path": "pages/API/element-takesnapshot/element-takesnapshot",
"style": { "style": {
...@@ -1084,12 +1087,14 @@ ...@@ -1084,12 +1087,14 @@
"enablePullDownRefresh" : false "enablePullDownRefresh" : false
} }
}, },
// #ifndef WEB
{ {
"path": "pages/template/schema/schema", "path": "pages/template/schema/schema",
"style": { "style": {
"navigationBarTitleText": "打开schema示例" "navigationBarTitleText": "打开schema示例"
} }
}, },
// #endif
{ {
"path": "pages/component/sticky-section/sticky-section", "path": "pages/component/sticky-section/sticky-section",
"style": { "style": {
...@@ -1104,6 +1109,7 @@ ...@@ -1104,6 +1109,7 @@
"enablePullDownRefresh" : false "enablePullDownRefresh" : false
} }
}, },
// #ifndef WEB
{ {
"path": "pages/template/share/share", "path": "pages/template/share/share",
"style": { "style": {
...@@ -1111,6 +1117,7 @@ ...@@ -1111,6 +1117,7 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
// #endif
{ {
"path" : "pages/component/general-event/touch-event", "path" : "pages/component/general-event/touch-event",
"style" : "style" :
......
...@@ -8,7 +8,7 @@ describe('ExtApi-DownloadFile', () => { ...@@ -8,7 +8,7 @@ describe('ExtApi-DownloadFile', () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
await page.waitFor(600); await page.waitFor(600);
await page.callMethod('jest_downloadFile'); await page.callMethod('jest_downloadFile');
await page.waitFor(500); await page.waitFor(1000);
res = await page.data('jest_result'); res = await page.data('jest_result');
}); });
......
...@@ -43,21 +43,21 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -43,21 +43,21 @@ describe('ExtApi-FileManagerTest', () => {
}) })
// 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败 // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
const btnUnLinkFileButton = await page.$('.btn-clear-file') const btnUnLinkFileButton = await page.$('#btn-clear-file')
await btnUnLinkFileButton.tap() await btnUnLinkFileButton.tap()
await isDone() await isDone()
// 清除文件夹 // 清除文件夹
const btnRmDirButton = await page.$('.btn-remove-dir') const btnRmDirButton = await page.$('#btn-remove-dir')
await btnRmDirButton.tap() await btnRmDirButton.tap()
await isDone() await isDone()
// 重新创建测试目录 // 重新创建测试目录
const btnMkdDirButton = await page.$('.btn-mkdir') const btnMkdDirButton = await page.$('#btn-mkdir')
await btnMkdDirButton.tap() await btnMkdDirButton.tap()
await isDone() await isDone()
const btnReadDirButton = await page.$('.btn-read-dir') const btnReadDirButton = await page.$('#btn-read-dir')
await btnReadDirButton.tap() await btnReadDirButton.tap()
await isDone() await isDone()
...@@ -104,7 +104,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -104,7 +104,7 @@ describe('ExtApi-FileManagerTest', () => {
expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\"]") expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\"]")
// 测试写入文件 // 测试写入文件
const btnWriteFileButton = await page.$('.btn-write-file') const btnWriteFileButton = await page.$('#btn-write-file')
await btnWriteFileButton.tap() await btnWriteFileButton.tap()
await isDone() await isDone()
// 检查目录列表数量 // 检查目录列表数量
...@@ -115,7 +115,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -115,7 +115,7 @@ describe('ExtApi-FileManagerTest', () => {
fileListSuccess = await getData('fileListSuccess') fileListSuccess = await getData('fileListSuccess')
expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"1.txt\"]") expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"1.txt\"]")
// 获取和对比 文件内容 // 获取和对比 文件内容
const btnReadFileButton = await page.$('.btn-read-file') const btnReadFileButton = await page.$('#btn-read-file')
await btnReadFileButton.tap() await btnReadFileButton.tap()
await isDone() await isDone()
let readFileRet = await getData('readFileRet') let readFileRet = await getData('readFileRet')
...@@ -134,7 +134,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -134,7 +134,7 @@ describe('ExtApi-FileManagerTest', () => {
readFileRet = await getData('readFileRet') readFileRet = await getData('readFileRet')
expect(readFileRet).toEqual("If you were a teardrop;In my eye,For fear of losing you,I would never cry.And if the golden sun,Should cease to shine its light,Just one smile from you,Would make my whole world bright.") expect(readFileRet).toEqual("If you were a teardrop;In my eye,For fear of losing you,I would never cry.And if the golden sun,Should cease to shine its light,Just one smile from you,Would make my whole world bright.")
const btnGetFileInfoButton = await page.$('.btn-get-file-info') const btnGetFileInfoButton = await page.$('#btn-get-file-info')
await btnGetFileInfoButton.tap() await btnGetFileInfoButton.tap()
await isDone() await isDone()
...@@ -161,7 +161,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -161,7 +161,7 @@ describe('ExtApi-FileManagerTest', () => {
copyFromFile:"a/1.txt", copyFromFile:"a/1.txt",
copyToFile:"a/2.txt" copyToFile:"a/2.txt"
}) })
const btnCopyFileButton = await page.$('.btn-copy-file') const btnCopyFileButton = await page.$('#btn-copy-file')
await btnCopyFileButton.tap() await btnCopyFileButton.tap()
await isDone() await isDone()
...@@ -181,7 +181,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -181,7 +181,7 @@ describe('ExtApi-FileManagerTest', () => {
renameToFile:"a/3.txt" renameToFile:"a/3.txt"
}) })
const btnRenameFileButton = await page.$('.btn-rename-file') const btnRenameFileButton = await page.$('#btn-rename-file')
await btnRenameFileButton.tap() await btnRenameFileButton.tap()
await isDone() await isDone()
...@@ -211,22 +211,22 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -211,22 +211,22 @@ describe('ExtApi-FileManagerTest', () => {
// 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败 // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
const btnUnLinkFileButton = await page.$('.btn-unlink-file') const btnUnLinkFileButton = await page.$('#btn-unlink-file')
await btnUnLinkFileButton.tap() await btnUnLinkFileButton.tap()
await isDone() await isDone()
// 清除文件夹 // 清除文件夹
const btnRmDirButton = await page.$('.btn-remove-dir') const btnRmDirButton = await page.$('#btn-remove-dir')
await btnRmDirButton.tap() await btnRmDirButton.tap()
await isDone() await isDone()
// 重新创建测试目录 // 重新创建测试目录
const btnMkdDirButton = await page.$('.btn-mkdir') const btnMkdDirButton = await page.$('#btn-mkdir')
await btnMkdDirButton.tap() await btnMkdDirButton.tap()
await isDone() await isDone()
const btnReadDirButton = await page.$('.btn-read-dir') const btnReadDirButton = await page.$('#btn-read-dir')
await btnReadDirButton.tap() await btnReadDirButton.tap()
await isDone() await isDone()
...@@ -283,7 +283,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -283,7 +283,7 @@ describe('ExtApi-FileManagerTest', () => {
// 获取和对比 文件内容 // 获取和对比 文件内容
const btnReadFileButton = await page.$('.btn-read-file') const btnReadFileButton = await page.$('#btn-read-file')
await btnReadFileButton.tap() await btnReadFileButton.tap()
await isDone() await isDone()
let readFileRet = await getData('readFileRet') let readFileRet = await getData('readFileRet')
...@@ -299,7 +299,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -299,7 +299,7 @@ describe('ExtApi-FileManagerTest', () => {
}) })
const btnWriteFileButton = await page.$('.btn-write-file') const btnWriteFileButton = await page.$('#btn-write-file')
await btnWriteFileButton.tap() await btnWriteFileButton.tap()
await isDone() await isDone()
...@@ -325,7 +325,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -325,7 +325,7 @@ describe('ExtApi-FileManagerTest', () => {
getFileInfoAlgorithm:"md5", getFileInfoAlgorithm:"md5",
}) })
const btnGetFileInfoButton = await page.$('.btn-get-file-info') const btnGetFileInfoButton = await page.$('#btn-get-file-info')
await btnGetFileInfoButton.tap() await btnGetFileInfoButton.tap()
await isDone() await isDone()
...@@ -367,7 +367,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -367,7 +367,7 @@ describe('ExtApi-FileManagerTest', () => {
renameToFile:"a/没有提前创建的目录/3.txt" renameToFile:"a/没有提前创建的目录/3.txt"
}) })
const btnRenameFileButton = await page.$('.btn-rename-file') const btnRenameFileButton = await page.$('#btn-rename-file')
await btnRenameFileButton.tap() await btnRenameFileButton.tap()
await isDone() await isDone()
...@@ -404,7 +404,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -404,7 +404,7 @@ describe('ExtApi-FileManagerTest', () => {
copyToFile:"a/提前创建的目录/4.txt" copyToFile:"a/提前创建的目录/4.txt"
}) })
const btnCopyFileButton = await page.$('.btn-copy-file') const btnCopyFileButton = await page.$('#btn-copy-file')
await btnCopyFileButton.tap() await btnCopyFileButton.tap()
await isDone() await isDone()
...@@ -457,22 +457,22 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -457,22 +457,22 @@ describe('ExtApi-FileManagerTest', () => {
// 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败 // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
const btnClearFileButton = await page.$('.btn-clear-file') const btnClearFileButton = await page.$('#btn-clear-file')
await btnClearFileButton.tap() await btnClearFileButton.tap()
await isDone() await isDone()
// 清除文件夹 // 清除文件夹
const btnRmDirButton = await page.$('.btn-remove-dir') const btnRmDirButton = await page.$('#btn-remove-dir')
await btnRmDirButton.tap() await btnRmDirButton.tap()
await isDone() await isDone()
// 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录 // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
const btnMkdDirButton = await page.$('.btn-mkdir') const btnMkdDirButton = await page.$('#btn-mkdir')
await btnMkdDirButton.tap() await btnMkdDirButton.tap()
await isDone() await isDone()
const btnReadDirButton = await page.$('.btn-read-dir') const btnReadDirButton = await page.$('#btn-read-dir')
await btnReadDirButton.tap() await btnReadDirButton.tap()
await isDone() await isDone()
...@@ -483,7 +483,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -483,7 +483,7 @@ describe('ExtApi-FileManagerTest', () => {
// 检查资源文件,此时不存在 // 检查资源文件,此时不存在
const btnAccessFileButton = await page.$('.btn-access-file') const btnAccessFileButton = await page.$('#btn-access-file')
await btnAccessFileButton.tap() await btnAccessFileButton.tap()
await isDone() await isDone()
...@@ -505,7 +505,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -505,7 +505,7 @@ describe('ExtApi-FileManagerTest', () => {
expect(accessFileRet).toEqual('access:ok') expect(accessFileRet).toEqual('access:ok')
// 尝试删除资源,期望失败 // 尝试删除资源,期望失败
const btnUnLinkFileButton = await page.$('.btn-unlink-file') const btnUnLinkFileButton = await page.$('#btn-unlink-file')
await btnUnLinkFileButton.tap() await btnUnLinkFileButton.tap()
await isDone() await isDone()
...@@ -520,7 +520,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -520,7 +520,7 @@ describe('ExtApi-FileManagerTest', () => {
copyFromFile:"static/list-mock/safe.png", copyFromFile:"static/list-mock/safe.png",
copyToFile:"a/从代码目录拷贝的资源.png" copyToFile:"a/从代码目录拷贝的资源.png"
}) })
const btnCopyFileButton = await page.$('.btn-copy-file') const btnCopyFileButton = await page.$('#btn-copy-file')
await btnCopyFileButton.tap() await btnCopyFileButton.tap()
await isDone() await isDone()
...@@ -548,7 +548,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -548,7 +548,7 @@ describe('ExtApi-FileManagerTest', () => {
expect(accessFileRet).toEqual('') expect(accessFileRet).toEqual('')
// 从页面的按钮触发一次文件复制 // 从页面的按钮触发一次文件复制
const btnCopyStaticFileButton = await page.$('.btn-copyStatic-file') const btnCopyStaticFileButton = await page.$('#btn-copyStatic-file')
await btnCopyStaticFileButton.tap() await btnCopyStaticFileButton.tap()
await isDone() await isDone()
...@@ -598,21 +598,21 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -598,21 +598,21 @@ describe('ExtApi-FileManagerTest', () => {
}) })
// 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败 // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
const btnUnLinkFileButton = await page.$('.btn-unlink-file') const btnUnLinkFileButton = await page.$('#btn-unlink-file')
await btnUnLinkFileButton.tap() await btnUnLinkFileButton.tap()
await isDone() await isDone()
// 清除文件夹 // 清除文件夹
const btnRmDirButton = await page.$('.btn-remove-dir') const btnRmDirButton = await page.$('#btn-remove-dir')
await btnRmDirButton.tap() await btnRmDirButton.tap()
await isDone() await isDone()
// 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录 // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
const btnMkdDirButton = await page.$('.btn-mkdir') const btnMkdDirButton = await page.$('#btn-mkdir')
await btnMkdDirButton.tap() await btnMkdDirButton.tap()
await isDone() await isDone()
const btnReadDirButton = await page.$('.btn-read-dir') const btnReadDirButton = await page.$('#btn-read-dir')
await btnReadDirButton.tap() await btnReadDirButton.tap()
await isDone() await isDone()
...@@ -622,17 +622,17 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -622,17 +622,17 @@ describe('ExtApi-FileManagerTest', () => {
expect(JSON.stringify(fileListSuccess)).toEqual('[]') expect(JSON.stringify(fileListSuccess)).toEqual('[]')
// 先用utf-8 写入内容 // 先用utf-8 写入内容
const btnWriteFileButton = await page.$('.btn-write-file') const btnWriteFileButton = await page.$('#btn-write-file')
await btnWriteFileButton.tap() await btnWriteFileButton.tap()
await isDone() await isDone()
const btnReadFileButton = await page.$('.btn-read-file') const btnReadFileButton = await page.$('#btn-read-file')
await btnReadFileButton.tap() await btnReadFileButton.tap()
await isDone() await isDone()
let readFileRet = await getData('readFileRet') let readFileRet = await getData('readFileRet')
expect(readFileRet).toEqual("我爱北京天安门,天安门前太阳升") expect(readFileRet).toEqual("我爱北京天安门,天安门前太阳升")
const btnGetFileInfoButton = await page.$('.btn-get-file-info') const btnGetFileInfoButton = await page.$('#btn-get-file-info')
await btnGetFileInfoButton.tap() await btnGetFileInfoButton.tap()
await isDone() await isDone()
...@@ -729,7 +729,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -729,7 +729,7 @@ describe('ExtApi-FileManagerTest', () => {
}) })
// 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败 // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
const btnUnLinkFileButton = await page.$('.btn-unlink-file') const btnUnLinkFileButton = await page.$('#btn-unlink-file')
await btnUnLinkFileButton.tap() await btnUnLinkFileButton.tap()
await isDone() await isDone()
...@@ -746,15 +746,15 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -746,15 +746,15 @@ describe('ExtApi-FileManagerTest', () => {
await isDone() await isDone()
// // 清除文件夹 // // 清除文件夹
const btnRmDirButton = await page.$('.btn-remove-dir') const btnRmDirButton = await page.$('#btn-remove-dir')
await btnRmDirButton.tap() await btnRmDirButton.tap()
await isDone() await isDone()
// // 重新创建测试目录 // // 重新创建测试目录
const btnMkdDirButton = await page.$('.btn-mkdir') const btnMkdDirButton = await page.$('#btn-mkdir')
await btnMkdDirButton.tap() await btnMkdDirButton.tap()
await isDone() await isDone()
const btnReadDirButton = await page.$('.btn-read-dir') const btnReadDirButton = await page.$('#btn-read-dir')
await btnReadDirButton.tap() await btnReadDirButton.tap()
await isDone() await isDone()
...@@ -777,11 +777,11 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -777,11 +777,11 @@ describe('ExtApi-FileManagerTest', () => {
let lastFailError = await getData('lastFailError') let lastFailError = await getData('lastFailError')
console.log(lastFailError) console.log(lastFailError)
const btnWriteFileButton = await page.$('.btn-write-file') const btnWriteFileButton = await page.$('#btn-write-file')
await btnWriteFileButton.tap() await btnWriteFileButton.tap()
await isDone() await isDone()
const btnStatFileButton = await page.$('.btn-stat-file') const btnStatFileButton = await page.$('#btn-stat-file')
await btnStatFileButton.tap() await btnStatFileButton.tap()
await isDone() await isDone()
...@@ -819,7 +819,7 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -819,7 +819,7 @@ describe('ExtApi-FileManagerTest', () => {
copyFromFile:'file:///android_asset/uni-uts/uni-prompt/toast_error.png', copyFromFile:'file:///android_asset/uni-uts/uni-prompt/toast_error.png',
copyToFile:'a/m/3.txt', copyToFile:'a/m/3.txt',
}) })
const btnCopyFileButton = await page.$('.btn-copy-file') const btnCopyFileButton = await page.$('#btn-copy-file')
await btnCopyFileButton.tap() await btnCopyFileButton.tap()
await isDone() await isDone()
......
...@@ -4,20 +4,20 @@ ...@@ -4,20 +4,20 @@
<!-- #endif --> <!-- #endif -->
<text>显示简易操作日志,详细日志需真机运行查看</text><button size="mini" @click="log=''">清空日志</button> <text>显示简易操作日志,详细日志需真机运行查看</text><button size="mini" @click="log=''">清空日志</button>
<text style="margin: 2px; padding: 2px; border: 1px solid #000000;" :value="log" /> <text style="margin: 2px; padding: 2px; border: 1px solid #000000;" :value="log" />
<button type="primary" @tap="statFileInfoTest" class="btn-stat-file">递归获取目录files的Stats对象{{statFile}}</button> <button type="primary" @tap="statFileInfoTest" id="btn-stat-file">递归获取目录files的Stats对象{{statFile}}</button>
<button type="primary" @tap="mkdirTest" class="btn-mkdir">创建文件夹{{mkdirFile}}</button> <button type="primary" @tap="mkdirTest" id="btn-mkdir">创建文件夹{{mkdirFile}}</button>
<button type="primary" @tap="writeFileTest" class="btn-write-file">覆盖写入文件{{writeFile}}</button> <button type="primary" @tap="writeFileTest" id="btn-write-file">覆盖写入文件{{writeFile}}</button>
<button type="primary" @tap="readDirTest" class="btn-read-dir">读取文件夹{{readDir}}</button> <button type="primary" @tap="readDirTest" id="btn-read-dir">读取文件夹{{readDir}}</button>
<button type="primary" @tap="readFileTest" class="btn-read-file">读取文件{{readFile}}</button> <button type="primary" @tap="readFileTest" id="btn-read-file">读取文件{{readFile}}</button>
<button type="primary" @tap="copyFileTest" class="btn-copy-file">复制文件{{copyFromFile}}到{{copyToFile}}</button> <button type="primary" @tap="copyFileTest" id="btn-copy-file">复制文件{{copyFromFile}}到{{copyToFile}}</button>
<button type="primary" @tap="renameFileTest" <button type="primary" @tap="renameFileTest"
class="btn-rename-file">重命名文件{{renameFromFile}}到{{renameToFile}}</button> id="btn-rename-file">重命名文件{{renameFromFile}}到{{renameToFile}}</button>
<button type="primary" @tap="accessFileTest" class="btn-access-file">判断文件{{accessFile}}是否存在</button> <button type="primary" @tap="accessFileTest" id="btn-access-file">判断文件{{accessFile}}是否存在</button>
<button type="primary" @tap="getFileInfoTest" class="btn-get-file-info">获取文件信息{{getFileInfoFile}}</button> <button type="primary" @tap="getFileInfoTest" id="btn-get-file-info">获取文件信息{{getFileInfoFile}}</button>
<button type="primary" @tap="unlinkTest" class="btn-unlink-file">删除文件{{unlinkFile}}</button> <button type="primary" @tap="unlinkTest" id="btn-unlink-file">删除文件{{unlinkFile}}</button>
<button type="primary" @tap="copyStaticToFilesTest" class="btn-copyStatic-file">从static目录复制文件到a目录</button> <button type="primary" @tap="copyStaticToFilesTest" id="btn-copyStatic-file">从static目录复制文件到a目录</button>
<button type="primary" @tap="unlinkAllFileTest" class="btn-clear-file">删除文件夹{{rmDirFile}}下的所有文件</button> <button type="primary" @tap="unlinkAllFileTest" id="btn-clear-file">删除文件夹{{rmDirFile}}下的所有文件</button>
<button type="primary" @tap="rmdirTest" class="btn-remove-dir">删除文件夹{{rmDirFile}}</button> <button type="primary" @tap="rmdirTest" id="btn-remove-dir">删除文件夹{{rmDirFile}}</button>
<!-- #ifdef APP --> <!-- #ifdef APP -->
</scroll-view> </scroll-view>
<!-- #endif --> <!-- #endif -->
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
methods: { methods: {
statFileInfoTest: function (e : any) { statFileInfoTest: function (_ : any) {
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
fileManager.stat({ fileManager.stat({
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
} as StatOptions) } as StatOptions)
}, },
getFileInfoTest: function (e : any) { getFileInfoTest: function () {
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
fileManager.getFileInfo({ fileManager.getFileInfo({
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
}, },
copyFileTest: function (e : any) { copyFileTest: function () {
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
} as CopyFileOptions) } as CopyFileOptions)
}, },
renameFileTest: function (e : any) { renameFileTest: function () {
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
...@@ -199,7 +199,7 @@ ...@@ -199,7 +199,7 @@
} as RenameOptions) } as RenameOptions)
}, },
readDirTest: function (e : any) { readDirTest: function () {
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
fileManager.readdir({ fileManager.readdir({
dirPath: `${this.basePath}${this.readDir}`, dirPath: `${this.basePath}${this.readDir}`,
...@@ -231,7 +231,7 @@ ...@@ -231,7 +231,7 @@
}, },
writeFileTest: function (e : any) { writeFileTest: function (_ : any) {
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
fileManager.writeFile({ fileManager.writeFile({
...@@ -263,7 +263,7 @@ ...@@ -263,7 +263,7 @@
}, },
readFileTest: function (e : any) { readFileTest: function () {
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
...@@ -294,7 +294,7 @@ ...@@ -294,7 +294,7 @@
} as ReadFileOptions) } as ReadFileOptions)
}, },
rmdirTest: function (e : any) { rmdirTest: function () {
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
fileManager.rmdir({ fileManager.rmdir({
dirPath: `${this.basePath}${this.rmDirFile}`, dirPath: `${this.basePath}${this.rmDirFile}`,
...@@ -322,7 +322,7 @@ ...@@ -322,7 +322,7 @@
} as RmDirOptions) } as RmDirOptions)
}, },
mkdirTest: function (e : any) { mkdirTest: function () {
// 准备测试数据 // 准备测试数据
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
...@@ -353,7 +353,7 @@ ...@@ -353,7 +353,7 @@
} as MkDirOptions) } as MkDirOptions)
}, },
accessFileTest: function (e : any) { accessFileTest: function () {
this.accessFileRet = '' this.accessFileRet = ''
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
fileManager.access({ fileManager.access({
...@@ -382,7 +382,7 @@ ...@@ -382,7 +382,7 @@
} as AccessOptions) } as AccessOptions)
}, },
unlinkTest: function (e : any) { unlinkTest: function () {
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
...@@ -410,7 +410,7 @@ ...@@ -410,7 +410,7 @@
} }
} as UnLinkOptions) } as UnLinkOptions)
}, },
unlinkAllFileTest: function (e : any) { unlinkAllFileTest: function () {
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
fileManager.readdir({ fileManager.readdir({
dirPath: `${this.basePath}${this.rmDirFile}`, dirPath: `${this.basePath}${this.rmDirFile}`,
...@@ -460,7 +460,7 @@ ...@@ -460,7 +460,7 @@
} }
} as ReadDirOptions) } as ReadDirOptions)
}, },
copyStaticToFilesTest: function (e : any) { copyStaticToFilesTest: function () {
let fileManager = uni.getFileSystemManager() let fileManager = uni.getFileSystemManager()
......
...@@ -22,7 +22,7 @@ async function request(page, method, header, data, url) { ...@@ -22,7 +22,7 @@ async function request(page, method, header, data, url) {
header: header header: header
}) })
res = await page.callMethod('jest_request') res = await page.callMethod('jest_request')
await page.waitFor(200); await page.waitFor(500);
res = await page.data('jest_result'); res = await page.data('jest_result');
expect(res).toBe(true) expect(res).toBe(true)
} }
......
...@@ -40,10 +40,10 @@ ...@@ -40,10 +40,10 @@
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<view class="uni-btn-v"> <view class="uni-btn-v">
<button class="uni-btn btn-getStorageInfoASync" type="primary" @tap="getStorageInfo"> <button class="uni-btn btn-getStorageInfoASync" type="primary" @tap="getStorageInfo">
获取存储概述-异步 获取存储概述信息-异步
</button> </button>
<button class="uni-btn btn-getStorageInfoSync" @tap="getStorageInfoSync"> <button class="uni-btn btn-getStorageInfoSync" @tap="getStorageInfoSync">
获取存储概述-同步 获取存储概述信息-同步
</button> </button>
</view> </view>
<text>{{ storageInfo }}</text> <text>{{ storageInfo }}</text>
......
...@@ -8,7 +8,7 @@ describe('ExtApi-UploadFile', () => { ...@@ -8,7 +8,7 @@ describe('ExtApi-UploadFile', () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
await page.waitFor(600); await page.waitFor(600);
await page.callMethod('jest_uploadFile'); await page.callMethod('jest_uploadFile');
await page.waitFor(500); await page.waitFor(1000);
res = await page.data('jest_result'); res = await page.data('jest_result');
}); });
......
...@@ -8,7 +8,7 @@ describe('ExtApi-WebSocket', () => { ...@@ -8,7 +8,7 @@ describe('ExtApi-WebSocket', () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
await page.waitFor(600); await page.waitFor(600);
await page.callMethod('jest_connectSocket'); await page.callMethod('jest_connectSocket');
await page.waitFor(500); await page.waitFor(1500);
res = await page.data('jest_result'); res = await page.data('jest_result');
}); });
......
describe('component-native-list-view', () => { describe('component-native-overflow', () => {
let page let page
beforeAll(async () => { beforeAll(async () => {
//打开list-view测试页 //打开list-view测试页
......
...@@ -21,10 +21,18 @@ ...@@ -21,10 +21,18 @@
<text class="text">点击修改Background</text> <text class="text">点击修改Background</text>
<view class="base-style transition-background" id="styleBackground" @click="changeBackground"></view> <view class="base-style transition-background" id="styleBackground" @click="changeBackground"></view>
</view> </view>
<view class="container">
<text class="text">动态修改Background</text>
<view class="base-style" id="propertyStyleBackground" @click="propertyChangeBackground"></view>
</view>
<view class="container"> <view class="container">
<text class="text">点击修改Transform</text> <text class="text">点击修改Transform</text>
<view class="base-style transition-transform" id="styleTransform" @click="changeTransform"></view> <view class="base-style transition-transform" id="styleTransform" @click="changeTransform"></view>
</view> </view>
<view class="container">
<text class="text">点击修改Transform(含transform-origin)</text>
<view class="base-style transition-transform" style="transform-origin: 0 0;" id="styleTransformWithOrigin" @click="changeTransformWithOrigin"></view>
</view>
<view class="container"> <view class="container">
<text class="text">点击修改Border</text> <text class="text">点击修改Border</text>
<view class="base-style transition-border" id="styleBorder" @click="changeBorder"></view> <view class="base-style transition-border" id="styleBorder" @click="changeBorder"></view>
...@@ -57,6 +65,11 @@ ...@@ -57,6 +65,11 @@
styleBorder: null as Element | null, styleBorder: null as Element | null,
isTransitionstylePosition: false, isTransitionstylePosition: false,
stylePosition: null as Element | null, stylePosition: null as Element | null,
isSetTransition: false,
isTransitionpropertystyleBackground: false,
propertyStyleBackground: null as Element | null,
isTransitionStyleTransformWithOrigin: false,
styleTransformWithOrigin: null as Element | null,
} }
}, },
onReady() { onReady() {
...@@ -67,6 +80,8 @@ ...@@ -67,6 +80,8 @@
this.styleTransform = uni.getElementById("styleTransform") this.styleTransform = uni.getElementById("styleTransform")
this.styleBorder = uni.getElementById("styleBorder") this.styleBorder = uni.getElementById("styleBorder")
this.stylePosition = uni.getElementById("stylePosition") this.stylePosition = uni.getElementById("stylePosition")
this.propertyStyleBackground = uni.getElementById("propertyStyleBackground")
this.styleTransformWithOrigin = uni.getElementById("styleTransformWithOrigin")
}, },
methods: { methods: {
changeWidthOrHeight() { changeWidthOrHeight() {
...@@ -107,6 +122,18 @@ ...@@ -107,6 +122,18 @@
) )
this.isTransitionstyleBackground = !this.isTransitionstyleBackground this.isTransitionstyleBackground = !this.isTransitionstyleBackground
}, },
propertyChangeBackground() {
if (!this.isSetTransition) {
this.propertyStyleBackground?.style?.setProperty("transition-property", "background-color")
this.propertyStyleBackground?.style?.setProperty("transition-duration", "1000")
this.isSetTransition = true
}
this.propertyStyleBackground?.style?.setProperty("background-color", this.isTransitionpropertystyleBackground
? 'brown'
: 'black'
)
this.isTransitionpropertystyleBackground = !this.isTransitionpropertystyleBackground
},
changeTransform() { changeTransform() {
this.styleTransform?.style?.setProperty("transform", this.isTransitionStyleTransform this.styleTransform?.style?.setProperty("transform", this.isTransitionStyleTransform
? 'rotate(0deg)' ? 'rotate(0deg)'
...@@ -114,6 +141,13 @@ ...@@ -114,6 +141,13 @@
) )
this.isTransitionStyleTransform = !this.isTransitionStyleTransform this.isTransitionStyleTransform = !this.isTransitionStyleTransform
}, },
changeTransformWithOrigin() {
this.styleTransformWithOrigin?.style?.setProperty("transform", this.isTransitionStyleTransformWithOrigin
? 'scaleX(1)'
: 'scaleX(0)'
)
this.isTransitionStyleTransformWithOrigin = !this.isTransitionStyleTransformWithOrigin
},
changeBorder() { changeBorder() {
this.styleBorder?.style?.setProperty("border-color", this.isTransitionstyleBorder this.styleBorder?.style?.setProperty("border-color", this.isTransitionstyleBorder
? 'brown' ? 'brown'
......
...@@ -139,6 +139,14 @@ describe('component-native-input', () => { ...@@ -139,6 +139,14 @@ describe('component-native-input', () => {
// await page.waitFor(500) // await page.waitFor(500)
// }) // })
it("cursor-color", async () => {
await page.setData({
cursor_color: "transparent",
})
await page.waitFor(500)
expect(await (await page.$('.uni-input-cursor-color')).property("cursor-color")).toBe("transparent")
})
it("afterAllTestScreenshot", async () => { it("afterAllTestScreenshot", async () => {
const image = await program.screenshot({ const image = await program.screenshot({
fullPage: true fullPage: true
......
...@@ -136,6 +136,15 @@ ...@@ -136,6 +136,15 @@
</view> </view>
</view> </view>
<view>
<view class="uni-title" @click="changeCursorColor">
<text class="uni-title-text">设置光标颜色为透明(点击本行文字生效,再点复位)</text>
</view>
<view class="uni-input-wrapper">
<input class="uni-input uni-input-cursor-color" :cursor-color="cursor_color" value="光标颜色" />
</view>
</view>
<view> <view>
<view class="uni-title"> <view class="uni-title">
<text class="uni-title-text">键盘弹起时,自动上推页面</text> <text class="uni-title-text">键盘弹起时,自动上推页面</text>
...@@ -219,6 +228,7 @@ ...@@ -219,6 +228,7 @@
inputClearValue: '', inputClearValue: '',
showPassword: true, showPassword: true,
cursor: -1, cursor: -1,
cursor_color: "#3393E2",
selectionStart: -1, selectionStart: -1,
selectionEnd: -1, selectionEnd: -1,
inputEventDetail: '', inputEventDetail: '',
...@@ -290,6 +300,13 @@ ...@@ -290,6 +300,13 @@
}, },
test_check_input_value():number { test_check_input_value():number {
return this.onMaxLengthInputValue.length return this.onMaxLengthInputValue.length
},
changeCursorColor(){
if(this.cursor_color == "#3393E2"){
this.cursor_color = "transparent"
}else{
this.cursor_color = "#3393E2"
}
} }
} }
} }
......
...@@ -61,6 +61,13 @@ describe('component-native-textarea', () => { ...@@ -61,6 +61,13 @@ describe('component-native-textarea', () => {
} = await textarea.size() } = await textarea.size()
expect(height).toBeLessThanOrEqual(150) expect(height).toBeLessThanOrEqual(150)
}) */ }) */
it("cursor-color", async () => {
await page.setData({
cursor_color: "transparent",
})
await page.waitFor(500)
expect(await textarea.property("cursor-color")).toBe("transparent")
})
it("inputmode", async () => { it("inputmode", async () => {
const inputmodeEnum = await page.data("inputmode_enum") const inputmodeEnum = await page.data("inputmode_enum")
...@@ -73,16 +80,4 @@ describe('component-native-textarea', () => { ...@@ -73,16 +80,4 @@ describe('component-native-textarea', () => {
await page.waitFor(500) await page.waitFor(500)
} }
}) })
it("confirm-type", async () => {
const inputmodeEnum = await page.data("confirm_type_enum")
for (var i = 0; i < inputmodeEnum.length; i++) {
var x = inputmodeEnum[i]
console.log(x['value'], x['name'])
await page.callMethod("radio_change_confirm_type_enum", x['value']);
await page.waitFor(500)
expect(await textarea.property("confirm-type")).toEqual(x['name'])
await page.waitFor(500)
}
})
}); });
...@@ -12,9 +12,8 @@ export default { ...@@ -12,9 +12,8 @@ export default {
auto_focus_boolean: false, auto_focus_boolean: false,
default_value:"", default_value:"",
maxlength:-1, maxlength:-1,
confirm_type_enum: [{"value":0,"name":"send"},{"value":1,"name":"search"},{"value":2,"name":"next"},{"value":3,"name":"go"},{"value":4,"name":"done"}] as ItemType[],
confirm_type_enum_current: 0,
inputmode_enum: [{"value":0,"name":"none"},{"value":1,"name":"text"},{"value":2,"name":"decimal"},{"value":3,"name":"numeric"},{"value":4,"name":"tel"},{"value":5,"name":"search"},{"value":6,"name":"email"},{"value":7,"name":"url"}] as ItemType[], inputmode_enum: [{"value":0,"name":"none"},{"value":1,"name":"text"},{"value":2,"name":"decimal"},{"value":3,"name":"numeric"},{"value":4,"name":"tel"},{"value":5,"name":"search"},{"value":6,"name":"email"},{"value":7,"name":"url"}] as ItemType[],
cursor_color: "#3393E2",
inputmode_enum_current: 0 inputmode_enum_current: 0
} }
}, },
...@@ -40,7 +39,7 @@ export default { ...@@ -40,7 +39,7 @@ export default {
change_confirm_hold_boolean(checked : boolean) { this.confirm_hold_boolean = checked }, change_confirm_hold_boolean(checked : boolean) { this.confirm_hold_boolean = checked },
change_focus_boolean(checked : boolean) { this.focus_boolean = checked }, change_focus_boolean(checked : boolean) { this.focus_boolean = checked },
change_auto_focus_boolean(checked : boolean) { this.auto_focus_boolean = checked }, change_auto_focus_boolean(checked : boolean) { this.auto_focus_boolean = checked },
radio_change_confirm_type_enum(checked : number) { this.confirm_type_enum_current = checked }, change_cursor_color_boolean(checked : boolean) { if(checked){ this.cursor_color = "transparent"} else {this.cursor_color = "#3393E2"}},
radio_change_inputmode_enum(checked : number) { this.inputmode_enum_current = checked } radio_change_inputmode_enum(checked : number) { this.inputmode_enum_current = checked }
} }
} }
...@@ -53,12 +52,12 @@ export default { ...@@ -53,12 +52,12 @@ export default {
class="uni-textarea" class="uni-textarea"
:auto-focus="auto_focus_boolean" :auto-focus="auto_focus_boolean"
:focus="focus_boolean" :focus="focus_boolean"
:confirm-type="confirm_type_enum[confirm_type_enum_current].name"
:confirm-hold="confirm_hold_boolean" :confirm-hold="confirm_hold_boolean"
:auto-height="auto_height_boolean" :auto-height="auto_height_boolean"
:fixed="fixed_boolean" :fixed="fixed_boolean"
:show-confirm-bar="show_confirm_bar_boolean" :show-confirm-bar="show_confirm_bar_boolean"
:adjust-position="adjust_position_boolean" :adjust-position="adjust_position_boolean"
:cursor-color="cursor_color"
:inputmode="inputmode_enum[inputmode_enum_current].name" :inputmode="inputmode_enum[inputmode_enum_current].name"
:maxlength="maxlength" :maxlength="maxlength"
@click="textarea_click" @click="textarea_click"
...@@ -119,11 +118,11 @@ export default { ...@@ -119,11 +118,11 @@ export default {
title="自动获取焦点" title="自动获取焦点"
@change="change_auto_focus_boolean" @change="change_auto_focus_boolean"
></boolean-data> ></boolean-data>
<enum-data <boolean-data
:items="confirm_type_enum" :defaultValue="false"
title="设置键盘右下角按钮的文字" title="改变光标颜色为透明"
@change="radio_change_confirm_type_enum" @change="change_cursor_color_boolean"
></enum-data> ></boolean-data>
<enum-data <enum-data
:items="inputmode_enum" :items="inputmode_enum"
title="是一个枚举属性,它提供了用户在编辑元素或其内容时可能输入的数据类型的提示。在符合条件的高版本webview里,uni-app的 web 和 app-vue 平台中可使用本属性。" title="是一个枚举属性,它提供了用户在编辑元素或其内容时可能输入的数据类型的提示。在符合条件的高版本webview里,uni-app的 web 和 app-vue 平台中可使用本属性。"
......
...@@ -404,7 +404,7 @@ ...@@ -404,7 +404,7 @@
name: '文件', name: '文件',
pages: [ pages: [
{ {
name: 'fileSystemManager沙盒文件管理', name: 'fileSystemManager文件管理',
url: 'get-file-system-manager' url: 'get-file-system-manager'
}, },
] as Page[], ] as Page[],
......
<template> <template>
<view> <view id="viewshot">
<button class="button" @click="shareText('https://uniapp.dcloud.io/uni-app-x','分享到')">分享</button> <button class="button" @click="shareText('https://uniapp.dcloud.io/uni-app-x','分享到')">分享文本</button>
<button class="button" @click="shareSnapShot">指定view截图并分享</button>
</view> </view>
</template> </template>
<script> <script>
import Intent from 'android.content.Intent'; import Intent from 'android.content.Intent';
import File from 'java.io.File';
export default { export default {
data() { data() {
...@@ -14,7 +16,7 @@ import Intent from 'android.content.Intent'; ...@@ -14,7 +16,7 @@ import Intent from 'android.content.Intent';
} }
}, },
methods: { methods: {
shareText(text:string,title:string){ shareText(text : string, title : string) {
const context = UTSAndroid.getUniActivity()!; const context = UTSAndroid.getUniActivity()!;
const intent = new Intent(Intent.ACTION_SEND) const intent = new Intent(Intent.ACTION_SEND)
intent.setType("text/plain"); intent.setType("text/plain");
...@@ -22,12 +24,37 @@ import Intent from 'android.content.Intent'; ...@@ -22,12 +24,37 @@ import Intent from 'android.content.Intent';
context.startActivity(Intent.createChooser(intent, title)); context.startActivity(Intent.createChooser(intent, title));
// 这里是简单的文本分享示例,如需分享文件图片,需要使用fileProvider // 这里是简单的文本分享示例,如需分享文件图片,需要使用fileProvider
}, },
shareSnapShot() {
uni.getElementById("viewshot")?.takeSnapshot(
{
success: function (res) {
// 打印截图文件临时路径
console.log(res.tempFilePath)
const context = UTSAndroid.getUniActivity()!;
const intent = new Intent(Intent.ACTION_SEND)
intent.setType("image/*");
let file = new File(res.tempFilePath)
const uri = UTSAndroid.getFileProviderUri(file) //3.99支持
intent.putExtra(Intent.EXTRA_STREAM, uri);
context.startActivity(Intent.createChooser(intent, "分享到"));
},
fail: function (res) {
console.log(res)
uni.showToast({
icon: 'error',
title: '截图失败'
})
}
}
)
},
} }
} }
</script> </script>
<style> <style>
.button { .button {
margin: 30rpx; margin: 30rpx;
} }
</style> </style>
## 1.0.3(2023-10-27)
遵循UniError规范
## 1.0.2(2023-10-27)
修改文档
## 1.0.1(2023-10-27)
支持js层调用
## 1.0.0(2023-10-26)
安装apk的插件
{
"id": "uni-installApk",
"displayName": "uni-installApk",
"version": "1.0.3",
"description": "uni-installApk",
"keywords": [
"uni-installApk"
],
"repository": "",
"engines": {
"HBuilderX": "^3.94"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "android.permission.REQUEST_INSTALL_PACKAGES"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"uni-ext-api": {
"uni": {
"installApk": {
"name": "installApk",
"app": {
"js": true,
"kotlin": true,
"swift": false
}
}
}
},
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "y"
},
"App": {
"app-android": "y",
"app-ios": "n"
},
"H5-mobile": {
"Safari": "n",
"Android Browser": "n",
"微信浏览器(Android)": "n",
"QQ浏览器(Android)": "n"
},
"H5-pc": {
"Chrome": "n",
"IE": "n",
"Edge": "n",
"Firefox": "n",
"Safari": "n"
},
"小程序": {
"微信": "n",
"阿里": "n",
"百度": "n",
"字节跳动": "n",
"QQ": "n",
"钉钉": "n",
"快手": "n",
"飞书": "n",
"京东": "n"
},
"快应用": {
"华为": "n",
"联盟": "n"
}
}
}
}
}
\ No newline at end of file
# uni-installApk
## 使用说明
Android平台安装Apk
**注意: 3.95以下需要自定义基座**
### uni.installApk(options : InstallApkOptions):void
安装apk
参数说明
```
type InstallApkOptions = {
/**
* apk文件地址
*/
filePath : string,
/**
* 接口调用成功的回调函数
* @defaultValue null
*/
success ?: (res : any) => void,
/**
* 接口调用失败的回调函数
* @defaultValue null
*/
fail ?: (err : any) => void,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
* @defaultValue null
*/
complete ?: (res : any) => void,
}
```
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="io.dcloud.uni.installApk">
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
</manifest>
\ No newline at end of file
import { InstallApkOptions, InstallApkSuccess } from "../interface.uts"
import { InstallApkFailImpl } from "../unierror.uts"
import Intent from 'android.content.Intent';
import Build from 'android.os.Build';
import File from 'java.io.File';
import FileProvider from 'androidx.core.content.FileProvider';
import Context from 'android.content.Context';
import Uri from 'android.net.Uri';
export function installApk(options : InstallApkOptions) : void {
const context = UTSAndroid.getAppContext() as Context
const filePath = UTSAndroid.convert2AbsFullPath(options.filePath)
const apkFile = new File(filePath)
if (!apkFile.exists() && !apkFile.isFile()) {
let error = new InstallApkFailImpl(1300002);
options.fail?.(error)
options.complete?.(error)
return
}
const intent = new Intent()
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.setAction(Intent.ACTION_VIEW)
if (Build.VERSION.SDK_INT >= 24) {
const authority = context.getPackageName() + ".dc.fileprovider"
const apkUri = FileProvider.getUriForFile(context, authority, apkFile)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
} else {
intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
}
context.startActivity(intent)
const success : InstallApkSuccess = {
errMsg: "success"
}
options.success?.(success)
options.complete?.(success)
}
\ No newline at end of file
declare namespace UniNamespace {
interface InstallApkSuccess {
/**
* 安装成功消息
*/
errMsg : string
}
type InstallApkErrorCode = 1300002
interface InstallApkFail {
errCode : InstallApkErrorCode
}
type InstallApkComplete = any
type InstallApkSuccessCallback = (res : InstallApkSuccess) => void
type InstallApkFailCallback = (err : InstallApkFail) => void
type InstallApkCompleteCallback = (res : InstallApkComplete) => void
interface InstallApkOptions {
/**
* apk文件地址
*/
filePath : string,
/**
* 接口调用成功的回调函数
* @defaultValue null
*/
success ?: InstallApkSuccessCallback | null,
/**
* 接口调用失败的回调函数
* @defaultValue null
*/
fail ?: InstallApkFailCallback | null,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
* @defaultValue null
*/
complete ?: InstallApkCompleteCallback | null
}
}
declare interface Uni {
/**
* installApk()
* @description
* 安装apk
* @param {InstallApkOptions}
* @return {void}
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4",
* "uniVer": "3.94+",
* "unixVer": "3.94+"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
* @example
```typescript
uni.installApk({
filePath: "/xx/xx/xx.apk",
complete: (res: any) => {
console.log("complete => " + JSON.stringify(res));
}
});
```
*/
installApk(options : UniNamespace.InstallApkOptions) : void
}
export interface Uni {
/**
* installApk()
* @description
* 安装apk
* @param {InstallApkOptions}
* @return {void}
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4",
* "uniVer": "3.94+",
* "unixVer": "3.94+"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
* @example
```typescript
uni.installApk({
filePath: "/xx/xx/xx.apk",
complete: (res: any) => {
console.log("complete => " + JSON.stringify(res));
}
});
```
*/
installApk(options : InstallApkOptions) : void
}
export type InstallApkSuccess = {
/**
* 安装成功消息
*/
errMsg : string
}
export type InstallApkComplete = any
export type InstallApkSuccessCallback = (res : InstallApkSuccess) => void
/**
* 错误码
* - 1300002 找不到文件
*/
export type InstallApkErrorCode = 1300002
/**
* 网络请求失败的错误回调参数
*/
export interface InstallApkFail extends IUniError {
errCode : InstallApkErrorCode
};
export type InstallApkFailCallback = (err : InstallApkFail) => void
export type InstallApkCompleteCallback = (res : InstallApkComplete) => void
export type InstallApkOptions = {
/**
* apk文件地址
*/
filePath : string,
/**
* 接口调用成功的回调函数
* @defaultValue null
*/
success ?: InstallApkSuccessCallback | null,
/**
* 接口调用失败的回调函数
* @defaultValue null
*/
fail ?: InstallApkFailCallback | null,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
* @defaultValue null
*/
complete ?: InstallApkCompleteCallback | null
}
\ No newline at end of file
import { InstallApkErrorCode, InstallApkFail } from "./interface.uts"
/**
* 错误主题
*/
export const UniErrorSubject = 'uni-installApk';
/**
* 错误码
* @UniError
*/
export const UniErrors : Map<InstallApkErrorCode, string> = new Map([
/**
* 找不到文件
*/
[1300002, 'No such file'],
]);
export class InstallApkFailImpl extends UniError implements InstallApkFail {
override errCode : InstallApkErrorCode
constructor(errCode : InstallApkErrorCode) {
super();
this.errSubject = UniErrorSubject;
this.errCode = errCode;
this.errMsg = UniErrors[errCode] ?? "";
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册