<template>
  <div class="wp">
    <div class="hd">
      <div class="logo"><img src="img/logo.png" /></div>
      <span class="y">
        欢迎您，<span id="user-name"></span> <span class="pipe">|</span
        ><a href="login.html">退出</a>
      </span>
    </div>
    <div class="cont">
      <div class="title cl">
        <span class="y"><a href="index.html">返回考试主页</a></span>
        <h2>数据同步</h2>
      </div>
      <div class="data">
        <p>
          本地已下载考生数量：<b id="student-count">{{ studentCount }}</b>
        </p>
        <p>
          上次下载完成时间：<b id="last-time">{{ lastTime }}</b>
        </p>
        <div class="btn">
          <a href="/sync-run"><span>开始同步数据</span></a>
        </div>
      </div>
    </div>
    <div class="ft">
      Copyright © 2011-2020 www.qmth.com.cn, All Rights Reserved
    </div>
  </div>
</template>

<script setup lang="ts">
import { store } from "@/store";
import { onMounted, ref } from "vue";

const lastTime =
  store.config["syncTime"][store.env.server.host + store.env.exam.id];

let studentCount = ref(0);
onMounted(async () => {
  const studentCountRes = await window.electron.queryStudentCount(
    JSON.parse(JSON.stringify(store))
  );
  console.log(studentCountRes);
  studentCount.value = studentCountRes;
});
</script>
