山东大学软件学院创新实训——项目记录(七)

基于RAG技术的心理健康大模型的开发及应用

本次任务重新设计主页面内容,将其变得比之前好看一些些,为之后进行连接大模型做好准备。

还是在之前主页面的Vue进行修改。

一、走马灯设计

这里设想将走马灯和写日记放在一起,背景是卡片。

主要实现代码:

这里主要还是使用了element-ui中的走马灯阿里向量库中的SVG进行设计。

    <el-card>
    <div class="main-container">
    <div class="carousel-container">
      <el-carousel :interval="4000" type="card" height="300px">
        <el-carousel-item v-for="(image, index) in carouselImages" :key="index">
          <div class="carousel-content">
            <img :src="image.src" :alt="image.alt" class="carousel-image"/>
            <div class="carousel-caption">{{ image.caption }}</div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>



    <div class="write-diary-container">
      <div class="calendar-d">
        <i class="iconfont icon-rili">
          <svg t="1717253152987" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3880" width="64" height="64"><path d="M0 85.333333m56.888889 0l910.222222 0q56.888889 0 56.888889 56.888889l0 824.888889q0 56.888889-56.888889 56.888889l-910.222222 0q-56.888889 0-56.888889-56.888889l0-824.888889q0-56.888889 56.888889-56.888889Z" fill="#4F3B36" p-id="3881"></path><path d="M28.444444 113.777778m56.888889 0l853.333334 0q56.888889 0 56.888889 56.888889l0 768q0 56.888889-56.888889 56.888889l-853.333334 0q-56.888889 0-56.888889-56.888889l0-768q0-56.888889 56.888889-56.888889Z" fill="#FFF0D1" p-id="3882"></path><path d="M28.444444 369.777778h967.111112v568.888889a56.888889 56.888889 0 0 1-56.888889 56.888889H85.333333a56.888889 56.888889 0 0 1-56.888889-56.888889V369.777778z" fill="#E0F3FB" p-id="3883"></path><path d="M0 341.333333h1024v28.444445H0z" fill="#4F3B36" p-id="3884"></path><path d="M284.444444 0a56.888889 56.888889 0 0 1 56.888889 56.888889v113.777778a56.888889 56.888889 0 0 1-113.777777 0V56.888889a56.888889 56.888889 0 0 1 56.888888-56.888889z m455.111112 0a56.888889 56.888889 0 0 1 56.888888 56.888889v113.777778a56.888889 56.888889 0 0 1-113.777777 0V56.888889a56.888889 56.888889 0 0 1 56.888889-56.888889z" fill="#4F3B36" p-id="3885"></path><path d="M256 28.444444m28.444444 0l0 0q28.444444 0 28.444445 28.444445l0 113.777778q0 28.444444-28.444445 28.444444l0 0q-28.444444 0-28.444444-28.444444l0-113.777778q0-28.444444 28.444444-28.444445Z" fill="#FF5E4D" p-id="3886"></path><path d="M711.111111 28.444444m28.444445 0l0 0q28.444444 0 28.444444 28.444445l0 113.777778q0 28.444444-28.444444 28.444444l0 0q-28.444444 0-28.444445-28.444444l0-113.777778q0-28.444444 28.444445-28.444445Z" fill="#FF5E4D" p-id="3887"></path></svg>
        </i>
        {{ currentDate }}
      </div>
      <div class="calendar-y">
        {{ currentMonth }} {{ currentYear }}
      </div>
      <div class="calendar-w">
        {{ currentDayOfWeek }}
      </div>
      <div>
        <router-link v-if="this.user" to="/blog" class="write-btn">
          <i class="iconfont icon-dianping"></i>写日记
        </router-link>
      </div>
    </div>
  </div>
    </el-card>

这里走马灯展示的是存在本地的图片:

