Skip to content

Commit e60e628

Browse files
committed
feat: better service starting, again
1 parent 736908e commit e60e628

5 files changed

Lines changed: 35 additions & 13 deletions

File tree

frontend/src/App.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { AuthState } from './stores'
33
import Clarity from '@microsoft/clarity'
44
import { Zap } from 'lucide-vue-next'
5-
import { onMounted, ref } from 'vue'
5+
import { onMounted, ref, watch } from 'vue'
66
import { useI18n } from 'vue-i18n'
77
import { useRouter } from 'vue-router'
88
import AppSidebar from '@/components/AppSidebar.vue'
@@ -12,13 +12,14 @@ import { SidebarInset, SidebarProvider, SidebarTrigger } from '@/components/ui/s
1212
import { Toaster } from '@/components/ui/sonner'
1313
import { useThemeStore } from '@/stores/theme'
1414
import ActionHandler from '@/views/ActionHandler.vue'
15-
import { useAuthStore } from './stores'
15+
import { useAuthStore, useServiceStore } from './stores'
1616
import 'vue-sonner/style.css'
1717
1818
const { t } = useI18n()
1919
const authStore = useAuthStore()
2020
const { replace, currentRoute } = useRouter()
2121
const themeStore = useThemeStore()
22+
const serviceStore = useServiceStore()
2223
2324
const authState = ref<AuthState | null>(null)
2425
const isCheckingAuth = ref(true)
@@ -33,6 +34,12 @@ onMounted(async () => {
3334
setTimeout(() => replace(currentRoute.value.path), 100)
3435
Clarity.init('sx60zbxtfz')
3536
})
37+
38+
watch(() => serviceStore.serverConnected, async (connected) => {
39+
if (connected) {
40+
authState.value = await authStore.checkAuth()
41+
}
42+
})
3643
</script>
3744

3845
<template>

frontend/src/components/LoginForm.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
import { ref } from 'vue'
33
import { useI18n } from 'vue-i18n'
44
import ServiceStatus from '@/components/ServiceStatus.vue'
5+
import StartServiceButton from '@/components/StartServiceButton.vue'
56
import ThemeToggle from '@/components/ThemeToggle.vue'
67
import { Button } from '@/components/ui/button'
78
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
89
import { Input } from '@/components/ui/input'
9-
import { useAuthStore } from '@/stores'
10+
import { useAuthStore, useServiceStore } from '@/stores'
1011
1112
const props = defineProps<{
1213
register?: boolean
1314
}>()
1415
1516
const { t } = useI18n()
17+
const serverStore = useServiceStore()
1618
const authStore = useAuthStore()
1719
1820
const username = ref('')
@@ -120,6 +122,7 @@ async function handleSubmit() {
120122
/>
121123
</div>
122124
<Button
125+
v-if="authStore.isLoading || serverStore.serverConnected"
123126
type="submit"
124127
class="w-full"
125128
:disabled="authStore.isLoading"
@@ -134,6 +137,14 @@ async function handleSubmit() {
134137
</div>
135138
<span v-else>{{ props.register ? t('loginForm.register') : t('loginForm.login') }}</span>
136139
</Button>
140+
<StartServiceButton v-else>
141+
<Button
142+
type="button"
143+
class="w-full opacity-50"
144+
>
145+
{{ t('service.disconnected') }}
146+
</Button>
147+
</StartServiceButton>
137148
<div
138149
v-if="errorMessage"
139150
id="error-message"

frontend/src/components/StartServiceButton.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ watch(() => serviceStore.serverConnected, (connected) => {
4444
<template>
4545
<AlertDialog v-model:open="showStartServiceDialog">
4646
<AlertDialogTrigger as-child>
47-
<Button
48-
size="sm"
49-
variant="link"
50-
class="inline underline px-0 opacity-80 hover:opacity-100 h-6"
51-
:class="props.class"
52-
>
53-
{{ t('service.tryStart') }}
54-
</Button>
47+
<slot>
48+
<Button
49+
size="sm"
50+
variant="link"
51+
class="inline underline px-0 opacity-80 hover:opacity-100 h-6"
52+
:class="props.class"
53+
>
54+
{{ t('service.tryStart') }}
55+
</Button>
56+
</slot>
5557
</AlertDialogTrigger>
5658
<AlertDialogContent>
5759
<AlertDialogHeader>

frontend/src/locales/en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@
440440
"passwordMismatch": "Passwords do not match",
441441
"operationFailed": "Operation failed",
442442
"networkError": "Network connection failed",
443-
"unknownError": "Unknown error"
443+
"unknownError": "Unknown error",
444+
"startService": "Start Service"
444445
},
445446
"stores": {
446447
"app": {

frontend/src/locales/zh-CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@
440440
"passwordMismatch": "两次输入的密码不一致",
441441
"operationFailed": "操作失败",
442442
"networkError": "网络连接失败",
443-
"unknownError": "未知错误"
443+
"unknownError": "未知错误",
444+
"startService": "启动服务"
444445
},
445446
"stores": {
446447
"app": {

0 commit comments

Comments
 (0)