Skip to content

Commit 50bf708

Browse files
committed
Open new tab when clicking file tree with mouse wheel
1 parent 0cec4b8 commit 50bf708

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

web_src/js/components/ViewFileTree.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ async function loadViewContent(url: string) {
3737
document.querySelector('.repo-view-content').innerHTML = await response.text();
3838
}
3939
40-
async function navigateTreeView(treePath: string) {
40+
async function navigateTreeView(treePath: string, newTab: boolean) {
4141
const url = `${props.repoLink}/src/${props.currentRefNameSubURL}/${pathEscapeSegments(treePath)}`;
42+
if (newTab) {
43+
window.open(url, '_blank');
44+
return;
45+
}
4246
window.history.pushState({treePath, url}, null, url);
4347
selectedItem.value = treePath;
4448
await loadViewContent(url);

web_src/js/components/ViewFileTreeItem.vue

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Item = {
1414
1515
const props = defineProps<{
1616
item: Item,
17-
navigateViewContent:(treePath: string) => void,
17+
navigateViewContent:(treePath: string, newTab: boolean) => void,
1818
loadChildren:(treePath: string, subPath?: string) => Promise<Item[]>,
1919
selectedItem?: string,
2020
}>();
@@ -35,13 +35,13 @@ const doLoadChildren = async () => {
3535
}
3636
};
3737
38-
const doLoadDirContent = () => {
39-
doLoadChildren();
40-
props.navigateViewContent(props.item.fullPath);
38+
const doLoadDirContent = (newTab: boolean) => {
39+
if (!newTab) doLoadChildren();
40+
props.navigateViewContent(props.item.fullPath, newTab);
4141
};
4242
43-
const doLoadFileContent = () => {
44-
props.navigateViewContent(props.item.fullPath);
43+
const doLoadFileContent = (newTab: boolean) => {
44+
props.navigateViewContent(props.item.fullPath, newTab);
4545
};
4646
4747
const doGotoSubModule = () => {
@@ -67,7 +67,8 @@ const doGotoSubModule = () => {
6767
v-else-if="item.entryMode === 'symlink'" class="tree-item type-symlink"
6868
:class="{'selected': selectedItem === item.fullPath}"
6969
:title="item.entryName"
70-
@click.stop="doLoadFileContent"
70+
@click.stop="doLoadFileContent(false)"
71+
@auxclick.stop="doLoadFileContent(true)"
7172
>
7273
<!-- symlink -->
7374
<div class="item-content">
@@ -80,7 +81,8 @@ const doGotoSubModule = () => {
8081
v-else-if="item.entryMode !== 'tree'" class="tree-item type-file"
8182
:class="{'selected': selectedItem === item.fullPath}"
8283
:title="item.entryName"
83-
@click.stop="doLoadFileContent"
84+
@click.stop="doLoadFileContent(false)"
85+
@auxclick.stop="doLoadFileContent(true)"
8486
>
8587
<!-- file -->
8688
<div class="item-content">
@@ -93,7 +95,8 @@ const doGotoSubModule = () => {
9395
v-else class="tree-item type-directory"
9496
:class="{'selected': selectedItem === item.fullPath}"
9597
:title="item.entryName"
96-
@click.stop="doLoadDirContent"
98+
@click.stop="doLoadDirContent(false)"
99+
@auxclick.stop="doLoadDirContent(true)"
97100
>
98101
<!-- directory -->
99102
<div class="item-toggle">

0 commit comments

Comments
 (0)