feat: 调整按钮样式

This commit is contained in:
王天骄
2026-06-08 17:34:22 +08:00
parent 2bfd15ba5e
commit 9a66c37ee7
30 changed files with 88 additions and 57 deletions
+50 -10
View File
@@ -2,11 +2,11 @@
<view class="profile-page">
<view class="profile-shell">
<view class="top-app-bar">
<button class="top-button" aria-label="首页" @click="emit('go-home')">
<view class="menu-icon"></view>
<button class="top-button nav-left" aria-label="首页" @click="goHome">
<view class="home-icon"></view>
</button>
<text class="page-title">个人中心</text>
<button class="top-button" aria-label="" @click="emit('open-settings')">
<button class="top-button nav-right" aria-label="" @click="openSettings">
<view class="settings-icon"></view>
</button>
</view>
@@ -133,7 +133,7 @@
</template>
<script setup lang="ts">
import { computed, onUnmounted, ref } from 'vue'
import { computed, getCurrentInstance, onUnmounted, ref } from 'vue'
const emit = defineEmits<{
(event: 'open-settings'): void
@@ -146,6 +146,10 @@ const toastVisible = ref(false)
let toastTimer: ReturnType<typeof setTimeout> | null = null
const instance = getCurrentInstance()
const hasGoHomeListener = Boolean(instance?.vnode.props?.onGoHome)
const hasOpenSettingsListener = Boolean(instance?.vnode.props?.onOpenSettings)
const profileMeta = [
{ label: '北京', icon: 'location-icon' },
{ label: '北大医学部', icon: 'school-icon' },
@@ -226,6 +230,28 @@ function handleAction(entry: ActionEntry) {
showToast(entry.toast || '功能即将开放')
}
function goHome() {
if (hasGoHomeListener) {
emit('go-home')
return
}
uni.reLaunch({
url: '/pages/home/home'
})
}
function openSettings() {
if (hasOpenSettingsListener) {
emit('open-settings')
return
}
uni.navigateTo({
url: '/pages/config/config'
})
}
onUnmounted(() => {
if (toastTimer) clearTimeout(toastTimer)
})
@@ -280,11 +306,15 @@ page {
background: #f9f9ff;
display: flex;
align-items: center;
justify-content: space-between;
justify-content: center;
flex: 0 0 auto;
}
.page-title {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
color: #00478d;
font-size: 20px;
line-height: 28px;
@@ -309,6 +339,8 @@ page {
}
.top-button {
position: absolute;
top: 8px;
width: 40px;
height: 40px;
display: flex;
@@ -317,6 +349,14 @@ page {
border-radius: 2px;
}
.top-button.nav-left {
left: 20px;
}
.top-button.nav-right {
right: 20px;
}
.top-button:active {
background: #ecedf6;
transform: scale(0.96);
@@ -697,7 +737,7 @@ page {
background: #00478d;
}
.menu-icon,
.home-icon,
.settings-icon,
.meta-icon,
.mood-icon,
@@ -714,15 +754,15 @@ page {
mask-size: contain;
}
.menu-icon,
.home-icon,
.settings-icon {
width: 24px;
height: 24px;
}
.menu-icon {
-webkit-mask-image: url("data:image/svg+xml,%3Csvg%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M3%206h18v2H3V6zm0%205h18v2H3v-2zm0%205h18v2H3v-2z'/%3E%3C/svg%3E");
mask-image: url("data:image/svg+xml,%3Csvg%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M3%206h18v2H3V6zm0%205h18v2H3v-2zm0%205h18v2H3v-2z'/%3E%3C/svg%3E");
.home-icon {
-webkit-mask-image: url("data:image/svg+xml,%3Csvg%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M10%2020v-6h4v6h5v-8h3L12%203%202%2012h3v8h5z'/%3E%3C/svg%3E");
mask-image: url("data:image/svg+xml,%3Csvg%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M10%2020v-6h4v6h5v-8h3L12%203%202%2012h3v8h5z'/%3E%3C/svg%3E");
}
.settings-icon {