uni-helper / vite-plugin-uni-layouts

为 Vite 下的 uni-app 提供类 nuxt 的 layouts 系统
MIT License
25 stars 6 forks source link

route希望可以自定义添加对象信息 现在自己添加对象信息就会导致插件运行效果不正确 没有正确加载布局 #12

Closed sharebravery closed 1 year ago

sharebravery commented 1 year ago

对问题的清晰和简明的描述

加入tabBar的信息之后 布局没有正确加载 不生效了

<route lang="yaml">
name: Demo
layout: default
style:
  navigationBarTitleText: Demo
tabBar:
  iconPath: static/images/tabBar/demo.png
  selectedIconPath: static/images/tabBar/selectedDemo.png
</route> 

推荐的解决方案

none

替代方案

No response

额外上下文

No response

检查

Ares-Chang commented 1 year ago

link #5 ,你添加的属性应该并没有被使用,应该不会产生问题。

我按照你提供的信息修改后并没有发现问题,如果依旧有问题可以提供一个 demo 仓库,感谢。

Ares-Chang commented 1 year ago

但是你的提议是个好想法,可能在未来会被添加支持的。

参考 [#10],可能会自定义存在于 meta 中等等...

sharebravery commented 1 year ago

找到问题了 吐血! 居然是头部注释的问题!

<!--
 * @Description: 头部不能有这个注释。。。
 * @Author:
 * @Date: 2023-06-30 09:05:38
-->

我本来还以为是我加上对tabbar的处理造成的 一直找一直找 o(╥﹏╥)o

    UniPages({
      dir: 'src/pages',
      routeBlockLang: 'yaml',
      exclude: ['**/components/*.vue'],
      subPackages: [
        'src/pages-sub',
      ],
      onBeforeWriteFile(ctx) {
        type PageMeta = (PageMetaDatum & { name: string; tabBar?: { text?: string; iconPath: string; selectedIconPath: string } })

        const pageMetaData = ctx.pageMetaData as PageMeta[]

        ctx.pagesGlobConfig!.tabBar!.list = pageMetaData.flatMap(e => 'tabBar' in e
          ? {
              pagePath: e.path,
              text: e.tabBar?.text ? e.tabBar.text : e.style?.navigationBarTitleText,
              iconPath: e.tabBar!.iconPath,
              selectedIconPath: e.tabBar!.selectedIconPath,
            }
          : [])
      },
    }),
Ares-Chang commented 1 year ago

Thanks

KeJunMao commented 11 months ago

@sharebravery 抱歉啊,之前没注意到这个 issue,问题已经在 https://github.com/uni-helper/vite-plugin-uni-layouts/commit/82d20ef9d8b72ac9db27d7ffdf7a1e45f94beee7 中修复,你可以更新到最新版本试试!