改造后台权限和APP权限
This commit is contained in:
@@ -217,17 +217,24 @@
|
||||
<div class="toast" id="toast"></div>
|
||||
|
||||
<script>
|
||||
function getAppPermissionCacheKey(uid) {
|
||||
return 'app_column_permissions:' + String(uid || '');
|
||||
}
|
||||
// 权限校验:根据 column-permissions 接口按 column_key 显示入口
|
||||
(function() {
|
||||
localStorage.setItem("uid",{{ user_id }})
|
||||
var uid = document.body.getAttribute('data-user-id');
|
||||
if (!uid) return;
|
||||
var cacheKey = getAppPermissionCacheKey(uid);
|
||||
var baseUrl = window.location.origin;
|
||||
var apiUrl = baseUrl + '/api/admin/user/' + uid + '/column-permissions';
|
||||
fetch(apiUrl, { credentials: 'same-origin' })
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(res) {
|
||||
if (!res || !res.success || !Array.isArray(res.items)) return;
|
||||
try {
|
||||
localStorage.setItem(cacheKey, JSON.stringify(res.items));
|
||||
} catch (e) {}
|
||||
var allowedKeys = res.items.map(function(item) { return (item.column_key || '').toLowerCase(); });
|
||||
document.querySelectorAll('.entrances .entrance-btn[data-column-key]').forEach(function(btn) {
|
||||
var key = (btn.getAttribute('data-column-key') || '').toLowerCase();
|
||||
@@ -251,6 +258,10 @@
|
||||
function handleLogout() {
|
||||
try{
|
||||
localStorage.removeItem('maixiang_api_key');
|
||||
var uid = document.body.getAttribute('data-user-id');
|
||||
if (uid) {
|
||||
localStorage.removeItem(getAppPermissionCacheKey(uid));
|
||||
}
|
||||
}catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user