@@ -7,11 +7,6 @@ import type { PluginOption, ServerOptions } from 'vite'
7
7
import { compileSFCTemplate } from './compiler'
8
8
import { idToFile , parseVueRequest } from './utils'
9
9
10
- function getInspectorPath ( ) {
11
- const pluginPath = normalizePath ( path . dirname ( fileURLToPath ( import . meta. url ) ) )
12
- return pluginPath . replace ( / \/ d i s t $ / , '/\/src' )
13
- }
14
-
15
10
export interface VueInspectorClient {
16
11
enabled : boolean
17
12
position : {
@@ -76,6 +71,21 @@ export interface VitePluginInspectorOptions {
76
71
appendTo ?: string
77
72
}
78
73
74
+ const toggleComboKeysMap = {
75
+ control : process . platform === 'win32' ? 'Ctrl(^)' : 'Control(^)' ,
76
+ meta : 'Command(⌘)' ,
77
+ shift : 'Shift(⇧)' ,
78
+ }
79
+
80
+ function getInspectorPath ( ) {
81
+ const pluginPath = normalizePath ( path . dirname ( fileURLToPath ( import . meta. url ) ) )
82
+ return pluginPath . replace ( / \/ d i s t $ / , '/\/src' )
83
+ }
84
+
85
+ export function normalizeComboKeyPrint ( toggleComboKey : string ) {
86
+ return toggleComboKey . split ( '-' ) . map ( key => toggleComboKeysMap [ key ] || key [ 0 ] . toUpperCase ( ) + key . slice ( 1 ) ) . join ( dim ( '+' ) )
87
+ }
88
+
79
89
export const DEFAULT_INSPECTOR_OPTIONS : VitePluginInspectorOptions = {
80
90
vue : 3 ,
81
91
enabled : false ,
@@ -139,9 +149,10 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
139
149
} ,
140
150
configureServer ( server ) {
141
151
const _printUrls = server . printUrls
152
+
142
153
server . printUrls = ( ) => {
143
154
const { toggleComboKey } = normalizedOptions
144
- const keys = toggleComboKey . split ( '-' ) . map ( k => k [ 0 ] . toUpperCase ( ) + k . slice ( 1 ) ) . join ( dim ( '+' ) )
155
+ const keys = normalizeComboKeyPrint ( toggleComboKey )
145
156
_printUrls ( )
146
157
console . log ( ` ${ green ( '➜' ) } ${ bold ( 'Vue Inspector' ) } : ${ green ( `Press ${ yellow ( keys ) } in App to toggle the Inspector` ) } \n` )
147
158
}
0 commit comments