From ec5db4532ff40f51dad21424b416e4048d6a6e9e Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Sun, 30 Jun 2024 11:42:17 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=A4=BA=E4=BE=8B=E9=A1=B5=E9=9D=A2=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 24 +- .../cloud-storage.uvue} | 0 .../create-inner-audio-context.uvue | 238 +++++++++++++ .../inner-audio-format.uvue | 134 ++++++++ .../inner-audio-path.uvue | 99 ++++++ .../inner-audio.test.js | 73 ++++ .../create-selector-query.uvue} | 0 .../nodes-info-child.uvue | 0 .../nodes-info.test.js | 0 .../{ => unicloud}/call-function.test.js | 0 .../cloud-function.uvue} | 0 .../cloud-object.uvue} | 0 .../API/unicloud/unicloud/cloud-storage.uvue | 92 +++++ pages/API/unicloud/unicloud/database.uvue | 322 ++++++++++++++++++ pages/component/canvas/{ => canvas}/ball.uvue | 0 .../unicloud-db/unicloud-db/datacom.uvue | 70 ++++ .../unicloud-db/mixin-datacom.test.js | 20 ++ .../unicloud-db/mixin-datacom.uvue | 27 ++ readme.md | 16 +- 19 files changed, 1100 insertions(+), 15 deletions(-) rename pages/API/{unicloud-file-api/unicloud-file-api.uvue => cloud-storage/cloud-storage.uvue} (100%) create mode 100644 pages/API/create-inner-audio-context/create-inner-audio-context.uvue create mode 100644 pages/API/create-inner-audio-context/inner-audio-format.uvue create mode 100644 pages/API/create-inner-audio-context/inner-audio-path.uvue create mode 100644 pages/API/create-inner-audio-context/inner-audio.test.js rename pages/API/{nodes-info/nodes-info.uvue => create-selector-query/create-selector-query.uvue} (100%) rename pages/API/{nodes-info => create-selector-query}/nodes-info-child.uvue (100%) rename pages/API/{nodes-info => create-selector-query}/nodes-info.test.js (100%) rename pages/API/unicloud/{ => unicloud}/call-function.test.js (100%) rename pages/API/unicloud/{call-function.uvue => unicloud/cloud-function.uvue} (100%) rename pages/API/unicloud/{import-object.uvue => unicloud/cloud-object.uvue} (100%) create mode 100644 pages/API/unicloud/unicloud/cloud-storage.uvue create mode 100644 pages/API/unicloud/unicloud/database.uvue rename pages/component/canvas/{ => canvas}/ball.uvue (100%) create mode 100644 pages/component/unicloud-db/unicloud-db/datacom.uvue create mode 100644 pages/component/unicloud-db/unicloud-db/mixin-datacom.test.js create mode 100644 pages/component/unicloud-db/unicloud-db/mixin-datacom.uvue diff --git a/pages.json b/pages.json index 14a96dd9..80ad54f8 100644 --- a/pages.json +++ b/pages.json @@ -308,7 +308,7 @@ } }, { - "path": "pages/component/datacom/datacom", + "path": "pages/component/unicloud-db/unicloud-db/mixin-datacom", "style": { "navigationBarTitleText": "mixinDatacom" } @@ -431,7 +431,7 @@ } }, { - "path" : "pages/component/canvas/ball", + "path" : "pages/component/canvas/canvas/ball", "style" : { "navigationBarTitleText" : "ball" @@ -554,7 +554,7 @@ } }, { - "path": "pages/API/nodes-info/nodes-info", + "path": "pages/API/create-selector-query/create-selector-query", "style": { "navigationBarTitleText": "查询节点信息的对象" } @@ -671,15 +671,15 @@ } }, { - "path": "pages/API/unicloud/call-function", + "path": "pages/API/unicloud/unicloud/cloud-function", "style": { - "navigationBarTitleText": "" + "navigationBarTitleText": "云函数" } }, { - "path": "pages/API/unicloud/import-object", + "path": "pages/API/unicloud/unicloud/cloud-object", "style": { - "navigationBarTitleText": "" + "navigationBarTitleText": "云对象" } }, { @@ -806,15 +806,15 @@ } }, { - "path": "pages/API/unicloud-file-api/unicloud-file-api", + "path": "pages/API/unicloud/unicloud/cloud-storage", "style": { - "navigationBarTitleText": "" + "navigationBarTitleText": "cloud storage" } }, { - "path": "pages/API/unicloud-database/unicloud-database", + "path": "pages/API/unicloud/unicloud/database", "style": { - "navigationBarTitleText": "" + "navigationBarTitleText": "database" } }, { @@ -916,7 +916,7 @@ } }, { - "path" : "pages/API/inner-audio/inner-audio", + "path" : "pages/API/create-inner-audio-context/create-inner-audio-context", "style" : { "navigationBarTitleText" : "inner-audio" diff --git a/pages/API/unicloud-file-api/unicloud-file-api.uvue b/pages/API/cloud-storage/cloud-storage.uvue similarity index 100% rename from pages/API/unicloud-file-api/unicloud-file-api.uvue rename to pages/API/cloud-storage/cloud-storage.uvue diff --git a/pages/API/create-inner-audio-context/create-inner-audio-context.uvue b/pages/API/create-inner-audio-context/create-inner-audio-context.uvue new file mode 100644 index 00000000..1f3b7e00 --- /dev/null +++ b/pages/API/create-inner-audio-context/create-inner-audio-context.uvue @@ -0,0 +1,238 @@ + + + diff --git a/pages/API/create-inner-audio-context/inner-audio-format.uvue b/pages/API/create-inner-audio-context/inner-audio-format.uvue new file mode 100644 index 00000000..9eec12ab --- /dev/null +++ b/pages/API/create-inner-audio-context/inner-audio-format.uvue @@ -0,0 +1,134 @@ + + + + + diff --git a/pages/API/create-inner-audio-context/inner-audio-path.uvue b/pages/API/create-inner-audio-context/inner-audio-path.uvue new file mode 100644 index 00000000..3b9ad2ae --- /dev/null +++ b/pages/API/create-inner-audio-context/inner-audio-path.uvue @@ -0,0 +1,99 @@ + + + + + diff --git a/pages/API/create-inner-audio-context/inner-audio.test.js b/pages/API/create-inner-audio-context/inner-audio.test.js new file mode 100644 index 00000000..92389d63 --- /dev/null +++ b/pages/API/create-inner-audio-context/inner-audio.test.js @@ -0,0 +1,73 @@ +describe('inner-audio', () => { + if (!process.env.uniTestPlatformInfo.startsWith('web')) { + it('app', () => { + expect(1).toBe(1) + }) + return + } + beforeAll(async () => { + page = await program.reLaunch('/pages/API/inner-audio/inner-audio') + await page.waitFor('view'); + }); + + function getData(key = '') { + return new Promise(async (resolve, reject) => { + const data = await page.data() + resolve(key ? data[key] : data) + }) + } + + it('onCanplay',async()=>{ + await page.waitFor(1000) + await page.waitFor(async()=>{ + return await getData('isCanplay') + }) + expect(await getData('buffered')).toBeGreaterThan(0) + }) + + it('play-onPlay-onTimeUpdate', async () => { + await page.callMethod('play') + await page.waitFor(3000); + expect(await getData('isPlaying')).toBeTruthy() + console.log("duration:",await getData('duration'),"currentTime:",await getData('currentTime')) + expect(await getData('duration')).toBeCloseTo(175.109, 0); + // console.log("isPaused",await getData('isPaused')) + // expect(await getData('currentTime')).toBeGreaterThan(0); + // expect(await getData('isPaused')).toBeFalsy(); + }); + + it('seek-onSeeking-onSeeked', async () => { + await page.callMethod('onchange',20) + await page.waitFor(500); + expect(await getData('onSeekingTest')).toBeTruthy(); + // expect(await getData('onWaitingTest')).toBeTruthy(); + expect(await getData('onSeekedTest')).toBeTruthy(); + }); + + it('pause-onPause', async () => { + await page.callMethod('pause') + await page.waitFor(500); + expect(await getData('isPlaying')).toBeFalsy() + // expect(await getData('isPaused')).toBeTruthy(); + }); + + it('stop-onStop', async () => { + await page.callMethod('play') + await page.waitFor(2000); + // 第一次点停止时,不触发onStop事件 + await page.callMethod('stop') + await page.callMethod('stop') + await page.waitFor(1000); + expect(await getData('isPlaying')).toBeFalsy() + // expect(await getData('isPaused')).toBeTruthy(); + }); + + it('onEnded', async () => { + await page.callMethod('onchange',173) + await page.waitFor(500); + await page.callMethod('play') + await page.waitFor(3000); + // expect(await getData('isPlayEnd')).toBeTruthy(); + }); + +}); diff --git a/pages/API/nodes-info/nodes-info.uvue b/pages/API/create-selector-query/create-selector-query.uvue similarity index 100% rename from pages/API/nodes-info/nodes-info.uvue rename to pages/API/create-selector-query/create-selector-query.uvue diff --git a/pages/API/nodes-info/nodes-info-child.uvue b/pages/API/create-selector-query/nodes-info-child.uvue similarity index 100% rename from pages/API/nodes-info/nodes-info-child.uvue rename to pages/API/create-selector-query/nodes-info-child.uvue diff --git a/pages/API/nodes-info/nodes-info.test.js b/pages/API/create-selector-query/nodes-info.test.js similarity index 100% rename from pages/API/nodes-info/nodes-info.test.js rename to pages/API/create-selector-query/nodes-info.test.js diff --git a/pages/API/unicloud/call-function.test.js b/pages/API/unicloud/unicloud/call-function.test.js similarity index 100% rename from pages/API/unicloud/call-function.test.js rename to pages/API/unicloud/unicloud/call-function.test.js diff --git a/pages/API/unicloud/call-function.uvue b/pages/API/unicloud/unicloud/cloud-function.uvue similarity index 100% rename from pages/API/unicloud/call-function.uvue rename to pages/API/unicloud/unicloud/cloud-function.uvue diff --git a/pages/API/unicloud/import-object.uvue b/pages/API/unicloud/unicloud/cloud-object.uvue similarity index 100% rename from pages/API/unicloud/import-object.uvue rename to pages/API/unicloud/unicloud/cloud-object.uvue diff --git a/pages/API/unicloud/unicloud/cloud-storage.uvue b/pages/API/unicloud/unicloud/cloud-storage.uvue new file mode 100644 index 00000000..d6a32187 --- /dev/null +++ b/pages/API/unicloud/unicloud/cloud-storage.uvue @@ -0,0 +1,92 @@ + + + + diff --git a/pages/API/unicloud/unicloud/database.uvue b/pages/API/unicloud/unicloud/database.uvue new file mode 100644 index 00000000..f37730e2 --- /dev/null +++ b/pages/API/unicloud/unicloud/database.uvue @@ -0,0 +1,322 @@ + + + + + diff --git a/pages/component/canvas/ball.uvue b/pages/component/canvas/canvas/ball.uvue similarity index 100% rename from pages/component/canvas/ball.uvue rename to pages/component/canvas/canvas/ball.uvue diff --git a/pages/component/unicloud-db/unicloud-db/datacom.uvue b/pages/component/unicloud-db/unicloud-db/datacom.uvue new file mode 100644 index 00000000..d6392ff8 --- /dev/null +++ b/pages/component/unicloud-db/unicloud-db/datacom.uvue @@ -0,0 +1,70 @@ + + + + + diff --git a/pages/component/unicloud-db/unicloud-db/mixin-datacom.test.js b/pages/component/unicloud-db/unicloud-db/mixin-datacom.test.js new file mode 100644 index 00000000..95a8804a --- /dev/null +++ b/pages/component/unicloud-db/unicloud-db/mixin-datacom.test.js @@ -0,0 +1,20 @@ +const PAGE_PATH = '/pages/component/mixin-datacom/mixin-datacom' + +describe('mixin-datacom', () => { + if (process.env.uniTestPlatformInfo.startsWith('web')) { + it('dummyTest', async () => { + expect(1).toBe(1) + }) + return + } + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500) + }) + it('mixinDatacomGet', async () => { + const datacom = await page.$('.datacom') + const children = await datacom.$$('.list-item') + expect(children.length > 0).toBe(true) + }) +}) diff --git a/pages/component/unicloud-db/unicloud-db/mixin-datacom.uvue b/pages/component/unicloud-db/unicloud-db/mixin-datacom.uvue new file mode 100644 index 00000000..9f3ce405 --- /dev/null +++ b/pages/component/unicloud-db/unicloud-db/mixin-datacom.uvue @@ -0,0 +1,27 @@ + + + + + diff --git a/readme.md b/readme.md index fd86721c..d5fe12c7 100644 --- a/readme.md +++ b/readme.md @@ -24,13 +24,23 @@ npx husky@9.0.11 #### pages.json -创建 component、API、css 示例页面时,如果该示例页面需要在对应 tabBar 菜单中展示,命名需要遵循以下规则: +创建 component、API、css 示例页面时,如果该示例页面需要在对应 tabBar 菜单中展示,`path` 命名需要遵循以下规则: - component pages/component/component-name/component-name - API pages/API/api-name/api-name - css pages/API/css-name/css-name -增加上述示例页面时,不需要基于平台兼容性补充条件编译,代码提交后,会自动生成对应的条件编译代码,并更新 pages.json。 +所以,如果是扩展示例,比如针对 `button type 属性` 的示例,`path` 可以是: +``` +pages/component/button/button-type +``` +如果想要该示例页面在菜单中显示,则需要调整为: +``` +pages/component/button/button/type +``` + + +**注意:**增加上述示例页面时,不需要基于平台兼容性补充条件编译,代码提交后,会自动生成对应的条件编译代码,并更新 pages.json。 pages.json 中增加后,需要在 [syntaxdoc](http://git.dcloud.io/uni-app-x/syntaxdoc) 仓库的 modules.json 中维护目录信息。 -**注意:** 调整现有页面的路径或平台兼容性,或移除页面时,如果该页面设计截图对比测试,需要同时调整 pages/pages.test.js 中的页面地址。 +**注意:**调整现有页面的路径或平台兼容性,或移除页面时,如果该页面设计截图对比测试,需要同时调整 pages/pages.test.js 中的页面地址。 -- GitLab