Skip to content

Commit

Permalink
fix: 修复空菜单无法切换为手动输入的bug,修复没有vueName无法读取到pathinfo.json中的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pixel(奇淼 committed Oct 26, 2024
1 parent c3fd7b9 commit 6bb8f8a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
17 changes: 17 additions & 0 deletions web/src/pathInfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"/src/view/about/index.vue": "About",
"/src/view/dashboard/components/banner.vue": "Banner",
"/src/view/dashboard/components/card.vue": "Card",
"/src/view/dashboard/components/charts-content-numbers.vue": "ChartsContentNumbers",
"/src/view/dashboard/components/charts-people-numbers.vue": "ChartsPeopleNumbers",
"/src/view/dashboard/components/charts.vue": "Charts",
"/src/view/dashboard/components/notice.vue": "Notice",
"/src/view/dashboard/components/pluginTable.vue": "PluginTable",
"/src/view/dashboard/components/quickLinks.vue": "QuickLinks",
"/src/view/dashboard/components/table.vue": "Table",
"/src/view/dashboard/components/wiki.vue": "Wiki",
"/src/view/dashboard/index.vue": "Dashboard",
"/src/view/error/index.vue": "Error",
"/src/view/error/reload.vue": "Reload",
Expand All @@ -13,7 +23,10 @@
"/src/view/layout/aside/asideComponent/menuItem.vue": "MenuItem",
"/src/view/layout/aside/combinationMode.vue": "GvaAside",
"/src/view/layout/aside/headMode.vue": "GvaAside",
"/src/view/layout/aside/index.vue": "Index",
"/src/view/layout/aside/normalMode.vue": "GvaAside",
"/src/view/layout/header/index.vue": "Index",
"/src/view/layout/header/tools.vue": "Tools",
"/src/view/layout/index.vue": "GvaLayout",
"/src/view/layout/screenfull/index.vue": "Screenfull",
"/src/view/layout/search/search.vue": "BtnBox",
Expand All @@ -30,19 +43,23 @@
"/src/view/superAdmin/dictionary/sysDictionary.vue": "SysDictionary",
"/src/view/superAdmin/dictionary/sysDictionaryDetail.vue": "SysDictionaryDetail",
"/src/view/superAdmin/index.vue": "SuperAdmin",
"/src/view/superAdmin/menu/components/components-cascader.vue": "ComponentsCascader",
"/src/view/superAdmin/menu/icon.vue": "Icon",
"/src/view/superAdmin/menu/menu.vue": "Menus",
"/src/view/superAdmin/operation/sysOperationRecord.vue": "SysOperationRecord",
"/src/view/superAdmin/params/sysParams.vue": "SysParams",
"/src/view/superAdmin/user/user.vue": "User",
"/src/view/system/state.vue": "State",
"/src/view/systemTools/autoCode/component/fieldDialog.vue": "FieldDialog",
"/src/view/systemTools/autoCode/component/previewCodeDialg.vue": "PreviewCodeDialg",
"/src/view/systemTools/autoCode/index.vue": "AutoCode",
"/src/view/systemTools/autoCodeAdmin/index.vue": "AutoCodeAdmin",
"/src/view/systemTools/autoPkg/autoPkg.vue": "AutoPkg",
"/src/view/systemTools/exportTemplate/exportTemplate.vue": "ExportTemplate",
"/src/view/systemTools/formCreate/index.vue": "FormGenerator",
"/src/view/systemTools/index.vue": "System",
"/src/view/systemTools/installPlugin/index.vue": "Index",
"/src/view/systemTools/pubPlug/pubPlug.vue": "PubPlug",
"/src/view/systemTools/system/system.vue": "Config",
"/src/plugin/announcement/form/info.vue": "InfoForm",
"/src/plugin/announcement/view/info.vue": "Info",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ const emits = defineEmits(['change'])
const pathOptions = ref([])
const tempPath = ref('')
const activeComponent = ref('')
const activeComponent = ref([])
const pathIsSelect = ref(true)
const togglePathIsSelect = () => {
if(pathIsSelect.value){
tempPath.value = activeComponent.value?.join('/')
tempPath.value = activeComponent.value?.join('/') || ''
}else{
activeComponent.value = tempPath.value.split('/')
console.log(activeComponent.value)
activeComponent.value = tempPath.value?.split('/') || []
}
pathIsSelect.value = !pathIsSelect.value
Expand Down
12 changes: 9 additions & 3 deletions web/vitePlugin/componentName/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import fs from 'fs';
import path from 'path';
import chokidar from 'chokidar';

const toPascalCase = (str) => {
return str.replace(/(^\w|-\w)/g, clearAndUpper);
};

const clearAndUpper = (text) => {
return text.replace(/-/, '').toUpperCase();
};

// 递归获取目录下所有的 .vue 文件
const getAllVueFiles = (dir, fileList = []) => {
const files = fs.readdirSync(dir);
Expand Down Expand Up @@ -35,10 +43,8 @@ const vueFilePathPlugin = (outputFilePath) => {
const pathNameMap = vueFiles.reduce((acc, filePath) => {
const content = fs.readFileSync(filePath, 'utf-8');
const componentName = extractComponentName(content);
if (componentName) {
let relativePath ="/" + path.relative(root, filePath).replace(/\\/g, '/');
acc[relativePath] = componentName;
}
acc[relativePath] = componentName || toPascalCase(path.basename(filePath, '.vue'));
return acc;
}, {});
const outputContent = JSON.stringify(pathNameMap, null, 2);
Expand Down

0 comments on commit 6bb8f8a

Please sign in to comment.