65 lines
1.6 KiB
Python
65 lines
1.6 KiB
Python
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.")
|