vbenjs / vben3

Next-generation Vben framework
https://vben.mufei88.com/
MIT License
556 stars 153 forks source link

从pinia持久化恢复的配置被项目配置文件setting/project.ts内的projectSetting覆盖 #245

Closed likui628 closed 1 year ago

likui628 commented 1 year ago

如图,设置“左侧菜单混合模式”和“灰色模式” image

F5刷新页面配置丢失, 以下useAppConfig内加的调试代码可以看出来,保存的配置的确被恢复了。

  persist: {
    beforeRestore: (ctx) => {
      console.log(`about to restore '${ctx.store.$state.navBarMode}'`)
    },
    afterRestore: (ctx) => {
      console.log(`just restored '${ctx.store.$state.navBarMode}'`)
    },
  },

但是最终会被项目配置文件setting/project.ts内的projectSetting内的相应配置替换掉。

之前的版本为什么没有这个问题,因为之前的配置字段对应不上,所以不会替换

export interface ProjectConfig extends SporadicSetting {
  // menuType: MenuTypeEnum;
  headerSetting: HeaderSetting
  // menuSetting
  menuSetting: MenuSetting
  // Multi-tab settings
  multiTabsSetting: MultiTabsSetting
  // Animation configuration
  transitionSetting: TransitionSetting
}