heyujie
2021-07-30 4b43bfb3f6f499f480712dd29bef52275466afd6
src/pages/vindicate/views/updateSettings.vue
@@ -1,6 +1,6 @@
<template>
  <div class="all">
    <div class="cluster-content">
    <div class="update-set-content">
      <div class="cluster-center" ref="left">
        <div
          class="menu-item"
@@ -17,38 +17,57 @@
      </div>
      <div class="cluster-right">
        <div class="net-set" v-if="activePage == 0">
          <el-radio-group v-model="radio2" size="medium">
          <el-radio-group
            v-model="radio2"
            size="medium"
            fill="rgba(61, 104, 225, 1)"
          >
            <el-radio-button label="检查更新"></el-radio-button>
            <el-radio-button label="上传更新"></el-radio-button>
          </el-radio-group>
          <div
            class="update-center"
            v-if="radio2 == '检查更新'"
            v-loading="upgrading"
            element-loading-text="更新中,请稍后"
            element-loading-spinner="el-icon-loading"
          >
            <span class="icon iconfont spin-bg">&#xe6ee;</span>
            <div class="desc" v-if="hasNewVersion">
              检查到最新版本:{{ newVersionName }}
          <div class="update-center" v-if="radio2 == '检查更新'">
            <span v-if="hasNewVersion||checking"
              class="icon iconfont spin-bg"
              :class="upgrading || checking ? 'spin-bg-rot' : ''"
              >&#xe6fb;</span
            >
            <span v-else
              class="icon iconfont spin-bg"
              >&#xe701;</span
            >
            <div class="desc" v-if="checking && !upgrading">
              正在检测版本更新……
            </div>
            <div class="desc desc-suc" v-else>已是最新版本</div>
            <div class="desc" v-if="!checking && hasNewVersion">
              {{ upgrading ? "正在升级至" : "检查到" }}最新版本:{{
                newVersionName
              }}
            </div>
            <div class="desc desc-suc" v-if="!checking && !hasNewVersion">
              当前已经是最新版本
            </div>
            <el-button
              v-if="hasNewVersion"
              v-if="hasNewVersion && !checking"
              :loading="upgrading"
              type="primary"
              style="width: 150px"
              size="small"
              @click="upgradeNewVersion"
              >更新</el-button
            >
            <div class="text-desc" v-if="hasNewVersion && !checking&& !upgrading">
              {{verText}}
            </div>
          </div>
          <div class="upload-center" v-if="radio2 == '上传更新'">
            <div class="upload-top">
              <!-- <div class="up-text">上传更新文件,只能上传文件</div> -->
              <el-upload
                class="upload-demo"
                drag
                action
                v-show="!shengjiing"
                :http-request="uploadPkg"
                :limit="1"
              >
@@ -63,16 +82,19 @@
                </div>
                <div class="el-upload__tip" slot="tip"></div>
              </el-upload>
              <!-- <fileUploader
                single
                url="/version/upload"
                @complete="onFileUpload"
                @file-added="onFileAdded"
              /> -->
              <span
                class="icon iconfont spin-bg"
                :class="shengjiing ? 'spin-bg-rot' : ''"
                v-if="shengjiing"
                >&#xe6fb;</span
              >
              <div class="desc" v-if="shengjiing">正在进行更新……</div>
              <el-button
                type="primary"
                style="width: 150px"
                style="width: 150px; font-size: 15px"
                @click="upgrade"
                size="small"
                class="uploader-btn"
                :loading="shengjiing"
                >{{ shengjiing ? "更新中" : "更新" }}</el-button
@@ -106,6 +128,8 @@
              <div class="name">{{ item.title }}</div>
              <el-switch
                v-model="item.val"
                active-value="1"
                inactive-value="0"
                active-color="rgba(61, 104, 225, 1)"
                @change="switchChange(item)"
              >
