Skip to content

Commit de2d1d1

Browse files
committed
fix(browser): url interaction
1 parent c9cd812 commit de2d1d1

File tree

2 files changed

+6
-27
lines changed

2 files changed

+6
-27
lines changed

addons/browser/locales/zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"New Page#!browser.1": "新页面",
33
"Open Web Page#!browser.2": "打开网页",
44
"Web Page#!browser.3": "网页",
5+
"Enter URL...#!browser.4": "输入 URL...",
56
"Browse URL#!cli.description.browse": "访问 URL",
67
"<url>#!cli.usage.browse": "<url>"
78
}

addons/browser/src/renderer/BrowserPane.vue

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import type { TerminalTab } from '@commas/types/terminal'
33
import * as commas from 'commas:api/renderer'
44
import normalizeURL from 'normalize-url'
5-
import { nextTick, watchEffect } from 'vue'
5+
import { watchEffect } from 'vue'
66
77
const { tab } = defineProps<{
88
tab: TerminalTab,
99
}>()
1010
11-
const { TerminalPane, WebContents, VisualIcon } = commas.ui.vueAssets
11+
const { TerminalPane, WebContents, VisualIcon, vI18n } = commas.ui.vueAssets
1212
1313
let url = $computed({
1414
get: () => tab.command,
@@ -41,22 +41,13 @@ function goBack() {
4141
view.goToOffset(-1)
4242
}
4343
44-
let isCustomizing = $ref(false)
4544
let customURL: string | undefined = $ref<string>()
4645
let customURLElement = $ref<HTMLInputElement>()
4746
4847
watchEffect(() => {
4948
customURL = url
5049
})
5150
52-
async function startCustomization() {
53-
isCustomizing = true
54-
await nextTick()
55-
if (customURLElement) {
56-
customURLElement.select()
57-
}
58-
}
59-
6051
async function customize() {
6152
if (customURL && customURL !== url) {
6253
url = normalizeURL(customURL, {
@@ -69,12 +60,10 @@ async function customize() {
6960
sortQueryParameters: false,
7061
})
7162
}
72-
isCustomizing = false
7363
}
7464
7565
function resetCustomization() {
7666
customURL = url
77-
isCustomizing = false
7867
}
7968
8069
function autoselect(event: FocusEvent) {
@@ -107,18 +96,18 @@ watchEffect((onInvalidate) => {
10796
<button type="button" data-commas :class="['browser-action', { disabled: !view?.canGoBack }]" @click="goBack">
10897
<VisualIcon name="lucide-undo-2" />
10998
</button>
110-
<form v-if="isCustomizing" class="custom-url-form" @submit.prevent="customize">
99+
<form class="custom-url-form" @submit.prevent="customize">
111100
<input
112101
ref="customURLElement"
113102
v-model="customURL"
103+
v-i18n:placeholder
114104
class="custom-url"
105+
placeholder="Enter URL...#!browser.4"
115106
autofocus
116107
@focus="autoselect"
117-
@blur="resetCustomization"
118108
@keydown.esc="resetCustomization"
119109
>
120110
</form>
121-
<span v-else class="page-url" @click="startCustomization">{{ url }}</span>
122111
<button type="button" data-commas :class="['browser-action', { disabled: !url }]" @click="openExternal">
123112
<VisualIcon name="lucide-square-arrow-out-up-right" />
124113
</button>
@@ -176,17 +165,6 @@ watchEffect((onInvalidate) => {
176165
background: transparent;
177166
outline: none;
178167
}
179-
.page-url {
180-
display: flex;
181-
flex: 1;
182-
align-self: stretch;
183-
align-items: center;
184-
min-width: 0;
185-
font-size: 12px;
186-
white-space: nowrap;
187-
text-overflow: ellipsis;
188-
overflow: hidden;
189-
}
190168
.web-page {
191169
flex: 1;
192170
min-height: 0;

0 commit comments

Comments
 (0)