mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
路由修改
This commit is contained in:
@@ -5,6 +5,18 @@ var ApiUtil = (function () {
|
||||
// 接口URL,更改此处即可
|
||||
var url = 'http://localhost:8082/api';
|
||||
var URI_CHAR = '/';
|
||||
var params = {};
|
||||
|
||||
(function () {
|
||||
var aPairs, aTmp;
|
||||
var queryString = window.location.search.toString();
|
||||
queryString = queryString.substring(1, queryString.length); //remove "?"
|
||||
aPairs = queryString.split("&");
|
||||
for (var i = 0; i < aPairs.length; i++) {
|
||||
aTmp = aPairs[i].split("=");
|
||||
params[aTmp[0]] = decodeURIComponent(aTmp[1]);
|
||||
}
|
||||
})();
|
||||
|
||||
function formatUri(uri) {
|
||||
if (uri.substring(0, 1) !== URI_CHAR) {
|
||||
@@ -49,5 +61,8 @@ var ApiUtil = (function () {
|
||||
}
|
||||
return url + formatUri(uri);
|
||||
}
|
||||
, getParam: function (paramName) {
|
||||
return params[paramName];
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
@@ -1,24 +0,0 @@
|
||||
var Common = (function () {
|
||||
|
||||
function initProfiles() {
|
||||
var $profileList = $('#profileList');
|
||||
if ($profileList.length > 0) {
|
||||
ApiUtil.post('system.profile.list', {}, function (resp) {
|
||||
var list = resp.data;
|
||||
var html = [];
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
html.push('<li' + (i == 0 ? ' class="layui-this"' : '') + '>' + list[i] + '</li>');
|
||||
}
|
||||
$profileList.html(html.join(''))
|
||||
|
||||
$profileList.find('li').on('click', function () {
|
||||
window.profile = $(this).text();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initProfiles();
|
||||
|
||||
return {}
|
||||
})();
|
@@ -14,7 +14,7 @@ var lib = (function () {
|
||||
,'../../assets/lib/layui/layui.js'
|
||||
,'../../assets/lib/easyopen/sdk.js'
|
||||
,'../../assets/js/ApiUtil.js'
|
||||
,'../../assets/js/common.js'
|
||||
,'../../assets/js/profile.js'
|
||||
]
|
||||
|
||||
var jsArr = [];
|
||||
|
30
sop-admin/sop-admin-front/assets/js/profile.js
Normal file
30
sop-admin/sop-admin-front/assets/js/profile.js
Normal file
@@ -0,0 +1,30 @@
|
||||
;(function () {
|
||||
var currentProfile = ApiUtil.getParam('profile') || 'default';
|
||||
|
||||
ApiUtil.post('system.profile.list', {}, function (resp) {
|
||||
var profileList = resp.data;
|
||||
var html = ['<div class="layui-tab layui-tab-brief" style="margin-top: 0px;">'];
|
||||
html.push('<ul id="profileList" class="layui-tab-title">')
|
||||
for (var i = 0; i < profileList.length; i++) {
|
||||
var profile = profileList[i];
|
||||
var cls = currentProfile == profile ? 'layui-this' : '';
|
||||
html.push('<li><a class="' + cls + '" href="' + getCurrentPage(profile) + '">' + profile + '</a></li>');
|
||||
}
|
||||
html.push('</ul>')
|
||||
html.push('</div>')
|
||||
$('.x-body').prepend(html.join(''));
|
||||
});
|
||||
|
||||
function getCurrentPage(profile) {
|
||||
var currentUrl = location.href.toString();
|
||||
var indexStart = currentUrl.lastIndexOf('/') + 1;
|
||||
var indexEnd = currentUrl.lastIndexOf('?');
|
||||
var page = indexEnd > -1
|
||||
? currentUrl.substring(indexStart, indexEnd)
|
||||
: currentUrl.substring(indexStart);
|
||||
|
||||
return page + '?q=' + new Date().getTime() + '&profile=' + profile;
|
||||
}
|
||||
|
||||
window.profile = currentProfile;
|
||||
})();
|
Reference in New Issue
Block a user