wip
This commit is contained in:
@ -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;
|
||||
|
||||
|
||||
@ -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 });
|
||||
};
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
Reference in New Issue
Block a user