<template>
  <div class='top_top'>
    <el-row class="top_page_css ttop_height">
      <el-col :span="12" style="padding-left: 10px; padding-top: 10px;">
        <div>&nbsp;</div>
        <!-- <div style="display: flex">
          <img width="23px" height="20px" src="../assets/logo_icon.png" />
          <span
            class="top-font"
            :class="$root.topPageFlag ? 'top-font_black' : 'top-font'"
            >&nbsp;&nbsp;自助式心理健康评估与认知行为干预系统</span
          >
        </div> -->
      </el-col>
      <el-col :span="12" style="text-align: right; margin-top: 10px">
        <img
          class="top-menu dragNo"
          width="15px"
          height="15px"
          @click="versionFlag = true"
          :src="
            $root.topPageFlag
              ? require('../assets/about.png')
              : require('../assets/about1.png')
          "
        />
        <!-- <el-popover
          placement="bottom"
          title=""
          width="200"
          trigger="click"
          content="心理效能增强系统1.1.1"
        >
          <img
            slot="reference"
            class="top-menu dragNo"
            width="15px"
            height="15px"
            :src="$root.topPageFlag?require('../assets/about.png'):require('../assets/about1.png')"
          />
        </el-popover> -->
        <!-- &nbsp;&nbsp;&nbsp;&nbsp;
        <img
          id="topPageHelp"
          class="top-menu dragNo"
          width="15px"
          height="15px"
          :src="
            $root.topPageFlag
              ? require('../assets/help.png')
              : require('../assets/help1.png')
          "
        /> -->
        &nbsp;&nbsp;&nbsp;&nbsp;

        <img
          id="min"
          class="top-menu dragNo"
          @click="narrow()"
          width="15px"
          height="15px"
          :src="
            $root.topPageFlag
              ? require('../assets/jian.png')
              : require('../assets/jian1.png')
          "
        />&nbsp;&nbsp;&nbsp;&nbsp;
        <img
          class="top-menu dragNo"
          width="15px"
          @click="amplification()"
          height="15px"
          :src="
            $root.topPageFlag
              ? require('../assets/fang.png')
              : require('../assets/fang1.png')
          "
        />&nbsp;&nbsp;&nbsp;&nbsp;
        <img
          class="top-menu dragNo"
          width="15px"
          @click="closeWin()"
          height="15px"
          :src="
            $root.topPageFlag
              ? require('../assets/close.png')
              : require('../assets/close1.png')
          "
        />&nbsp;&nbsp;&nbsp;&nbsp;
      </el-col>
    </el-row>
    <el-dialog title="" :visible.sync="versionFlag" width="60%" center>
      <el-row>
        <el-col :span="6" style="text-align: center">
          <img width="23px" height="20px" src="../assets/logo_icon.png" />
          <p>自助式心理健康评估与认知行为干预系统</p>
        </el-col>
        <el-col :span="18">
          <h4>关于自助式心理健康评估与认知行为干预系统</h4>
          <!-- <p>版权所有©{{ year }}北京决明科技有限公司</p> -->
          <p>版权所有©{{ year }}</p>
          <p>
            本软件产品仅限于个人用户基于个人目的使用，禁止将本软件用于生产、经营等商业用途或者其它用途。
          </p>
          <p>
            警告:
            本计算机程序受著作权法和国际公约的保护，未经授权擅自复制或传播本程序的部分或全部，
            可能受到严厉的民事及刑事制裁，并将在法律许可的范围内受到最大可能的起诉.
          </p>
          <p><span>Version:</span> 1.2.1</p>
          <p><span>Build:</span>#fdfd1a6073</p>
          <p><span>Build on:</span>2024/01/29</p>
          <p><span>Windows:</span>{{ windowsVersion }}</p>
        </el-col>
      </el-row>
      <!-- <span slot="footer" class="dialog-footer">
        <el-button @click="centerDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="centerDialogVisible = false"
          >确 定</el-button
        >
      </span> -->
    </el-dialog>
  </div>
</template>
<script>
let ipcRenderer = require("electron").ipcRenderer;
const { shell } = require("electron");
var os = require("os");
export default {
  name: "TopPage",
  data() {
    return {
      serveBaseUrl: "",
      versionFlag: false,
      year: "",
      windowsVersion: "",
    };
  },
  mounted() {
    // console.log(os.release())
    // parseFloat(os.release()) ;
    let versionLin = os.release();
    let list = versionLin.split(".");

    if (parseInt(list[0]) == 10) {
      if (list.length == 3) {
        if (parseInt(list[2]) > 22000) {
          this.windowsVersion = "11";
        } else {
          this.windowsVersion = "10";
        }
      } else {
        this.windowsVersion = "10";
      }
    } else if (parseInt(list[0]) == 6) {
      if (parseInt(list[1]) == 3) {
        this.windowsVersion = "8.1";
      } else if (parseInt(list[1]) == 2) {
        this.windowsVersion = "8";
      } else if (parseInt(list[1]) == 1) {
        this.windowsVersion = "7";
      } else {
        this.windowsVersion = "";
      }
    } else if (parseInt(list[0]) == 5) {
      this.windowsVersion = "XP";
    }

    // if (list.length == 3) {
    //   if (list[2] > 22000) {
    //     this.windowsVersion = "11";
    //   } else {
    //     this.windowsVersion = "10";
    //   }
    // } else {
    //   if (list[0] == 5) {
    //     this.windowsVersion = "XP";
    //   } else if (list[0] == 6) {
    //   }
    // }
    // console.log(versionLin > 10);

    // if (versionLin > 10) {
    //   this.windowsVersion = "10";
    // }
    //release()
    ipcRenderer.send("asynchronoushrv-controlpanel", 1);
  // sessionStorage.setItem('1111','1234567')
    this.getYearFun();
    ipcRenderer.on("send-message-control", (event, arg) => {
      //调用方法进行配置
      this.serveBaseUrl = arg;
      // sessionStorage.setItem("num", that.account);
      sessionStorage.setItem('urlNews',arg)
      // console.log("我得到数据了拉阿拉啦啦啦啦啦");
      //  console.log(arg);
    });
    const links = document.getElementById("topPageHelp");
    links.addEventListener("click", (e) => {
      const url = links.getAttribute("href");
      e.preventDefault();
      //\\resources\\exe\\HelpCenter\\help.html
      shell.openExternal(
        this.serveBaseUrl + "\\resources\\exe\\HelpCenter\\help.html"
      );
      //shell.openExternal(this.serveBaseUrl + "\\resources\\exe\\HelpCenter\\help.html");
      //shell.openExternal(this.serveBaseUrl + "\\exe\\HelpCenter\\zb使用说明书.pdf");
    });

  },
  methods: {
    getYearFun() {
      let date = new Date();
      this.year = date.getFullYear();
    },
    narrow() {
      ipcRenderer.send("window-min");
    },
    amplification() {
      ipcRenderer.send("window-max");
    },
    closeWin() {
      ipcRenderer.send("window-close");
    },
  },
};
</script>
<style>
.top_page_css {
  -webkit-app-region: drag;
}
.top-font {
  color: #ffffff;
  line-height: 20px;
  font-size: 16px;
  font-weight: 500;
}
.top-font_black {
  color: #000000;
  line-height: 20px;
  font-size: 16px;
  font-weight: 500;
}
.top-menu {
  cursor: pointer;
}
.dragNo {
  -webkit-app-region: no-drag;
}
.ttop_height {
  height: 5vh;
}
.top_top{
  position: absolute;
  width:100%;
  margin-left:auto;
  z-index: 3000;
}
</style>