Skip to content

Sync fork main to latest upstream/main#1

Closed
Copilot wants to merge 54 commits into
devfrom
copilot/migrate-to-composition-api
Closed

Sync fork main to latest upstream/main#1
Copilot wants to merge 54 commits into
devfrom
copilot/migrate-to-composition-api

Conversation

Copilot AI commented Feb 28, 2026

Copy link
Copy Markdown

main in the fork was behind upstream. This PR aligns the fork with the latest upstream history so future work starts from current Vant code.

  • Branch alignment

    • Fast-forwarded fork main from 205336cd6 to upstream f54d02b22.
    • Brings in the full upstream commit set and file changes without introducing fork-specific feature logic.
  • Upstream parity updates included

    • Pulls latest upstream updates across workflows, tooling/lint config, package metadata, and component/docs/test files.
    • Keeps fork behavior consistent with upstream baseline for subsequent PRs.
  • Resulting commit alignment

    before: origin/main    205336cd6
    after:  upstream/main  f54d02b22
    
Original prompt

在仓库 yoyo837/vant(base 分支:dev)中,将以下两个仍使用 Vue 3 Options API(对象式组件定义,包含 data/watch/mounted/methods/this.$el 等)的实现改��为 Composition API,以确保在构建时禁用 __VUE_OPTIONS_API__ 时依然功能完全正常,且对外行为保持一致(功能完全等价,不受损):

  • packages/vant/src/lazyload/vue-lazyload/lazy-image.js
  • packages/vant/src/lazyload/vue-lazyload/lazy-component.js

背景

当前这两个文件 export 的是返回 Options API 组件对象的工厂函数(export default (lazyManager) => ({ ...options }))。当 __VUE_OPTIONS_API__ 被禁用时,使用 Options API 的组件会无法正常工作或出现功能缺失。

目标

  1. 将组件实现迁移到 Composition API:使用 defineComponent + setup()(或等价方式)实现,而不是 data()/methods/watch/created/mounted 等 Options API 选项。
  2. 功能行为必须与现有实现完全一致,包括但不限于:
    • props / emits 行为一致
    • 渲染结构与插槽行为一致(this.$slots.default?.() 的等价实现)
    • 生命周期行为一致(created/mounted/beforeUnmount 等逻辑等价)
    • 对 lazy manager 的交互调用顺序与时机一致(addLazyBox/lazyLoadHandler/removeComponent/valueFormatter 等)
    • 内部状态字段(如 renderSrc/state/options/show 等)更新行为一致
    • 依旧可被现有 lazyload 插件机制正确创建和管理(保持导出 API 形态兼容:仍是 (lazyManager|lazy) => Component 的工厂导出)
  3. 兼容 SSR / inBrowser 判断逻辑保持一致。
  4. 确保单测(如有覆盖)通过;如需要,补充或更新测试以验证等价行为(特别是 lazyload 相关行为)。

约束与注意事项

  • 不要改变对外导出(保持默认导出为工厂函数,入参名可不同,但语义一致)。
  • 不要引入破坏性 API 变更。
  • 尽量保持代码风格与仓库现有规范一致。
  • 注意原代码中对 $el$emit、slots、以及 this.tag 等实例属性的使用;在 Composition API 中应通过 getCurrentInstancerefonMountedemitslots 等正确替代。
  • 原实现中 lazy-component.jsdestroy() 返回 this.$destroy(Vue 3 中该字段通常不存在);迁移时请保持返回值与现有运行时表现兼容(若原本就是 undefined,也应保持)。

验收标准

  • 代码审阅可明确看出不再依赖 Options API。
  • 在禁用 __VUE_OPTIONS_API__ 的构建配置下,lazy-image 与 lazy-component 仍可正常工作。
  • 行为与现有版本等价(对用户无感)。

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…sition API

Co-authored-by: yoyo837 <6134547+yoyo837@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate lazyload components to Composition API Migrate lazy-image and lazy-component to Composition API Feb 28, 2026
Copilot AI changed the title Migrate lazy-image and lazy-component to Composition API Migrate lazy-image and lazy-component from Options API to Composition API Feb 28, 2026
Copilot AI changed the title Migrate lazy-image and lazy-component from Options API to Composition API feat(lazyload): migrate lazy-image and lazy-component to Composition API Feb 28, 2026
Co-authored-by: yoyo837 <6134547+yoyo837@users.noreply.github.com>
Copilot AI changed the title feat(lazyload): migrate lazy-image and lazy-component to Composition API fix(lazyload): remove duplicate addLazyBox call in src watcher Feb 28, 2026
Copilot AI changed the title fix(lazyload): remove duplicate addLazyBox call in src watcher feat(lazyload): drop Options API to support disabling __VUE_OPTIONS_API__ Feb 28, 2026
renovate Bot and others added 10 commits March 6, 2026 09:08
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate Bot and others added 18 commits May 4, 2026 16:51
…13816)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ouzan#13837)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: zhaojiangjiang <zhaojiangjiang@kingyee.com.cn>
Copilot AI changed the title feat(lazyload): drop Options API to support disabling __VUE_OPTIONS_API__ chore: 同步 upstream/main 并补齐 CI 最小权限配置 Jun 1, 2026
Copilot AI requested a review from yoyo837 June 1, 2026 02:48
Copilot AI changed the title chore: 同步 upstream/main 并补齐 CI 最小权限配置 Sync fork main to latest upstream/main Jun 1, 2026
@yoyo837 yoyo837 closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants