mirror of
https://github.com/purocean/yn.git
synced 2026-10-16 15:41:46 +08:00
fix: restore default terminal font when setting is empty
This commit is contained in:
@@ -29,6 +29,7 @@ export default defineComponent({
|
||||
const domRef = ref<HTMLElement | null>(null)
|
||||
|
||||
let xterm: Terminal | null = null
|
||||
let defaultFontFamily: string | undefined
|
||||
// eslint-disable-next-line no-undef
|
||||
let socket: Socket | null = null
|
||||
let resizeObserver: ResizeObserver | null = null
|
||||
@@ -72,7 +73,7 @@ export default defineComponent({
|
||||
|
||||
return {
|
||||
fontSize: getSetting('terminal.font-size', 16),
|
||||
fontFamily: fontFamily || undefined,
|
||||
fontFamily: fontFamily || defaultFontFamily,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,14 +101,17 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
if (!xterm) {
|
||||
const { fontFamily, ...terminalOptions } = getTerminalOptions()
|
||||
xterm = new Terminal({
|
||||
cols: 80,
|
||||
rows: 24,
|
||||
cursorStyle: 'underline',
|
||||
fontWeightBold: '500',
|
||||
...getTerminalOptions(),
|
||||
...terminalOptions,
|
||||
...opts
|
||||
})
|
||||
defaultFontFamily = xterm.options.fontFamily
|
||||
xterm.options.fontFamily = opts?.fontFamily || fontFamily || defaultFontFamily
|
||||
|
||||
changeTheme()
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ const mocks = vi.hoisted(() => ({
|
||||
dispose = vi.fn()
|
||||
|
||||
constructor (options: any) {
|
||||
this.options = options
|
||||
this.options = { fontFamily: 'courier-new, courier, monospace', ...options }
|
||||
mocks.terminals.push(this)
|
||||
}
|
||||
},
|
||||
@@ -221,7 +221,7 @@ describe('Xterm', () => {
|
||||
mocks.settings.set('terminal.font-family', '')
|
||||
mocks.settingHandler({ changedKeys: ['terminal.font-size'] })
|
||||
expect(term.options.fontSize).toBe(20)
|
||||
expect(term.options.fontFamily).toBeUndefined()
|
||||
expect(term.options.fontFamily).toBe('courier-new, courier, monospace')
|
||||
expect(mocks.fitAddons[0].fit).toHaveBeenCalledTimes(3)
|
||||
|
||||
socket.handlers.get('disconnect')?.()
|
||||
|
||||
Reference in New Issue
Block a user