fix: update date path

This commit is contained in:
yanglbme 2020-08-30 09:43:05 +08:00
parent ec2ae4aa51
commit 624a0d3307
6 changed files with 36 additions and 36 deletions

View File

@ -16,12 +16,12 @@ const fileUploadConfig = {
} }
function fileUpload(content, fileName) { function fileUpload(content, filename) {
const date = new Date(); 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 uuid = uuidv4();
const token = fileUploadConfig.accessToken[Math.floor(Math.random() * fileUploadConfig.accessToken.length)].replace('doocsmd', ''); 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}`; const url = `https://api.github.com/repos/${fileUploadConfig.username}/${fileUploadConfig.repo}/contents/${dir}/${dateFilename}`;
return fetch({ return fetch({

View File

@ -200,7 +200,7 @@ export function fixCodeWhiteSpace(value = 'pre') {
const preDomList = document.getElementsByClassName('code__pre'); const preDomList = document.getElementsByClassName('code__pre');
if (preDomList.length > 0) { if (preDomList.length > 0) {
preDomList.forEach(pre=> { preDomList.forEach(pre => {
pre.style.whiteSpace = value; pre.style.whiteSpace = value;
}) })
} }

View File

@ -109,14 +109,14 @@ export default {
return !this.nightMode ? 'success' : 'default'; return !this.nightMode ? 'success' : 'default';
}, },
...mapState({ ...mapState({
output: state=> state.output, output: state => state.output,
editor: state=> state.editor, editor: state => state.editor,
cssEditor: state=> state.cssEditor, cssEditor: state => state.cssEditor,
currentFont: state=> state.currentFont, currentFont: state => state.currentFont,
currentSize: state=> state.currentSize, currentSize: state => state.currentSize,
currentColor: state=> state.currentColor, currentColor: state => state.currentColor,
codeTheme: state=> state.codeTheme, codeTheme: state => state.codeTheme,
nightMode: state=> state.nightMode nightMode: state => state.nightMode
}) })
}, },
methods: { methods: {
@ -156,9 +156,9 @@ export default {
}, },
// //
beforeUpload(file) { beforeUpload(file) {
uploadImgFile(file).then(res=> { uploadImgFile(file).then(res => {
this.$emit('uploaded', res) this.$emit('uploaded', res)
}).catch(err=> { }).catch(err => {
this.$message({ this.$message({
showClose: true, showClose: true,
message: err, message: err,
@ -201,7 +201,7 @@ export default {
e.target.blur(); e.target.blur();
}, },
// CSS // CSS
async customStyle () { async customStyle() {
this.$emit('showCssEditor'); this.$emit('showCssEditor');
this.$nextTick(() => { this.$nextTick(() => {
if(!this.cssEditor) { if(!this.cssEditor) {

View File

@ -21,10 +21,10 @@ export default {
}, },
computed: { computed: {
btnType() { btnType() {
return !this.nightMode ? 'success' : 'default'; return this.nightMode ? 'default' : 'success';
}, },
...mapState({ ...mapState({
nightMode: state=> state.nightMode nightMode: state => state.nightMode
}) })
} }
} }

View File

@ -59,9 +59,9 @@ export default {
// el-upload // el-upload
// //
beforeUpload(file) { beforeUpload(file) {
uploadImgFile(file).then(res=> { uploadImgFile(file).then(res => {
this.$emit('menuTick', 'insertPic', res) this.$emit('menuTick', 'insertPic', res)
}).catch(err=> { }).catch(err => {
this.$message({ this.$message({
showClose: true, showClose: true,
message: err, message: err,

View File

@ -93,14 +93,14 @@ export default {
}, },
computed: { computed: {
...mapState({ ...mapState({
wxRenderer: state=> state.wxRenderer, wxRenderer: state => state.wxRenderer,
output: state=> state.output, output: state => state.output,
editor: state=> state.editor, editor: state => state.editor,
cssEditor: state=> state.cssEditor, cssEditor: state => state.cssEditor,
currentSize: state=> state.currentSize, currentSize: state => state.currentSize,
currentColor: state=> state.currentColor, currentColor: state => state.currentColor,
nightMode: state=> state.nightMode, nightMode: state => state.nightMode,
rightClickMenuVisible: state=> state.rightClickMenuVisible rightClickMenuVisible: state => state.rightClickMenuVisible
}) })
}, },
created() { created() {
@ -132,9 +132,9 @@ export default {
if (item.kind === 'file') { if (item.kind === 'file') {
this.isImgLoading = true; this.isImgLoading = true;
const pasteFile = item.getAsFile() const pasteFile = item.getAsFile()
uploadImgFile(pasteFile).then(res=> { uploadImgFile(pasteFile).then(res => {
this.uploaded(res) this.uploaded(res)
}).catch(err=> { }).catch(err => {
this.$message({ this.$message({
showClose: true, showClose: true,
message: err, message: err,
@ -206,7 +206,7 @@ export default {
}, },
// //
leftAndRightScroll() { leftAndRightScroll() {
const scrollCB = text=> { const scrollCB = text => {
let source, target; let source, target;
clearTimeout(this.timeout); clearTimeout(this.timeout);
@ -214,14 +214,14 @@ export default {
source = this.$refs.preview.$el; source = this.$refs.preview.$el;
target = document.getElementsByClassName('CodeMirror-scroll')[0]; target = document.getElementsByClassName('CodeMirror-scroll')[0];
this.editor.off('scroll', editorScrollCB); this.editor.off('scroll', editorScrollCB);
this.timeout = setTimeout(()=> { this.timeout = setTimeout(() => {
this.editor.on('scroll', editorScrollCB); this.editor.on('scroll', editorScrollCB);
}, 300); }, 300);
} else if (text === 'editor') { } else if (text === 'editor') {
source = document.getElementsByClassName('CodeMirror-scroll')[0]; source = document.getElementsByClassName('CodeMirror-scroll')[0];
target = this.$refs.preview.$el; target = this.$refs.preview.$el;
target.removeEventListener("scroll", previewScrollCB, false); target.removeEventListener("scroll", previewScrollCB, false);
this.timeout = setTimeout(()=> { this.timeout = setTimeout(() => {
target.addEventListener("scroll", previewScrollCB, false); target.addEventListener("scroll", previewScrollCB, false);
}, 300); }, 300);
} }
@ -231,10 +231,10 @@ export default {
target.scrollTo(0, height); target.scrollTo(0, height);
}; };
const editorScrollCB = ()=> { const editorScrollCB = () => {
scrollCB('editor'); scrollCB('editor');
}; };
const previewScrollCB = ()=> { const previewScrollCB = () => {
scrollCB('preview'); scrollCB('preview');
}; };
@ -244,12 +244,12 @@ export default {
// //
onEditorRefresh() { onEditorRefresh() {
this.editorRefresh(); this.editorRefresh();
setTimeout(()=> PR.prettyPrint(), 0); setTimeout(() => PR.prettyPrint(), 0);
}, },
// //
endCopy() { endCopy() {
this.backLight = false; this.backLight = false;
setTimeout(()=> { setTimeout(() => {
this.isCoping = false; this.isCoping = false;
}, 800); }, 800);
}, },