index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <RightFillPano>
  3. <template #header>
  4. <div class="btns header-btns">
  5. <ui-button class="start" @click="start" type="primary">开始录制</ui-button>
  6. </div>
  7. </template>
  8. <ui-group title="全部视频" class="tree">
  9. <Draggable :list="records" draggable=".sign" itemKey="id">
  10. <template #item="{ element: record }">
  11. <Sign
  12. :record="getSignRecord(record)"
  13. :key="record.id"
  14. @delete="deleteRecord(record)"
  15. @updateTitle="(title: string) => (record.title = title)"
  16. @updateCover="(cover: string) => (record.cover = cover)"
  17. />
  18. </template>
  19. </Draggable>
  20. </ui-group>
  21. </RightFillPano>
  22. </template>
  23. <script lang="ts" setup>
  24. import { ref, watch } from "vue";
  25. import { showMeasuresStack, showTaggingsStack } from "@/env";
  26. import { useViewStack } from "@/hook";
  27. import { diffArrayChange, togetherCallback } from "@/utils";
  28. import { RecordProcess } from "./help";
  29. import {
  30. records,
  31. createRecord,
  32. Record,
  33. RecordStatus,
  34. autoSaveRecords,
  35. initialRecords,
  36. getRecordFragmentBlobs,
  37. isTemploraryID,
  38. initialTaggingStyles,
  39. initialPaths,
  40. } from "@/store";
  41. import { RightFillPano } from "@/layout";
  42. import Draggable from "vuedraggable";
  43. import Sign from "./sign.vue";
  44. import { Dialog } from "bill/index";
  45. import { initialTaggings } from "@/store/tagging";
  46. import { initialMeasures } from "@/store/measure";
  47. import { initialGuides } from "@/store/guide";
  48. initialRecords();
  49. initialTaggingStyles();
  50. initialTaggings();
  51. initialMeasures();
  52. initialGuides();
  53. initialPaths();
  54. const start = () => records.value.push(createRecord());
  55. const deleteRecord = async (record: Record) => {
  56. const isTemp = getRecordFragmentBlobs(record).length === 0 && isTemploraryID(record.id);
  57. if (isTemp || (await Dialog.confirm("确定要删除视频吗?"))) {
  58. const index = records.value.indexOf(record);
  59. if (~index) {
  60. records.value.splice(index, 1);
  61. }
  62. }
  63. };
  64. const getSignRecord = (record: Record): RecordProcess => ({
  65. ...record,
  66. immediately: record.status === RecordStatus.UN,
  67. });
  68. const setOptions = [
  69. { value: "tagging", label: "标签" },
  70. { value: "measure", label: "测量" },
  71. ] as const;
  72. type SetKey = typeof setOptions[number]["value"];
  73. const setting = ref<SetKey[]>(["tagging", "measure"]);
  74. watch(
  75. setting,
  76. (setting, oldSetting = [], onCleanup) => {
  77. const { added } = diffArrayChange(setting, oldSetting);
  78. const pops = added.map((value) => {
  79. if (value === "measure") {
  80. return showMeasuresStack.push(ref(true));
  81. } else {
  82. return showTaggingsStack.push(ref(true));
  83. }
  84. });
  85. onCleanup(togetherCallback(pops));
  86. },
  87. { flush: "sync" }
  88. );
  89. useViewStack(() => {
  90. // const pop = showTaggingsStack.push(ref(false))
  91. return () => {
  92. setting.value = [];
  93. // pop()
  94. };
  95. });
  96. useViewStack(autoSaveRecords);
  97. </script>
  98. <style lang="scss" src="./style.scss" scoped></style>