所有页面的语法改写为setup形式;

修改了Header组件的样式、布局;
更新了IFLOW上下文;
添加了全局样式;
添加了pinia状态管理;
This commit is contained in:
User
2025-10-10 11:43:51 +08:00
parent 0d4c7353f4
commit e40288e8ef
20 changed files with 2147 additions and 1521 deletions

View File

@@ -1,313 +1,186 @@
<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 class="code-fun-flex-row code-fun-items-center component">
<!-- 左侧图标 -->
<img v-if="leftType == 'settings'" class="left-icon" src="/assets/icons/drawable-xxhdpi/btn_settings.png" @click="handleLeftAction" />
<img v-else class="left-icon" src="/assets/icons/drawable-xxhdpi/btn_back.png" @click="handleLeftAction" />
<!-- 标题区域 -->
<div class="title-container" @click="handleTitlePress" v-if="leftType == 'settings'">
<span class="text">{{ title }}</span>
<!-- 文件夹展开图标 -->
<img class="folder-icon" :src="folderExpanded ? '/assets/icons/drawable-xxhdpi/folder_title_arrow_pressed.png' : '/assets/icons/drawable-xxhdpi/folder_title_arrow_normal.png'" @click.stop="handleFolderToggle" />
</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 class="title-container" v-else>
<span class="text">{{ title }}</span>
</div>
<!-- 右侧操作按钮 -->
<img v-if="actionIcon === 'create'" class="image_4" src="/assets/icons/drawable-xxhdpi/btn_create.png" @click="handleAction" />
<i class="image_4" v-else></i>
</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
}
<script setup>
import { ref, computed } from 'vue'
const props = defineProps({
title: {
type: String,
required: true,
},
data() {
return {
localFolderExpanded: false
}
onBack: {
type: Function,
default: null,
},
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;
}
}
onAction: {
type: Function,
default: null,
},
methods: {
handleFolderToggle() {
// 切换文件夹展开状态
if (this.isFolderExpanded === undefined) {
// 如果父组件没有传递isFolderExpanded则使用本地状态
this.localFolderExpanded = !this.localFolderExpanded;
}
// 调用父组件传递的回调函数
if (this.onFolderToggle) {
this.onFolderToggle();
}
}
actionText: {
type: String,
default: '',
},
actionIcon: {
type: String,
default: '',
},
leftIcon: {
type: String,
default: '',
},
leftType: {
type: String,
default: 'back',
},
onLeftAction: {
type: Function,
default: null,
},
onFolderToggle: {
type: Function,
default: null,
},
isFolderExpanded: {
type: Boolean,
default: undefined,
},
onTitlePress: {
type: Function,
default: null,
},
})
const localFolderExpanded = ref(false)
const folderExpanded = computed(() => {
// 优先使用父组件传递的isFolderExpanded状态否则使用本地状态
return props.isFolderExpanded !== undefined ? props.isFolderExpanded : localFolderExpanded.value
})
const actionIconSource = computed(() => {
// 根据actionIcon属性返回对应的图标路径
switch (props.actionIcon) {
case 'settings':
return '/assets/icons/drawable-xxhdpi/btn_settings.png'
case 'create':
return '/assets/icons/drawable-xxhdpi/btn_create.png'
default:
return null
}
})
const leftIconSource = computed(() => {
// 根据leftIcon属性返回对应的图标路径
switch (props.leftIcon) {
case 'folder':
// 文件夹图标根据展开状态切换
return folderExpanded.value ? '/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
}
})
const handleFolderToggle = () => {
// 切换文件夹展开状态
if (props.isFolderExpanded === undefined) {
// 如果父组件没有传递isFolderExpanded则使用本地状态
localFolderExpanded.value = !localFolderExpanded.value
}
// 调用父组件传递的回调函数
if (props.onFolderToggle) {
props.onFolderToggle()
}
}
const handleLeftAction = () => {
// 处理左侧图标点击事件
if (props.onLeftAction) {
props.onLeftAction()
} else if (props.leftType !== 'settings' && props.onBack) {
// 兼容旧版本的onBack属性
props.onBack()
}
}
const handleAction = () => {
// 处理右侧操作按钮点击事件
if (props.onAction) {
props.onAction()
}
}
const handleTitlePress = () => {
// 处理标题点击事件
if (props.onTitlePress) {
props.onTitlePress()
}
}
</script>
<style scoped>
.header-container {
position: relative;
width: 100%;
height: 48px;
background-color: var(--background-card);
box-shadow: 0 1px 0 0 var(--border);
<style scoped lang="less">
.component {
padding: 2rem 0.72rem 0.5rem 0.72rem;
background-color: #00000000;
background-image: url(https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/686f20ecd54496f19f54e801/68e862ab9520a30011f388ff/17600644443142372133.png);
background-size: cover;
background-position: 0% 0%;
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;
}
.left-icon,
.image_4 {
width: 1.7rem;
height: 1.7rem;
cursor: pointer;
}
.header-right-area {
display: flex;
flex-direction: row;
align-items: center;
height: 100%;
flex-shrink: 0;
}
.title-container {
display: flex;
align-items: center;
cursor: pointer;
flex: 1;
justify-content: center;
.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;
}
.folder-icon {
width: 0.8rem;
height: 0.8rem;
margin-left: 0.2rem;
cursor: pointer;
}
.header-icon-button:hover {
background-color: var(--black-05);
.text {
color: #e3dbd4;
font-size: 1.01rem;
line-height: 1.01rem;
}
}
}
.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>
</style>