feat: 概览页重启按钮优化 (#2926)

Refs #2921
This commit is contained in:
ssongliu 2023-11-13 15:02:08 +08:00 committed by GitHub
parent 78576a3724
commit fb556d6149
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 28 deletions

View file

@ -31,7 +31,7 @@ func NewIDashboardService() IDashboardService {
} }
func (u *DashboardService) Restart(operation string) error { func (u *DashboardService) Restart(operation string) error {
if operation != "panel" && operation != "system" { if operation != "1panel" && operation != "system" {
return fmt.Errorf("handle restart operation %s failed, err: nonsupport such operation", operation) return fmt.Errorf("handle restart operation %s failed, err: nonsupport such operation", operation)
} }
itemCmd := fmt.Sprintf("%s 1pctl restart", cmd.SudoHandleCmd()) itemCmd := fmt.Sprintf("%s 1pctl restart", cmd.SudoHandleCmd())

View file

@ -6,8 +6,8 @@
</div> </div>
</template> </template>
<div> <div>
<span style="font-size: 12px">{{ operationInfo }}</span> <span v-if="operationInfo" style="font-size: 12px">{{ operationInfo }}</span>
<div style="margin-top: 10px"> <div :style="{ 'margin-top': operationInfo ? '10px' : '0px' }">
<span style="font-size: 12px">{{ $t('commons.msg.operateConfirm') }}</span> <span style="font-size: 12px">{{ $t('commons.msg.operateConfirm') }}</span>
<span style="font-size: 12px; color: red; font-weight: 500">'{{ submitInputInfo }}'</span> <span style="font-size: 12px; color: red; font-weight: 500">'{{ submitInputInfo }}'</span>
</div> </div>

View file

@ -286,9 +286,6 @@ const message = {
home: { home: {
restart_1panel: 'Restart Panel', restart_1panel: 'Restart Panel',
restart_system: 'Restart Server', restart_system: 'Restart Server',
panel: '1Panel',
system: '1Panel Server',
restartHelper: 'About to restart {0}, do you want to continue?',
operationSuccess: 'Operation successful! Restarting, please wait...', operationSuccess: 'Operation successful! Restarting, please wait...',
overview: 'Overview', overview: 'Overview',
entranceHelper: entranceHelper:

View file

@ -284,9 +284,6 @@ const message = {
home: { home: {
restart_1panel: '重啟面板', restart_1panel: '重啟面板',
restart_system: '重啟服務器', restart_system: '重啟服務器',
panel: '1Panel 面板',
system: '1Panel 服務器',
restartHelper: '即將重新啟動 {0}是否繼續',
operationSuccess: '操作成功正在重啟請稍候...', operationSuccess: '操作成功正在重啟請稍候...',
overview: '概覽', overview: '概覽',
entranceHelper: '設置安全入口有利於提高系統的安全性如有需要前往 面板設置-安全 啟用安全入口', entranceHelper: '設置安全入口有利於提高系統的安全性如有需要前往 面板設置-安全 啟用安全入口',

View file

@ -284,9 +284,6 @@ const message = {
home: { home: {
restart_1panel: '重启面板', restart_1panel: '重启面板',
restart_system: '重启服务器', restart_system: '重启服务器',
panel: '1Panel 面板',
system: '1Panel 服务器',
restartHelper: '即将重新启动 {0}是否继续',
operationSuccess: '操作成功正在重启请稍候...', operationSuccess: '操作成功正在重启请稍候...',
overview: '概览', overview: '概览',
entranceHelper: '设置安全入口有利于提高系统的安全性如有需要前往 面板设置-安全 启用安全入口', entranceHelper: '设置安全入口有利于提高系统的安全性如有需要前往 面板设置-安全 启用安全入口',

View file

@ -10,11 +10,11 @@
> >
<template #route-button> <template #route-button>
<div class="router-button"> <div class="router-button">
<el-button link type="primary" @click="restart('panel')"> <el-button link type="primary" @click="onRestart('1panel')">
{{ $t('home.restart_1panel') }} {{ $t('home.restart_1panel') }}
</el-button> </el-button>
<el-divider direction="vertical" /> <el-divider direction="vertical" />
<el-button link type="primary" @click="restart('system')"> <el-button link type="primary" @click="onRestart('system')">
{{ $t('home.restart_system') }} {{ $t('home.restart_system') }}
</el-button> </el-button>
</div> </div>
@ -230,10 +230,13 @@
</CardWithHeader> </CardWithHeader>
</el-col> </el-col>
</el-row> </el-row>
<ConfirmDialog ref="confirmDialogRef" @confirm="onSave"></ConfirmDialog>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
import { onMounted, onBeforeUnmount, ref, reactive } from 'vue'; import { onMounted, onBeforeUnmount, ref, reactive } from 'vue';
import Status from '@/views/home/status/index.vue'; import Status from '@/views/home/status/index.vue';
import App from '@/views/home/app/index.vue'; import App from '@/views/home/app/index.vue';
@ -252,6 +255,8 @@ const router = useRouter();
const globalStore = GlobalStore(); const globalStore = GlobalStore();
const statusRef = ref(); const statusRef = ref();
const restartType = ref();
const confirmDialogRef = ref();
const appRef = ref(); const appRef = ref();
const isSafety = ref(); const isSafety = ref();
@ -540,20 +545,19 @@ const loadSafeStatus = async () => {
isSafety.value = res.data.securityEntrance; isSafety.value = res.data.securityEntrance;
}; };
const restart = async (type: string) => { const onRestart = (type: string) => {
ElMessageBox.confirm( restartType.value = type;
i18n.global.t('home.restartHelper', [i18n.global.t('home.' + type)]), let params = {
i18n.global.t('commons.msg.operate'), header: i18n.global.t('home.restart_' + type),
{ operationInfo: '',
confirmButtonText: i18n.global.t('commons.button.confirm'), submitInputInfo: i18n.global.t('database.restartNow'),
cancelButtonText: i18n.global.t('commons.button.cancel'), };
type: 'info', confirmDialogRef.value!.acceptParams(params);
}, };
).then(async () => { const onSave = async () => {
globalStore.isOnRestart = true; globalStore.isOnRestart = true;
MsgSuccess(i18n.global.t('home.operationSuccess')); MsgSuccess(i18n.global.t('home.operationSuccess'));
await systemRestart(type); await systemRestart(restartType.value);
});
}; };
const onFocus = () => { const onFocus = () => {