-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
476 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<template> | ||
<div> | ||
<el-drawer v-model="drawerVisiable" :destroy-on-close="true" :close-on-click-modal="false" size="30%"> | ||
<template #header> | ||
<DrawerHeader :header="$t('setting.title')" :back="handleClose" /> | ||
</template> | ||
<el-form ref="formRef" label-position="top" :model="form" @submit.prevent v-loading="loading"> | ||
<el-row type="flex" justify="center"> | ||
<el-col :span="22"> | ||
<el-form-item :label="$t('setting.title')" prop="panelName" :rules="Rules.requiredInput"> | ||
<el-input clearable v-model="form.panelName" /> | ||
</el-form-item> | ||
</el-col> | ||
</el-row> | ||
</el-form> | ||
<template #footer> | ||
<span class="dialog-footer"> | ||
<el-button @click="drawerVisiable = false">{{ $t('commons.button.cancel') }}</el-button> | ||
<el-button :disabled="loading" type="primary" @click="onSavePanelName(formRef)"> | ||
{{ $t('commons.button.confirm') }} | ||
</el-button> | ||
</span> | ||
</template> | ||
</el-drawer> | ||
</div> | ||
</template> | ||
<script lang="ts" setup> | ||
import { computed, reactive, ref } from 'vue'; | ||
import i18n from '@/lang'; | ||
import { MsgSuccess } from '@/utils/message'; | ||
import { updateSetting } from '@/api/modules/setting'; | ||
import { FormInstance } from 'element-plus'; | ||
import { Rules } from '@/global/form-rules'; | ||
import { GlobalStore } from '@/store'; | ||
const globalStore = GlobalStore(); | ||
const themeConfig = computed(() => globalStore.themeConfig); | ||
const emit = defineEmits<{ (e: 'search'): void }>(); | ||
interface DialogProps { | ||
panelName: string; | ||
} | ||
const drawerVisiable = ref(); | ||
const loading = ref(); | ||
const form = reactive({ | ||
panelName: '', | ||
}); | ||
const formRef = ref<FormInstance>(); | ||
const acceptParams = (params: DialogProps): void => { | ||
form.panelName = params.panelName; | ||
drawerVisiable.value = true; | ||
}; | ||
const onSavePanelName = async (formEl: FormInstance | undefined) => { | ||
if (!formEl) return; | ||
formEl.validate(async (valid) => { | ||
if (!valid) return; | ||
await updateSetting({ key: 'PanelName', value: form.panelName }) | ||
.then(async () => { | ||
globalStore.setThemeConfig({ ...themeConfig.value, panelName: form.panelName }); | ||
document.title = form.panelName; | ||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); | ||
loading.value = false; | ||
drawerVisiable.value = false; | ||
emit('search'); | ||
return; | ||
}) | ||
.catch(() => { | ||
loading.value = false; | ||
}); | ||
}); | ||
}; | ||
const handleClose = () => { | ||
drawerVisiable.value = false; | ||
}; | ||
defineExpose({ | ||
acceptParams, | ||
}); | ||
</script> |
Oops, something went wrong.