zhangzengfei
2023-09-06 c0c034b3ef0fdf0fd9c802d5984dbd717db6817a
src/pages/vindicate/index/App.vue
@@ -13,19 +13,22 @@
        <span class="card-text">{{ item.name }}</span>
      </div>
    </div>
    <systemClean v-if="activePage == 1" style="width: 100%" :free="free" :full="full" @refreshPercent="getLeftPer" ref="view_1"></systemClean>
    <systemClean
      v-if="activePage == 1"
      style="width: 100%"
      :free="free"
      :full="full"
      @refreshPercent="getLeftPer"
      ref="view_1"
    ></systemClean>
    <updateSettings v-if="activePage == 0" style="width: 100%" ref="view_0"></updateSettings>
    <!-- <back-up v-if="activePage == 3" style="width: 100%"></back-up> -->
    <back-up v-if="activePage == 3" style="width: 100%"></back-up>
    <restartSettings v-if="activePage == 2" style="width: 100%" ref="view_2"></restartSettings>
    <sysInfo v-if="activePage == 3" style="width: 100%" ref="view_3"></sysInfo>
    <sysInfo v-if="activePage == 4" style="width: 100%" ref="view_3"></sysInfo>
  </div>
    <div class="welcome-page" v-else ref="curPage" @click="showRecomand = false">
    <div
      class="search-box"
      :class="showRecomand ? 'border-change' : ''"
      @click.stop
    >
  <div class="welcome-page" v-else ref="curPage" @click="showRecomand = false" @mouseup="mouseDownIndex = ''">
    <div class="search-box" :class="showRecomand ? 'border-change' : ''" @click.stop>
      <!-- @blur="showRecomand = false" -->
      <el-input
        class="search-input"
@@ -40,17 +43,10 @@
      </el-input>
      <div class="search-res" v-if="showRecomand">
        <div
          class="res-bar"
          v-for="(item, index) in searchArrForShow"
          :key="index"
          @click="pickQuick(item.addr)"
        >
        <div class="res-bar" v-for="(item, index) in searchArrForShow" :key="index" @click="pickQuick(item.addr)">
          {{ item.name }}
        </div>
        <div class="no-res-bar" v-if="searchArrForShow.length == 0">
          没有找到与 {{ searchText }} 相关的结果
        </div>
        <div class="no-res-bar" v-if="searchArrForShow.length == 0">没有找到与 {{ searchText }} 相关的结果</div>
      </div>
      <div class="dummy-end" v-if="showRecomand" style="height: 14px"></div>
    </div>
@@ -60,6 +56,8 @@
        @click="openWelcome(i)"
        v-for="(item, i) in menuArr"
        :key="i"
        @mousedown="mouseDownIndex = i"
        :class="mouseDownIndex === i ? 'nav-child-active' : ''"
      >
        <div class="child-info">
          <!-- <span class="icon iconfont welcome-icon">{{ item.icon }}</span> -->