@@ -121,7 +145,6 @@
<script>
import {
  getDevInfo,
  fileUpload,
  doUpgrade,
  checkNewVersion,
  upgradeNewVersion,
@@ -130,31 +153,21 @@
  getSettings,
  updateSettings,
} from "@/api/system";
import { getUrlKey } from "@/api/utils";
export default {
  filters: {
    nameFilter(v) {
      switch (v) {
        case value:
          break;
        default:
          break;
      }
      return;
    },
  },
  data() {
    return {
      radio2: "检查更新",
      activePage: 0,
      patchUpdateStatus: "",
      probeSum: 0,
      timer: null,
      timer: null,verText:"",
      patchFile: {},
      fileAdded: false,
      curVersionName: "",
      shengjiing: false,
      upgrading: false,
      checking: true,
      newVersionName: "",
      hasNewVersion: true,
      sysSetList: [
@@ -175,7 +188,18 @@
    };
  },
  mounted() {
    this.fetchUpgradInfo();
    const isAutoUpdate = getUrlKey("autoUpdate");
    if (isAutoUpdate==1) {
      this.checking = false
      this.upgradeNewVersion()
      // this.showWelcome = false;
      // this.activeIndex = this.menuArr.findIndex((x) => x.name == menu);
      // this.$nextTick(() => {
      //   this.$refs.netSettings.openRight(2);
      // });
    }else{
      this.fetchUpgradInfo();
    }
    this.fetchSettings();
  },
  methods: {
@@ -196,17 +220,25 @@
      });
    },
    fetchUpgradInfo() {
      this.checking = true;
      checkNewVersion().then((res) => {
        setTimeout(() => {
          this.checking = false;
        }, 800);
        this.newVersionName = res.data.newVersion;
        this.curVersionName = res.data.curVersion;
        this.hasNewVersion = res.data.hasNewVersion;
        this.verText=res.data.newVersionInfo
        if (!this.hasNewVersion) {
          this.upgrading = false;
        }
      });
    },
    upgradeNewVersion() {
      this.upgrading = true;
      upgradeNewVersion().then((res) => {
        this.upgrading = false;
        this.$message.success("更新版本成功");
        this.$notify.success("更新版本成功");
        this.fetchUpgradInfo();
      });
    },
@@ -233,7 +265,7 @@
        id: this.pkgID,
      }).then((res) => {
        this.shengjiing = false;
        this.$message.success("更新版本成功");
        this.$notify.success("更新版本成功");
        this.pkgID = "";
      });
    },
@@ -279,13 +311,12 @@
      this.activePage = typ;
    },
    switchChange(item) {
      let data = {
      updateSettings({
        name: item.name,
        value: item.val,
      };
      updateSettings(data).then((res) => {
      }).then((res) => {
        if (res.code == 200) {
          this.$message.success("更新成功");
          this.$notify.success("更新成功");
        }
      });
    },
@@ -296,8 +327,7 @@
.all {
  width: 100%;
}
.cluster-content {
.update-set-content {
  height: 100%;
  display: flex;
  flex-direction: row;
@@ -386,33 +416,55 @@
      flex-direction: column;
      justify-content: space-between;
      height: 95%;
      @keyframes spin {
        from {
          transform: rotate(0deg);
        }
        to {
          transform: rotate(360deg);
        }
      }
      .spin-bg {
        color: rgb(206, 205, 205);
        font-size: 100px;
        margin-bottom: 20px;
      }
      .spin-bg-rot {
        animation: spin 0.8s linear infinite;
      }
      .desc {
        height: 20px;
        line-height: 20px;
        font-size: 15px;
        color: rgb(231, 121, 58);
        margin-bottom: 20px;
        font-weight: 600;
      }
      .update-center {
        display: flex;
        flex-direction: column;
        align-items: center;
        .spin-bg {
          color: rgb(206, 205, 205);
          font-size: 110px;
          margin-bottom: 5px;
        }
        .desc {
          height: 20px;
          line-height: 20px;
          font-size: 15px;
          color: rgb(231, 121, 58);
          margin-bottom: 20px;
          font-weight: 600;
        }
        .desc-suc {
          color: rgb(58, 231, 58);
          color: #3a8120;
        }
        .el-button {
          width: 100px;
          font-size: 15px;
        }
        .text-desc{
          width: 260px;
          margin-top: 20px;
          background-color: rgba(250, 250, 250, 1);
          border: 1px dashed rgba(220, 220, 220, 1);
          height: 100px;
          padding: 10px 20px;
          color: rgba(94, 94, 94, 1);
          text-align: left;
          font-size: 14px;
          border-radius:5px ;
        }
      }
      .upload-center {
        .update-center {