File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " moviepilot" ,
3- "version" : " 1.1.4 " ,
3+ "version" : " 1.1.5 " ,
44 "private" : true ,
55 "scripts" : {
66 "dev" : " vite --host" ,
Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import { useStore } from ' vuex'
3+ import { useConfirm } from ' vuetify-use-dialog'
4+ import { useToast } from ' vue-toast-notification'
35import router from ' @/router'
46import avatar1 from ' @images/avatars/avatar-1.png'
7+ import api from ' @/api'
58
69// Vuex Store
710const store = useStore ()
811
12+ // 确认框
13+ const createConfirm = useConfirm ()
14+
15+ // 提示框
16+ const $toast = useToast ()
17+
918// 执行注销操作
1019function 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中获取信息
1959const superUser = store .state .auth .superUser
2060const 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 >
You can’t perform that action at this time.
0 commit comments