@@ -72,75 +70,103 @@
</template>
<script>
import {
  freedisk
} from "@/api/system";
import { getUrlKey } from "@/api/utils";
import systemClean from "../views/systemClean";
import updateSettings from "../views/updateSettings";
// import BackUp from "../views/backUp";
import restartSettings from "../views/restartSettings";
import sysInfo from "../views/sysInfo";
import { freedisk } from "@/api/system"
import { getUrlKey } from "@/api/utils"
import systemClean from "../views/systemClean"
import updateSettings from "../views/updateSettings"
import BackUp from "../views/backUp"
import restartSettings from "../views/restartSettings"
import sysInfo from "../views/sysInfo"
export default {
  name: "settings",
  components: {
    systemClean,
    updateSettings,
 //   BackUp,
    restartSettings,sysInfo
    BackUp,
    restartSettings,
    sysInfo
  },
  data() {
    return {
      menuArr: [
        { name: "更新设置" ,img_black:"/images/vindicate/更新设置-黑.png", img_white:"/images/vindicate/更新设置-白.png",img_welcome:"/images/vindicate/更新设置.png"},
        { name: "系统清理" ,img_black:"/images/vindicate/系统清理-黑.png", img_white:"/images/vindicate/系统清理-白.png",img_welcome:"/images/vindicate/系统清理.png"},
        { name: "重启设置" ,img_black:"/images/vindicate/重启设置-黑.png", img_white:"/images/vindicate/重启设置-白.png",img_welcome:"/images/vindicate/重启设置.png"},
        { name: "系统信息" ,img_black:"/images/vindicate/系统信息-黑.png", img_white:"/images/vindicate/系统信息-白.png",img_welcome:"/images/vindicate/系统信息.png"},
        // {
        //   name: "更新设置",
        //   img_black: "/images/vindicate/更新设置-黑.png",
        //   img_white: "/images/vindicate/更新设置-白.png",
        //   img_welcome: "/images/vindicate/更新设置.png",
        // },
        // {
        //   name: "系统清理",
        //   img_black: "/images/vindicate/系统清理-黑.png",
        //   img_white: "/images/vindicate/系统清理-白.png",
        //   img_welcome: "/images/vindicate/系统清理.png",
        // },
        {
          name: "重启设置",
          img_black: "/images/vindicate/重启设置-黑.png",
          img_white: "/images/vindicate/重启设置-白.png",
          img_welcome: "/images/vindicate/重启设置.png"
        },
        {
          name: "备份还原",
          img_black: "/images/vindicate/系统清理-黑.png",
          img_white: "/images/vindicate/系统清理-白.png",
          img_welcome: "/images/vindicate/系统清理.png"
        },
        {
          name: "系统信息",
          img_black: "/images/vindicate/系统信息-黑.png",
          img_white: "/images/vindicate/系统信息-白.png",
          img_welcome: "/images/vindicate/系统信息.png"
        }
      ],
      searchArr: [
        { name: "系统设置", addr: [0] },
        { name: "系统更新", addr: [0, 0] },
        { name: "更新设置", addr: [0, 1] },
        { name: "系统清理", addr: [1] },
        // { name: "系统设置", addr: [0] },
        // { name: "系统更新", addr: [0, 0] },
        // { name: "更新设置", addr: [0, 1] },
        // { name: "系统清理", addr: [1] },
        { name: "重启设置", addr: [2] },
        { name: "系统信息", addr: [3] },
        { name: "系统信息", addr: [3] }
      ],
      activePage: 0,
      free: 0,
      full: 0,
      showWelcome:true,
      searchText:'',
      showRecomand:false
    };
      showWelcome: true,
      searchText: "",
      showRecomand: false,
      mouseDownIndex: ""
    }
  },
  created() {
    let color = localStorage.getItem('--colorCard')
    if(color) {
      document.documentElement.style.setProperty('--colorCard',`${color}`)
    }
    let color = localStorage.getItem("--colorCard")
    if (color) {
      document.documentElement.style.setProperty("--colorCard", `${color}`)
    }
  },
  mounted() {
    const menu = getUrlKey("menu");
    const menu = getUrlKey("menu")
    if (menu) {
      this.activePage = this.menuArr.findIndex((x) => x.name == menu);
      this.activePage = this.menuArr.findIndex((x) => x.name == menu)
      // this.$nextTick(() => {
      //   this.$refs.netSettings.openRight(2);
      // });
    }
     this.getLeftPer()
     console.log(99999);
     window.addEventListener("message",(e)=>{
     console.log(999);
     if(e.data.msg === 'changeColor') {
     document.documentElement.style.setProperty('--colorCard',`${e.data.color}`)
       }
     })
    this.getLeftPer()
    window.addEventListener("message", (e) => {
      if (e.data.msg === "changeColor") {
        document.documentElement.style.setProperty("--colorCard", `${e.data.color}`)
      }
      if (e.data.msg === "返回系统维护") {
        this.showWelcome = true
      }
    })
  },
  methods: {
    openMenu(item, i) {
      this.activePage = i;
      this.activePage = i
    },
    getLeftPer(){
    getLeftPer() {
      freedisk().then((res) => {
        this.free = res.data.free
        this.full = res.data.all
@@ -148,37 +174,58 @@
    },
    pickQuick(addr) {
      if (addr.length == 1) {
        this.openWelcome(addr[0]);
        this.openWelcome(addr[0])
      } else {
        this.openWelcome(addr[0]);
        this.openWelcome(addr[0])
        this.$nextTick(() => {
          if (addr[0] == 1) {
            // addr[1] == 0
            //   ? this.changeSwitch("isNtp")
            //   : this.changeSwitch("isManual");
            return;
            return
          }
          this.$refs[`view_${addr[0]}`].openRight(addr[1]);
        });
          this.$refs[`view_${addr[0]}`].openRight(addr[1])
        })
      }
    },
    openWelcome(i) {
      this.showWelcome = false;
      this.openMenu(1,i);
    },
      this.showWelcome = false
      this.openMenu(1, i)
    }
  },
  computed:{
     searchArrForShow() {
  computed: {
    searchArrForShow() {
      if (this.searchText == "") {
        return this.searchArr;
        return this.searchArr
      } else {
        return this.searchArr.filter((item) => {
          return item.name.indexOf(this.searchText.toUpperCase()) > -1;
        });
          return item.name.indexOf(this.searchText.toUpperCase()) > -1
        })
      }
    },
    }
  },
  watch: {
    showWelcome(newVal) {
      if (newVal) {
        // 隐藏返回按按钮
        window.parent.postMessage(
          {
            msg: "hiddenBack"
          },
          "*"
        )
      } else {
        //显示返回按钮
        window.parent.postMessage(
          {
            msg: "showBack"
          },
          "*"
        )
      }
    }
  }
};
}
</script>
<style lang="scss">
.welcome-page {
@@ -227,34 +274,35 @@
        line-height: 36px;
        outline: 0;
        padding: 0 20px;
        -webkit-transition: border-color 0.2s
          cubic-bezier(0.645, 0.045, 0.355, 1);
        -webkit-transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
        transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
        width: 100%;
        font-weight: bold;
        &::-webkit-input-placeholder { /* WebKit browsers */
        color: #828282;
        font-weight: normal;
        font-size: 14px;
        &::-webkit-input-placeholder {
          /* WebKit browsers */
          color: #828282;
          font-weight: normal;
          font-size: 14px;
        }
        &:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
        color: #828282;
        font-weight: normal;
        font-size: 14px;
        &:-moz-placeholder {
          /* Mozilla Firefox 4 to 18 */
          color: #828282;
          font-weight: normal;
          font-size: 14px;
        }
        &::-moz-placeholder { /* Mozilla Firefox 19+ */
        color: #828282;
        font-weight: normal;
        font-size: 14px;
        &::-moz-placeholder {
          /* Mozilla Firefox 19+ */
          color: #828282;
          font-weight: normal;
          font-size: 14px;
        }
        &:-ms-input-placeholder { /* Internet Explorer 10+ */
        color: #828282;
        font-weight: normal;
        font-size: 14px;
      }
        &:-ms-input-placeholder {
          /* Internet Explorer 10+ */
          color: #828282;
          font-weight: normal;
          font-size: 14px;
        }
      }
      .el-input__suffix {
        display: flex;
@@ -308,25 +356,30 @@
    }
  }
  .nav-items {
    max-width: 960px;
    margin: 0 auto;
    .nav-child {
      box-sizing: border-box;
      background-color: rgba(251, 251, 255, 0.1);
      backdrop-filter: blur(4px);
      float: left;
      width: 442px;
      width: 288px;
      height: 190px;
      margin: 0 15px;
      margin-bottom: 30px;
      margin: 0 10px;
      margin-bottom: 20px;
      border-radius: 15px;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      border: 2px solid #F2F2F7;
      border: 2px solid #f2f2f7;
      &:hover {
        border: 2px solid #4E94FF;
        background: #F2F2F7;
        background: #f2f2f7;
      }
      &-active {
        border: 2px solid #4e94ff;
      }
      // box-shadow: 2px 2px 4px rgb(226, 226, 226);
@@ -353,9 +406,9 @@
      }
    }
    // .nav-child:hover {
      // box-shadow: 4px 4px 12px rgb(218, 218, 218);
      // transform: translate3d(0, -1px, 0);
      // transition: all 0.3s;
    // box-shadow: 4px 4px 12px rgb(218, 218, 218);
    // transform: translate3d(0, -1px, 0);
    // transition: all 0.3s;
    // }
  }
}
@@ -368,6 +421,14 @@
  flex: 1;
  flex-basis: auto;
  box-sizing: border-box;
  position: relative;
  .back {
    position: absolute;
    top: 0;
    left: 0;
  }
  .container-left {
    height: 100%;
    width: 244px;
@@ -384,7 +445,7 @@
      cursor: pointer;
      border-radius: 8px;
      margin-bottom: 4px;
      display: flex;
      display: flex;
      background-color: #fff;
      align-items: center;
      .icon_white {
@@ -411,9 +472,9 @@
      color: #fff;
      background-color: var(--colorCard) !important;
      .icon_black {
      visibility: hidden;
        visibility: hidden;
      }
      .icon_white{
      .icon_white {
        visibility: visible;
      }
      .iconfont {
@@ -421,18 +482,14 @@
        background-color: #fff;
      }
    }
    .left-card:hover {
      background-color: #F2F2F7;
      background-color: #f2f2f7;
    }
  }
}
.vindicate {
  border-top:2px solid #E1E0E6 ;
  border-top: 2px solid #e1e0e6;
}
</style>