diff --git a/Yes.Blog/Areas/Admin/Pages/Theme/Import.cshtml b/Yes.Blog/Areas/Admin/Pages/Theme/Import.cshtml index ac66c8d..d3ea61b 100644 --- a/Yes.Blog/Areas/Admin/Pages/Theme/Import.cshtml +++ b/Yes.Blog/Areas/Admin/Pages/Theme/Import.cshtml @@ -37,19 +37,19 @@
diff --git a/Yes.Blog/wwwroot/admin/images/zip.png b/Yes.Blog/wwwroot/admin/images/zip.png new file mode 100644 index 0000000..c2b469a Binary files /dev/null and b/Yes.Blog/wwwroot/admin/images/zip.png differ diff --git a/Yes.Blog/wwwroot/admin/js/theme/import.js b/Yes.Blog/wwwroot/admin/js/theme/import.js index 9cf3ca1..e55ceae 100644 --- a/Yes.Blog/wwwroot/admin/js/theme/import.js +++ b/Yes.Blog/wwwroot/admin/js/theme/import.js @@ -14,6 +14,7 @@ isSubmitting: false, themeName: "", fileName: "", + uploadFile:"", loadFiles() { axios.get('/themes/' + themeName +'/files') @@ -29,9 +30,20 @@ }); return this; }, + isZipFile(filename) { + if (typeof filename !== 'string') return false; + return /\.zip$/i.test(filename); + }, handleThemeUpload(file) { + if (!this.isZipFile(file.name)) { + window.pushError("请上传zip文件"); + return; + } + this.uploadFile = file; + }, + save() { const formData = new FormData(); - formData.append('file', file); + formData.append('file', this.uploadFile); axios.post('/themes/upload', formData, { headers: { @@ -42,22 +54,7 @@ location.href = "/admin/theme"; }) }, - editFile() { - if (this.isSubmitting) { - return; - } - this.isSubmitting = true; - axios.put('/themes/' + themeName + '/files/' + fileName, { content: this.file.content }) - .then(data => { - console.log('data:', data); - location.href = "/admin/theme/detail?themeName=" + themeName + "&fileName=" + fileName + ""; - }) - .finally(() => { - this.isSubmitting = false; - }); - - }, - addIcon() { + addFile() { const fileinput = document.getElementById('img-file-input'); if (fileinput) { fileinput.click();