MarkHeader.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div
  3. class="
  4. tw-flex tw-gap-4 tw-justify-between tw-items-center
  5. header-container
  6. tw-px-1
  7. "
  8. v-if="store.setting"
  9. >
  10. <div>
  11. {{
  12. `${store.setting.subject.code ?? ""}-${
  13. store.setting.subject.name ?? ""
  14. }`
  15. }}
  16. </div>
  17. <div class="tw-flex tw-gap-1">
  18. <div>
  19. 编号<span class="highlight-text">{{
  20. store.currentTask?.secretNumber
  21. }}</span>
  22. </div>
  23. </div>
  24. <ul v-if="!isSingleStudent" class="tw-flex tw-gap-2 tw-mb-0">
  25. <li>
  26. 待处理<span class="highlight-text">{{
  27. store.status.totalCount ?? "-"
  28. }}</span>
  29. </li>
  30. <li>
  31. 已处理<span class="highlight-text">{{
  32. store.status.markedCount ?? "-"
  33. }}</span>
  34. </li>
  35. </ul>
  36. <ul class="tw-flex tw-gap-2 tw-mb-0">
  37. <li @click="upScale" title="放大">
  38. <ZoomInOutlined
  39. class="icon-font icon-font-size-20 tw-cursor-pointer"
  40. :style="{
  41. color: greaterThanOneScale ? 'red' : 'white',
  42. }"
  43. />
  44. </li>
  45. <li @click="downScale" title="缩小">
  46. <ZoomOutOutlined
  47. class="icon-font icon-font-size-20 tw-cursor-pointer"
  48. :style="{
  49. color: lessThanOneScale ? 'red' : 'white',
  50. }"
  51. />
  52. </li>
  53. <li @click="normalScale" title="适应">
  54. <FullscreenOutlined
  55. class="icon-font icon-font-size-20 tw-cursor-pointer"
  56. />
  57. </li>
  58. </ul>
  59. <div @click="toggleHistory" v-if="!isSingleStudent" title="回看">
  60. <HistoryOutlined class="icon-font icon-font-size-20 tw-cursor-pointer" />
  61. </div>
  62. <a-popover title="小助手" trigger="hover" class="tw-cursor-pointer">
  63. <template #content>
  64. <table class="assistant-table">
  65. <tr v-if="store.setting.subject.paperUrl">
  66. <td>试卷</td>
  67. <td>
  68. <a-switch
  69. v-model:checked="store.setting.uiSetting['paper.modal']"
  70. />
  71. </td>
  72. </tr>
  73. <tr v-if="store.setting.subject.answerUrl">
  74. <td>答案</td>
  75. <td>
  76. <a-switch
  77. v-model:checked="store.setting.uiSetting['answer.modal']"
  78. />
  79. </td>
  80. </tr>
  81. <tr>
  82. <td>缩略图</td>
  83. <td>
  84. <a-switch
  85. v-model:checked="store.setting.uiSetting['minimap.modal']"
  86. />
  87. </td>
  88. </tr>
  89. </table>
  90. </template>
  91. <div class="tw-flex">
  92. 小助手
  93. <DownOutlined
  94. style="font-size: 12px; display: inline-block"
  95. class="tw-self-center tw-ml-1"
  96. />
  97. </div>
  98. </a-popover>
  99. <div class="tw-flex tw-place-items-center">
  100. <UserOutlined class="icon-font icon-with-text" />{{
  101. store.setting.userName
  102. }}
  103. </div>
  104. <div
  105. class="tw-flex tw-place-items-center tw-cursor-pointer"
  106. @click="closeWindow"
  107. >
  108. <PoweroffOutlined class="icon-font icon-with-text" />关闭
  109. </div>
  110. </div>
  111. </template>
  112. <script lang="ts">
  113. import { computed, defineComponent, onMounted, ref } from "vue";
  114. import { store } from "@/features/mark/store";
  115. import {
  116. ZoomInOutlined,
  117. ZoomOutOutlined,
  118. FullscreenOutlined,
  119. HistoryOutlined,
  120. UserOutlined,
  121. PoweroffOutlined,
  122. AlertOutlined,
  123. QuestionCircleOutlined,
  124. DownOutlined,
  125. } from "@ant-design/icons-vue";
  126. import { useRoute } from "vue-router";
  127. import { clearArbitrateTask } from "@/api/arbitratePage";
  128. export default defineComponent({
  129. name: "MarkHeader",
  130. components: {
  131. ZoomInOutlined,
  132. ZoomOutOutlined,
  133. FullscreenOutlined,
  134. HistoryOutlined,
  135. UserOutlined,
  136. PoweroffOutlined,
  137. AlertOutlined,
  138. QuestionCircleOutlined,
  139. DownOutlined,
  140. },
  141. setup() {
  142. const route = useRoute();
  143. let isSingleStudent = !!route.query.historyId;
  144. const {
  145. subjectCode,
  146. groupNumber,
  147. historyId: libraryId,
  148. } = route.query as {
  149. subjectCode: string;
  150. groupNumber: string;
  151. historyId: string;
  152. };
  153. const upScale = () => {
  154. const s = store.setting.uiSetting["answer.paper.scale"];
  155. if (s < 3)
  156. store.setting.uiSetting["answer.paper.scale"] = +(s + 0.2).toFixed(1);
  157. };
  158. const downScale = () => {
  159. const s = store.setting.uiSetting["answer.paper.scale"];
  160. if (s > 0.2)
  161. store.setting.uiSetting["answer.paper.scale"] = +(s - 0.2).toFixed(1);
  162. };
  163. const normalScale = () => {
  164. store.setting.uiSetting["answer.paper.scale"] = 1;
  165. };
  166. const toggleHistory = () => {
  167. store.historyOpen = !store.historyOpen;
  168. };
  169. const greaterThanOneScale = computed(() => {
  170. return store.setting.uiSetting["answer.paper.scale"] > 1;
  171. });
  172. const lessThanOneScale = computed(() => {
  173. return store.setting.uiSetting["answer.paper.scale"] < 1;
  174. });
  175. async function updateClearTask() {
  176. await clearArbitrateTask(libraryId, subjectCode, groupNumber);
  177. }
  178. const closeWindow = async () => {
  179. await updateClearTask();
  180. window.close();
  181. };
  182. onMounted(() => {
  183. // 不确定是否一定能在关闭页面时调用
  184. window.addEventListener("beforeunload", () => {
  185. updateClearTask();
  186. });
  187. });
  188. return {
  189. store,
  190. isSingleStudent,
  191. upScale,
  192. downScale,
  193. normalScale,
  194. greaterThanOneScale,
  195. lessThanOneScale,
  196. toggleHistory,
  197. closeWindow,
  198. };
  199. },
  200. });
  201. </script>
  202. <style scoped>
  203. .header-container {
  204. position: relative;
  205. font-size: 16px;
  206. height: 40px;
  207. background-color: #5d6d7d;
  208. color: white;
  209. }
  210. .highlight-text {
  211. color: #ffe400;
  212. }
  213. .icon-font {
  214. display: block;
  215. }
  216. .icon-font-size-20 {
  217. font-size: 20px;
  218. }
  219. .icon-with-text {
  220. font-size: 18px;
  221. line-height: 18px;
  222. }
  223. </style>