TestStatus.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <h1>展示新前端获取status的结果</h1>
  3. <div>valid: {{ valid }}</div>
  4. <div>totalCount: {{ totalCount }}</div>
  5. <div>personCount: {{ personCount }}</div>
  6. <div>markedCount: {{ markedCount }}</div>
  7. <div>problemCount: {{ problemCount }}</div>
  8. <div>arbitrateCount: {{ arbitrateCount }}</div>
  9. <div>mode: {{ store.setting.mode }}</div>
  10. </template>
  11. <script lang="ts">
  12. import { ModeEnum } from "@/types";
  13. import { reactive, defineComponent, onMounted, toRefs } from "vue";
  14. import { store } from "@/features/mark/store";
  15. export default defineComponent({
  16. name: "TestStatus",
  17. setup: () => {
  18. const state = reactive({
  19. valid: false,
  20. totalCount: 0,
  21. personCount: 0,
  22. markedCount: 0,
  23. problemCount: 0,
  24. arbitrateCount: 0,
  25. });
  26. async function updateCount() {
  27. const statusRes = await (
  28. await fetch("/mark/getStatus", { method: "POST" })
  29. ).json();
  30. const groupRes = await (
  31. await fetch("/mark/getGroup", { method: "POST" })
  32. ).json();
  33. console.log(groupRes);
  34. const taskRes = await (
  35. await fetch("/mark/getTask", { method: "POST" })
  36. ).json();
  37. console.log(taskRes);
  38. console.log(statusRes, statusRes.totalCount);
  39. state.valid = statusRes.valid;
  40. state.totalCount = statusRes.totalCount;
  41. state.personCount = statusRes.personCount;
  42. state.markedCount = statusRes.markedCount;
  43. state.problemCount = statusRes.problemCount;
  44. state.arbitrateCount = statusRes.arbitrateCount;
  45. // test re-render
  46. store.setting.mode = ModeEnum.COMMON;
  47. }
  48. onMounted(() => {
  49. updateCount();
  50. });
  51. return { ...toRefs(state), store };
  52. },
  53. updated() {
  54. console.log("TestStatus updated");
  55. },
  56. });
  57. </script>
  58. <style scoped>
  59. a {
  60. color: #42b983;
  61. }
  62. label {
  63. margin: 0 0.5em;
  64. font-weight: bold;
  65. }
  66. code {
  67. background-color: #eee;
  68. padding: 2px 4px;
  69. border-radius: 4px;
  70. color: #304455;
  71. }
  72. </style>