From 4e57cc40899cb6dcaeec1eda0a2325a74e44f9db Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期五, 14 三月 2025 18:41:27 +0800 Subject: [PATCH] 微信修改 --- src/stores/chatRoom.ts | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/stores/chatRoom.ts b/src/stores/chatRoom.ts index 4a4be26..abf64f8 100644 --- a/src/stores/chatRoom.ts +++ b/src/stores/chatRoom.ts @@ -1,15 +1,15 @@ -import { reject } from 'lodash-es'; import { computed, ref } from 'vue'; import { CreateHistoryGroup, GetHistoryGroups, getSectionList, getSelectSample, getUserTemplateList } from '../api/ai/chat'; +import { PostLogin } from '../api/ai/user'; +import { PingLogin } from '../api/system'; +import { LOGIN_CLIENT, STORED_ACCOUNT_KEY, handleAfterLogin } from '../layout/component/login/login'; import type { ChatRoomItem } from '../layout/component/sidebar/components/types'; import { router } from '../router'; +import { decrypt } from '../utils/cypto'; import emitter from '../utils/mitt'; import { gotoRoute } from '../utils/route'; -import { Local } from '../utils/storage'; -import { PingLogin } from '../api/system'; -import { SSEClient } from '../utils/sse/SSEClient'; -import { accessSessionKey } from '../utils/request'; -import { MAIN_URL } from '../constants'; +import { Local, LocalPlus } from '../utils/storage'; +import { getCurrentPosition } from '../utils/brower'; /** * Room 鍏宠仈鐨勪竴浜涢厤缃� @@ -65,7 +65,7 @@ /** @description 褰撳墠鑱婂ぉ瀹� groupType */ export const activeGroupType = computed({ get: () => { - const result = getRoomConfig(activeRoomId.value, 'activeGroupType') ?? '涓氬姟鍦烘櫙'; + const result = getRoomConfig(activeRoomId.value, 'activeGroupType') ?? groupTypeList.value.at(-1); return result; }, set: (value) => { @@ -124,7 +124,7 @@ export const getAllData = async () => { Promise.allSettled([getSectionList(), getSelectSample({}), getUserTemplateList()]) .then((res) => { - let [sectionList, selectSample, userTemplateList] = res; + const [sectionList, selectSample, userTemplateList] = res; sceneGroupList.value = sectionList?.value?.groups ?? []; getSelectListSample(selectSample, userTemplateList); }) @@ -147,13 +147,13 @@ export const newChatRoomClick = async () => { const res = await CreateHistoryGroup({ - group_title: '鏂板缓瀵硅瘽寮�濮�', + group_title: '鏂板缓瀵硅瘽', }); const newRoom = { id: res.history_group_id, isInitial: true, - title: '鏂板缓瀵硅瘽寮�濮�', + title: '鏂板缓瀵硅瘽', }; if (!chatRoomList.value) { chatRoomList.value = [newRoom]; @@ -257,4 +257,32 @@ return timer; }; +/** + * 鑷姩鐧诲綍锛屼粠鏈湴鑾峰彇鐧诲綍淇℃伅 + * @returns + */ +export const autoLogin = async () => { + const account = LocalPlus.get(STORED_ACCOUNT_KEY); + if (!account) return; + const accountInfo = decrypt(account); + if (!accountInfo) return; + const res: any = await PostLogin({ + user: accountInfo.username, + pass: accountInfo.password, + client: LOGIN_CLIENT, + }); + if (!res.json_ok || !res.hswatersession) { + return; + } + handleAfterLogin(res); +}; +export const currentPosition = ref<Position>(null); + +export const getGlobalPosition = () => { + getCurrentPosition(); + + setInterval(() => { + getCurrentPosition(); + }, 1000 * 60 * 60); +}; -- Gitblit v1.9.3