| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import { ref } from 'vue'
- import { fetchScenes, getSyncSceneInfo, SceneType, SceneTypeDesc } from '@/api'
- import { fetchStoreItems } from '@/utils'
- import type { Scene, Scenes } from '@/api'
- import { Dialog } from 'bill/expose-common'
- import { getUserInfo } from '@/api/user'
- export type { Scene, Scenes } from '@/api'
- export const scenes = ref<Scenes>([])
- export const getScene = (sceneId: Scene['id']) => scenes.value.find(scene => scene.id === sceneId)
- export const initialScenes = fetchStoreItems(
- scenes,
- fetchScenes,
- )
- export { SceneType, SceneTypeDesc, SceneStatus } from '@/api'
- export const SceneTypePaths: { [key in SceneType]: string[] } = {
- [SceneType.SWKK]: [
- "/swkk/spg.html",
- "/swkk/epg.html",
- `/livestream/fd/criminal.html`,
- ],
- [SceneType.SWKJ]: ["/swkk/spg.html", "/swkk/epg.html"],
- [SceneType.DSFXJ]: ["/swkk/spg.html", "/swkk/epg.html"],
- [SceneType.SWSS]: ["/swss/index.html", "/swss/index.html"],
- [SceneType.SWMX]: import.meta.env.DEV
- ? ["/dev-code/index.html", "/dev-code/index.html"]
- : ["/code/index.html", "/code/index.html"],
- [SceneType.SWSSMX]: ["/swkk/spg.html", "/swkk/epg.html"],
- [SceneType.SWYDSS]: ["/swss/index.html", "/swss/index.html"],
- [SceneType.SWYDMX]: ["/swkk/spg.html", "/swkk/epg.html"],
- };
- export const getSWKKSyncLink = async (scene: Scene) => {
- console.log('scene', scene)
- const supportTypes = [SceneType.SWKJ, SceneType.SWSSMX, SceneType.SWYDMX, SceneType.DSFXJ];
- const kkScenes = scenes.value.filter((scene) =>
- supportTypes.includes(scene.type)
- );
- let msg: string | null = null;
- if (!kkScenes.length) {
- msg = `带看仅支持${supportTypes
- .map((type) => SceneTypeDesc[type])
- .join("、")}类型场景,请添加此类型场景。`;
- }
- if (msg) {
- Dialog.alert(msg);
- throw msg;
- }
- const url = new URL(SceneTypePaths[SceneType.SWKK][2], window.location.href);
- const userInfo = await getUserInfo();
- const roomId = await getSyncSceneInfo(scene);
- const params = {
- vruserId: userInfo.userName,
- // platform: "fd",
- roomId,
- // domain: location.href,
- // fromMiniApp: "0",
- role: "leader",
- // avatar: '/code/favicon.ico',
- redirect: encodeURIComponent(location.href),
- name: userInfo.userName,
- m: scene.raw.num,
- };
- for (const [name, val] of Object.entries(params)) {
- url.searchParams.append(name, val || "");
- }
- return url;
- };
|