This commit is contained in:
xd
2025-06-05 22:47:41 +08:00
parent ed99c7b1ae
commit 6805b590c7
17 changed files with 144 additions and 56 deletions

View File

@ -1,10 +1,10 @@
import { RoleType, PageUrl } from '@/constants/app';
import { PageUrl, RoleType } from '@/constants/app';
import { CollectEventName } from '@/constants/event';
import { ANCHOR_TAB_LIST, COMPANY_TAB_LIST } from '@/hooks/use-config';
import http from '@/http';
import { API } from '@/http/api';
import store from '@/store';
import { changeRoleType, changeHomePage } from '@/store/actions';
import { changeHomePage, changeRoleType } from '@/store/actions';
import { selectRoleType } from '@/store/selector';
import { sleep } from '@/utils/common';
import { collectEvent } from '@/utils/event';
@ -18,7 +18,9 @@ const postSwitchRoleType = (appMode: RoleType) => {
export const getRoleType = () => selectRoleType(store.getState());
export const isAnchorMode = () => getRoleType() === RoleType.Anchor;
export const getRoleTypeWithDefault = () => getRoleType() || RoleType.Anchor;
export const isAnchorMode = () => getRoleTypeWithDefault() === RoleType.Anchor;
export const isCompanyMode = () => getRoleType() === RoleType.Company;

View File

@ -18,7 +18,7 @@ import {
IChatActionDetail,
ChatWatchRequest,
} from '@/types/message';
import { getRoleType } from '@/utils/app';
import { getRoleTypeWithDefault } from '@/utils/app';
import { logWithPrefix, oncePromise } from '@/utils/common';
import { collectEvent } from '@/utils/event';
import { navigateTo } from '@/utils/route';
@ -60,12 +60,12 @@ export const requestMessageList = oncePromise(async () => {
});
export const requestChatDetail = (chatId: string) => {
const data = { chatId, roleType: getRoleType() };
const data = { chatId, roleType: getRoleTypeWithDefault() };
return http.post<IChatInfo>(API.MESSAGE_CHAT, { data, contentType: 'application/x-www-form-urlencoded' });
};
export const requestNewChatMessages = (params: GetNewChatMessagesRequest) => {
const data = { ...params, roleType: getRoleType() };
const data = { ...params, roleType: getRoleTypeWithDefault() };
return http.post<IChatMessage[]>(API.MESSAGE_CHAT_NEW, { data });
};

View File

@ -77,7 +77,7 @@ export const formatMoney = (cents: number) => {
};
export function formatTimestamp(timestamp: string): string {
// 创建 Date 对象
const date = new Date(timestamp);
const date = new Date(/^\d+$/.test(timestamp) ? Number(timestamp) : timestamp);
// 获取年、月、日、时、分、秒
const YYYY = date.getFullYear();