Skip to content

Commit 91fdaf4

Browse files
committed
chore: update
2 parents 2c429ba + 946ec80 commit 91fdaf4

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

packages/core/src/index.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ import type { PluginOption, ServerOptions } from 'vite'
77
import { compileSFCTemplate } from './compiler'
88
import { idToFile, parseVueRequest } from './utils'
99

10-
function getInspectorPath() {
11-
const pluginPath = normalizePath(path.dirname(fileURLToPath(import.meta.url)))
12-
return pluginPath.replace(/\/dist$/, '/\/src')
13-
}
14-
1510
export interface VueInspectorClient {
1611
enabled: boolean
1712
position: {
@@ -76,6 +71,21 @@ export interface VitePluginInspectorOptions {
7671
appendTo?: string
7772
}
7873

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(/\/dist$/, '/\/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+
7989
export const DEFAULT_INSPECTOR_OPTIONS: VitePluginInspectorOptions = {
8090
vue: 3,
8191
enabled: false,
@@ -139,9 +149,10 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
139149
},
140150
configureServer(server) {
141151
const _printUrls = server.printUrls
152+
142153
server.printUrls = () => {
143154
const { toggleComboKey } = normalizedOptions
144-
const keys = toggleComboKey.split('-').map(k => k[0].toUpperCase() + k.slice(1)).join(dim('+'))
155+
const keys = normalizeComboKeyPrint(toggleComboKey)
145156
_printUrls()
146157
console.log(` ${green('➜')} ${bold('Vue Inspector')}: ${green(`Press ${yellow(keys)} in App to toggle the Inspector`)}\n`)
147158
}

packages/unplugin/src/nuxt.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { dim, green, yellow } from 'kolorist'
2-
import { DEFAULT_INSPECTOR_OPTIONS } from 'vite-plugin-vue-inspector'
1+
import { green, yellow } from 'kolorist'
2+
import { DEFAULT_INSPECTOR_OPTIONS, normalizeComboKeyPrint } from 'vite-plugin-vue-inspector'
33
import type { Options } from './types'
44
import unplugin from '.'
55

@@ -17,7 +17,7 @@ export default (options: Options, nuxt: any) => {
1717
return
1818
const normalizedOptions = { ...DEFAULT_INSPECTOR_OPTIONS, ...options }
1919
const { toggleComboKey } = normalizedOptions
20-
const keys = toggleComboKey.split('-').map(k => k[0].toUpperCase() + k.slice(1)).join(dim('+'))
20+
const keys = normalizeComboKeyPrint(toggleComboKey)
2121
console.log(` ${'> Vue Inspector'}: ${green(`Press ${yellow(keys)} in App to toggle the Inspector`)}\n`)
2222
printed = true
2323
})

0 commit comments

Comments
 (0)