|
|
@@ -7,6 +7,11 @@ import ServiceFormDialog from './components/ServiceFormDialog.vue'
|
|
|
import LogDialog from './components/LogDialog.vue'
|
|
|
import PortKillDialog from './components/PortKillDialog.vue'
|
|
|
import CategoryTree from './components/CategoryTree.vue'
|
|
|
+import AppConfirm from './components/AppConfirm.vue'
|
|
|
+import AppToast from './components/AppToast.vue'
|
|
|
+import { useDialog } from './composables/useDialog'
|
|
|
+
|
|
|
+const { confirm, toast } = useDialog()
|
|
|
|
|
|
const services = ref<ServiceConfig[]>([])
|
|
|
const loading = ref(false)
|
|
|
@@ -75,12 +80,18 @@ const handleEdit = (service: ServiceConfig) => {
|
|
|
}
|
|
|
|
|
|
const handleDelete = async (id: string) => {
|
|
|
- if (!confirm('确定要删除此服务吗?')) return
|
|
|
+ const ok = await confirm({
|
|
|
+ message: '确定要删除此服务吗?',
|
|
|
+ danger: true,
|
|
|
+ confirmText: '删除',
|
|
|
+ })
|
|
|
+ if (!ok) return
|
|
|
try {
|
|
|
await serviceApi.delete(id)
|
|
|
await fetchServices()
|
|
|
+ toast('服务已删除', 'success')
|
|
|
} catch (e) {
|
|
|
- alert('删除失败: ' + (e as Error).message)
|
|
|
+ toast('删除失败:' + (e as Error).message, 'error')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -90,7 +101,7 @@ const handleStart = async (id: string) => {
|
|
|
await fetchServices()
|
|
|
} catch (e: any) {
|
|
|
const msg = e?.response?.data?.error || e.message
|
|
|
- alert('启动失败: ' + msg)
|
|
|
+ toast('启动失败:' + msg, 'error')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -100,7 +111,7 @@ const handleStop = async (id: string) => {
|
|
|
await fetchServices()
|
|
|
} catch (e: any) {
|
|
|
const msg = e?.response?.data?.error || e.message
|
|
|
- alert('停止失败: ' + msg)
|
|
|
+ toast('停止失败:' + msg, 'error')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -126,7 +137,7 @@ const handleStartAll = async () => {
|
|
|
await serviceApi.startAll()
|
|
|
await fetchServices()
|
|
|
} catch (e: any) {
|
|
|
- alert('一键启动失败: ' + e.message)
|
|
|
+ toast('一键启动失败:' + e.message, 'error')
|
|
|
} finally {
|
|
|
loading.value = false
|
|
|
}
|
|
|
@@ -138,7 +149,7 @@ const handleStopAll = async () => {
|
|
|
await serviceApi.stopAll()
|
|
|
await fetchServices()
|
|
|
} catch (e: any) {
|
|
|
- alert('一键停止失败: ' + e.message)
|
|
|
+ toast('一键停止失败:' + e.message, 'error')
|
|
|
} finally {
|
|
|
loading.value = false
|
|
|
}
|
|
|
@@ -153,9 +164,10 @@ const handleFormSave = async (data: ServiceConfig) => {
|
|
|
}
|
|
|
showFormDialog.value = false
|
|
|
await fetchServices()
|
|
|
+ toast('保存成功', 'success')
|
|
|
} catch (e: any) {
|
|
|
const msg = e?.response?.data?.error || e.message
|
|
|
- alert('保存失败: ' + msg)
|
|
|
+ toast('保存失败:' + msg, 'error')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -277,6 +289,9 @@ onUnmounted(() => {
|
|
|
:service-name="portServiceName"
|
|
|
@killed="handlePortKilled"
|
|
|
/>
|
|
|
+
|
|
|
+ <AppConfirm />
|
|
|
+ <AppToast />
|
|
|
</div>
|
|
|
</template>
|
|
|
|