From beaf87d38c6b6e877d8b91563f74a7753dac35aa Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Thu, 18 Apr 2024 18:01:19 +0800 Subject: [PATCH] refactor(component instance): provide & inject --- pages.json | 44 +++++++++---------- .../inject/inject-composition.uvue | 32 ++++++++++++++ .../inject/inject-options-1.uvue} | 26 +++++------ .../inject/inject-options-2.uvue} | 20 ++++----- .../provide/provide-composition.test.js} | 4 +- .../provide/provide-composition.uvue | 15 +++++++ .../provide/provide-options-1.test.js} | 7 ++- .../provide/provide-options-1.uvue} | 5 +-- .../provide/provide-options-2.test.js} | 4 +- .../provide/provide-options-2.uvue} | 2 +- .../dependency-injection/provide/inject.uvue | 31 ------------- .../dependency-injection/provide/provide.uvue | 15 ------- pages/composition/inject/inject.test.js | 13 ------ pages/composition/inject/inject.uvue | 12 ----- pages/index/index.uvue | 21 +++++++++ 15 files changed, 123 insertions(+), 128 deletions(-) create mode 100644 pages/component-instance/inject/inject-composition.uvue rename pages/{composition/provide/component-for-inject-1.uvue => component-instance/inject/inject-options-1.uvue} (79%) rename pages/{composition/provide/component-for-inject-2.uvue => component-instance/inject/inject-options-2.uvue} (67%) rename pages/{composition-api/dependency-injection/provide/provide-inject.test.js => component-instance/provide/provide-composition.test.js} (85%) create mode 100644 pages/component-instance/provide/provide-composition.uvue rename pages/{composition/provide/provide.test.js => component-instance/provide/provide-options-1.test.js} (93%) rename pages/{composition/provide/provide.uvue => component-instance/provide/provide-options-1.uvue} (89%) rename pages/{composition/provide/provide-page2.test.js => component-instance/provide/provide-options-2.test.js} (92%) rename pages/{composition/provide/provide-page2.uvue => component-instance/provide/provide-options-2.uvue} (94%) delete mode 100644 pages/composition-api/dependency-injection/provide/inject.uvue delete mode 100644 pages/composition-api/dependency-injection/provide/provide.uvue delete mode 100644 pages/composition/inject/inject.test.js delete mode 100644 pages/composition/inject/inject.uvue diff --git a/pages.json b/pages.json index 9fad6a9..fa15670 100644 --- a/pages.json +++ b/pages.json @@ -419,6 +419,26 @@ "navigationBarTitleText": "call-method-other 组合式 API" } }, + { + "path": "pages/component-instance/provide/provide-options-1", + "style": { + "navigationBarTitleText": "provide 选项式 API 字面量" + } + }, + { + "path": "pages/component-instance/provide/provide-options-2", + "style": { + "navigationBarTitleText": "provide 选项式 API 函数" + } + }, + { + "path": "pages/component-instance/provide/provide-composition", + "style": { + "navigationBarTitleText": "provide 组合式 API" + } + }, + + { "path": "pages/component-instance/circular-reference/circular-reference", "style": { @@ -537,24 +557,6 @@ } }, // #endif - { - "path": "pages/composition/provide/provide", - "style": { - "navigationBarTitleText": "provide" - } - }, - { - "path": "pages/composition/provide/provide-page2", - "style": { - "navigationBarTitleText": "provide-page-2" - } - }, - { - "path": "pages/composition/inject/inject", - "style": { - "navigationBarTitleText": "inject" - } - }, { "path": "pages/composition/setup/setup", "style": { @@ -791,12 +793,6 @@ "navigationBarTitleText": "onScopeDispose" } }, - { - "path": "pages/composition-api/dependency-injection/provide/provide", - "style": { - "navigationBarTitleText": "依赖注入" - } - }, { "path": "pages/built-in/component/teleport/teleport-options", "style": { diff --git a/pages/component-instance/inject/inject-composition.uvue b/pages/component-instance/inject/inject-composition.uvue new file mode 100644 index 0000000..f5e3646 --- /dev/null +++ b/pages/component-instance/inject/inject-composition.uvue @@ -0,0 +1,32 @@ + + + \ No newline at end of file diff --git a/pages/composition/provide/component-for-inject-1.uvue b/pages/component-instance/inject/inject-options-1.uvue similarity index 79% rename from pages/composition/provide/component-for-inject-1.uvue rename to pages/component-instance/inject/inject-options-1.uvue index 17e132b..0657dec 100644 --- a/pages/composition/provide/component-for-inject-1.uvue +++ b/pages/component-instance/inject/inject-options-1.uvue @@ -1,41 +1,41 @@ \ No newline at end of file diff --git a/pages/composition-api/dependency-injection/provide/provide.uvue b/pages/composition-api/dependency-injection/provide/provide.uvue deleted file mode 100644 index 4022ed0..0000000 --- a/pages/composition-api/dependency-injection/provide/provide.uvue +++ /dev/null @@ -1,15 +0,0 @@ - - - \ No newline at end of file diff --git a/pages/composition/inject/inject.test.js b/pages/composition/inject/inject.test.js deleted file mode 100644 index 01bc3ed..0000000 --- a/pages/composition/inject/inject.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const PAGE_PATH = '/pages/composition/inject/inject' - -describe('inject', () => { - it('basic', async () => { - const page = await program.reLaunch(PAGE_PATH) - await page.waitFor('view') - const globalProvideMsgEl = await page.$('.global-provide-msg') - const globalProvideMsgElText = await globalProvideMsgEl.text() - expect(globalProvideMsgElText).toBe( - 'globalProvideMsg: global provide message' - ) - }) -}) diff --git a/pages/composition/inject/inject.uvue b/pages/composition/inject/inject.uvue deleted file mode 100644 index 1db7743..0000000 --- a/pages/composition/inject/inject.uvue +++ /dev/null @@ -1,12 +0,0 @@ - - - diff --git a/pages/index/index.uvue b/pages/index/index.uvue index b7834aa..a195434 100644 --- a/pages/index/index.uvue +++ b/pages/index/index.uvue @@ -331,6 +331,27 @@ export default { url: 'call-method-other-composition' } ] + }, + { + id: 'provide', + name: 'provide', + children: [ + { + id: 'provide-options-1', + name: 'provide 选项式 API 字面量方式', + url: 'provide-options-1' + }, + { + id: 'provide-options-2', + name: 'provide 选项式 API 函数方式', + url: 'provide-options-2' + }, + { + id: 'provide-composition', + name: 'provide 组合式 API', + url: 'provide-composition' + }, + ] } ] as Page[] }, -- GitLab