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

fix(vue3): Optimize the priority of calculating the displayed name of the component on the devtool #2050

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/app-backend-vue3/src/components/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export function getInstanceName (instance) {
for (const key in instance.appContext?.components) {
if (instance.appContext.components[key] === instance.type) return saveComponentName(instance, key)
}
const fileName = getComponentFileName(instance.type || {})
if (fileName) {
return fileName
}
return 'Anonymous Component'
}

Expand All @@ -45,10 +49,10 @@ function saveComponentName (instance, key) {
}

function getComponentTypeName (options) {
const name = options.name || options._componentTag || options.__vdevtools_guessedName || options.__name
if (name) {
return name
}
return options.name || options._componentTag || options.__vdevtools_guessedName || options.__name
}

function getComponentFileName (options) {
const file = options.__file // injected by vue-loader
if (file) {
return classify(basename(file, '.vue'))
Expand Down