diff --git a/README.md b/README.md index a16e8cb..3cc166c 100644 --- a/README.md +++ b/README.md @@ -104,4 +104,4 @@ FinClip 小程序支持以下第三方框架,您可以在以下框架的基础 [![Stargazers repo roster for @finogeeks/miniprogram-demo](https://reporoster.com/stars/finogeeks/miniprogram-demo)](https://github.com/finogeeks/miniprogram-demo/stargazers) ## Forkers -[![Forkers repo roster for @finogeeks/miniprogram-demo](https://reporoster.com/forks/finogeeks/miniprogram-demo)](https://github.com/finogeeks/miniprogram-demo/network/members) +[![Forkers repo roster for @finogeeks/miniprogram-demo](https://reporoster.com/forks/finogeeks/miniprogram-demo)](https://github.com/finogeeks/miniprogram-demo/network/members) \ No newline at end of file diff --git a/app.js b/app.js index e8613fa..b0da6b2 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,7 @@ //app.js App({ - onLaunch: function () { + onLaunch: function (opt) { + console.log('onLaunch: ', opt) // 展示本地存储能力 var logs = wx.getStorageSync('logs') || [] logs.unshift(Date.now()) diff --git a/app.json b/app.json index a1759e7..ea94f5e 100644 --- a/app.json +++ b/app.json @@ -32,8 +32,14 @@ "pages/component/movable/movable", "pages/component/doc-web-view/doc-web-view", "pages/component/page-meta/page-meta", + "pages/component/map/map", + "pages/component/multiple-map/multiple-map", + "pages/component/keyboard-accessory/keyboard-accessory", "pages/component/camera/camera", - "pages/component/cover-view/cover-view" + "pages/component/cover-view/cover-view", + "pages/component/webrtc/webrtc", + "pages/component/page-container/page-container", + "pages/component/share-element/share-element" ], "subpackages": [ { @@ -83,7 +89,10 @@ "pages/FileSystemManager/writefile", "pages/EventChannel/firstpage/index", "pages/EventChannel/secondpage/index", - "pages/Accelerometer/index" + "pages/Accelerometer/index", + "pages/getRandomValues/getRandomValues", + "pages/checkIsOpenAccessibility/index", + "pages/locationapi/index" ] } ], diff --git a/fide.project.config.json b/fide.project.config.json new file mode 100644 index 0000000..edc8dad --- /dev/null +++ b/fide.project.config.json @@ -0,0 +1,12 @@ +{ + "description": "项目配置文件", + "packOptions": { + "ignore": [] + }, + "setting": { + "useOldBuilder": false + }, + "compileType": "miniprogram", + "projectname": "applet-demo", + "isGameTourist": false +} \ No newline at end of file diff --git a/image/anne.png b/image/anne.png new file mode 100644 index 0000000..9e00fb5 Binary files /dev/null and b/image/anne.png differ diff --git a/image/bob.png b/image/bob.png new file mode 100644 index 0000000..33dc61a Binary files /dev/null and b/image/bob.png differ diff --git a/image/demo1.jpg b/image/demo1.jpg new file mode 100644 index 0000000..f876dc3 Binary files /dev/null and b/image/demo1.jpg differ diff --git a/image/demo2.jpg b/image/demo2.jpg new file mode 100644 index 0000000..c0071b2 Binary files /dev/null and b/image/demo2.jpg differ diff --git a/image/duck.gif b/image/duck.gif new file mode 100644 index 0000000..54632da Binary files /dev/null and b/image/duck.gif differ diff --git a/image/emma.png b/image/emma.png new file mode 100644 index 0000000..fe441c4 Binary files /dev/null and b/image/emma.png differ diff --git a/image/frank.png b/image/frank.png new file mode 100644 index 0000000..aee6e91 Binary files /dev/null and b/image/frank.png differ diff --git a/image/green_tri.png b/image/green_tri.png index a83f974..40ddb2b 100644 Binary files a/image/green_tri.png and b/image/green_tri.png differ diff --git a/image/icon64_appwx_logo.png b/image/icon64_appwx_logo.png index 91a38f9..4a751d3 100644 Binary files a/image/icon64_appwx_logo.png and b/image/icon64_appwx_logo.png differ diff --git a/image/icon_API.png b/image/icon_API.png index 76e6cb9..5a9f649 100644 Binary files a/image/icon_API.png and b/image/icon_API.png differ diff --git a/image/icon_API_HL.png b/image/icon_API_HL.png index 6fa3707..423f306 100644 Binary files a/image/icon_API_HL.png and b/image/icon_API_HL.png differ diff --git a/image/icon_API_dark.png b/image/icon_API_dark.png index 7b8f2e2..f8db640 100644 Binary files a/image/icon_API_dark.png and b/image/icon_API_dark.png differ diff --git a/image/icon_cloud.png b/image/icon_cloud.png index 8530b16..48244ff 100644 Binary files a/image/icon_cloud.png and b/image/icon_cloud.png differ diff --git a/image/icon_cloud_HL.png b/image/icon_cloud_HL.png index 7285cc8..eb5c23a 100644 Binary files a/image/icon_cloud_HL.png and b/image/icon_cloud_HL.png differ diff --git a/image/icon_cloud_dark.png b/image/icon_cloud_dark.png index d30fc6f..aa2555e 100644 Binary files a/image/icon_cloud_dark.png and b/image/icon_cloud_dark.png differ diff --git a/image/icon_component.png b/image/icon_component.png index 301f579..bc88a63 100644 Binary files a/image/icon_component.png and b/image/icon_component.png differ diff --git a/image/icon_component_HL.png b/image/icon_component_HL.png index 65c3fcb..1d98c0b 100644 Binary files a/image/icon_component_HL.png and b/image/icon_component_HL.png differ diff --git a/image/icon_component_dark.png b/image/icon_component_dark.png index 1228520..2842352 100644 Binary files a/image/icon_component_dark.png and b/image/icon_component_dark.png differ diff --git a/image/icon_foot.png b/image/icon_foot.png index 3288ee1..67d9f07 100644 Binary files a/image/icon_foot.png and b/image/icon_foot.png differ diff --git a/image/location.png b/image/location.png index b9e731e..8dc57c3 100644 Binary files a/image/location.png and b/image/location.png differ diff --git a/image/logo.png b/image/logo.png new file mode 100644 index 0000000..e5b0627 Binary files /dev/null and b/image/logo.png differ diff --git a/image/olivia.png b/image/olivia.png new file mode 100644 index 0000000..4025830 Binary files /dev/null and b/image/olivia.png differ diff --git a/image/pause.png b/image/pause.png index 9acb73d..8abff52 100644 Binary files a/image/pause.png and b/image/pause.png differ diff --git a/image/play.png b/image/play.png index 982f2f2..b025c6c 100644 Binary files a/image/play.png and b/image/play.png differ diff --git a/image/plus.png b/image/plus.png index 73ddfe3..83857c3 100644 Binary files a/image/plus.png and b/image/plus.png differ diff --git a/image/plus_dark.png b/image/plus_dark.png index b9bb683..27cbae5 100644 Binary files a/image/plus_dark.png and b/image/plus_dark.png differ diff --git a/image/record.png b/image/record.png index a62ef81..3161053 100644 Binary files a/image/record.png and b/image/record.png differ diff --git a/image/scott.png b/image/scott.png new file mode 100644 index 0000000..7bb975f Binary files /dev/null and b/image/scott.png differ diff --git a/image/share.png b/image/share.png index baac7f9..a478782 100644 Binary files a/image/share.png and b/image/share.png differ diff --git a/image/stop.png b/image/stop.png index 9e65f3e..fcb6cb0 100644 Binary files a/image/stop.png and b/image/stop.png differ diff --git a/image/susan.png b/image/susan.png new file mode 100644 index 0000000..1b553fc Binary files /dev/null and b/image/susan.png differ diff --git a/image/trash.png b/image/trash.png index 83d68f3..8920900 100644 Binary files a/image/trash.png and b/image/trash.png differ diff --git a/image/wechat.png b/image/wechat.png index 470931c..a761227 100644 Binary files a/image/wechat.png and b/image/wechat.png differ diff --git a/image/wechatHL.png b/image/wechatHL.png index 3c5e52b..1b4ad2f 100644 Binary files a/image/wechatHL.png and b/image/wechatHL.png differ diff --git a/packageAPI/pages/FileSystemManager/writefile.js b/packageAPI/pages/FileSystemManager/writefile.js index 9e678cc..93aa8d3 100644 --- a/packageAPI/pages/FileSystemManager/writefile.js +++ b/packageAPI/pages/FileSystemManager/writefile.js @@ -1,526 +1,167 @@ // pages/writefile/index.js console.log('page 打印', wx.env.USER_DATA_PATH); + +// const base64 = require('../../utils/data') +let fs = null Page({ /** * 页面的初始数据 */ data: { - filePath: `${wx.env.USER_DATA_PATH}/d`, + // base64, + // 配置路径循环生成 + paths: [ + `finfile://usr/a.txt`, + `finfile://usr/b.txt`, + `finfile://usr/c.txt`, + `finfile://usr/test`, + `finfile://usr/1.zip`, + `finfile://usr/test/a.txt`, + `finfile://usr/test/b.txt`, + `finfile://usr/test/c.txt`, + `finfile://temp/c.txt`, + `finfile://temp/a/b/c`, + `finfile://store/c.txt`, + `http://usr/1.zip`, + `http://usr/aa`, + `http://usr/aa/ab.txt`, + `http://store/a.txt`, + `http://store/b.txt`, + `http://store/test`, + `wxfile://usr/aa`, + `wxfile://usr/aa/abc.txt`, + + ], + + + filePath: '', data: "", - encoding: "utf-8", - source: "", - readencoding:"utf-8" - + encoding: "", + recursive: null, + path1: '', + path2: '', + flag: '', + position: '', + offset:'', + entries:'' }, - readFileFunc(path, encoding,position,length) { - console.log('readFile encoding:', encoding, '; path:', path); - - const fs = wx.getFileSystemManager() - fs.readFile({ - filePath: path, - encoding, - position, - length, - - success(res) { - console.log('readFile success:', res) - }, - fail(res) { - console.log('readFile fail:', res) - } + onLoad() { + this.setData({ + filePath: `${wx.env.USER_DATA_PATH}` }) + fs = wx.getFileSystemManager() }, - readFileSyncFunc(path, encoding, position, length) { - console.log('readFileSync encoding:', encoding, '; path:', path); - - const fs = wx.getFileSystemManager() - - try { - const res = fs.readFileSync(path, encoding,position,length) - console.log('readFileSync res:', res) - } catch (e) { - console.log('readFileSync error:', e) - } - }, - - //同步 - writeFileSync() { - const fs = wx.getFileSystemManager() - try { - const res = fs.writeFileSync( - /* `${wx.env.USER_DATA_PATH}/hello.mp3` */null, "", 'utf8' - ) - console.log('writeFileSync:', res) - - } catch (e) { - console.error('writeFileSync err:', e) - } - }, - - //异步文件测试 - writeFile() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - filePath: this.data.filePath, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(this.data.filePath, this.data.encoding,1,3) - this.readFileFunc(this.data.filePath, this.data.encoding,2,4) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, - - writeFileStartRange() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - filePath: this.data.filePath, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(this.data.filePath, this.data.encoding,3,1) - this.readFileFunc(this.data.filePath, this.data.encoding,3,1) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, - - writeFileLength0() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - filePath: this.data.filePath, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(this.data.filePath, this.data.encoding,2,0) - this.readFileFunc(this.data.filePath, this.data.encoding,2,0) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, - - writeFileLengthPoint() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - filePath: this.data.filePath, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(this.data.filePath, this.data.encoding,2,1.2) - this.readFileFunc(this.data.filePath, this.data.encoding,2,1.2) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } + setParams(e) { + const { key } = e.currentTarget.dataset + this.setData({ + [key]: e.detail.value }) }, - writeFileReadnoEncoding() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - const path = `${wx.env.USER_DATA_PATH}/nc` - fs.writeFile({ - filePath:path, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log('写文件路径:' ,path), - this.readFileSyncFunc(path) - this.readFileFunc(path) - }, - fail(res) { - console.log('writeFile fail:', res) -// console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, + - writeFilePermission() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - - data: this.data.data, - filePath:`${wx.env.USER_DATA_PATH}/d`, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(this.data.filePath, this.data.encoding,1,3) - this.readFileFunc(this.data.filePath, this.data.encoding,2,4) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, - - writeFileNotFound() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - - data: this.data.data, - filePath:`${wx.env.USER_DATA_PATH}/d`, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(`${wx.env.USER_DATA_PATH}/dl`,this.data.encoding,1,3) - this.readFileFunc(`${wx.env.USER_DATA_PATH}/dl`, this.data.encoding,2,4) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, - - base64File() { - const path = `${wx.env.USER_DATA_PATH}/d` - wx.fileToBase64({ - url: path, - success: (res) => { - console.log('fileToBase64 success: ', res) - console.log(res.data) - }, - fail(res) { - console.log('fileToBase64 fail: ', res) - } - }) - }, - - saveFile() { - wx.saveFile({ - filePath: `${wx.env.USER_DATA_PATH}/d`, - success(res) { - console.log("保存成功", res) - }, - fail(res) { - console.log("保存失败", res) - } - }) - }, - - - - downFile() { + downZipSave(){ + const fs=wx.getFileSystemManager() wx.downloadFile({ - url: `${wx.env.USER_DATA_PATH}/d`, - success(res) { - console.log("下载成功", res) - }, - fail(res) { - console.log("下载失败", res) - } - }) - }, - - //图片 - writeImage() { - const fs = wx.getFileSystemManager() - const path = `${wx.env.USER_DATA_PATH}/a` - fs.writeFile({ - filePath: path, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeImagSuccess', res) - console.log(path) - this.readFileSyncFunc(path, 'base64') - this.readFileFunc(path, 'base64') - }, - fail(res) { - console.log('writeImageFail', res) - } - }) - }, - - imagePreview() { - wx.previewImage({ - urls: [`${wx.env.USER_DATA_PATH}/a`], - success(res) { - console.log("图片预览成功", res) - }, - fail(res) { - console.log("图片预览失败", res) - } - }) - }, - - - imageCompress() { - - wx.compressImage({ - src: '`${wx.env.USER_DATA_PATH}/a`', - - success(res) { - console.log("图片压缩成功", res) - }, - fail(res) { - console.log("图片压缩失败", res) - } - }) - }, - - - imageSaveToPhotosAlbum() { - wx.saveImageToPhotosAlbum({ - filePath: `${wx.env.USER_DATA_PATH}/a`, - - success(res) { - console.log("图片保存到相册成功", res) - }, - fail(res) { - console.log("图片保存到相册失败", res) - } - }) - }, - - fileUpload() { - - wx.uploadFile({ - filePath: `${wx.env.USER_DATA_PATH}/a`, - name: 'file', - url: 'https://finchat-mop-b.finogeeks.club/api/v1/mop/finstore/dev/files?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjUxOTQyMjgsImZjaWQiOiI1ZmYzZDhmZWU3YzNiNTAwMDExYWQxMmEiLCJpYXQiOjE2MjUxODcwMjgsImlzcyI6Ijc1NWUxNnFrNVZLUnBlcWhKM1IySVFwV2NOdlQ5TWJOIn0.IQXdjiH5One-GVsU9E5KTze0fXJ7InJE-BrmcQs9yIc', - success(res) { - console.log("文件上传成功", res) - }, - fail(res) { - console.log("文件上传失败", res) - } - }) - }, - - - - //视频 - writeVideo() { - const fs = wx.getFileSystemManager() - const path = `${wx.env.USER_DATA_PATH}/b.mp4` - fs.writeFile({ - filePath: path, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeVideo Success', res) - console.log(`${wx.env.USER_DATA_PATH}/b.mp4`) - - this.readFileSyncFunc(path, 'base64') - this.readFileFunc(path, 'base64') - }, - - fail(res) { - console.log('writeFail', res) - } - }) - }, - - videoSaveToPhotosAlbum() { - wx.saveVideoToPhotosAlbum({ - filePath: `${wx.env.USER_DATA_PATH}/b.mp4`, - success(res) { - console.log("视频保存到相册成功", res) - }, - fail(res) { - console.log("视频保存到相册失败", res) - } - }) - }, - - - mediaPreview() { - wx.previewMedia({ - sources: [ - { - "url": `${wx.env.USER_DATA_PATH}/b.mp4`, - "type": "video" - } - ], - success(res) { - console.log("视频播放成功", res) - }, - fail(res) { - console.log("视频播放失败", res) - } - }) - }, - - - videoPreview() { - wx.previewVideo({ - - url: `${wx.env.USER_DATA_PATH}/b.mp4`, - autoplay: true, - success(res) { - console.log('视频播放成功', res) - }, - fail(res) { - console.log('播放失败', res) - } - }) - - }, - - //语音 - writeAudio() { - const fs = wx.getFileSystemManager() - const path = `${wx.env.USER_DATA_PATH}/c.mp3` - fs.writeFile({ - filePath: path, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeAudio Success', res) - console.log(`${wx.env.USER_DATA_PATH}/c.mp3`) - this.readFileSyncFunc(path, 'base64',10,13) - this.readFileFunc(path, 'base64',20,15) - }, - - fail(res) { - console.log('writeFail', res) - } - }) - }, - - innerAudioPlay() { - const ctx = wx.createInnerAudioContext() - ctx.src = `${wx.env.USER_DATA_PATH}/c.mp3` - /* ctx.seek(20) */ - ctx.play() - ctx.onPlay(() => { - console.log('开始播放') - }) - ctx.onError((res) => { - console.log(res.errMsg) - console.log(res.errCode) - console.log(res) - }) - }, - - - voicePlay() { - - wx.playVoice({ - filePath: `${wx.env.USER_DATA_PATH}/c.mp3`, - success(res) { - console.log("播放成功", res) - }, - fail(res) { - console.log("播放失败", res) - } - }) - }, - - - documentOpen() { - const fs = wx.getFileSystemManager() - fs.writeFile({ - filePath: `${wx.env.USER_DATA_PATH}/wd.doc`, - data: this.data.data, - encoding: this.data.encoding, - success(res) { - console.log('writeSuccess', res) - console.log(`${wx.env.USER_DATA_PATH}/wd.doc`) - wx.openDocument({ - filePath: `${wx.env.USER_DATA_PATH}/wd.doc`, - - success(res) { - console.log("文件打开成功", res) + url: 'https://app.finogeeks.com/finchat/sdk/FinApplet-dev-2.34.0-alpha20210826v06.zip', + success(res){ + console.log("文件下载成功",res) + fs.saveFile({ + tempFilePath: res.tempFilePath, + filePath: `${wx.env.USER_DATA_PATH}/1.zip`, + success(res){ + console.log("zip保存成功",res) }, - fail(res) { - console.log("文件打开失败", res) + fail(res){ + console.log("zip保存失败",res) } }) - }, - fail(res) { - console.log('writeFail', res) } }) }, + invokeApi(e) { + console.log('点击了 button') + const { api, encoding, data, recursive, flag, length, entries, position, offset, arr = [], set, arrayBuffer, ...params } = e.currentTarget.dataset + if (api) { + // 将配置的参数转换为 data 参数 + Object.keys(params).forEach(value => { + const key = params[value] + params[value] = this.data[key] + }) - - - - - writeFileArrayBuffer() { - console.log("打印地址", this.data.filePath) - /* console.log("打印data",this.data.data) */ - const fs = wx.getFileSystemManager() - fs.writeFile({ - data: wx.base64ToArrayBuffer(this.data.data), - filePath: `${wx.env.USER_DATA_PATH}/d`, - encoding: this.data.encoding, - success(res) { - console.log('writeSuccess', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - }, - fail(res) { - console.log('writeFail', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) + // encoding 和 data 有配置就是 true,直接赋值 + if (encoding !== undefined) { + params.encoding = this.data.encoding + } + + if (entries !== undefined) { + params.entries = this.data.entries + } + + if (length !== undefined) { + params.length = this.data.length + } + if (position !== undefined) { + params.position = this.data.position + } + + if (data !== undefined) { + params.data = this.data.data + } + if (recursive !== undefined) { + params.recursive = this.data.recursive + } + + if (flag !== undefined) { + params.flag = this.data.flag + } + + if (arrayBuffer !== undefined) { + params.arrayBuffer = new ArrayBuffer(arrayBuffer) + } + + if (api.endsWith('Sync') && arr && arr.length) { + let list = arr.split(',').map(key => this.data[key]) + console.log('准备执行同步 api:', api, list) + fs[api].apply(this, list) + } else { + console.log('准备执行 api:', api, params) + const res = fs[api]({ + ...params, + success: (res) =>{ + if (set && res[set]) { + this.setData({ + [set]: res[set] + }) + } + console.log('调用成功 success') + console.log(res) + }, + fail (res) { + console.log('调用失败 fail') + console.log(res) + } + }) + if (res) { + console.log('调用成功 success:', res) + } + if (set) { + this.setData({ + [set]: res + }) + } } - }) - }, - - bindchangepath(e) { - this.setData({ - filePath: e.detail.value - }) - }, - - bindchangeencoding(e) { - this.setData({ - encoding: e.detail.value - }) - }, - - bindchangedata(e) { - this.setData({ - data: e.detail.value - }) - }, - - + } + } }) + \ No newline at end of file diff --git a/packageAPI/pages/FileSystemManager/writefile.json b/packageAPI/pages/FileSystemManager/writefile.json index 59917b8..8835af0 100644 --- a/packageAPI/pages/FileSystemManager/writefile.json +++ b/packageAPI/pages/FileSystemManager/writefile.json @@ -1,4 +1,3 @@ { - "usingComponents": {}, - "disableScroll":false + "usingComponents": {} } \ No newline at end of file diff --git a/packageAPI/pages/FileSystemManager/writefile.wxml b/packageAPI/pages/FileSystemManager/writefile.wxml index d1d768b..646006a 100644 --- a/packageAPI/pages/FileSystemManager/writefile.wxml +++ b/packageAPI/pages/FileSystemManager/writefile.wxml @@ -1,133 +1,383 @@ - - - - -设置 - -验证filePath允许设置的值(打开页面初始化时,设置的是本地路径) - -http地址 -代码包中的一个图片路径 -设置为空 -本地路径 -null + +路径参数 path 1 + + http地址 + 代码包中的一个图片路径 + 本地路径 + 设置为空 + null + {{item}} -修改writeFile encoding类型 - -ascii -base64 -binary -hex -ucs2(以小端序读取) -ucs-2(以小端序读取) -utf16le(以小端序读取) -utf-16le(以小端序读取) -utf-8 -utf8 -latin1 - -123 +修改 entries 参数 + + true + 111 + 设置为空 -修改data类型 - -空值 -abc -中文 -[] -null - -image_base64 - - - -video_base64 - -audio_base64 - - -wenjian - - -新文件 +修改 recursive 参数 + + true + 111 + 设置为空 - - - - +修改 flag 参数 + + a + ax + a+ + ax+ + as + as+ + r + r+ + w + wx + w+ + wx+ + null + 111 + 设置为空 + - - - - - - - - - - +修改 length 参数 + + -1 + + 0.5 + 1 + 3 + 3.1zsad + 3.9 + 50 + sss + null + - - +修改 position 参数 + + -1 + + 0.5 + 3 + 3.1zsad + 3.9 + 50 + sss + null + + +修改 offset 参数 + + -1 + + 0.5 + 3 + 3.1zsad + 3.9 + 50 + sss + null + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -image - - - - - +修改 encoding 参数 + + ascii + base64 + binary + hex + ucs2(以小端序读取) + ucs-2(以小端序读取) + utf16le(以小端序读取) + utf-16le(以小端序读取) + utf-8 + utf8 + latin1 + + 123 + -video - - - - +修改 data 参数 + + 空值 + abc + 中文 + [] + null + + image_base64 + + video_base64 + + audio_base64 + + wenjian + 新文件 + -audio - - - - + 路径参数 path 2 + + http地址 + 代码包中的一个图片路径 + 本地路径 + 设置为空 + null + {{item}} + \ No newline at end of file diff --git a/packageAPI/pages/FileSystemManager/writefile.wxss b/packageAPI/pages/FileSystemManager/writefile.wxss index b2b35dc..1ac0271 100644 --- a/packageAPI/pages/FileSystemManager/writefile.wxss +++ b/packageAPI/pages/FileSystemManager/writefile.wxss @@ -1,8 +1,6 @@ -/* pages/writefile/index.wxss */ - -.title { - padding: 10rpx 20rpx; - font-size: 30rpx; - font-weight: bold; - text-align: center; +/* pages/file-2/index.wxss */ +.box { + display: flex; + flex-wrap: wrap; + padding-bottom: 300rpx; } diff --git a/packageAPI/pages/audio/xuwei.jpg b/packageAPI/pages/audio/xuwei.jpg index 7095142..316ae2c 100644 Binary files a/packageAPI/pages/audio/xuwei.jpg and b/packageAPI/pages/audio/xuwei.jpg differ diff --git a/packageAPI/pages/canvas/canvas.js b/packageAPI/pages/canvas/canvas.js index c3ba3cb..8cf412c 100644 --- a/packageAPI/pages/canvas/canvas.js +++ b/packageAPI/pages/canvas/canvas.js @@ -1,5 +1,14 @@ const example = require('./example.js') +function randomHexColor() { + var r = Math.floor(Math.random() * 256); //随机生成256以内r值 + var g = Math.floor(Math.random() * 256); //随机生成256以内g值 + var b = Math.floor(Math.random() * 256); //随机生成256以内b值 + var alpha = Math.random() * 0.4 + 0.6; //随机生成1以内a值 + return `rgba(${r},${g},${b},${alpha})`; //返回rgba(r,g,b,a)格式颜色 + +} + Page({ onShareAppMessage() { return { @@ -8,53 +17,165 @@ Page({ } }, + log1(e) { + console.log('ctx1:', e.type, e) + }, + + log2(e) { + console.log('ctx2:', e.type, e) + }, + onLoad() { - this.context = wx.createContext() - console.log('wx.createContext', this.context); const methods = Object.keys(example) - console.log(methods); this.setData({ methods }) + // 旧获取 canvas 方式 + const ctx1 = wx.createCanvasContext('canvas1'); + console.log('ctx1', ctx1) + + // 新获取 canvas 方式 + let ctx2 + let canvas2 + const query = wx.createSelectorQuery() + query.select('#canvas2').fields({ node: true, size: true }).exec((res) => { + canvas2 = res[0].node + ctx2 = canvas2.getContext('2d') + + // 可以设置 dpr 的值,绘制高分辨率的图 + const dpr = 1 || wx.getSystemInfoSync().pixelRatio + canvas2.width = res[0].width * dpr + canvas2.height = res[0].height * dpr + console.log('ctx2', ctx2) + }) + + // fino 基础库兼容新旧写法,两者均可获取到同样的 context + // 当 canvas 带 native 时,表示用原生组件 + // 原生组件下,仅 putImageData 和 getImageData api 会有区别 + const that = this methods.forEach(function (method) { that[method] = function () { - // 写法1 官方文档有描述的写法, 微信基础库支持,我们不支持 - // - console.log('call action', method) - const ctx = wx.createCanvasContext('canvas'); - example[method](ctx) - ctx.draw(false, (res) => { console.log(res) }); - const actions = that.context.getActions() - console.log('that.context.getActions()', actions, ctx); - - // 写法2 更旧版本的写法 微信支持,fino基础库不支持 - // wx.createContext 和 wx.drawCanvas 疑似已经被从官方基础库文档中移除,但是官方基础库依旧支持 + console.log("run:", method) + let color = null + if (method === 'setRandom') { + color = randomHexColor() + } + example[method](ctx1, true, color) + // 旧版需要调用 draw 接口 + ctx1.draw(true, (res) => { console.log('ctx1 draw finish:', res) }); - // example[method](that.context) - // const actions = that.context.getActions() - // wx.drawCanvas({ - // canvasId: 'canvas', - // actions - // }) - - // 写法3 同层渲染的原生canvas 就没实现 + example[method](ctx2, false, color, canvas2) + try { + // 微信新的 canvas 没有 draw 方法,加个报错兼容 + ctx2.draw(true, (res) => { console.log('ctx2 draw finish:', res) }) + } catch (err) { + } } }) }, toTempFilePath() { wx.canvasToTempFilePath({ - canvasId: 'canvas', + canvasId: 'canvas1', success(res) { - console.log(res) + console.log('canvas1', res) }, fail(res) { - console.log(res) + console.log('canvas1', res) } }) + + const query = wx.createSelectorQuery() + query.select('#canvas2').fields({ node: true, size: true }).exec((res) => { + const canvas = res[0].node + + wx.canvasToTempFilePath({ + canvas, + success(res) { + console.log('canvas2', res) + }, + + fail(res) { + console.log('canvas2', res) + } + }) + }) + }, + imageData() { + + // 旧版 + // 整一个绿色方块 + const arr = new Array(100 * 100 * 4); + for (var i = 0; i < arr.length; i += 4) { + arr[i + 0] = 0; + arr[i + 1] = 255; + arr[i + 2] = 0; + arr[i + 3] = 255; + } + // 把绿色方块画到 0 0 坐标 + wx.canvasPutImageData({ + canvasId: 'canvas1', + x: 0, + y: 0, + width: 100, + height: 100, + data: new Uint8ClampedArray(arr), + success(res) { + console.log(res) + }, + fail: console.log + }) + // 获取 0 0 坐标,100 * 100 的图 + wx.canvasGetImageData({ + canvasId: 'canvas1', + x: 50, + y: 50, + width: 100, + height: 100, + success(res) { + console.log(res) + // 把获取到的,画到 200 0 坐标上 + // 会出现两个绿色方块 + wx.canvasPutImageData({ + canvasId: 'canvas1', + x: 200, + y: 0, + width: 100, + height: 100, + data: res.data, + success(res) { + console.log(res) + }, + fail: console.log + }) + }, + fail: console.log + }) + + + // 新版 + const query = wx.createSelectorQuery() + query.select('#canvas2').fields({ node: true, size: true }).exec((res) => { + const canvas = res[0].node + const context = canvas.getContext('2d') + // 一个绿色方块数据 + const imgData = context.createImageData(100, 100); + for (var i = 0; i < imgData.data.length; i += 4) { + imgData.data[i + 0] = 0; + imgData.data[i + 1] = 255; + imgData.data[i + 2] = 0; + imgData.data[i + 3] = 255; + } + + context.putImageData(imgData, 0, 0, 20, 20, 100, 100) + + const image = context.getImageData(50, 50, 100, 100) + context.putImageData(image, 200, 0, 20, 20, 100, 100) + }) + } }) diff --git a/packageAPI/pages/canvas/canvas.wxml b/packageAPI/pages/canvas/canvas.wxml index 7961737..d000dd0 100644 --- a/packageAPI/pages/canvas/canvas.wxml +++ b/packageAPI/pages/canvas/canvas.wxml @@ -2,16 +2,47 @@ -