Commit f0acf426 authored by Van's avatar Van

🎨 #12724

parent b0490929
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
<h2>401 Unauthorized!</h2> <h2>401 Unauthorized!</h2>
<img class="img-error" src="${staticServePath}/images/401.png" alt="401" title="401 Unauthorized!" /> <img class="img-error" src="${staticServePath}/images/401.png" alt="401" title="401 Unauthorized!" />
<div class="a-error"> <div class="a-error">
Please <a href="${loginURL}">Start</a> or return to <a href="${servePath}">Index</a>. Please <a href="${loginURL}">start</a> or return to <a href="${servePath}">Index</a>.
</div> </div>
</@commonPage> </@commonPage>
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
<h2>404 Not Found!</h2> <h2>404 Not Found!</h2>
<img class="img-error" src="${staticServePath}/images/404.gif" title="404" alt="404 Not Found!"/> <img class="img-error" src="${staticServePath}/images/404.gif" title="404" alt="404 Not Found!"/>
<div class="a-error"> <div class="a-error">
Please <a href="${loginURL}">Start</a> or return to <a href="${servePath}">Index</a>. Please <a href="${loginURL}">start</a> or return to <a href="${servePath}">Index</a>.
</div> </div>
</@commonPage> </@commonPage>
\ No newline at end of file
...@@ -24,12 +24,14 @@ ...@@ -24,12 +24,14 @@
/* theme list 相关操作 */ /* theme list 相关操作 */
admin.themeList = { admin.themeList = {
skinDirName: '',
mobileSkinDirName: '',
/* /*
* 初始化 * 初始化
*/ */
init: function () { init: function () {
$.ajax({ $.ajax({
url: Label.servePath + '/console/preference/', url: Label.servePath + '/console/skin',
type: 'GET', type: 'GET',
cache: false, cache: false,
success: function (result, textStatus) { success: function (result, textStatus) {
...@@ -39,40 +41,47 @@ admin.themeList = { ...@@ -39,40 +41,47 @@ admin.themeList = {
return return
} }
var preference = result.preference admin.themeList.skinDirName = result.skin.skinDirName
admin.themeList.mobileSkinDirName = result.skin.mobileSkinDirName
// skin var skins = JSON.parse(result.skin.skins)
var skins = eval('(' + preference.skins + ')')
var skinsHTML = '' var skinsHTML = ''
for (var i = 0; i < skins.length; i++) { for (var i = 0; i < skins.length; i++) {
var selectedClass = '' var selectedClass = ''
if (skins[i].skinName === preference.skinName if (skins[i].skinDirName === result.skin.skinDirName) {
&& skins[i].skinDirName === preference.skinDirName) { selectedClass = ' selected'
selectedClass += ' selected'
} }
skinsHTML += '<div class="fn__left skinItem' + selectedClass + skinsHTML += '<div class="fn__left skinItem' + selectedClass +
'"><div class="ft__center">' + '"><div class="ft__center">' + skins[i].skinDirName
skins[i].skinName
+ '</div><img class="skinPreview" src="' + '</div><img class="skinPreview" src="'
+ Label.staticServePath + '/skins/' + skins[i].skinDirName + Label.staticServePath + '/skins/' + skins[i].skinDirName
+ '/preview.png"/><div><button class="small update fn__left" data-name="' + + '/preview.png"/><div>'
skins[i].skinDirName + '">' + Label.enableLabel +
'</button><button class="small fn__right" onclick="window.open(\'' + if (skins[i].skinDirName !== result.skin.skinDirName) {
Label.servePath + '?skin=' + skins[i].skinName + '\')">' skinsHTML += '<button class="small update fn__left" data-name="' +
+ Label.previewLabel + '</button><button class="small mobile fn__left">' + skins[i].skinDirName + '">' + Label.enableLabel +
Label.setMobileLabel + '</button></div></div>' '</button>'
}
if (skins[i].skinDirName !== result.skin.mobileSkinDirName) {
skinsHTML += '<button class="small mobile fn__left" data-name="' +
skins[i].skinDirName + '">' +
Label.setMobileLabel + '</button>'
}
skinsHTML += '<button class="small fn__right" onclick="window.open(\'' +
Label.servePath + '?skin=' + skins[i].skinDirName + '\')">'
+ Label.previewLabel + '</button></div></div>'
} }
$('#skinMain').append(skinsHTML + '<div class=\'fn__clear\'></div>') $('#skinMain').append(skinsHTML + '<div class=\'fn__clear\'></div>')
$('.skinItem .update').click(function () { $('.skinItem .update').click(function () {
$('.skinItem').removeClass('selected') admin.preference.update($(this).data('name'), 'pc')
$(this).closest('.skinItem').addClass('selected')
admin.preference.update()
}) })
$('.skinItem .mobile').click(function () { $('.skinItem .mobile').click(function () {
$('.skinItem').removeClass('selected') admin.preference.update($(this).data('name'), 'mobile')
$(this).closest('.skinItem').addClass('selected')
admin.preference.update()
}) })
$('#loadMsg').text('') $('#loadMsg').text('')
...@@ -82,22 +91,25 @@ admin.themeList = { ...@@ -82,22 +91,25 @@ admin.themeList = {
/* /*
* @description 更新 * @description 更新
*/ */
update: function () { update: function (skinDirName, type) {
if (!admin.preference.validate()) {
return
}
$('#tipMsg').text('') $('#tipMsg').text('')
$('#loadMsg').text(Label.loadingLabel) $('#loadMsg').text(Label.loadingLabel)
var requestJSONObject = { var requestJSONObject = {
'preference': { skin: {
'skinDirName': $('#skinMain').data('skinDirName'), skinDirName: admin.themeList.skinDirName,
mobileSkinDirName: admin.themeList.mobileSkinDirName,
}, },
} }
if (type === 'pc') {
requestJSONObject.skin.skinDirName = skinDirName
} else {
requestJSONObject.skin.mobileSkinDirName = skinDirName
}
$.ajax({ $.ajax({
url: Label.servePath + '/console/preference/', url: Label.servePath + '/console/skin',
type: 'PUT', type: 'PUT',
cache: false, cache: false,
data: JSON.stringify(requestJSONObject), data: JSON.stringify(requestJSONObject),
...@@ -107,11 +119,7 @@ admin.themeList = { ...@@ -107,11 +119,7 @@ admin.themeList = {
$('#loadMsg').text('') $('#loadMsg').text('')
return return
} }
admin.preference.init()
if ($('#localeString').val() !== admin.preference.locale) {
window.location.reload()
}
$('#loadMsg').text('') $('#loadMsg').text('')
}, },
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment