From 07956353784fb1157a197faade08e27c426c42cf Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Mon, 25 Jul 2022 16:10:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20?= =?UTF-8?q?=E4=BB=AA=E8=A1=A8=E6=9D=BF=E8=83=8C=E6=99=AF=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E9=87=8D=E6=96=B0=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/staticResource/staticResource.js | 10 +- frontend/src/lang/en.js | 11 +- frontend/src/lang/tw.js | 3 + frontend/src/lang/zh.js | 3 + frontend/src/views/background/index.vue | 2 +- .../PanelStyle/BackgroundSelector.vue | 152 ++++++++++++------ 6 files changed, 121 insertions(+), 60 deletions(-) diff --git a/frontend/src/api/staticResource/staticResource.js b/frontend/src/api/staticResource/staticResource.js index 40ee10055e..9af311c16d 100644 --- a/frontend/src/api/staticResource/staticResource.js +++ b/frontend/src/api/staticResource/staticResource.js @@ -2,9 +2,7 @@ import request from '@/utils/request' import { uuid } from 'vue-uuid' import store from '@/store' -export function uploadFile(fileId, file) { - const param = new FormData() - param.append('file', file.file) +export function uploadFile(fileId, param) { return request({ url: '/static/resource/upload/' + fileId, method: 'post', @@ -16,10 +14,12 @@ export function uploadFile(fileId, file) { export function uploadFileResult(file, callback) { const fileId = uuid.v1() - const fileName = file.file.name + const fileName = file.name const newFileName = fileId + fileName.substr(fileName.lastIndexOf('.'), fileName.length) const fileUrl = store.state.staticResourcePath + newFileName - uploadFile(fileId, file).then(() => { + const param = new FormData() + param.append('file', file) + uploadFile(fileId, param).then(() => { callback(fileUrl) }) } diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index e0e3fb7cd6..429ffa0efa 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -1544,10 +1544,13 @@ export default { sure_bt: 'Confirm' }, panel: { - create_by: '创建人', - create_time: '创建时间', - update_by: '最近修改人', - update_time: '最近修改时间', + panel_background_item: 'Customize panel background', + panel_background_image_tips: 'Currently.Jpeg,.Jpg,.Png,.Gif files are supported, and the size should not exceed 15m', + reUpload: 'reUpload', + create_by: 'Create By', + create_time: 'Create Time', + update_by: 'Update By', + update_time: 'Update Time', target_url: 'Target Url', target_url_tips: 'You can click fields to splice URLs or parameters', select_world: 'Select World', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 1119087f3c..82b5fa89e7 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -1544,6 +1544,9 @@ export default { sure_bt: '確定' }, panel: { + panel_background_item: '自定义仪表板背景', + panel_background_image_tips: '当前支持.jpeg,.jpg,.png,.gif文件,大小不要超过15M', + reUpload: '重新上传', create_by: '创建人', create_time: '创建时间', update_by: '最近修改人', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 1767f03c2e..4bc67a27ac 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -1552,6 +1552,9 @@ export default { sure_bt: '确定' }, panel: { + panel_background_item: '自定义仪表板背景', + panel_background_image_tips: '当前支持.jpeg,.jpg,.png,.gif文件,大小不要超过15M', + reUpload: '重新上传', create_by: '创建人', create_time: '创建时间', update_by: '最近修改人', diff --git a/frontend/src/views/background/index.vue b/frontend/src/views/background/index.vue index c1659f9d3b..df0ed3d101 100644 --- a/frontend/src/views/background/index.vue +++ b/frontend/src/views/background/index.vue @@ -213,7 +213,7 @@ export default { }, upload(file) { const _this = this - uploadFileResult(file, (fileUrl) => { + uploadFileResult(file.file, (fileUrl) => { _this.curComponent.commonBackground.outerImage = fileUrl }) } diff --git a/frontend/src/views/panel/SubjectSetting/PanelStyle/BackgroundSelector.vue b/frontend/src/views/panel/SubjectSetting/PanelStyle/BackgroundSelector.vue index 9b672f2485..e4d73faa64 100644 --- a/frontend/src/views/panel/SubjectSetting/PanelStyle/BackgroundSelector.vue +++ b/frontend/src/views/panel/SubjectSetting/PanelStyle/BackgroundSelector.vue @@ -1,49 +1,47 @@ @@ -59,6 +57,7 @@ export default { name: 'BackgroundSelector', data() { return { + maxImageSize: 15000000, fileList: [], dialogImageUrl: '', dialogVisible: false, @@ -82,6 +81,9 @@ export default { } }, methods: { + goFile() { + this.$refs.files.click() + }, commitStyle() { const canvasStyleData = deepCopy(this.canvasStyleData) canvasStyleData.panel = this.panel @@ -103,11 +105,34 @@ export default { }, upload(file) { const _this = this + if (file.size > this.maxImageSize) { + this.sizeMessage() + } + uploadFileResult(file.file, (fileUrl) => { + _this.$store.state.styleChangeTimes++ + _this.panel.imageUrl = fileUrl + _this.fileList = [{ url: this.panel.imageUrl }] + _this.commitStyle() + }) + }, + reUpload(e) { + const file = e.target.files[0] + const _this = this + if (file.size > this.maxImageSize) { + this.sizeMessage() + } uploadFileResult(file, (fileUrl) => { _this.$store.state.styleChangeTimes++ _this.panel.imageUrl = fileUrl + _this.fileList = [{ url: this.panel.imageUrl }] _this.commitStyle() }) + }, + sizeMessage() { + this.$notify({ + message: '背景图片请不要大于15M', + position: 'top-left' + }) } } } @@ -115,18 +140,22 @@ export default {