WindowTxt.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <script setup>
  2. import dayjs from "dayjs";
  3. import { computed, onMounted, onUnmounted, ref } from "vue";
  4. import { WindowTxtStore } from "@/components/WindowQingXiCheAndQv/store/WindowTxtStore.js";
  5. import { ComVal } from "../ThreeWorldEventQingXiCheAndQv/common/ComVal.js";
  6. // 当前展示的内容
  7. let txt = ref("");
  8. let txtCode = "WindowTxt";
  9. /**
  10. * 退出的逻辑
  11. */
  12. const exitEvent = () => {
  13. ComVal.find().fpsEventDel(txtCode);
  14. WindowTxtStore().obj.WindowTxtViewOpen = false;
  15. }
  16. onMounted(() => {
  17. txtEvent();
  18. });
  19. /**
  20. * 一个一个字展示的逻辑
  21. */
  22. const txtEvent = () => {
  23. // console.log(
  24. // "WindowTxtStore().obj.WindowTxtViewTxt 开始展示文字",
  25. // WindowTxtStore().obj.WindowTxtViewTxt
  26. // );
  27. if (typeof WindowTxtStore().obj.WindowTxtViewTxt != "string") {
  28. return;
  29. }
  30. // 分割字符串
  31. var txtArray = WindowTxtStore().obj.WindowTxtViewTxt.split("");
  32. // 开始从第一个文字写入
  33. var txtArrayIndex = -1;
  34. ComVal.find().fpsEventDel(txtCode);
  35. ComVal.find().fpsEventAdd(txtCode, null, (1000 / 15), function(fpsEventAddRet) {
  36. try {
  37. // 写入完成了
  38. if (txtArrayIndex > txtArray.length) {
  39. ComVal.find().fpsEventDel(fpsEventAddRet.code);
  40. return;
  41. }
  42. var editTxt = "";
  43. for (var i = 0; i < txtArrayIndex; i++) {
  44. if (txtArray[i] == null || txtArray[i] == undefined) {
  45. continue;
  46. }
  47. editTxt += txtArray[i];
  48. }
  49. txtArrayIndex += 1;
  50. // console.log("本次写入的文字", editTxt);
  51. txt.value = editTxt;
  52. } catch (e) {
  53. ComVal.find().fpsEventDel(fpsEventAddRet.code);
  54. return;
  55. }
  56. });
  57. }
  58. </script>
  59. <template>
  60. <div class="WindowTxt">
  61. <div class="main">
  62. <img class="exit" v-on:click="exitEvent()" src="../../assets/res/img/window/exit.png" />
  63. <!-- <div class="title" >文字信息</div> -->
  64. <div class="title" >操作事项</div>
  65. <div class="content commonsScrollbar">
  66. {{ txt }}
  67. </div>
  68. </div>
  69. </div>
  70. </template>
  71. <style lang="less" >
  72. * {
  73. box-sizing:border-box;
  74. -moz-box-sizing:border-box; /* Firefox */
  75. -webkit-box-sizing:border-box; /* Safari */
  76. }
  77. </style>
  78. <style lang="less" scoped>
  79. @import "./css/commonsScrollbar.less";
  80. .WindowTxt * {
  81. -moz-user-select: none;
  82. -webkit-user-select: none;
  83. -ms-user-select: none;
  84. -khtml-user-select: none;
  85. user-select: none;
  86. }
  87. .WindowTxt {
  88. position: fixed;
  89. z-index: 0;
  90. width: 0px;
  91. height: 0px;
  92. top: 0px;
  93. left: 0px;
  94. z-index: 1000;
  95. .main {
  96. position: fixed;
  97. width: 35.4285rem;
  98. height: 21.8571rem;
  99. top: 25%;
  100. left: 10%;
  101. background-image: url("../../assets/res/img/window/bg.png");
  102. background-position: center;
  103. background-size: 100% 100%;
  104. .exit {
  105. position: absolute;
  106. width: 1.4285rem;
  107. top: 3.0714rem;
  108. right: 3.2142rem;
  109. // 手势
  110. cursor:pointer;
  111. }
  112. .title {
  113. position: absolute;
  114. color: #FEFEFE;
  115. font-size: 1.4285rem;
  116. font-weight: 500;
  117. top: 2.65rem;
  118. left: 5.428rem;
  119. }
  120. .content {
  121. position: absolute;
  122. top: 5rem;
  123. left: 3.5714rem;
  124. right: 3.5714rem;
  125. bottom: 3rem;
  126. color: #FEFEFE;
  127. font-size: 1.2857rem;
  128. font-weight: 400;
  129. line-height: 2.15rem;
  130. // 换行
  131. word-break: break-all;
  132. /** 让文本带有 \n 自动换行 */
  133. white-space: pre-wrap;
  134. // text-wrap: normal;
  135. // white-space: normal;
  136. }
  137. }
  138. }
  139. </style>