From 180a8b3ba8819684852ef4a21c85a138c667a2d8 Mon Sep 17 00:00:00 2001 From: agileago Date: Tue, 13 May 2025 10:52:43 +0800 Subject: [PATCH 1/6] =?UTF-8?q?perf:=20=E6=8F=90=E9=AB=98=E6=80=A7?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/simple-props/composables.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/simple-props/composables.ts b/src/simple-props/composables.ts index daa68ec..b13f400 100644 --- a/src/simple-props/composables.ts +++ b/src/simple-props/composables.ts @@ -19,7 +19,6 @@ export function useProps(): T { const getProps = () => { return Object.fromEntries(Object.entries(instance.vnode.props || {}).map(([k, v]) => [camelizePropKey(k), v])) } - const attrs = useAttrs() return new Proxy( {}, @@ -35,7 +34,10 @@ export function useProps(): T { // @ts-ignore return instance.props[key] } else { - return attrs[key as string] || attrs[p as string] + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + instance.proxy?.$attrs + + return Reflect.get(getProps(), key, receiver) } }, ownKeys() { From b89a4863080cc66466fca68bd3588e984941d7bb Mon Sep 17 00:00:00 2001 From: agileago Date: Tue, 13 May 2025 10:53:21 +0800 Subject: [PATCH 2/6] v1.1.1 --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0609be..fcc7050 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [1.1.1](https://github.com/agileago/vue3-oop/compare/v1.1.0...v1.1.1) (2025-05-13) + + +### Performance Improvements + +* 提高性能 ([180a8b3](https://github.com/agileago/vue3-oop/commit/180a8b3ba8819684852ef4a21c85a138c667a2d8)) + + + # [1.1.0](https://github.com/agileago/vue3-oop/compare/v1.0.21...v1.1.0) (2025-05-12) diff --git a/package.json b/package.json index ab970fc..f1c666a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue3-oop", - "version": "1.1.0", + "version": "1.1.1", "packageManager": "pnpm@9.1.1", "engines": { "pnpm": ">=9.0" From 5f8bd9143aec10e7c00e568fe127fc960b73ba50 Mon Sep 17 00:00:00 2001 From: agileago Date: Tue, 20 May 2025 10:50:21 +0800 Subject: [PATCH 3/6] feat: add If component for conditional rendering --- src/components/index.ts | 11 +++++++++++ src/index.ts | 1 + 2 files changed, 12 insertions(+) create mode 100644 src/components/index.ts diff --git a/src/components/index.ts b/src/components/index.ts new file mode 100644 index 0000000..dadc791 --- /dev/null +++ b/src/components/index.ts @@ -0,0 +1,11 @@ +import type { SetupContext } from 'vue' +import type { JSX } from 'vue/jsx-runtime' + +interface IfProps { + /*判断条件*/ + condition: any +} +export function If(props: IfProps, ctx: SetupContext) { + if (!props.condition) return null + return ctx.slots.default?.() as unknown as JSX.Element +} diff --git a/src/index.ts b/src/index.ts index 1562404..8ac3c22 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,7 @@ export { Hook } from './decorators/hook' export { createDecorator, getProtoMetadata } from './decorators/util' export * from './helper' export * from './simple-props' +export * from './components' export { Component, InjectorKey, getCurrentInjector, createCurrentInjector, injectService, provideService } from './di' export type { ComponentOptions } from './di' export type { From ed354bf4816de65625275236ab752c069119b09e Mon Sep 17 00:00:00 2001 From: agileago Date: Tue, 20 May 2025 10:50:51 +0800 Subject: [PATCH 4/6] v1.1.2 --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcc7050..6c41de1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [1.1.2](https://github.com/agileago/vue3-oop/compare/v1.1.1...v1.1.2) (2025-05-20) + + +### Features + +* add If component for conditional rendering ([5f8bd91](https://github.com/agileago/vue3-oop/commit/5f8bd9143aec10e7c00e568fe127fc960b73ba50)) + + + ## [1.1.1](https://github.com/agileago/vue3-oop/compare/v1.1.0...v1.1.1) (2025-05-13) diff --git a/package.json b/package.json index f1c666a..ca63d06 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue3-oop", - "version": "1.1.1", + "version": "1.1.2", "packageManager": "pnpm@9.1.1", "engines": { "pnpm": ">=9.0" From edf85eb2df1bc5d32e138d5af16c61d4943e0e9a Mon Sep 17 00:00:00 2001 From: agileago Date: Thu, 5 Jun 2025 17:21:30 +0800 Subject: [PATCH 5/6] fix: correct provides handling in provideService function --- src/di/index.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/di/index.ts b/src/di/index.ts index f27f7eb..e5ef460 100644 --- a/src/di/index.ts +++ b/src/di/index.ts @@ -170,18 +170,31 @@ interface Constructable { constructor: Function } function provideService(...service: T[]) { - const instance = getCurrentInstance()! + const currentInstance = getCurrentInstance()! + // @ts-ignore + let provides = currentInstance.provides + // by default an instance inherits its parent's provides object + // but when it needs to provide values of its own, it creates its + // own provides object using parent provides object as prototype. + // this way in `inject` we can simply look up injections from direct + // parent and let the prototype chain do the work. + // @ts-ignore + const parentProvides = currentInstance.parent && currentInstance.parent.provides + if (parentProvides === provides) { + // @ts-ignore + provides = currentInstance.provides = Object.create(parentProvides) + } // @ts-ignore let injector: ReflectiveInjector - if (Reflect.has(instance, InjectorKey as symbol)) { + if (Object.prototype.hasOwnProperty.call(provides, InjectorKey as symbol)) { // @ts-ignore - injector = instance.provides[InjectorKey] + injector = currentInstance.provides[InjectorKey] } // @ts-ignore if (!injector) { injector = ReflectiveInjector.resolveAndCreate([], inject(InjectorKey)) // @ts-ignore - instance.provides[InjectorKey] = injector + currentInstance.provides[InjectorKey] = injector } ReflectiveInjector.resolve(service.map(k => ({ provide: k.constructor, useValue: k }))).forEach((provider, i) => { From ab45efd25c381549032241e23d7f430ed790de9b Mon Sep 17 00:00:00 2001 From: agileago Date: Thu, 5 Jun 2025 17:22:13 +0800 Subject: [PATCH 6/6] v1.2.0 --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c41de1..7f1ee0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# [1.2.0](https://github.com/agileago/vue3-oop/compare/v1.1.2...v1.2.0) (2025-06-05) + + +### Bug Fixes + +* correct provides handling in provideService function ([edf85eb](https://github.com/agileago/vue3-oop/commit/edf85eb2df1bc5d32e138d5af16c61d4943e0e9a)) + + + ## [1.1.2](https://github.com/agileago/vue3-oop/compare/v1.1.1...v1.1.2) (2025-05-20) diff --git a/package.json b/package.json index ca63d06..294c266 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue3-oop", - "version": "1.1.2", + "version": "1.2.0", "packageManager": "pnpm@9.1.1", "engines": { "pnpm": ">=9.0"