This commit is contained in:
2025-05-16 23:14:52 +08:00
parent 5080850523
commit c6d62a68ca
25 changed files with 543 additions and 60 deletions

View File

@@ -18,7 +18,7 @@
});
},
showModal: false,
confirmAction() {
editTheme() {
this.isSubmitting = true;
axios.put('themes', { theme: theme })
.then(data => {
@@ -28,6 +28,16 @@
this.isSubmitting = false;
});
},
confirmDelete() {
this.isSubmitting = true;
axios.delete('themes?theme=' + theme)
.then(data => {
this.loadItems();
})
.finally(() => {
this.isSubmitting = false;
});
},
init() {
this.loadItems();

View File

@@ -0,0 +1,57 @@
document.addEventListener('alpine:init', function () {
Alpine.data('data', function () {
const themeName = getUrlParameter("theme") || "default";
return {
file: {
},
tagInput: "",
tempfile: null,
coverUrl: "",
files: [],
isSubmitting: false,
themeName: "",
fileName: "",
uploadFile:"",
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', this.uploadFile);
axios.post('/themes/upload?theme=' + this.themeName, formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
.then(data => {
location.href = "/admin/theme";
})
},
addFile() {
const fileinput = document.getElementById('img-file-input');
if (fileinput) {
fileinput.click();
}
},
init() {
this.themeName = themeName;
window.addEventListener('load', () => {
document.title = "自定义模板内容 - " + window.config.name + "";
});
}
};
})
});