1
0

index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <div class="layer">
  3. <ly-top class="top" v-if="router?.currentRoute?.value?.name != 'mediaLibrary'" />
  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="showScene || !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. <iframe
  22. v-if="caseId"
  23. :key="qpisceneList &&qpisceneList.length"
  24. :src="sceneURL"
  25. frameborder="0"
  26. :style="{ width: '100%', height: '100%' }"
  27. ></iframe>
  28. </div>
  29. </div>
  30. <div class="main p-4" :class="{ fullmain: hiddenSlide && !showScene }">
  31. <router-view v-slot="{ Component }">
  32. <component :is="Component" />
  33. </router-view>
  34. </div>
  35. </div>
  36. </template>
  37. </div>
  38. </div>
  39. </template>
  40. <script lang="ts" setup>
  41. import lyTop from "./top/index.vue";
  42. import lySlide from "./slide/index.vue";
  43. import { routeIsSystem, router } from "@/router";
  44. import { computed, ref, onMounted, watch } from "vue";
  45. import { menuRouteNames } from "@/app";
  46. import { setUrlData } from "@/store/user";
  47. import { useRouter, useRoute } from "vue-router";
  48. import { updateByTreeFileLists, getCaseSceneListData, getUrlSrc, getcaseLists, getCaseSceneList } from "@/store/case";
  49. import { json } from "stream/consumers";
  50. const isSystem = computed(() => routeIsSystem());
  51. const router = useRouter();
  52. const caseId = computed(() => {
  53. const caseId = router.currentRoute.value.params.caseId;
  54. if (caseId) {
  55. return Number(caseId);
  56. }
  57. });
  58. const getAllParams = () => {
  59. let href = window.location.href;
  60. let query = href.substring(href.indexOf("?") + 1);
  61. let vars = query.split("&");
  62. let obj = {};
  63. for (let i = 0; i < vars.length; i++) {
  64. let pair = vars[i].split("=");
  65. // 将参数名和参数值分别作为对象的属性名和属性值
  66. obj[pair[0]] = pair[1];
  67. }
  68. return obj;
  69. };
  70. let querys = getAllParams() || {};
  71. setUrlData(querys)
  72. if(querys.ga == '1'){
  73. router.replace('/home/'+caseId.value as number)
  74. }
  75. if(querys.path){
  76. router.replace(querys.path)
  77. }
  78. if(querys.appServer){
  79. router.replace(querys.path)
  80. }
  81. // const qpisceneList = ref(getCaseSceneListData() as any[]);
  82. console.log('caseIdgetUrlSrc', getUrlSrc({ type: 99 }, querys.caseId || caseId.value));
  83. const sceneList = ref([]);
  84. const sceneURL = ref( getUrlSrc({ type: 99 }, querys.caseId || caseId.value) || `/code/index.html?caseId=${caseId.value}#/show`)
  85. const sceneListName = ref('')
  86. const modeList = ref([])
  87. const init = async () => {
  88. modeList.value = modeList.value.length == 0 ? await getcaseLists(caseId.value as number) : modeList.value;
  89. let listss = await getCaseSceneList(caseId.value as number);
  90. sceneList.value = listss;
  91. if(listss.length){
  92. sceneList.value.unshift({ id: -1, type: 99, name: '多元融合' });
  93. let url = getUrlSrc({ id: 0 }, caseId.value)
  94. sceneURL.value = url;
  95. }
  96. console.log('init', modeList.value, sceneList.value, modeList.value.length);
  97. handleCommand()
  98. // let url = getUrlSrc({ id: 0 }, caseId.value)
  99. // sceneURL.value = url;
  100. }
  101. // init()
  102. const qpisceneList = computed(() => getCaseSceneListData(caseId.value as number));
  103. watch(() => qpisceneList.value, () => {
  104. console.log(qpisceneList.value, 'qpisceneList');
  105. // if(!qpisceneList.value instanceof Array){
  106. // return;
  107. // }
  108. // let newqpisceneList = qpisceneList.value && JSON.parse(JSON.stringify(qpisceneList.value)) || []
  109. // if(newqpisceneList.length){
  110. // newqpisceneList.unshift({ id: -1, type: 99, name: '多元融合' });
  111. // }
  112. // console.log('qpisceneList', qpisceneList.value, newqpisceneList);
  113. // sceneList.value = qpisceneList.value && [...newqpisceneList] || []
  114. // handleCommand()
  115. })
  116. onMounted(() => {
  117. // setupSDK(document.querySelector('iframe') as HTMLIFrameElement)
  118. })
  119. updateByTreeFileLists()
  120. const hiddenSlide = computed(
  121. () => !menuRouteNames.includes(router.currentRoute.value.name as string)
  122. );
  123. const showScene = computed(
  124. () => ['homes'].includes(router.currentRoute.value.name as string)
  125. );
  126. const handleCommand = (command) => {
  127. let newid = command || sceneList.value[0].id;
  128. console.log('handleCommand', command, newid, sceneList.value);
  129. let item = sceneList.value.find(item => item.id == newid);
  130. sceneListName.value = item.name;
  131. let url = getUrlSrc(item, caseId.value)
  132. sceneURL.value = url;
  133. console.log('handleCommand', command, item, url);
  134. }
  135. const handleClick = (command: string) => {
  136. console.log('handleClick', command);
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .layer {
  141. position: absolute;
  142. z-index: 1;
  143. width: 100%;
  144. height: 100%;
  145. display: flex;
  146. flex-direction: column;
  147. .top {
  148. flex: 0 0 auto;
  149. }
  150. .content {
  151. flex: 1 0;
  152. display: flex;
  153. overflow: hidden;
  154. .slide {
  155. width: 16.66rem;
  156. flex: 0 0 auto;
  157. }
  158. .view {
  159. flex: 0 0 auto;
  160. width: calc(100% - 16.66rem);
  161. background-color: var(--bgColor);
  162. // flex-direction: column;
  163. display: flex;
  164. &.full {
  165. width: 100%;
  166. }
  167. .app-wrap, .app-view {
  168. width: calc(100% - 320px);
  169. height: 100%;
  170. }
  171. .player {
  172. flex: 0 0 auto;
  173. height: 32px;
  174. }
  175. .main {
  176. margin: 0 0px 10px 0;
  177. display: flex;
  178. flex-direction: column;
  179. overflow: hidden;
  180. flex: 1;
  181. background: #fff;
  182. }
  183. .fullmain{
  184. background-color: var(--bgColor);
  185. overflow-y: scroll;
  186. }
  187. .app-scene{
  188. position: relative;
  189. }
  190. .sceneList{
  191. position: absolute;
  192. width: 200px;
  193. text-align: center;
  194. left: calc(50% - 100px);
  195. top: 42px;
  196. color: #fff;
  197. font-weight: bold;
  198. }
  199. // .sceneList{
  200. // width: 48px;
  201. // height: 38px;
  202. // position: absolute;
  203. // left: 10px;
  204. // top: 10px;
  205. // padding: 6px 0;
  206. // line-height: 42px;
  207. // background: rgba(27, 27, 28, 0.80);
  208. // text-align: center;
  209. // cursor: pointer;
  210. // }
  211. }
  212. }
  213. }
  214. </style>
  215. <style lang="scss">
  216. .el-dropdown{
  217. width: 200px;
  218. }
  219. </style>