1
This commit is contained in:
@@ -37,19 +37,19 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>选择要导入的模板文件</label>
|
<label>选择要导入的模板文件</label>
|
||||||
<div id="img-container">
|
<div id="img-container">
|
||||||
<template x-if="config.logo">
|
<template x-if="uploadFile">
|
||||||
<div class="img-thumb img-item">
|
<div class="img-thumb img-item">
|
||||||
<img class="thumb-icon" :src="config.logo" />
|
<img class="thumb-icon" src="/admin/images/zip.png" />
|
||||||
<a href="javascript:;" class="img-remove" x-on:click="config.logo='';tempfile=null">x</a>
|
<a href="javascript:;" class="img-remove" x-on:click="uploadFile='';tempfile=null">x</a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template x-if="!config.logo">
|
<template x-if="!uploadFile">
|
||||||
<div class="img-up-add img-item">
|
<div class="img-up-add img-item">
|
||||||
<span class="img-add-icon" x-on:click="addIcon()">+</span>
|
<span class="img-add-icon" x-on:click="addFile()">+</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<input type="hidden" x-model="config.logo">
|
<input type="hidden" x-model="uploadFile">
|
||||||
<input type="file" name="files" id="img-file-input" x-model="tempfile" x-on:change="handleThemeUpload($event.target.files[0],function(url){ config.logo=url; })">
|
<input type="file" name="files" id="img-file-input" x-model="tempfile" x-on:change="handleThemeUpload($event.target.files[0])">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
BIN
Yes.Blog/wwwroot/admin/images/zip.png
Normal file
BIN
Yes.Blog/wwwroot/admin/images/zip.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
@@ -14,6 +14,7 @@
|
|||||||
isSubmitting: false,
|
isSubmitting: false,
|
||||||
themeName: "",
|
themeName: "",
|
||||||
fileName: "",
|
fileName: "",
|
||||||
|
uploadFile:"",
|
||||||
loadFiles() {
|
loadFiles() {
|
||||||
|
|
||||||
axios.get('/themes/' + themeName +'/files')
|
axios.get('/themes/' + themeName +'/files')
|
||||||
@@ -29,9 +30,20 @@
|
|||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
isZipFile(filename) {
|
||||||
|
if (typeof filename !== 'string') return false;
|
||||||
|
return /\.zip$/i.test(filename);
|
||||||
|
},
|
||||||
handleThemeUpload(file) {
|
handleThemeUpload(file) {
|
||||||
|
if (!this.isZipFile(file.name)) {
|
||||||
|
window.pushError("请上传zip文件");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.uploadFile = file;
|
||||||
|
},
|
||||||
|
save() {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', this.uploadFile);
|
||||||
|
|
||||||
axios.post('/themes/upload', formData, {
|
axios.post('/themes/upload', formData, {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -42,22 +54,7 @@
|
|||||||
location.href = "/admin/theme";
|
location.href = "/admin/theme";
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
editFile() {
|
addFile() {
|
||||||
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() {
|
|
||||||
const fileinput = document.getElementById('img-file-input');
|
const fileinput = document.getElementById('img-file-input');
|
||||||
if (fileinput) {
|
if (fileinput) {
|
||||||
fileinput.click();
|
fileinput.click();
|
||||||
|
|||||||
Reference in New Issue
Block a user