Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

views/windows目录不支持子目录吗?如果支持代码组织是不是更优 #4

Open
chaegumi opened this issue Mar 7, 2024 · 2 comments

Comments

@chaegumi
Copy link

chaegumi commented Mar 7, 2024

如题,文档中没看到,我试验windowName不知道如何写
比如我主菜单有很多模块,在windows目录下,想要一个模块一个目录,然后window在各个模块目录下

@hooray
Copy link
Member

hooray commented Mar 7, 2024

是的,不支持嵌套目录结构,如果要实现该特性,需要同步修改 src/views/windows/registerWindowComponent.ts 文件,该文件实现所有窗口组件的全局自动注册

@chaegumi
Copy link
Author

chaegumi commented Mar 7, 2024

export default function registerWindowComponent(app: App) {
  const componentsContext = import.meta.glob('./**/index.vue')
  for (const path in componentsContext) {
    let name = path.replace('./', '')
    console.log(name)
    name = name.slice(0, name.lastIndexOf('/'))
    console.log(name)
    console.log(path)
    app.component(name, defineAsyncComponent(componentsContext[path] as any))
  }
}

好像只要把indexOf改成lastIndexOf
menu中的windowName:写成'Server/Servers'这样。你们不内置支持吗?这样改不会产生别的问题吧

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

No branches or pull requests

2 participants