Skip to content

Commit 687d238

Browse files
authored
feat(component): Add support for better naming of /index.vue components (#1994)
1 parent dbea1f0 commit 687d238

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

packages/app-backend-vue3/src/components/util.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { classify } from '@vue-devtools/shared-utils'
2-
import { basename } from '../util'
1+
import { classify, basename } from '@vue-devtools/shared-utils'
32
import { ComponentInstance, App } from '@vue/devtools-api'
43
import { BackendContext } from '@vue-devtools/app-backend-api'
54

packages/app-backend-vue3/src/util.ts

-9
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ export function flatten (items) {
99
}, [])
1010
}
1111

12-
// Use a custom basename functions instead of the shimed version
13-
// because it doesn't work on Windows
14-
export function basename (filename, ext) {
15-
return path.basename(
16-
filename.replace(/^[a-zA-Z]:/, '').replace(/\\/g, '/'),
17-
ext,
18-
)
19-
}
20-
2112
export function returnError (cb: () => any) {
2213
try {
2314
return cb()

packages/shared-utils/src/util.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,13 @@ export function getCustomDateDetails (val: Date) {
359359

360360
// Use a custom basename functions instead of the shimed version
361361
// because it doesn't work on Windows
362-
function basename (filename, ext) {
362+
export function basename (filename, ext) {
363+
filename = filename.replace(/\\/g, '/')
364+
if (filename.includes(`/index${ext}`)) {
365+
filename = filename.replace(`/index${ext}`, ext)
366+
}
363367
return path.basename(
364-
filename.replace(/^[a-zA-Z]:/, '').replace(/\\/g, '/'),
368+
filename.replace(/^[a-zA-Z]:/, ''),
365369
ext,
366370
)
367371
}

packages/shell-dev-vue3/src/App.vue

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import SetupScript from './SetupScript.vue'
2121
import SetupDataLike from './SetupDataLike.vue'
2222
import SetupTSScriptProps from './SetupTSScriptProps.vue'
2323
import DomOrder from './DomOrder.vue'
24+
import IndexComponent from './IndexComponent/index.vue'
2425
2526
import { h, createApp } from 'vue'
2627
import SimplePlugin from './devtools-plugin/simple'
@@ -51,6 +52,7 @@ export default {
5152
SetupDataLike,
5253
SetupTSScriptProps,
5354
DomOrder,
55+
IndexComponent,
5456
inline: {
5557
render: () => h('h3', 'Inline component definition'),
5658
},
@@ -122,6 +124,7 @@ export default {
122124
</div>
123125

124126
<Child question="Life" />
127+
<IndexComponent />
125128
<NestedMore />
126129
<NativeTypes ref="nativeTypes" />
127130
<EventEmit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<h2>Index component</h2>
3+
</template>

0 commit comments

Comments
 (0)