Skip to content

Commit 23db48e

Browse files
committed
feat:优化连接设置
1 parent aee2fd1 commit 23db48e

File tree

4 files changed

+88
-60
lines changed

4 files changed

+88
-60
lines changed

apps/frontend/app/pages/no-signal.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ const goConnectionSettings = () => {
1212
from: String(route.query.from || '/'),
1313
},
1414
},
15+
{ replace: true },
1516
)
1617
}
18+
19+
const retryConnection = () => {
20+
const target = String(route.query.from || '/')
21+
navigateTo(target, { replace: true })
22+
}
1723
</script>
1824

1925
<template>
@@ -26,9 +32,11 @@ const goConnectionSettings = () => {
2632

2733
<div class="relative mx-auto flex min-h-full w-full max-w-3xl items-center justify-center px-4 py-10">
2834
<section
29-
class="w-full rounded-3xl border border-base-content/10 bg-base-100/72 p-8 text-center shadow-[0_20px_80px_rgba(0,0,0,0.18)] backdrop-blur-xl md:p-10">
35+
class="w-full rounded-3xl border border-base-content/10 bg-base-100/72 p-8 text-center shadow-[0_20px_80px_rgba(0,0,0,0.18)] backdrop-blur-xl md:p-10"
36+
>
3037
<div
31-
class="mx-auto grid h-16 w-16 place-items-center rounded-2xl border border-error/25 bg-error/10 text-error">
38+
class="mx-auto grid h-16 w-16 place-items-center rounded-2xl border border-error/25 bg-error/10 text-error"
39+
>
3240
<Icon name="mingcute:wifi-off-line" size="30" />
3341
</div>
3442

@@ -37,7 +45,10 @@ const goConnectionSettings = () => {
3745
当前设备与后端服务连接超时,应用已进入保护状态。请检查网络或更新服务地址后继续使用。
3846
</p>
3947

40-
<div class="mt-8 flex justify-center">
48+
<div class="mt-8 flex justify-center gap-3">
49+
<button class="btn btn-ghost rounded-xl px-7" @click="retryConnection">
50+
重试连接
51+
</button>
4152
<button class="btn btn-primary rounded-xl px-7" @click="goConnectionSettings">
4253
设置连接
4354
</button>

apps/frontend/app/pages/settings/connection.vue

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script setup lang="ts">
1+
<script setup lang="ts">
22
import { normalizeEndpointUrl, probeBackendReachability, resolveRuntimeApiBaseUrl } from '~/utils/backend-endpoint'
33
44
definePageMeta({ layout: 'default' })
@@ -24,10 +24,34 @@ const normalizeWsInput = (value: string) => normalizeEndpointUrl(value, { defaul
2424
const normalizedServerUrl = computed(() => normalizeHttpInput(form.backendServerUrl))
2525
const canSave = computed(() => !!normalizedServerUrl.value)
2626
27-
const handleBack = () => {
28-
// const target = String(route.query.from || '/')
29-
// navigateTo(target, { replace: true })
30-
router.back();
27+
const resolveFallbackTarget = () => {
28+
const from = String(route.query.from || '').trim()
29+
if (from && !from.startsWith('/settings/connection') && !from.startsWith('/no-signal')) {
30+
return from
31+
}
32+
return '/settings/general'
33+
}
34+
35+
const navigateBackSafely = async () => {
36+
const fallback = resolveFallbackTarget()
37+
if (String(route.query.from || '').trim()) {
38+
await navigateTo(fallback, { replace: true })
39+
return
40+
}
41+
42+
if (import.meta.client && window.history.length > 1) {
43+
const before = `${window.location.pathname}${window.location.search}`
44+
router.back()
45+
await new Promise((resolve) => setTimeout(resolve, 120))
46+
const after = `${window.location.pathname}${window.location.search}`
47+
if (after !== before) return
48+
}
49+
50+
await navigateTo(fallback, { replace: true })
51+
}
52+
53+
const handleBack = async () => {
54+
await navigateBackSafely()
3155
}
3256
3357
const socketEndpoint = computed(() => {
@@ -108,7 +132,7 @@ async function saveAndRetry() {
108132
// ? fallback
109133
// : from
110134
// await navigateTo(target)
111-
router.back();
135+
await navigateBackSafely()
112136
} finally {
113137
saving.value = false
114138
}
@@ -118,7 +142,7 @@ async function saveAndRetry() {
118142
<template>
119143
<div class="min-h-full bg-transparent px-4 py-8">
120144
<div class="mx-auto w-full max-w-2xl">
121-
<section class="rounded-2xl border border-base-content/10 bg-base-100/80 p-6 shadow-sm backdrop-blur-md md:p-7">
145+
<section class="rounded-2xl p-6 shadow-sm backdrop-blur-md md:p-7">
122146
<header class="mb-6">
123147
<button class="btn btn-ghost btn-sm mb-3 rounded-lg px-2" @click="handleBack">
124148
<Icon name="mingcute:left-line" size="16" />
@@ -131,26 +155,24 @@ async function saveAndRetry() {
131155
<div class="grid grid-cols-1 gap-4">
132156
<label class="form-control">
133157
<div class="label py-1">
134-
<span class="label-text text-sm font-medium">服务器地址</span>
158+
<span class="label-text text-sm font-medium">服务器地址</span>
135159
</div>
136160
<input v-model="form.backendServerUrl" type="text" class="input input-bordered h-11 rounded-xl bg-base-100"
137161
placeholder="例如 10.105.86.133:8080 或 api.example.com" />
138162
</label>
139163
</div>
140164

141-
<div class="mt-5 rounded-xl border border-base-content/10 bg-base-200/45 p-4">
142-
<div class="grid grid-cols-1 gap-3">
143-
<label class="form-control">
144-
<span class="mb-1 text-xs font-medium text-base-content/65">Socket 地址</span>
145-
<input :value="socketEndpoint || '请先填写服务器地址'" type="text"
146-
class="input input-bordered h-10 rounded-lg bg-base-100/70 text-sm" readonly />
147-
</label>
148-
<label class="form-control">
149-
<span class="mb-1 text-xs font-medium text-base-content/65">LiveKit 地址</span>
150-
<input :value="livekitEndpoint || '请先填写服务器地址'" type="text"
151-
class="input input-bordered h-10 rounded-lg bg-base-100/70 text-sm" readonly />
152-
</label>
153-
</div>
165+
<div class="grid grid-cols-1 gap-3 mt-2">
166+
<label class="form-control">
167+
<span class="mb-1 text-xs font-medium text-base-content/65">Socket 地址:</span>
168+
<input :value="socketEndpoint || '请先填写服务器地址'" type="text"
169+
class="input input-bordered h-10 rounded-lg bg-base-100/70 text-sm" readonly />
170+
</label>
171+
<label class="form-control">
172+
<span class="mb-1 text-xs font-medium text-base-content/65">LiveKit 地址:</span>
173+
<input :value="livekitEndpoint || '请先填写服务器地址'" type="text"
174+
class="input input-bordered h-10 rounded-lg bg-base-100/70 text-sm" readonly />
175+
</label>
154176
</div>
155177

156178
<div class="mt-6 flex items-center gap-2">

apps/frontend/app/pages/settings/index/about.vue

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const toast = useToast()
66
const { copy } = useClipboard()
77
88
const appName = 'Junction'
9-
const appVersion = '1.0.0'
9+
const appVersion = '0.1.1'
1010
const buildDate = '2026-02-02'
1111
1212
const linkItems = [
@@ -56,15 +56,15 @@ const copyBuildInfo = async () => {
5656
</script>
5757

5858
<template>
59-
<div class="min-h-full w-full overflow-y-auto bg-transparent p-4 font-sans text-base-content selection:bg-base-content/20 sm:p-8">
59+
<div
60+
class="min-h-full w-full overflow-y-auto bg-transparent p-4 font-sans text-base-content selection:bg-base-content/20 sm:p-8">
6061
<div class="mx-auto flex w-full max-w-2xl flex-col gap-8">
61-
<section class="flex flex-col items-center gap-6 rounded-[2rem] border border-base-content/5 bg-base-content/[0.02] p-6 shadow-sm sm:flex-row sm:items-start sm:p-8">
62-
<div class="group flex h-20 w-20 shrink-0 items-center justify-center rounded-2xl border border-base-content/10 bg-base-content/[0.04]">
63-
<Icon
64-
name="mingcute:asterisk-fill"
65-
size="3rem"
66-
class="h-10 w-10 text-base-content/80 transition-transform duration-700 ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:rotate-180"
67-
/>
62+
<section
63+
class="flex flex-col items-center gap-6 rounded-[2rem] border border-base-content/5 bg-base-content/[0.02] p-6 shadow-sm sm:flex-row sm:items-start sm:p-8">
64+
<div
65+
class="group flex h-20 w-20 shrink-0 items-center justify-center rounded-2xl border border-base-content/10 bg-base-content/[0.04]">
66+
<Icon name="mingcute:asterisk-fill" size="3rem"
67+
class="h-10 w-10 text-base-content/80 transition-transform duration-700 ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:rotate-180" />
6868
</div>
6969

7070
<div class="flex flex-1 flex-col items-center gap-4 sm:items-start">
@@ -74,16 +74,17 @@ const copyBuildInfo = async () => {
7474
</div>
7575

7676
<div class="flex flex-wrap items-center justify-center gap-2 sm:justify-start">
77-
<span class="rounded-lg border border-base-content/5 bg-base-content/[0.03] px-3 py-1.5 text-xs font-medium text-base-content/70">
77+
<span
78+
class="rounded-lg border border-base-content/5 bg-base-content/[0.03] px-3 py-1.5 text-xs font-medium text-base-content/70">
7879
版本 {{ appVersion }}
7980
</span>
80-
<span class="rounded-lg border border-base-content/5 bg-base-content/[0.03] px-3 py-1.5 text-xs font-medium text-base-content/70">
81+
<span
82+
class="rounded-lg border border-base-content/5 bg-base-content/[0.03] px-3 py-1.5 text-xs font-medium text-base-content/70">
8183
构建于 {{ buildDate }}
8284
</span>
8385
<button
8486
class="ml-1 flex items-center gap-1.5 rounded-lg bg-base-content px-3.5 py-1.5 text-xs font-semibold text-base-100 shadow-md shadow-base-content/10 transition-all duration-200 hover:opacity-85 active:scale-95"
85-
@click="copyBuildInfo"
86-
>
87+
@click="copyBuildInfo">
8788
<Icon name="mingcute:copy-2-line" class="h-3.5 w-3.5" />
8889
<span>复制信息</span>
8990
</button>
@@ -93,49 +94,43 @@ const copyBuildInfo = async () => {
9394

9495
<section class="flex flex-col gap-3">
9596
<h2 class="pl-2 text-xs font-bold tracking-wider text-base-content/40">官方链接</h2>
96-
<div class="flex flex-col overflow-hidden rounded-3xl border border-base-content/5 bg-base-content/[0.02] shadow-sm">
97-
<button
98-
v-for="(item, index) in linkItems"
99-
:key="item.title"
97+
<div
98+
class="flex flex-col overflow-hidden rounded-3xl border border-base-content/5 bg-base-content/[0.02] shadow-sm">
99+
<button v-for="(item, index) in linkItems" :key="item.title"
100100
class="group flex w-full items-center gap-4 p-4 text-left transition-colors duration-300 hover:bg-base-content/[0.04]"
101101
:class="{ 'border-b border-base-content/5': index !== linkItems.length - 1 }"
102-
@click="openExternalUrl(item.url)"
103-
>
104-
<div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-base-content/5 bg-base-content/[0.04] text-base-content/60 transition-all duration-300 group-hover:bg-base-content group-hover:text-base-100">
102+
@click="openExternalUrl(item.url)">
103+
<div
104+
class="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-base-content/5 bg-base-content/[0.04] text-base-content/60 transition-all duration-300 group-hover:bg-base-content group-hover:text-base-100">
105105
<Icon :name="item.icon" class="h-5 w-5 transition-transform duration-300 group-hover:scale-110" />
106106
</div>
107107
<div class="flex min-w-0 flex-1 flex-col gap-0.5">
108108
<h3 class="text-sm font-semibold text-base-content/90">{{ item.title }}</h3>
109109
<p class="truncate text-xs text-base-content/50">{{ item.description }}</p>
110110
</div>
111-
<Icon
112-
name="mingcute:right-line"
113-
class="h-4 w-4 shrink-0 text-base-content/20 transition-all duration-300 group-hover:translate-x-1 group-hover:text-base-content/60"
114-
/>
111+
<Icon name="mingcute:right-line"
112+
class="h-4 w-4 shrink-0 text-base-content/20 transition-all duration-300 group-hover:translate-x-1 group-hover:text-base-content/60" />
115113
</button>
116114
</div>
117115
</section>
118116

119117
<section class="flex flex-col gap-3">
120118
<h2 class="pl-2 text-xs font-bold tracking-wider text-base-content/40">支持与反馈</h2>
121-
<div class="flex flex-col overflow-hidden rounded-3xl border border-base-content/5 bg-base-content/[0.02] shadow-sm">
122-
<button
123-
v-for="(item, index) in supportItems"
124-
:key="item.title"
119+
<div
120+
class="flex flex-col overflow-hidden rounded-3xl border border-base-content/5 bg-base-content/[0.02] shadow-sm">
121+
<button v-for="(item, index) in supportItems" :key="item.title"
125122
class="group flex w-full items-center gap-4 p-4 text-left transition-colors duration-300 hover:bg-base-content/[0.04]"
126123
:class="{ 'border-b border-base-content/5': index !== supportItems.length - 1 }"
127-
@click="openExternalUrl(item.url)"
128-
>
129-
<div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-base-content/5 bg-base-content/[0.04] text-base-content/60 transition-all duration-300 group-hover:bg-base-content group-hover:text-base-100">
124+
@click="openExternalUrl(item.url)">
125+
<div
126+
class="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-base-content/5 bg-base-content/[0.04] text-base-content/60 transition-all duration-300 group-hover:bg-base-content group-hover:text-base-100">
130127
<Icon :name="item.icon" class="h-5 w-5 transition-transform duration-300 group-hover:scale-110" />
131128
</div>
132129
<div class="min-w-0 flex-1">
133130
<h3 class="text-sm font-semibold text-base-content/90">{{ item.title }}</h3>
134131
</div>
135-
<Icon
136-
name="mingcute:external-link-line"
137-
class="h-4 w-4 shrink-0 text-base-content/20 transition-all duration-300 group-hover:-translate-y-0.5 group-hover:translate-x-0.5 group-hover:text-base-content/60"
138-
/>
132+
<Icon name="mingcute:external-link-line"
133+
class="h-4 w-4 shrink-0 text-base-content/20 transition-all duration-300 group-hover:-translate-y-0.5 group-hover:translate-x-0.5 group-hover:text-base-content/60" />
139134
</button>
140135
</div>
141136
</section>

apps/frontend/src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
33
"productName": "Junction",
4-
"version": "0.1.0",
4+
"version": "0.1.1",
55
"identifier": "com.junction.dev",
66
"build": {
77
"frontendDist": "../.output/public",

0 commit comments

Comments
 (0)