Skip to content

Commit c950c91

Browse files
committed
feat: pass url params
1 parent 073f4ef commit c950c91

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/api/modules/workspace.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ function getTerminalTabByPane(pane: TerminalTabPane, info: Partial<TerminalTab>
5353
return tabs.find(tab => tab.pane?.name === pane.name && isMatch(tab, info))
5454
}
5555

56-
function createPaneTab(pane: TerminalTabPane, info?: Partial<TerminalTab>) {
56+
export type PaneTabInfo = Pick<TerminalTab, 'command' | 'process' | 'cwd' | 'shell'>
57+
58+
function createPaneTab(pane: TerminalTabPane, info?: Partial<PaneTabInfo>) {
5759
return reactive({
5860
pid: 0,
5961
process: pane.name,
@@ -65,7 +67,7 @@ function createPaneTab(pane: TerminalTabPane, info?: Partial<TerminalTab>) {
6567
} as TerminalTab)
6668
}
6769

68-
function openPaneTab(name: string, info?: Partial<TerminalTab>) {
70+
function openPaneTab(name: string, info?: Partial<PaneTabInfo>) {
6971
const pane = getPane(name)
7072
if (!pane) return
7173
if (!pane.volatile) {

src/renderer/compositions/terminal.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { WebglAddon } from '@xterm/addon-webgl'
1313
import type { IMarker, ITerminalOptions } from '@xterm/xterm'
1414
import { Terminal } from '@xterm/xterm'
1515
import { toKeyEvent } from 'keyboardevent-from-electron-accelerator'
16-
import { isMatch, trim } from 'lodash'
16+
import { isMatch, pick, trim } from 'lodash'
1717
import type { MaybeRefOrGetter } from 'vue'
1818
import { effectScope, markRaw, nextTick, reactive, shallowReactive, toRaw, toValue, watch, watchEffect } from 'vue'
1919
import { ipcRenderer } from '@commas/electron-ipc'
@@ -584,7 +584,15 @@ export function handleTerminalMessages() {
584584
ipcRenderer.on('open-url', (event, address) => {
585585
const url = new URL(address)
586586
const paths = trim(url.pathname, '/').split('/')
587-
commas.proxy.workspace.openPaneTab(paths[0])
587+
commas.proxy.workspace.openPaneTab(
588+
paths[0],
589+
pick(Object.fromEntries(url.searchParams), [
590+
'command',
591+
'process',
592+
'cwd',
593+
'shell',
594+
]),
595+
)
588596
paneTabURL = address
589597
})
590598
ipcRenderer.on('save', () => {

0 commit comments

Comments
 (0)