Skip to content

Commit d2058ad

Browse files
committed
fix launcher tab
1 parent d65ffec commit d2058ad

File tree

3 files changed

+48
-12
lines changed

3 files changed

+48
-12
lines changed

src/web/components/log.tsx

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import Color from 'color'
12
import { css, styled } from 'decorock'
2-
import { Component, createEffect, createSignal, For } from 'solid-js'
3+
import { on, Component, createEffect, createSignal, For, Show } from 'solid-js'
34

45
import { classnames } from '~/web/lib/classnames'
56

@@ -13,6 +14,17 @@ const Container = styled.div`
1314
font-size: 0.9rem;
1415
white-space: nowrap;
1516
}
17+
18+
a {
19+
color: ${(p) =>
20+
p.theme.name === 'light'
21+
? Color('rgb(0, 255, 255)').darken(0.25)
22+
: Color('rgb(0, 255, 255)')};
23+
text-underline-offset: 2px;
24+
&:hover {
25+
text-decoration: underline;
26+
}
27+
}
1628
`
1729

1830
export const Log: Component<{
@@ -22,14 +34,18 @@ export const Log: Component<{
2234
autoScroll?: boolean
2335
}> = (props) => {
2436
const [ref, setRef] = createSignal<HTMLDivElement>()
25-
createEffect(() => {
26-
if (typeof props.autoScroll !== 'undefined' && !props.autoScroll) return
27-
props.children
28-
setTimeout(() => {
29-
const el = ref()!
30-
el.scrollTop = el.scrollHeight
31-
})
32-
})
37+
const [onBottom, setOnBottom] = createSignal(true)
38+
39+
createEffect(
40+
on(
41+
() => props.children,
42+
() => {
43+
const el = ref()!
44+
if (typeof props.autoScroll !== 'undefined' && !props.autoScroll) return
45+
if (onBottom()) el.scrollTop = el.scrollHeight
46+
},
47+
),
48+
)
3349

3450
return (
3551
<Container
@@ -45,8 +61,28 @@ export const Log: Component<{
4561
overflow-y: auto;
4662
`,
4763
)}
64+
onScroll={(e) => {
65+
setOnBottom(
66+
e.currentTarget.scrollHeight - e.currentTarget.scrollTop === e.currentTarget.clientHeight,
67+
)
68+
}}
4869
>
49-
<For each={props.children}>{(log) => <p>{log}</p>}</For>
70+
<For each={props.children}>
71+
{(log) => {
72+
const logs = log.split(/(http:\/\/[^\s]+)/g)
73+
return (
74+
<p>
75+
<For each={logs}>
76+
{(t) => (
77+
<Show when={t.match(/(http:\/\/[^\s]+)/)} fallback={t}>
78+
<a href={t}>{t}</a>
79+
</Show>
80+
)}
81+
</For>
82+
</p>
83+
)
84+
}}
85+
</For>
5086
</Container>
5187
)
5288
}

src/web/pages/webui/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const WebUI = () => {
6666
overflow-y: auto;
6767
`}
6868
show={isSelected()}
69-
unmount={label !== 'UI'}
69+
unmount={label !== 'UI' && label !== 'Launcher'}
7070
>
7171
<Comp />
7272
</TabPanel>

src/web/pages/webui/launcher.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const createArgs = () => {
4949
if (!key.startsWith('webui/args')) continue
5050
const arg = key.split('/').slice(-1)[0]
5151
if (arg === 'custom') result += ` ${val}`
52-
else if (typeof val === 'boolean' && val) result += ` --${arg}`
52+
else if (typeof val === 'boolean') result += val ? ` --${arg}` : ''
5353
else if (typeof val === 'string') result += ` --${arg} "${val}"`.replace(/\\/g, '\\\\')
5454
else result += ` --${arg} ${val}`
5555
}

0 commit comments

Comments
 (0)