index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div class="layer">
  3. <ly-top class="top" />
  4. <div class="content">
  5. <router-view v-slot="{ Component }" v-if="isSystem">
  6. <component :is="Component" />
  7. </router-view>
  8. <template v-else>
  9. <ly-slide class="slide" :names="menuRouteNames" v-if="!hiddenSlide" />
  10. <div class="view" :class="{ full: hiddenSlide }">
  11. <div class="app-wrap m-4" v-if="!hiddenSlide">
  12. <div
  13. class="app-scene"
  14. ref="sceneRef"
  15. :style="{
  16. width: '100%',
  17. height: 'calc(100% - 24px)',
  18. // display: showScene ? 'none' : 'block'
  19. }"
  20. >
  21. <div class="poprs sceneList" v-if="sceneList.length">
  22. <el-dropdown placement="bottom-start" trigger="click" @command="handleCommand">
  23. <span class="el-dropdown-link" style="color: #fff">
  24. {{sceneListName}}
  25. <el-icon class="el-icon--right">
  26. <arrow-down />
  27. </el-icon>
  28. </span>
  29. <template #dropdown>
  30. <el-dropdown-menu>
  31. <el-dropdown-item v-for="item,index in sceneList" :key="index" :command="item.id">{{ item.name || '多元融合' }}</el-dropdown-item>
  32. </el-dropdown-menu>
  33. </template>
  34. </el-dropdown>
  35. <!-- <div v-for="item,index in sceneList" :key="index">
  36. {{ item.name }}
  37. </div> -->
  38. </div>
  39. <!-- @load="setupSDK($event.target)" -->
  40. <iframe
  41. v-if="caseId"
  42. :src="sceneURL"
  43. frameborder="0"
  44. :style="{ width: '100%', height: '100%' }"
  45. ></iframe>
  46. </div>
  47. </div>
  48. <div class="main p-4" :class="{ fullmain: hiddenSlide }">
  49. <router-view v-slot="{ Component }">
  50. <component :is="Component" />
  51. </router-view>
  52. </div>
  53. </div>
  54. </template>
  55. </div>
  56. </div>
  57. </template>
  58. <script lang="ts" setup>
  59. import lyTop from "./top/index.vue";
  60. import lySlide from "./slide/index.vue";
  61. import { routeIsSystem, router } from "@/router";
  62. import { computed, ref, onMounted, watch } from "vue";
  63. import { menuRouteNames } from "@/app";
  64. import { updateByTreeFileLists, getCaseSceneListData, getUrlSrc, getcaseLists, getCaseSceneList } from "@/store/case";
  65. import { json } from "stream/consumers";
  66. console.log(menuRouteNames, 'menuRouteNames', router.currentRoute.value.name);
  67. const isSystem = computed(() => routeIsSystem());
  68. const caseId = computed(() => {
  69. const caseId = router.currentRoute.value.params.caseId;
  70. if (caseId) {
  71. return Number(caseId);
  72. }
  73. });
  74. // const qpisceneList = ref(getCaseSceneListData() as any[]);
  75. const sceneList = ref([]);
  76. const sceneURL = ref(``)
  77. const sceneListName = ref('')
  78. const modeList = ref([])
  79. const init = async () => {
  80. modeList.value = modeList.value.length == 0 ? await getcaseLists(caseId.value as number) : modeList.value;
  81. sceneList.value = await getCaseSceneList(caseId.value as number);
  82. if(modeList.value.length){
  83. sceneList.value.unshift({ id: -1, type: 99, name: '多元融合' });
  84. }
  85. handleCommand()
  86. // let url = getUrlSrc({ id: 0 }, caseId.value)
  87. // sceneURL.value = url;
  88. }
  89. init()
  90. const qpisceneList = computed(() => getCaseSceneListData(caseId.value as number));
  91. watch(() => qpisceneList.value, () => {
  92. let newqpisceneList = JSON.parse(JSON.stringify(qpisceneList.value))
  93. if(modeList.value.length){
  94. newqpisceneList.unshift({ id: -1, type: 99, name: '多元融合' });
  95. }
  96. sceneList.value = [...newqpisceneList]
  97. })
  98. console.log(sceneList, 'sceneList');
  99. onMounted(() => {
  100. // setupSDK(document.querySelector('iframe') as HTMLIFrameElement)
  101. })
  102. updateByTreeFileLists()
  103. const hiddenSlide = computed(
  104. () => !menuRouteNames.includes(router.currentRoute.value.name as string)
  105. );
  106. const handleCommand = (command) => {
  107. let newid = command || sceneList.value[0].id;
  108. let item = sceneList.value.find(item => item.id == newid);
  109. sceneListName.value = item.name;
  110. let url = getUrlSrc(item, caseId.value)
  111. sceneURL.value = url;
  112. console.log('handleCommand', command, item, url);
  113. }
  114. const handleClick = (command: string) => {
  115. console.log('handleClick', command);
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .layer {
  120. position: absolute;
  121. z-index: 1;
  122. width: 100%;
  123. height: 100%;
  124. display: flex;
  125. flex-direction: column;
  126. .top {
  127. flex: 0 0 auto;
  128. }
  129. .content {
  130. flex: 1 0;
  131. display: flex;
  132. overflow: hidden;
  133. .slide {
  134. width: 16.66rem;
  135. flex: 0 0 auto;
  136. }
  137. .view {
  138. flex: 0 0 auto;
  139. width: calc(100% - 16.66rem);
  140. background-color: var(--bgColor);
  141. // flex-direction: column;
  142. display: flex;
  143. &.full {
  144. width: 100%;
  145. }
  146. .app-wrap, .app-view {
  147. width: calc(100% - 320px);
  148. height: 100%;
  149. }
  150. .player {
  151. flex: 0 0 auto;
  152. height: 32px;
  153. }
  154. .main {
  155. margin: 0 0px 10px 0;
  156. display: flex;
  157. flex-direction: column;
  158. overflow: hidden;
  159. flex: 1;
  160. background: #fff;
  161. }
  162. .fullmain{
  163. background-color: var(--bgColor);
  164. overflow-y: scroll;
  165. }
  166. .app-scene{
  167. position: relative;
  168. }
  169. .sceneList{
  170. position: absolute;
  171. left: 21px;
  172. top: 42px;
  173. color: #fff;
  174. font-weight: bold;
  175. }
  176. // .sceneList{
  177. // width: 48px;
  178. // height: 38px;
  179. // position: absolute;
  180. // left: 10px;
  181. // top: 10px;
  182. // padding: 6px 0;
  183. // line-height: 42px;
  184. // background: rgba(27, 27, 28, 0.80);
  185. // text-align: center;
  186. // cursor: pointer;
  187. // }
  188. }
  189. }
  190. }
  191. </style>