feat: makeClassNameByUrl

This commit is contained in:
FairyEver 2021-11-08 14:30:46 +08:00
parent e84827e900
commit a019df4c20
2 changed files with 2 additions and 10 deletions

View File

@ -16,7 +16,7 @@
<script>
import { makeNameByUrl } from 'd2/utils/component.js'
import { useMenuMainStore } from 'd2/store/menu-main.js'
import { computed, watch } from 'vue'
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { compact } from 'lodash-es'
import { storeToRefs } from 'pinia'
@ -41,14 +41,6 @@ export default {
const selectedKey = computed(() => getMenuId(getMenuByUrl(route.fullPath)))
watch(() => route.fullPath, value => {
console.log('route.fullPath', value)
})
watch(selectedKey, value => {
console.log('selectedKey', value)
})
const selectedKeys = computed(() => compact([selectedKey.value]))
const openKeys = computed(() => getMenuPids(selectedKey.value))

View File

@ -60,5 +60,5 @@ export function makeClassName (name) {
* @returns {string} component name. eg: 'name-space-foo-bar'
*/
export function makeClassNameByUrl (url) {
return kebabCase(camelCase(makeNameByUrl(url)))
return kebabCase(makeNameByUrl(url)).replace(/-(\d)/g, '$1')
}