123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import { defineStore } from 'pinia';
- import { KankanMetaDataType } from '/#/sdk';
- import { getApp } from '/@/hooks/userApp';
- // useApp,
- export interface FloorsType {
- id: string;
- subgroup?: string;
- name: string;
- segment?: any[];
- tagging?: any[];
- ['vertex-xy']?: any[];
- }
- interface SceneState {
- tags: any[];
- floors: FloorsType[];
- metadata: KankanMetaDataType;
- }
- export const getStaticURL = (path: string) => {
- return import.meta.env.BASE_URL + import.meta.env.VITE_APP_STATIC_DIR + '/' + path;
- };
- export const useSceneStore = defineStore({
- id: 'scene',
- state: (): SceneState => ({
- tags: [],
- floors: [],
- metadata: {} as KankanMetaDataType,
- }),
- getters: {
- musicURL(): Nullable<string> {
- const musicURl = this.metadata.music;
- if (musicURl) {
- if (/^0\d$/.test(musicURl)) {
- return getStaticURL(`static/music/${musicURl}.mp3`);
- } else {
- const app = getApp();
- return app.resource.getUserResourceURL(
- this.metadata.musicFile.replace(/(.+)\.(.+)/, 'music-user.$2'),
- );
- }
- }
- return null;
- },
- loadingLogoFile(): Nullable<string> {
- if (this.metadata.loadingLogo == 'user') {
- const app = getApp();
- return app.resource.getUserResourceURL(this.metadata.loadingLogoFile);
- }
- return null;
- },
- },
- actions: {
- load(metadata: KankanMetaDataType): void {
- this.metadata = metadata;
- document.title = metadata.title;
- },
- loadFloorData(floors: FloorsType[]) {
- if (floors?.length) {
- this.floors = floors.map((item) => {
- return { id: item.subgroup, name: item.name };
- }) as FloorsType[];
- }
- },
- },
- });
|