LabelArea.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* 标注区 */
  2. <template>
  3. <gy-card title="标注区" area-style="label" circle-style="yellow" content-style="25">
  4. <div v-for="mk in values" :key="mk" @contextmenu="contextmenu(mk)" style="width:100px;margin-left:10px;margin-top:10px;display: inline-block;">
  5. <img src="../../assets/img/LabelArea/flag.png" style="float:left;margin-top:5px;margin-left:12px;"/>
  6. <div style="text-align:center;font-size:12px;float:right;margin-right:12px;">{{mk.title}}</div>
  7. <input v-model="mk.value" style="font-size:12px;border:none;background-color:#292929;height:26px;border-radius:6px;text-align:center;outline:none;width:100px;color:rgb(220,220,220);"/>
  8. </div>
  9. </gy-card>
  10. </template>
  11. <script>
  12. import BackgroundData from "../../assets/script/BackgroundData";
  13. export default {
  14. name: "LabelArea",
  15. data() {
  16. return {
  17. values: new Array(),
  18. };
  19. },
  20. created() {
  21. this.refreshTimer = setInterval(this.refreshData, 1000);
  22. },
  23. methods: {
  24. refreshData() {
  25. this.values = new Array();
  26. this.values = BackgroundData.getInstance().Marks;
  27. },
  28. contextmenu(mk) {
  29. const { remote } = require("electron");
  30. var that = this;
  31. const menuTemplate = [
  32. {
  33. label: "删除",
  34. click() {
  35. that.remove(mk);
  36. },
  37. },
  38. ];
  39. const menu = remote.Menu.buildFromTemplate(menuTemplate);
  40. menu.popup(remote.getCurrentWindow());
  41. },
  42. remove(mk) {
  43. var indx = -1;
  44. for (var ind in this.values) {
  45. if (this.values[ind].id == mk.id) {
  46. indx = ind;
  47. break;
  48. }
  49. }
  50. if (indx < 0) return;
  51. this.values.splice(indx, 1);
  52. BackgroundData.getInstance().removeMarked(mk);
  53. },
  54. },
  55. };
  56. </script>
  57. <style scoped>
  58. </style>