HelpInfoBar.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <el-popover :width="220" placement="bottom" trigger="hover">
  3. <template #reference>
  4. <div class="header-icon-bar">
  5. <HcIcon class="header-icon" name="question" />
  6. </div>
  7. </template>
  8. <div class="header-pover-menu-list">
  9. <div class="list-item">
  10. <span class="text">开启功能气泡提示</span>
  11. <el-switch v-model="bubbleVal" @change="bubbleUpdate" />
  12. </div>
  13. <div v-if="excelUrl" class="list-item" @click="excelPreviewClick">
  14. <span class="text">查看系统操作文档</span>
  15. <img :src="getAssetsHomeFile('word.png')" alt="" class="icon">
  16. <img :src="getAssetsHomeFile('word1.png')" alt="" class="icon1">
  17. </div>
  18. <div v-if="videoUrl" class="list-item" @click="videoPreviewModal = true">
  19. <span class="text">当前页面功能讲解</span>
  20. <img :src="getAssetsHomeFile('video.png')" alt="" class="icon">
  21. <img :src="getAssetsHomeFile('video1.png')" alt="" class="icon1">
  22. </div>
  23. <div class="list-item" @click="toOrderService">
  24. <span class="text">工单服务\需求反馈</span>
  25. <img :src="getAssetsHomeFile('screen.png')" alt="" class="icon" @click.stop="screenShortClick">
  26. <img :src="getAssetsHomeFile('screen1.png')" alt="" class="icon1" @click.stop="screenShortClick">
  27. </div>
  28. </div>
  29. </el-popover>
  30. <!-- 当前页面功能讲解 -->
  31. <el-dialog v-model="videoPreviewModal" :before-close="videoPreviewModalClose" destroy-on-close width="62rem">
  32. <video :src="videoUrl" autoplay="autoplay" class="preview-video" controls="controls">
  33. 您的浏览器不支持 video
  34. </video>
  35. </el-dialog>
  36. </template>
  37. <script setup>
  38. import { nextTick, ref, watch } from 'vue'
  39. import { useRoute, useRouter } from 'vue-router'
  40. import { useAppStore } from '~src/store'
  41. import ScreenShot from 'js-web-screen-shot'
  42. import { getStoreValue } from '~src/utils/storage'
  43. import { getObjValue, getToObjVal } from 'js-fast-way'
  44. //初始变量
  45. const router = useRouter()
  46. const useRoutes = useRoute()
  47. const useAppState = useAppStore()
  48. //相关变量
  49. const route = getObjValue(getStoreValue('route'))
  50. const bubbleVal = ref(useAppState.getBubble)
  51. const videoUrl = ref('')
  52. const excelUrl = ref('')
  53. const videoPreviewModal = ref(false)
  54. const webRtcVal = ref(false)
  55. const fullScreenVal = ref(true)
  56. //监听
  57. watch(() => [
  58. useAppState.getBubble,
  59. useRoutes.name,
  60. useAppState.getShotWebRtc,
  61. useAppState.getFullScreen,
  62. ], ([Bubble, routeName, webRtc, fullScreen]) => {
  63. bubbleVal.value = Bubble
  64. getVideoUrl(routeName)
  65. getExcelUrl(routeName)
  66. setScreenShotData(webRtc, fullScreen)
  67. })
  68. //渲染完成
  69. nextTick(() => {
  70. getVideoUrl(useRoutes?.name)
  71. getExcelUrl(useRoutes?.name)
  72. const webRtc = useAppState.getShotWebRtc
  73. const fullScreen = useAppState.getFullScreen
  74. setScreenShotData(webRtc, fullScreen)
  75. })
  76. //取文档地址
  77. const getExcelUrl = (name) => {
  78. excelUrl.value = getToObjVal(route, name, 'excelUrl')
  79. }
  80. //取视频地址
  81. const getVideoUrl = (name) => {
  82. videoUrl.value = getToObjVal(route, name, 'videoUrl')
  83. }
  84. //处理屏幕截图的配置
  85. const setScreenShotData = (webRtc, fullScreen) => {
  86. webRtcVal.value = parseInt(webRtc) === 1
  87. fullScreenVal.value = parseInt(fullScreen) === 1
  88. }
  89. //开关值改变
  90. const bubbleUpdate = (val) => {
  91. bubbleVal.value = val
  92. useAppState.setBubble(val)
  93. }
  94. //工单服务\需求反馈
  95. const screenShortClick = () => {
  96. nextTick(() => {
  97. new ScreenShot({
  98. enableWebRtc: webRtcVal.value, //截图方式
  99. clickCutFullScreen: fullScreenVal.value, //全屏
  100. loadCrossImg: true, //跨域
  101. level: 999999,
  102. completeCallback: getScreenShotImg,
  103. noScroll: false,
  104. })
  105. /*setTimeout(() => {}, 800)*/
  106. })
  107. }
  108. //获取裁剪区域图片信息
  109. const getScreenShotImg = (base64) => {
  110. window.sessionStorage.setItem('screenShort-base64', base64)
  111. //跳转到工单服务\需求反馈
  112. const useRoutePath = useRoutes.path
  113. useAppState.setScreenShort(true)
  114. if (useRoutePath !== '/other/order-service') {
  115. router.push({ name: 'order-service' })
  116. }
  117. }
  118. //工单服务\需求反馈
  119. const toOrderService = () => {
  120. router.push({ name: 'order-service' })
  121. }
  122. // 获取assets静态资源
  123. const getAssetsHomeFile = (url) => {
  124. const path = `../../assets/images/${url}`
  125. const modules = import.meta.globEager('../../assets/images/*')
  126. return modules[path].default
  127. }
  128. //关闭视频弹窗
  129. const videoPreviewModalClose = () => {
  130. videoPreviewModal.value = false
  131. }
  132. //查看系统操作文档
  133. const excelPreviewClick = () => {
  134. if (excelUrl.value) {
  135. window.open(excelUrl.value, '_blank')
  136. } else {
  137. window?.$message.warning('暂无文档')
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .header-icon-bar {
  143. position: relative;
  144. height: 40px;
  145. width: 40px;
  146. border-radius: 100px;
  147. display: flex;
  148. justify-content: center;
  149. align-items: center;
  150. font-size: 26px;
  151. cursor: pointer;
  152. margin-right: 30px;
  153. border: 1px solid #00000000;
  154. background: #f1f5f8;
  155. color: #202532;
  156. box-shadow: var(--hc-shadow);
  157. }
  158. .hc-layout-box .hc-container-view.home .hc-header-view .hc-header-content .header-icon-bar {
  159. border: 1px solid white;
  160. color: inherit;
  161. box-shadow: initial;
  162. background: initial;
  163. }
  164. .header-pover-menu-list {
  165. position: relative;
  166. margin: -5px -12px;
  167. .list-item {
  168. position: relative;
  169. padding: 10px 24px;
  170. cursor: pointer;
  171. display: flex;
  172. align-items: center;
  173. transition: background-color 0.2s;
  174. .text {
  175. flex: auto;
  176. }
  177. .icon, .icon1 {
  178. width: 24px;
  179. height: 24px;
  180. }
  181. .icon1 {
  182. display: none;
  183. }
  184. &:hover {
  185. color: #ffffff;
  186. background-color: var(--el-color-primary);
  187. .icon {
  188. display: none;
  189. }
  190. .icon1 {
  191. display: block;
  192. }
  193. }
  194. }
  195. }
  196. .preview-video {
  197. width: 100%;
  198. }
  199. </style>