修改BUG:个人中心点击保存网站样式操作日志中出现两条记录 closed #IVBVX

#Issue
https://gitee.com/LongbowEnterprise/dashboard/issues?id=IVBVX
This commit is contained in:
Argo Zhang 2019-04-12 20:26:59 +08:00
parent bc82933c07
commit e3a68b094c
2 changed files with 121 additions and 121 deletions

View File

@ -120,7 +120,7 @@
</div>
</div>
<div class="modal-footer" asp-auth="saveTheme">
<button id="btnSaveCss" data-method="css" class="btn btn-secondary" type="button"><i class="fa fa-save"></i><span>保存</span></button>
<button id="btnSaveCss" data-method="profileCss" class="btn btn-secondary" type="button"><i class="fa fa-save"></i><span>保存</span></button>
</div>
</div>
</div>

View File

@ -1,121 +1,121 @@
$(function () {
var $headerIcon = $('#headerIcon');
var preIcon = $headerIcon.attr('src');
var $file = $('#fileIcon');
var defFileName = $file.attr('data-file');
$file.fileinput({
uploadUrl: $.formatUrl(Profiles.url),
deleteUrl: $.formatUrl(Profiles.del),
browseOnZoneClick: true,
theme: 'fa',
language: 'zh',
maxFileSize: 5000,
allowedFileExtensions: ['jpg', 'png', 'bmp', 'gif', 'jpeg'],
initialPreview: [
preIcon
],
initialPreviewConfig: [
{ caption: "现在头像", size: $file.attr('data-init'), showZoom: true, showRemove: defFileName !== 'default.jpg', key: defFileName }
],
initialPreviewAsData: true,
overwriteInitial: true,
dropZoneTitle: "请选择头像",
msgPlaceholder: "请选择头像",
fileActionSettings: { showUpload: false }
}).on('fileuploaded', function (event, data, previewId, index) {
var url = data.response.initialPreview[0];
if (!!url === true) $headerIcon.attr('src', url);
}).on('filebeforedelete', function (e, key) {
if (key === "default.jpg") return true;
return new Promise(function (resolve, reject) {
swal({
title: "您确定要删除吗?",
type: "warning",
showCancelButton: true,
cancelButtonClass: 'btn-secondary',
confirmButtonText: "我要删除",
confirmButtonClass: "btn-danger ml-2",
cancelButtonText: "取消"
}, function (del) {
resolve(!del);
if (del) $file.fileinput('default');
});
});
}).on('filedeleted', function (event, key, jqXHR, data) {
$headerIcon.attr('src', $.formatUrl('images/uploader/default.jpg'));
});
$.fn.fileinput.Constructor.prototype.default = function () {
$.extend(this, {
initialPreview: [
$.formatUrl('images/uploader/default.jpg')
],
initialPreviewConfig: [
{ caption: "现在头像", size: 7195, showZoom: true, showRemove: false, key: 'default.jpg' }
]
});
this._initPreviewCache();
this._initPreview(true);
this._initPreviewActions();
this._initZoom();
};
$.footer();
var dataBinder = new DataEntity({
Password: "#currentPassword",
NewPassword: "#newPassword",
DisplayName: "#displayName",
UserName: "#userName",
Css: "#css",
App: '#app'
});
$('button[data-method]').on('click', function (e) {
var $this = $(this);
if ($this.parent().attr("data-admin") === "True") return false;
var data = dataBinder.get();
switch ($this.attr('data-method')) {
case 'password':
data.UserStatus = 'ChangePassword';
$.bc({ url: Profiles.url, method: "put", data: data, title: "更改密码" });
break;
case 'user':
data.UserStatus = 'ChangeDisplayName';
$.bc({
url: Profiles.url, method: "put", data: data, title: "修改用户显示名称",
callback: function (result) {
if (result) {
$('#userDisplayName').text(data.DisplayName);
}
}
});
break;
case 'css':
data.UserStatus = 'ChangeTheme';
$.bc({
url: Profiles.url, method: "put", data: data, title: "保存样式", callback: function (result) {
if (result) {
window.setTimeout(function () { window.location.reload(true); }, 1000);
}
}
});
break;
case 'app':
data.UserStatus = 'SaveApp';
$.bc({
url: Profiles.url, method: "put", data: data, title: "保存应用", callback: function (result) {
if (result) {
window.setTimeout(function () { window.location.reload(true); }, 1000);
}
}
});
break;
}
});
if ($('[enctype="multipart/form-data"]').length === 0) {
$('.card-img').removeClass('d-none');
}
$('#css').dropdown('val');
$('#app').dropdown('val');
$(function () {
var $headerIcon = $('#headerIcon');
var preIcon = $headerIcon.attr('src');
var $file = $('#fileIcon');
var defFileName = $file.attr('data-file');
$file.fileinput({
uploadUrl: $.formatUrl(Profiles.url),
deleteUrl: $.formatUrl(Profiles.del),
browseOnZoneClick: true,
theme: 'fa',
language: 'zh',
maxFileSize: 5000,
allowedFileExtensions: ['jpg', 'png', 'bmp', 'gif', 'jpeg'],
initialPreview: [
preIcon
],
initialPreviewConfig: [
{ caption: "现在头像", size: $file.attr('data-init'), showZoom: true, showRemove: defFileName !== 'default.jpg', key: defFileName }
],
initialPreviewAsData: true,
overwriteInitial: true,
dropZoneTitle: "请选择头像",
msgPlaceholder: "请选择头像",
fileActionSettings: { showUpload: false }
}).on('fileuploaded', function (event, data, previewId, index) {
var url = data.response.initialPreview[0];
if (!!url === true) $headerIcon.attr('src', url);
}).on('filebeforedelete', function (e, key) {
if (key === "default.jpg") return true;
return new Promise(function (resolve, reject) {
swal({
title: "您确定要删除吗?",
type: "warning",
showCancelButton: true,
cancelButtonClass: 'btn-secondary',
confirmButtonText: "我要删除",
confirmButtonClass: "btn-danger ml-2",
cancelButtonText: "取消"
}, function (del) {
resolve(!del);
if (del) $file.fileinput('default');
});
});
}).on('filedeleted', function (event, key, jqXHR, data) {
$headerIcon.attr('src', $.formatUrl('images/uploader/default.jpg'));
});
$.fn.fileinput.Constructor.prototype.default = function () {
$.extend(this, {
initialPreview: [
$.formatUrl('images/uploader/default.jpg')
],
initialPreviewConfig: [
{ caption: "现在头像", size: 7195, showZoom: true, showRemove: false, key: 'default.jpg' }
]
});
this._initPreviewCache();
this._initPreview(true);
this._initPreviewActions();
this._initZoom();
};
$.footer();
var dataBinder = new DataEntity({
Password: "#currentPassword",
NewPassword: "#newPassword",
DisplayName: "#displayName",
UserName: "#userName",
Css: "#css",
App: '#app'
});
$('button[data-method]').on('click', function (e) {
var $this = $(this);
if ($this.parent().attr("data-admin") === "True") return false;
var data = dataBinder.get();
switch ($this.attr('data-method')) {
case 'password':
data.UserStatus = 'ChangePassword';
$.bc({ url: Profiles.url, method: "put", data: data, title: "更改密码" });
break;
case 'user':
data.UserStatus = 'ChangeDisplayName';
$.bc({
url: Profiles.url, method: "put", data: data, title: "修改用户显示名称",
callback: function (result) {
if (result) {
$('#userDisplayName').text(data.DisplayName);
}
}
});
break;
case 'profileCss':
data.UserStatus = 'ChangeTheme';
$.bc({
url: Profiles.url, method: "put", data: data, title: "保存样式", callback: function (result) {
if (result) {
window.setTimeout(function () { window.location.reload(true); }, 1000);
}
}
});
break;
case 'app':
data.UserStatus = 'SaveApp';
$.bc({
url: Profiles.url, method: "put", data: data, title: "保存应用", callback: function (result) {
if (result) {
window.setTimeout(function () { window.location.reload(true); }, 1000);
}
}
});
break;
}
});
if ($('[enctype="multipart/form-data"]').length === 0) {
$('.card-img').removeClass('d-none');
}
$('#css').dropdown('val');
$('#app').dropdown('val');
});