wujingjing
2025-02-19 404600d8352b4ecac6daf963b63e01bec543fcb3
定时获取位置
已修改3个文件
46 ■■■■■ 文件已修改
src/components/chat/Chat.vue 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.ts 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stores/chatRoom.ts 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/chat/Chat.vue
@@ -132,21 +132,21 @@
        ...judgeParams,
    } as any;
    // if (!position) {
    //     const loadingInstance = ElLoadingService({
    //         text: '获取位置中...',
    //         target: '.layout-parent',
    //         fullscreen:false,
    //     });
    //     position = await getCurrentPosition().finally(() => {
    //         loadingInstance.close();
    //     });
    // }
    if (!position) {
        const loadingInstance = ElLoadingService({
            text: '获取位置中...',
            target: '.layout-parent',
            fullscreen:false,
        });
        position = await getCurrentPosition().finally(() => {
            loadingInstance.close();
        });
    }
    // if (position) {
    //     const { latitude, longitude } = position;
    //     params.cur_pos = [longitude, latitude].join(',');
    // }
    if (position) {
        const { latitude, longitude } = position;
        params.cur_pos = [longitude, latitude].join(',');
    }
    if (activeGroupType.value) {
        params.group_type = activeGroupType.value;
src/main.ts
@@ -11,7 +11,7 @@
import { initBackEndControlRoutes } from './router/backEnd';
import '/@/theme/index.scss';
import '@amap/amap-jsapi-types';
import { autoLogin, getAllData ,pingLogin} from './stores/chatRoom';
import { autoLogin, getAllData ,getGlobalPosition,pingLogin} from './stores/chatRoom';
import { setTheme } from '/@/utils/theme';
import { accessSessionKey } from './utils/request';
import { Local } from './utils/storage';
@@ -37,3 +37,5 @@
// 获取全局数据
getAllData();
pingLogin();
getGlobalPosition();
src/stores/chatRoom.ts
@@ -9,6 +9,7 @@
import emitter from '../utils/mitt';
import { gotoRoute } from '../utils/route';
import { Local, LocalPlus } from '../utils/storage';
import { getCurrentPosition } from '../utils/brower';
/**
 * Room 关联的一些配置
@@ -83,10 +84,7 @@
// 主场景 列表
export const sceneGroupList = ref([]);
// groupType 列表
export const groupTypeList = computed(() =>
    Array.from(new Set(sceneGroupList.value.map((item) => item.group_type)))
);
export const groupTypeList = computed(() => Array.from(new Set(sceneGroupList.value.map((item) => item.group_type))));
// 办公/模板 列表
export const exampleSceneList = ref([]);
export const officeList = ref([]);
@@ -280,3 +278,11 @@
};
export const currentPosition = ref<Position>(null);
export const getGlobalPosition = () => {
    getCurrentPosition();
    setInterval(() => {
        getCurrentPosition();
    }, 1000 * 60 * 60);
};