初步完成merchant和admin不同role的展示内容逻辑

This commit is contained in:
2026-03-12 10:18:04 +08:00
parent c90b549b89
commit f19dd093bf
13 changed files with 853 additions and 110 deletions

64
update_header.py Normal file
View File

@@ -0,0 +1,64 @@
import codecs
path = r'd:\骅锋\mall\layouts\admin\components\AdminHeader.uvue'
with codecs.open(path, 'r', 'utf-8') as f:
text = f.read()
# Replace logout logic
old_logout = '''function handleLogout(e: any) {
if (e && typeof e.stopPropagation === 'function') {
e.stopPropagation()
}
showUserMenu.value = false
uni.showModal({
title: '提示',
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
logout()
uni.removeStorageSync('adminRole')
uni.removeStorageSync('token')
// Force the layout cleanup to wait for the dialog to disappear
setTimeout(() => {
uni.reLaunch({
url: '/pages/user/login'
})
}, 300)
}
}
})
}'''
new_logout = '''import { clearAdminRoleCache } from '@/layouts/admin/utils/role.uts'
function handleLogout(e: any) {
if (e && typeof e.stopPropagation === 'function') {
e.stopPropagation()
}
showUserMenu.value = false
uni.showModal({
title: '提示',
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
logout()
clearAdminRoleCache()
uni.removeStorageSync('token')
// Force the layout cleanup to wait for the dialog to disappear
setTimeout(() => {
uni.reLaunch({
url: '/pages/user/login'
})
}, 300)
}
}
})
}'''
if old_logout in text:
text = text.replace(old_logout, new_logout)
with codecs.open(path, 'w', 'utf-8') as f:
f.write(text)
print("AdminHeader logout logic updated.")
else:
print("AdminHeader target old snippet not found.")