初始化提交

This commit is contained in:
2025-10-10 08:13:38 +08:00
commit 0d4c7353f4
1361 changed files with 13945 additions and 0 deletions

313
src/components/Header.vue Normal file
View File

@@ -0,0 +1,313 @@
<template>
<div class="header-container">
<!-- 左侧区域 -->
<div class="header-left-area">
<!-- 左侧图标 -->
<div
v-if="onBack"
@click="onBack"
class="header-icon-button"
>
<img
src="/assets/icons/drawable-xxhdpi/btn_back.png"
class="header-icon"
alt="back"
/>
</div>
<div
v-else-if="leftIcon === 'back' && leftIconSource && onLeftAction"
@click="onLeftAction"
class="header-icon-button"
>
<img
:src="leftIconSource"
class="header-icon"
alt="left icon"
/>
</div>
<div
v-else-if="leftIcon === 'settings'"
@click="onLeftAction"
class="header-icon-button"
>
<img
:src="leftIconSource"
class="header-icon"
alt="settings"
/>
</div>
</div>
<!-- 中间标题区域 -->
<div
@click="onTitlePress"
class="header-title-container"
>
<span class="header-title">
{{ title }}
</span>
<!-- 文件夹切换按钮 (在标题区域内) -->
<div
v-if="leftIcon === 'settings'"
@click.stop="handleFolderToggle"
class="folder-toggle-button"
>
<img
:src="folderExpanded ? '/assets/icons/drawable-xxhdpi/folder_title_arrow_pressed.png' : '/assets/icons/drawable-xxhdpi/folder_title_arrow_normal.png'"
class="folder-toggle-icon"
alt="folder toggle"
/>
</div>
</div>
<!-- 右侧区域 -->
<div class="header-right-area">
<div
v-if="onAction"
@click="onAction"
class="header-icon-button"
>
<img
v-if="actionIconSource"
:src="actionIconSource"
class="header-icon"
alt="action"
/>
<span
v-else
class="header-action-text"
>
{{ actionText }}
</span>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'Header',
props: {
title: {
type: String,
required: true
},
onBack: {
type: Function,
default: null
},
onAction: {
type: Function,
default: null
},
actionText: {
type: String,
default: ''
},
actionIcon: {
type: String,
default: ''
},
leftIcon: {
type: String,
default: ''
},
onLeftAction: {
type: Function,
default: null
},
onFolderToggle: {
type: Function,
default: null
},
isFolderExpanded: {
type: Boolean,
default: undefined
},
onTitlePress: {
type: Function,
default: null
}
},
data() {
return {
localFolderExpanded: false
}
},
computed: {
folderExpanded() {
// 优先使用父组件传递的isFolderExpanded状态否则使用本地状态
return this.isFolderExpanded !== undefined ? this.isFolderExpanded : this.localFolderExpanded;
},
actionIconSource() {
// 根据actionIcon属性返回对应的图标路径
switch (this.actionIcon) {
case 'settings':
return '/assets/icons/drawable-xxhdpi/btn_settings.png';
case 'create':
return '/assets/icons/drawable-xxhdpi/btn_create.png';
default:
return null;
}
},
leftIconSource() {
// 根据leftIcon属性返回对应的图标路径
switch (this.leftIcon) {
case 'folder':
// 文件夹图标根据展开状态切换
return this.folderExpanded
? '/assets/icons/drawable-xxhdpi/folder_title_arrow_pressed.png'
: '/assets/icons/drawable-xxhdpi/folder_title_arrow_normal.png';
case 'back':
// 返回图标
return '/assets/icons/drawable-xxhdpi/btn_back.png';
case 'settings':
// 设置图标
return '/assets/icons/drawable-xxhdpi/btn_settings.png';
default:
return null;
}
}
},
methods: {
handleFolderToggle() {
// 切换文件夹展开状态
if (this.isFolderExpanded === undefined) {
// 如果父组件没有传递isFolderExpanded则使用本地状态
this.localFolderExpanded = !this.localFolderExpanded;
}
// 调用父组件传递的回调函数
if (this.onFolderToggle) {
this.onFolderToggle();
}
}
}
}
</script>
<style scoped>
.header-container {
position: relative;
width: 100%;
height: 48px;
background-color: var(--background-card);
box-shadow: 0 1px 0 0 var(--border);
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 0 4px;
}
.header-left-area {
display: flex;
flex-direction: row;
align-items: center;
height: 100%;
flex-shrink: 0;
}
.header-right-area {
display: flex;
flex-direction: row;
align-items: center;
height: 100%;
flex-shrink: 0;
}
.header-icon-button {
width: 44px;
height: 44px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
border-radius: 4px;
transition: background-color 0.2s ease;
flex-shrink: 0;
}
.header-icon-button:hover {
background-color: var(--black-05);
}
.header-icon-button:active {
background-color: var(--black-10);
transform: scale(0.95);
}
.header-icon {
width: 24px;
height: 24px;
object-fit: contain;
}
.header-title-container {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
cursor: pointer;
transition: background-color 0.2s ease;
border-radius: 4px;
padding: 4px 8px;
flex: 1;
margin: 0 8px;
}
.header-title-container:hover {
background-color: var(--black-05);
}
.header-title-container:active {
background-color: var(--black-10);
transform: scale(0.98);
}
.header-title {
font-size: 18px;
font-weight: 600;
color: var(--text-primary);
text-align: center;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex-shrink: 1;
}
.folder-toggle-button {
width: 20px;
height: 20px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
transition: background-color 0.2s ease;
border-radius: 4px;
flex-shrink: 0;
margin-left: 8px;
}
.folder-toggle-button:hover {
background-color: var(--black-05);
}
.folder-toggle-button:active {
background-color: var(--black-10);
transform: scale(0.95);
}
.folder-toggle-icon {
width: 20px;
height: 20px;
object-fit: contain;
}
.header-action-text {
font-size: 16px;
color: var(--primary);
font-weight: 500;
}
</style>