23 lines
826 B
Python
23 lines
826 B
Python
import codecs
|
|
|
|
path = r'd:\骅锋\mall\layouts\admin\AdminLayout.uvue'
|
|
with codecs.open(path, 'r', 'utf-8') as f:
|
|
text = f.read()
|
|
|
|
if 'refreshAdminRole' not in text:
|
|
text = text.replace("import { hasAdminModuleAccess } from '@/layouts/admin/utils/role.uts'", "import { hasAdminModuleAccess, refreshAdminRole } from '@/layouts/admin/utils/role.uts'")
|
|
|
|
insert_code = '''onMounted(async () => {
|
|
// 核心修复:挂载时强制刷新一下角色(异步获取 ak_users/metadata 并覆盖缓存)
|
|
await refreshAdminRole()
|
|
|
|
initNavState()'''
|
|
|
|
text = text.replace("onMounted(() => {\n initNavState()", insert_code)
|
|
|
|
with codecs.open(path, 'w', 'utf-8') as f:
|
|
f.write(text)
|
|
print("AdminLayout updated with refreshAdminRole.")
|
|
else:
|
|
print("AdminLayout already updated.")
|