data() {
    return {
      carouselImages: [
        { src: require('@/assets/R-C1.jpg'), alt: 'Image 1', caption: '深夜理长' },
        { src: require('@/assets/OIP-C (2).jpg'), alt: 'Image 2', caption: '世界如此之大' },
        { src: require('@/assets/R-C.jpg'), alt: 'Image 3', caption: '我们只需要一个安安静静写字阅读的地方' },
      ],}

其中的caption可以展示在走马灯的图片上。

二、时间栏以及写日记实现 

因为这里使用到了时间,因此在js中进行获取当前时间。

data中保存当前的时间参数:

data() {
    return {
      currentDate: '',
      currentMonth: '',
      currentYear: '',
      currentDayOfWeek: '',}

data中获取当前时间:

就可以在前端进行展示了。

去写日记,是直接进行连接到写日记的路径上。

三、style设计

这是最为头疼一部分,每次都可以在上面花许多时间。

.main-container {
  display: flex;
}
.carousel-container {
  flex: 1;
  margin-right: 20px; /* Adjust margin as needed */
}
.carousel-content {
  position: relative;
  width: 100%;
  height: 100%;
}
.carousel-caption {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
}
.write-diary-container {
  flex: 0 0 auto; 
  width: 200px; 
}
.calendar-d {
  font-size: 60px;
  line-height: 60px;
  color: #606060;
  margin: 10px auto;
  text-shadow: 1px 1px 1px #313131;
}
.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.calendar-y {
  font-size: 30px;
  color: #606060;
  margin: 10px auto;
}
.write-btn {
  display: block;
  padding: 20px 50px;
  width: 80%;
  text-align: center;
  border: 1px solid #efefef;
  border-radius: 50px;
  margin: 25px auto;
  color: #61cbe6;
  font-size: 18px;
}

四、 前端展示

这里还没有进行大模型连接,因此今日一句还是死数据进行展示。这里是使用了动画让用户进行自操作,增加交互乐趣。

五、实现下拉功能,显示今日一句

同理这个部分依然是使用element-ui中的卡片进行展示。

首先引入import dynamics from 'dynamics.js'。

html部分:

<el-card style="margin-top: 10px">
    <section>
    <div class="home-ad" style="width: 100%;height: 300px">

      <h2 class="h2">
        <i class="iconfont icon-rili">
          <svg t="1717255554915" class="icon" viewBox="0 0 1118 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1852" width="32" height="32"><path d="M0 0m74.640492 0l951.666272 0q74.640492 0 74.640492 74.640492l0 858.365657q0 74.640492-74.640492 74.640492l-951.666272 0q-74.640492 0-74.640492-74.640492l0-858.365657q0-74.640492 74.640492-74.640492Z" fill="#AFE1FA" p-id="1853"></path><path d="M620.449089 482.830682H886.355842a74.640492 74.640492 0 0 1 74.640492 74.640492v0.839706H545.808597v-0.839706a74.640492 74.640492 0 0 1 74.640492-74.640492zM620.449089 709.084674H886.355842a74.640492 74.640492 0 0 1 74.640492 74.640492H545.808597a74.640492 74.640492 0 0 1 74.640492-74.640492zM828.042958 257.043194H886.355842a74.640492 74.640492 0 0 1 74.640492 74.640492v0.839706H753.402466v-0.839706a74.640492 74.640492 0 0 1 74.640492-74.640492zM643.774243 214.591414H326.552152v330.004275a130.620861 130.620861 0 1 0-37.320246 247.24663A132.393573 132.393573 0 0 0 401.192644 659.635348V363.872398h242.581599z" fill="#F5834A" p-id="1854"></path></svg>
        </i> 今日一句
        <span class="more">
      </span>
      </h2>
      <div>
        <div
            class="draggable"
            @mousedown="startDrag"
            @touchstart="startDrag"
            @mousemove="onDrag"
            @touchmove="onDrag"
            @mouseup="stopDrag"
            @touchend="stopDrag"
            @mouseleave="stopDrag"
        >
          <svg class="bg" width="320" height="260">
            <path :d="headerPath" fill="#3F51B5"></path>
          </svg>
          <div class="header">往下拉</div>
          <div class="content" :style="contentPosition">Hello</div>
        </div>
      </div>
    </div>
    </section>
    </el-card>

这里定义了七个函数进行实现。

scirpt设计,实现拖拽功能:

data() {
    return {
      headerHeight: 120,
      isDragging: false,
      start: { x: 0, y: 0 },
      // 使用 data 返回一个响应式对象
      c: reactive({ x: this.headerHeight, y: this.headerHeight }),
    };},
computed: {
    headerPath() {
      return `M0,0 L320,0 320,${this.headerHeight}Q${this.c.x},${this.c.y} 0,${this.headerHeight}`;
    },
    contentPosition() {
      const dy = this.c.y - this.headerHeight;
      const dampen = dy > 0 ? 2 : 4;
      return {
        transform: `translate(0,${dy / dampen}px)`,
      };
    },
  },
methods: {
    startDrag(e) {
      e = e.changedTouches ? e.changedTouches[0] : e;
      this.isDragging = true;
      this.start.x = e.pageX;
      this.start.y = e.pageY;
    },
    onDrag(e) {
      e = e.changedTouches ? e.changedTouches[0] : e;
      if (this.isDragging) {
        this.c.x = this.headerHeight + (e.pageX - this.start.x);
        const dy = e.pageY - this.start.y;
        const dampen = dy > 0 ? 1.5 : 4;
        this.c.y = this.headerHeight + dy / dampen;
      }
    },
    stopDrag() {
      if (this.isDragging) {
        this.isDragging = false;
        dynamics.animate(
            this.c,
            { x: this.headerHeight, y: this.headerHeight },
            { type: dynamics.spring, duration: 700, friction: 280 },
            () => {
            }
        );
      }
    },
    getCurrentDate() {
      const now = new Date();
      const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
      this.currentDate = now.getDate();
      this.currentMonth = this.getMonthName(now.getMonth());
      this.currentYear = now.getFullYear();
      this.currentDayOfWeek = days[now.getDay()];
    },
    getMonthName(monthIndex) {
      const months = [
        'January', 'February', 'March', 'April', 'May', 'June',
        'July', 'August', 'September', 'October', 'November', 'December'
      ];
      return months[monthIndex];
    }
  }
};

style设计:

.draggable {
  background-color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  width: 320px;
  height: 240px;
  overflow: hidden;
  margin: 30px auto;
  position: relative;
  text-align: center;
  font-size: 14px;
  font-weight: 300;
  user-select: none;
  border-radius: 8px;
}
.bg {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
}
.header,
.content {
  position: relative;
  z-index: 1;
  padding: 30px;
  box-sizing: border-box;
}
.header {
  color: #fff;
  height: 120px;
  font-size: 2em;
  font-weight: bold;
}

六、今后任务

继续实现主页内容,并增加大模型返回的每日一句进行展示。并且设计推送音乐功能。

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值