diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 82b0b1ab..aa4b3148 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -78,8 +78,8 @@ const useAppStore = defineStore('app', { */ getLoginBackground(state) { const path = state.loginBackground; - if (!path) { - return ''; + if (!path || path === '#') { + return '#'; } if (validHttp(path)) { return path; diff --git a/src/views/login.vue b/src/views/login.vue index 6378310b..055b2d9b 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -89,7 +89,7 @@ function fnGetCaptcha() { // 判断是否有背景地址 const calcBG = computed(() => { const bgURL = appStore.getLoginBackground; - if (bgURL) { + if (bgURL && bgURL !== '#') { return { backgroundImage: `url(${bgURL})`, backgroundPosition: 'center', @@ -101,9 +101,6 @@ const calcBG = computed(() => { onMounted(() => { fnGetCaptcha(); - const container = document.getElementsByClassName('container').item(0); - if (container) { - } }); /**改变多语言 */ diff --git a/src/views/system/setting/components/change-login-bg.vue b/src/views/system/setting/components/change-login-bg.vue index 03edc1b7..91e93a15 100644 --- a/src/views/system/setting/components/change-login-bg.vue +++ b/src/views/system/setting/components/change-login-bg.vue @@ -76,7 +76,7 @@ function fnUpload(up: UploadRequestOption) { function fnEdit(v: boolean) { state.edite = v; if (!v) { - state.filePath = ''; + state.filePath = '#'; state.flag = appStore.getLoginBackground; } } @@ -107,8 +107,35 @@ function fnSave() { }); } +/**还原初始背景 */ +function fnRevert() { + Modal.confirm({ + title: '提示', + content: `确认要将背景图还原到系统初始默认的背景吗?`, + onOk() { + // 发送请求 + const hide = message.loading('请稍等...', 0); + state.loading = true; + state.filePath = '#'; + changeValue({ key: 'sys.loginBackground', value: state.filePath }).then( + res => { + state.loading = false; + hide(); + if (res.code === RESULT_CODE_SUCCESS) { + message.success('还原成功', 3); + appStore.loginBackground = state.filePath; + fnEdit(false); + } else { + message.error(res.msg, 3); + } + } + ); + }, + }); +} + onMounted(() => { - state.filePath = ''; + state.filePath = appStore.getLoginBackground; state.flag = appStore.getLoginBackground; }); @@ -117,7 +144,8 @@ onMounted(() => { @@ -152,14 +180,18 @@ onMounted(() => { - 系统登录界面背景样式如预览区域所示
- 请将选择合适的图片进行进行上传。 + 系统登录界面背景样式如预览区域所示,请以实际显示为准
+ 请将选择合适的图片进行进行上传。
+ 通过点击《还原》按钮,将背景图还原到系统初始默认的背景。
@@ -169,7 +201,9 @@ onMounted(() => {