feat: update

This commit is contained in:
chashaobao
2025-06-27 22:46:24 +08:00
parent 0020eb8dbe
commit de2f380cd9
22 changed files with 183 additions and 59 deletions

View File

@ -37,12 +37,19 @@ export const switchDefaultTab = async () => {
};
export const switchRoleType = async (appMode?: RoleType) => {
const curMode = getRoleType();
if (curMode && appMode === curMode) {
console.log('[utils:app] skip switch role because of role type is equal to that of local');
return;
}
if (!appMode) {
const curMode = getRoleType();
console.log('[utils:app] no app mode from arguments');
appMode = curMode === RoleType.Anchor ? RoleType.Company : RoleType.Anchor;
}
console.log('switchRoleType', appMode);
console.log('[utils:app] switchRoleType', appMode);
try {
await postSwitchRoleType(appMode);
store.dispatch(changeRoleType(appMode));

View File

@ -4,12 +4,12 @@ export const isDev = () => process.env.NODE_ENV === 'development';
// export const isDev = () => true;
export const isIPhone = (() => {
const info = Taro.getSystemInfoSync();
const info = Taro.getDeviceInfo();
return info.platform === 'ios';
})();
export const isDesktop = (() => {
const info = Taro.getSystemInfoSync();
const info = Taro.getDeviceInfo();
return info.platform === 'windows' || info.platform === 'mac';
})();

View File

@ -101,6 +101,7 @@ export const postAddMessageTimes = async (source: string) => {
await postSubscribe(MessageSubscribeIds, successIds);
};
export const postCreateChat = (toUserId: string) => {
return http.post<IChatInfo>(API.MESSAGE_CREATE_CHAT, { data: { toUserId } });
};

View File

@ -7,24 +7,35 @@ import { logWithPrefix } from '@/utils/common';
const log = logWithPrefix('subscribe-utils');
export const isSubscribeRefused = async (tempId: SubscribeTempId | SubscribeTempId[]) => {
export const isSubscribeRefused = async (
tempId: SubscribeTempId | SubscribeTempId[]
): Promise<[boolean, SubscribeTempId[]]> => {
tempId = Array.isArray(tempId) ? tempId : [tempId];
const { subscriptionsSetting } = await Taro.getSetting({ withSubscriptions: true });
log('isSubscribeRefuse subscriptionsSetting:', subscriptionsSetting);
if (!subscriptionsSetting) {
return false;
return [false, []];
}
const { mainSwitch, itemSettings = {} } = subscriptionsSetting;
if (!mainSwitch) {
return true;
return [true, []];
}
return tempId.some(id => {
const acceptedIds: SubscribeTempId[] = [];
let refused = false;
tempId.some(id => {
const item = itemSettings[id];
if (!item) {
return false;
if (item === 'accept') {
acceptedIds.push(id);
}
return item === 'reject';
if (refused) {
return;
}
refused = item === 'reject';
});
return [refused || false, acceptedIds];
};
export const subscribeMessage = async (tempIds: SubscribeTempId[]) => {