<template>
  <!-- 图生图 -->
  <div class="home-container">
    <!-- 展开收起侧边栏 -->
    <div
      class="icon-expand"
      :style="{
        backgroundColor: drawerVisible ? '#44449c' : '#7F70C840',
        left: drawerVisible ? '18%' : '0'
      }"
      @click="toggleDrawer"
    >
      <span
        class="vertical-lines"
        :style="{
          color: drawerVisible ? '#8a78d0' : 'white'
        }"
        >||</span
      >
    </div>

    <!-- 左侧折叠面板 -->
    <LeftPanel ref="leftPanelRef" v-if="drawerVisible"/>

    <div class="left-group2">
      <div class="title-box">
        <div class="box-icon" @click="goBack">
          <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
          图生图
        </div>
      </div>
      <div class="img-box">
        <p>
          <img
              style="width: fit-content; height: 180px; margin: 10px;"
              src="@/assets/images/color.png"
              class="avatar user"
          />
        </p>
        <p>期待你的画作喔~</p>
      </div>
    </div>

    <!-- 图生图 -->
    <imageToImage />
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ArrowLeftBold } from '@element-plus/icons-vue'
import LeftPanel from '@/components/LeftPanel.vue'
import imageToImage from '@/components/ai/image/imageToImage.vue'

const router = useRouter()
const leftPanelRef = ref(null)
const drawerVisible = ref(true)

// 切换抽屉显示状态
const toggleDrawer = () => {
  drawerVisible.value = !drawerVisible.value
}

// 返回上一页
const goBack = () => {
  router.push('/ai-laboratory')
}
</script>

<style scoped lang="scss">
@use 'sass:math';
// 定义rpx转换函数
@function rpx($px) {
  @return math.div($px, 750) * 100vw;
}

:deep(.el-image-viewer__wrapper) {
  z-index: 10000 !important;
}

.icon-expand {
  width: rpx(8);
  height: rpx(35);
  border-top-right-radius: rpx(5);
  border-bottom-right-radius: rpx(5);
  z-index: 9999;
  position: absolute;
  top: 50%;
  left: 18%;
  transform: translateY(-50%);
  background-color: #44449c;
  cursor: pointer; // 添加鼠标指针样式
  clip-path: polygon(0 0, 100% 15%, 100% 85%, 0 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
}

.icon-expand .vertical-lines {
  color: #8a78d0;
  font-size: rpx(10);
}

.home-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: row;
  gap: rpx(0);
  background-color: #ece9fd;
  // background: linear-gradient(
  //   to bottom,
  //   #e2ddfc,
  //   #f1effd
  // );
}

// 侧边栏
.left-group2 {
  width: rpx(150);
  height: 100%;
}

.left-group2 img {
  width: rpx(110);
  height: auto;
  margin-top: rpx(30);
}

.title-box {
  height: rpx(50);
}

.box-icon {
  width: 100%;
  height: 100%;
  flex: 1;
  display: flex; // 添加 flex 布局
  align-items: center; // 垂直居中
  color: black; // 设置图标颜色为白色
  padding-left: rpx(15);
  font-size: rpx(10); // 设置图标大小，可按需调整
  cursor: pointer; // 添加鼠标指针样式
}

.box-icon .left-icon {
  margin-left: rpx(10);
  margin-right: rpx(5); // 设置图标和文字之间的间距 ;
}

.img-box {
  margin-top: rpx(50);
  color: #a39dce;
}
</style>