Skip to content

Commit 6cc9c1a

Browse files
committed
feat 内建重启
1 parent fffb1c6 commit 6cc9c1a

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "moviepilot",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

src/layouts/components/UserProfile.vue

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
<script setup lang="ts">
22
import { useStore } from 'vuex'
3+
import { useConfirm } from 'vuetify-use-dialog'
4+
import { useToast } from 'vue-toast-notification'
35
import router from '@/router'
46
import avatar1 from '@images/avatars/avatar-1.png'
7+
import api from '@/api'
58
69
// Vuex Store
710
const store = useStore()
811
12+
// 确认框
13+
const createConfirm = useConfirm()
14+
15+
// 提示框
16+
const $toast = useToast()
17+
918
// 执行注销操作
1019
function logout() {
1120
// 清除登录状态信息
@@ -15,6 +24,37 @@ function logout() {
1524
router.push('/login')
1625
}
1726
27+
// 执行重启操作
28+
async function restart() {
29+
// 弹出提示
30+
const confirmed = await createConfirm({
31+
title: '确认',
32+
content: '确认重启系统吗?',
33+
confirmationText: '确认',
34+
cancellationText: '取消',
35+
dialogProps: {
36+
maxWidth: '30rem',
37+
},
38+
})
39+
40+
if (confirmed) {
41+
// 调用API重启
42+
try {
43+
const result: { [key: string]: any } = await api.get('system/restart')
44+
if (!result.success) {
45+
// 重启成功
46+
$toast.error(result.message)
47+
return
48+
}
49+
}
50+
catch (error) {
51+
console.error(error)
52+
}
53+
// 注销
54+
logout()
55+
}
56+
}
57+
1858
// 从Vuex Store中获取信息
1959
const superUser = store.state.auth.superUser
2060
const userName = store.state.auth.userName
@@ -93,6 +133,19 @@ const avatar = store.state.auth.avatar
93133
<!-- Divider -->
94134
<VDivider class="my-2" />
95135

136+
<!-- 👉 restart -->
137+
<VListItem @click="restart">
138+
<template #prepend>
139+
<VIcon
140+
class="me-2"
141+
icon="mdi-restart"
142+
size="22"
143+
/>
144+
</template>
145+
146+
<VListItemTitle>重启</VListItemTitle>
147+
</VListItem>
148+
96149
<!-- 👉 Logout -->
97150
<VListItem @click="logout">
98151
<template #prepend>

0 commit comments

Comments
 (0)