43 lines
2.0 KiB
Python
43 lines
2.0 KiB
Python
import codecs
|
|
file_path = r'd:\\骅锋\\mall\\layouts\\admin\\components\\AdminHeader.uvue'
|
|
with codecs.open(file_path, 'r', 'utf-8') as f:
|
|
text = f.read()
|
|
|
|
# I will replace the user-profile-container entirely with a solid implementation, including the overlay.
|
|
old_html = r''' <!-- 用户个人中心 / 下拉菜单 -->
|
|
<view class="user-profile-container" @click="goToUserCenter">
|
|
<text class="user-name">crmeb demo</text>
|
|
<text class="user-arrow">▼</text>
|
|
|
|
<view class="user-dropdown" v-if="showUserMenu">
|
|
<view class="dropdown-item" @click.stop="goToUserCenter">个人中心</view>
|
|
<view class="dropdown-item" @click.stop="handleLogout">退出登录</view>
|
|
</view>
|
|
</view>'''
|
|
|
|
new_html = r''' <!-- 点击外部收起菜单的遮罩层 -->
|
|
<view class="user-dropdown-overlay" v-if="showUserMenu" @click="closeUserMenu"></view>
|
|
|
|
<!-- 用户个人中心 / 下拉菜单 -->
|
|
<view class="user-profile-container" @click="toggleUserMenu">
|
|
<text class="user-name">crmeb demo</text>
|
|
<text class="user-arrow">▼</text>
|
|
|
|
<view class="user-dropdown" v-if="showUserMenu">
|
|
<view class="dropdown-item" @click.stop="goToUserCenter">个人中心</view>
|
|
<view class="dropdown-item" @click.stop="handleLogout">退出登录</view>
|
|
</view>
|
|
</view>'''
|
|
|
|
text = text.replace(old_html, new_html)
|
|
|
|
# Add closeUserMenu to script if doesn't exist
|
|
if 'function closeUserMenu' not in text:
|
|
text = text.replace('function toggleUserMenu() {', 'function closeUserMenu() {\n showUserMenu.value = false\n}\n\nfunction toggleUserMenu() {')
|
|
|
|
# Adjust goToUserCenter to remove toast, just keep logic
|
|
text = text.replace('uni.showToast({ title: "尝试打开个人中心...", icon: "none", duration: 2000 });\n console.log([AdminHeader] goToUserCenter called);\n console.log([AdminHeader] goToUserCenter called);', '')
|
|
|
|
with codecs.open(file_path, 'w', 'utf-8') as f:
|
|
f.write(text)
|