ruoyi-ui/src/views/homeRoot/index.vue
@@ -1,7 +1,7 @@
<template>
  <div class="app-container">
    <div class="container">
      <h1 style="font-size:21px;padding-top:30px">早上好!
      <h1 style="font-size: 21px;">{{ greeting +',' + user.userName }}
      <el-dropdown style="float:right">
        <span class="el-dropdown-link">
          <img src="../../assets/images/Frame.png">
@@ -188,11 +188,14 @@
<script>
import {listRoot} from "@/api/root/index";
import { getUserProfile } from "@/api/system/user";
export default {
  name: "index",
  data(){
    return{
      user: {},
      greeting: "",
      imageSrc: require('../../assets/images/Group 407.png') ,
      dropdownList: [
        { name: '只显示第一代', src: 'Group 407.png' },
@@ -301,10 +304,8 @@
  },
  created() {
    // this.getCateInfor()
    // for (let i = 0; i < this.contactList.length; i++) {
    //   this.formDat[i] = this.contactList[i];
    // }
    this.setGreeting();
    this.getUser();
  },
  mounted() {
     this.getList(1);
@@ -331,8 +332,6 @@
      }
    },
    generation_1(){
    //  alert(127)
      // this.getList(1)
            listRoot(1).then(response => {
@@ -423,7 +422,27 @@
        }
      );
    },
    setGreeting() {
      const currentTime = new Date();
      const currentHour = currentTime.getHours();
      if (currentHour < 12) {
        this.greeting = "早上好";
      } else if (currentHour < 14) {
        this.greeting = "中午好";
      } else if (currentHour < 18) {
        this.greeting = "下午好";
      } else {
        this.greeting = "晚上好";
      }
    },
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data;
      });
    }
  }
}
</script>