From 624a0d330739c0a01efb9a4516339cafe4055599 Mon Sep 17 00:00:00 2001 From: yanglbme Date: Sun, 30 Aug 2020 09:43:05 +0800 Subject: [PATCH] fix: update date path --- src/api/file.js | 6 ++-- src/assets/scripts/util.js | 2 +- src/components/CodemirrorEditor/header.vue | 22 ++++++------ .../CodemirrorEditor/resetDialog.vue | 4 +-- .../CodemirrorEditor/rightClickMenu.vue | 4 +-- src/view/CodemirrorEditor.vue | 34 +++++++++---------- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/api/file.js b/src/api/file.js index 5b7e850..250ecd1 100644 --- a/src/api/file.js +++ b/src/api/file.js @@ -16,12 +16,12 @@ const fileUploadConfig = { } -function fileUpload(content, fileName) { +function fileUpload(content, filename) { const date = new Date(); - const dir = date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate(); + const dir = date.getFullYear() + '/' + (date.getMonth() + 1).toString().padStart(2, '0') + '/' + date.getDate().toString().padStart(2, '0'); const uuid = uuidv4(); const token = fileUploadConfig.accessToken[Math.floor(Math.random() * fileUploadConfig.accessToken.length)].replace('doocsmd', ''); - const dateFilename = new Date().getTime() + '-' + uuid + '.' + fileName.split('.')[1]; + const dateFilename = new Date().getTime() + '-' + uuid + '.' + filename.split('.')[1]; const url = `https://api.github.com/repos/${fileUploadConfig.username}/${fileUploadConfig.repo}/contents/${dir}/${dateFilename}`; return fetch({ diff --git a/src/assets/scripts/util.js b/src/assets/scripts/util.js index 6d417e4..18339cf 100644 --- a/src/assets/scripts/util.js +++ b/src/assets/scripts/util.js @@ -200,7 +200,7 @@ export function fixCodeWhiteSpace(value = 'pre') { const preDomList = document.getElementsByClassName('code__pre'); if (preDomList.length > 0) { - preDomList.forEach(pre=> { + preDomList.forEach(pre => { pre.style.whiteSpace = value; }) } diff --git a/src/components/CodemirrorEditor/header.vue b/src/components/CodemirrorEditor/header.vue index ec2fb7c..bccd457 100644 --- a/src/components/CodemirrorEditor/header.vue +++ b/src/components/CodemirrorEditor/header.vue @@ -109,14 +109,14 @@ export default { return !this.nightMode ? 'success' : 'default'; }, ...mapState({ - output: state=> state.output, - editor: state=> state.editor, - cssEditor: state=> state.cssEditor, - currentFont: state=> state.currentFont, - currentSize: state=> state.currentSize, - currentColor: state=> state.currentColor, - codeTheme: state=> state.codeTheme, - nightMode: state=> state.nightMode + output: state => state.output, + editor: state => state.editor, + cssEditor: state => state.cssEditor, + currentFont: state => state.currentFont, + currentSize: state => state.currentSize, + currentColor: state => state.currentColor, + codeTheme: state => state.codeTheme, + nightMode: state => state.nightMode }) }, methods: { @@ -156,9 +156,9 @@ export default { }, // 图片上传前的处理 beforeUpload(file) { - uploadImgFile(file).then(res=> { + uploadImgFile(file).then(res => { this.$emit('uploaded', res) - }).catch(err=> { + }).catch(err => { this.$message({ showClose: true, message: err, @@ -201,7 +201,7 @@ export default { e.target.blur(); }, // 自定义CSS样式 - async customStyle () { + async customStyle() { this.$emit('showCssEditor'); this.$nextTick(() => { if(!this.cssEditor) { diff --git a/src/components/CodemirrorEditor/resetDialog.vue b/src/components/CodemirrorEditor/resetDialog.vue index 90be414..30aaeca 100644 --- a/src/components/CodemirrorEditor/resetDialog.vue +++ b/src/components/CodemirrorEditor/resetDialog.vue @@ -21,10 +21,10 @@ export default { }, computed: { btnType() { - return !this.nightMode ? 'success' : 'default'; + return this.nightMode ? 'default' : 'success'; }, ...mapState({ - nightMode: state=> state.nightMode + nightMode: state => state.nightMode }) } } diff --git a/src/components/CodemirrorEditor/rightClickMenu.vue b/src/components/CodemirrorEditor/rightClickMenu.vue index 4d0f6e8..ce9b4ff 100644 --- a/src/components/CodemirrorEditor/rightClickMenu.vue +++ b/src/components/CodemirrorEditor/rightClickMenu.vue @@ -59,9 +59,9 @@ export default { // 空函数,阻断el-upload上传 // 图片上传前的处理 beforeUpload(file) { - uploadImgFile(file).then(res=> { + uploadImgFile(file).then(res => { this.$emit('menuTick', 'insertPic', res) - }).catch(err=> { + }).catch(err => { this.$message({ showClose: true, message: err, diff --git a/src/view/CodemirrorEditor.vue b/src/view/CodemirrorEditor.vue index 92ce4f9..fcc9651 100644 --- a/src/view/CodemirrorEditor.vue +++ b/src/view/CodemirrorEditor.vue @@ -93,14 +93,14 @@ export default { }, computed: { ...mapState({ - wxRenderer: state=> state.wxRenderer, - output: state=> state.output, - editor: state=> state.editor, - cssEditor: state=> state.cssEditor, - currentSize: state=> state.currentSize, - currentColor: state=> state.currentColor, - nightMode: state=> state.nightMode, - rightClickMenuVisible: state=> state.rightClickMenuVisible + wxRenderer: state => state.wxRenderer, + output: state => state.output, + editor: state => state.editor, + cssEditor: state => state.cssEditor, + currentSize: state => state.currentSize, + currentColor: state => state.currentColor, + nightMode: state => state.nightMode, + rightClickMenuVisible: state => state.rightClickMenuVisible }) }, created() { @@ -132,9 +132,9 @@ export default { if (item.kind === 'file') { this.isImgLoading = true; const pasteFile = item.getAsFile() - uploadImgFile(pasteFile).then(res=> { + uploadImgFile(pasteFile).then(res => { this.uploaded(res) - }).catch(err=> { + }).catch(err => { this.$message({ showClose: true, message: err, @@ -206,7 +206,7 @@ export default { }, // 左右滚动 leftAndRightScroll() { - const scrollCB = text=> { + const scrollCB = text => { let source, target; clearTimeout(this.timeout); @@ -214,14 +214,14 @@ export default { source = this.$refs.preview.$el; target = document.getElementsByClassName('CodeMirror-scroll')[0]; this.editor.off('scroll', editorScrollCB); - this.timeout = setTimeout(()=> { + this.timeout = setTimeout(() => { this.editor.on('scroll', editorScrollCB); }, 300); } else if (text === 'editor') { source = document.getElementsByClassName('CodeMirror-scroll')[0]; target = this.$refs.preview.$el; target.removeEventListener("scroll", previewScrollCB, false); - this.timeout = setTimeout(()=> { + this.timeout = setTimeout(() => { target.addEventListener("scroll", previewScrollCB, false); }, 300); } @@ -231,10 +231,10 @@ export default { target.scrollTo(0, height); }; - const editorScrollCB = ()=> { + const editorScrollCB = () => { scrollCB('editor'); }; - const previewScrollCB = ()=> { + const previewScrollCB = () => { scrollCB('preview'); }; @@ -244,12 +244,12 @@ export default { // 更新编辑器 onEditorRefresh() { this.editorRefresh(); - setTimeout(()=> PR.prettyPrint(), 0); + setTimeout(() => PR.prettyPrint(), 0); }, // 复制结束 endCopy() { this.backLight = false; - setTimeout(()=> { + setTimeout(() => { this.isCoping = false; }, 800); },