123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <template>
- <h1>展示新前端获取status的结果</h1>
- <div>valid: {{ valid }}</div>
- <div>totalCount: {{ totalCount }}</div>
- <div>personCount: {{ personCount }}</div>
- <div>markedCount: {{ markedCount }}</div>
- <div>problemCount: {{ problemCount }}</div>
- <div>arbitrateCount: {{ arbitrateCount }}</div>
- <div>mode: {{ store.setting.mode }}</div>
- </template>
- <script lang="ts">
- import { ModeEnum } from "@/types";
- import { reactive, defineComponent, onMounted, toRefs } from "vue";
- import { store } from "@/features/mark/store";
- export default defineComponent({
- name: "TestStatus",
- setup: () => {
- const state = reactive({
- valid: false,
- totalCount: 0,
- personCount: 0,
- markedCount: 0,
- problemCount: 0,
- arbitrateCount: 0,
- });
- async function updateCount() {
- const statusRes = await (
- await fetch("/mark/getStatus", { method: "POST" })
- ).json();
- const groupRes = await (
- await fetch("/mark/getGroup", { method: "POST" })
- ).json();
- console.log(groupRes);
- const taskRes = await (
- await fetch("/mark/getTask", { method: "POST" })
- ).json();
- console.log(taskRes);
- console.log(statusRes, statusRes.totalCount);
- state.valid = statusRes.valid;
- state.totalCount = statusRes.totalCount;
- state.personCount = statusRes.personCount;
- state.markedCount = statusRes.markedCount;
- state.problemCount = statusRes.problemCount;
- state.arbitrateCount = statusRes.arbitrateCount;
- // test re-render
- store.setting.mode = ModeEnum.COMMON;
- }
- onMounted(() => {
- updateCount();
- });
- return { ...toRefs(state), store };
- },
- updated() {
- console.log("TestStatus updated");
- },
- });
- </script>
- <style scoped>
- a {
- color: #42b983;
- }
- label {
- margin: 0 0.5em;
- font-weight: bold;
- }
- code {
- background-color: #eee;
- padding: 2px 4px;
- border-radius: 4px;
- color: #304455;
- }
- </style>
|