diff --git a/apps/web-antd/src/api/im/friend/request/index.ts b/apps/web-antd/src/api/im/friend/request/index.ts index e57e4a5f2..726f09e88 100644 --- a/apps/web-antd/src/api/im/friend/request/index.ts +++ b/apps/web-antd/src/api/im/friend/request/index.ts @@ -55,7 +55,7 @@ export function refuseFriendRequest( /** 查询「我相关」的好友申请列表(游标分页:传 maxId 加载更多) */ export function getMyFriendRequestList(limit: number, maxId?: number) { const params: Record = { limit }; - if (maxId != null) { + if (maxId) { params.maxId = maxId; } return requestClient.get( diff --git a/apps/web-antd/src/views/im/home/components/picker/conversation-picker-panel.vue b/apps/web-antd/src/views/im/home/components/picker/conversation-picker-panel.vue index 767128b01..085b0a2e7 100644 --- a/apps/web-antd/src/views/im/home/components/picker/conversation-picker-panel.vue +++ b/apps/web-antd/src/views/im/home/components/picker/conversation-picker-panel.vue @@ -4,6 +4,7 @@ import type { Conversation } from '../../types'; import { computed, ref } from 'vue'; import { IconifyIcon as Icon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { Input, message } from 'ant-design-vue'; @@ -81,7 +82,7 @@ const recentForwardConversations = computed(() => .map((key) => byKey.value.get(key)) .filter( (c): c is Conversation => - c != null && !hideSet.value.has(getConversationKey(c)), + !isUndefined(c) && !hideSet.value.has(getConversationKey(c)), ), ); @@ -96,7 +97,7 @@ const selectedConversations = computed(() => .map((key) => byKey.value.get(key)) .filter( (conversation): conversation is Conversation => - conversation != null && + !isUndefined(conversation) && !hideSet.value.has(getConversationKey(conversation)), ), ); diff --git a/apps/web-antd/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue b/apps/web-antd/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue index 6ceef33e7..cafb6cad4 100644 --- a/apps/web-antd/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue +++ b/apps/web-antd/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue @@ -7,6 +7,7 @@ import { computed, ref, watch } from 'vue'; import { confirm } from '@vben/common-ui'; import { CommonStatusEnum } from '@vben/constants'; import { IconifyIcon as Icon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { Button, @@ -95,13 +96,10 @@ const myId = computed(() => getCurrentUserId()); /** 历史退群群:禁所有群操作入口(邀请 / 移出 / 改资料 / 禁言 / 审批 / 退出等),只保留展示;props.group 是 GroupLite 无 joinStatus,回 store 取全量 */ const isQuitGroup = computed(() => { const id = props.group?.id; - return id != null && isGroupQuit(groupStore.getGroup(id)); + return !isUndefined(id) && isGroupQuit(groupStore.getGroup(id)); }); const isOwner = computed( - () => - !isQuitGroup.value && - props.group != null && - props.group.ownerId === myId.value, + () => !isQuitGroup.value && props.group?.ownerId === myId.value, ); /** 当前用户在群里的角色(来自 props.members 的 me 行);用于判定是否可移出他人 */ const myRole = computed( diff --git a/apps/web-antd/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue b/apps/web-antd/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue index 6c38ee84c..8193fd428 100644 --- a/apps/web-antd/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue +++ b/apps/web-antd/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue @@ -5,6 +5,7 @@ import { computed } from 'vue'; import { confirm } from '@vben/common-ui'; import { IconifyIcon as Icon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { Tag } from 'ant-design-vue'; @@ -86,7 +87,7 @@ const showSendName = computed(() => { return false; } const lastType = props.conversation.lastMessageType; - return lastType != null && isNormalMessage(lastType); + return !isUndefined(lastType) && isNormalMessage(lastType); }); /** 列表展示文案:草稿优先(对齐微信 PC:有草稿时盖掉最后一条预览)→ 撤回实时算 → lastContent 兜底 */ @@ -96,7 +97,7 @@ const lastContentDisplay = computed(() => { } if ( props.conversation.lastMessageType === ImContentType.RECALL && - props.conversation.lastSenderId != null + !isUndefined(props.conversation.lastSenderId) ) { return buildRecallTip( props.conversation.lastSenderId, diff --git a/apps/web-antd/src/views/im/home/pages/conversation/components/message/message-item.vue b/apps/web-antd/src/views/im/home/pages/conversation/components/message/message-item.vue index e58691790..2ab61b5ad 100644 --- a/apps/web-antd/src/views/im/home/pages/conversation/components/message/message-item.vue +++ b/apps/web-antd/src/views/im/home/pages/conversation/components/message/message-item.vue @@ -13,6 +13,7 @@ import { computed, inject } from 'vue'; import { confirm } from '@vben/common-ui'; import { IconifyIcon as Icon } from '@vben/icons'; import { useUserStore } from '@vben/stores'; +import { isUndefined } from '@vben/utils'; import { useClipboard } from '@vueuse/core'; import { message as antdMessage, Tag } from 'ant-design-vue'; @@ -251,7 +252,7 @@ const redialRtcCall = inject(IM_RTC_REDIAL_KEY); /** 私聊 RTC_CALL_END 气泡点击:用同款 mediaType 重拨 */ function handleRtcCallBubbleClick() { const mediaType = rtcCallEndPrivatePayload.value?.mediaType; - if (mediaType == null) { + if (isUndefined(mediaType)) { return; } redialRtcCall?.(mediaType); diff --git a/apps/web-antd/src/views/im/manager/group/components/select.vue b/apps/web-antd/src/views/im/manager/group/components/select.vue index 6903c2bdc..d29643912 100644 --- a/apps/web-antd/src/views/im/manager/group/components/select.vue +++ b/apps/web-antd/src/views/im/manager/group/components/select.vue @@ -4,6 +4,7 @@ import type { ImManagerGroupApi } from '#/api/im/manager/group'; import { computed, ref, useAttrs, watch } from 'vue'; import { IconifyIcon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { Input, Tooltip } from 'ant-design-vue'; @@ -47,13 +48,13 @@ const showClear = computed(() => { props.allowClear && !props.disabled && hovering.value && - props.modelValue != null + props.modelValue !== null ); }); /** 根据编号查询群信息(用于编辑回显) */ async function resolveItemById(id: number | undefined) { - if (id == null) { + if (isUndefined(id)) { selectedItem.value = undefined; return; } @@ -83,7 +84,9 @@ function handleClick(event: MouseEvent) { clearSelected(); return; } - dialogRef.value?.open(props.modelValue == null ? [] : [props.modelValue]); + dialogRef.value?.open( + isUndefined(props.modelValue) ? [] : [props.modelValue], + ); } /** 弹窗选中回调 */ diff --git a/apps/web-antd/src/views/im/utils/pull.ts b/apps/web-antd/src/views/im/utils/pull.ts index 76c9af1ec..6524af26b 100644 --- a/apps/web-antd/src/views/im/utils/pull.ts +++ b/apps/web-antd/src/views/im/utils/pull.ts @@ -1,3 +1,5 @@ +import { isUndefined } from '@vben/utils'; + import { getDb } from './db'; /** @@ -54,16 +56,15 @@ export async function runIncrementalPull( ): Promise { const storedCursor = await getPullCursor(cursorKey); const highWater = { ...storedCursor }; - let cursor = - storedCursor.lastUpdateTime == null - ? {} - : { - lastUpdateTime: Math.max( - 0, - storedCursor.lastUpdateTime - PULL_OVERLAP_MS, - ), - lastId: 0, - }; + let cursor = isUndefined(storedCursor.lastUpdateTime) + ? {} + : { + lastUpdateTime: Math.max( + 0, + storedCursor.lastUpdateTime - PULL_OVERLAP_MS, + ), + lastId: 0, + }; for (let page = 0; page < PULL_MAX_PAGES; page++) { if (isActive && !isActive()) { return; @@ -89,12 +90,12 @@ export async function runIncrementalPull( if (!last) { return; } - if (last.updateTime == null) { + if (isUndefined(last.updateTime)) { return; } cursor = { lastUpdateTime: last.updateTime, lastId: last.id }; if ( - highWater.lastUpdateTime == null || + isUndefined(highWater.lastUpdateTime) || cursor.lastUpdateTime > highWater.lastUpdateTime || (cursor.lastUpdateTime === highWater.lastUpdateTime && cursor.lastId > (highWater.lastId ?? 0)) @@ -154,14 +155,14 @@ export async function runMinIdPull(options: { // 本批最大消息 id 作为下次游标;无有效 id 则本批 apply 后停(无法继续翻页) const validIds = list .map((record) => record.id) - .filter((id): id is number => id != null); + .filter((id): id is number => id !== null); const nextMinId = validIds.length > 0 ? Math.max(...validIds) : undefined; // applyPage 返回 false:本页未落地(如入库失败),不推进游标并终止,避免漏消息 if ((await applyPage(list, nextMinId)) === false) { return; } // 无有效 id,或游标没前进(后端契约是 id > minId,理论不会出现):停,防御死翻 - if (nextMinId == null || nextMinId <= minId) { + if (isUndefined(nextMinId) || nextMinId <= minId) { return; } minId = nextMinId; diff --git a/apps/web-antd/src/views/mall/product/spu/components/spu-showcase.vue b/apps/web-antd/src/views/mall/product/spu/components/spu-showcase.vue index f9a08cef6..d339cb2af 100644 --- a/apps/web-antd/src/views/mall/product/spu/components/spu-showcase.vue +++ b/apps/web-antd/src/views/mall/product/spu/components/spu-showcase.vue @@ -58,7 +58,7 @@ watch( // 只有商品发生变化时才重新查询 if ( productSpus.value.length === 0 || - productSpus.value.some((spu) => spu.id == null || !ids.includes(spu.id)) + productSpus.value.some((spu) => spu.id === null || !ids.includes(spu.id)) ) { productSpus.value = await getSpuDetailList(ids); } diff --git a/apps/web-antd/src/views/mall/promotion/combination/components/showcase.vue b/apps/web-antd/src/views/mall/promotion/combination/components/showcase.vue index 41834033b..e04abe99c 100644 --- a/apps/web-antd/src/views/mall/promotion/combination/components/showcase.vue +++ b/apps/web-antd/src/views/mall/promotion/combination/components/showcase.vue @@ -60,7 +60,7 @@ watch( if ( activityList.value.length === 0 || activityList.value.some( - (activity) => activity.id == null || !ids.includes(activity.id), + (activity) => activity.id === null || !ids.includes(activity.id), ) ) { activityList.value = await getCombinationActivityListByIds(ids); diff --git a/apps/web-antd/src/views/mall/promotion/seckill/components/showcase.vue b/apps/web-antd/src/views/mall/promotion/seckill/components/showcase.vue index c0fcbf126..769feaa44 100644 --- a/apps/web-antd/src/views/mall/promotion/seckill/components/showcase.vue +++ b/apps/web-antd/src/views/mall/promotion/seckill/components/showcase.vue @@ -59,7 +59,7 @@ watch( if ( activityList.value.length === 0 || activityList.value.some( - (activity) => activity.id == null || !ids.includes(activity.id), + (activity) => activity.id === null || !ids.includes(activity.id), ) ) { activityList.value = await getSeckillActivityListByIds(ids as number[]); diff --git a/apps/web-antd/src/views/wms/order/check/index.vue b/apps/web-antd/src/views/wms/order/check/index.vue index c99d6a5bc..40c6c6a89 100644 --- a/apps/web-antd/src/views/wms/order/check/index.vue +++ b/apps/web-antd/src/views/wms/order/check/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/apps/web-antd/src/views/wms/order/movement/index.vue b/apps/web-antd/src/views/wms/order/movement/index.vue index ec05422e2..a178f3f1b 100644 --- a/apps/web-antd/src/views/wms/order/movement/index.vue +++ b/apps/web-antd/src/views/wms/order/movement/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/apps/web-antd/src/views/wms/order/receipt/index.vue b/apps/web-antd/src/views/wms/order/receipt/index.vue index d2eb7f588..7e783aed9 100644 --- a/apps/web-antd/src/views/wms/order/receipt/index.vue +++ b/apps/web-antd/src/views/wms/order/receipt/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/apps/web-antd/src/views/wms/order/shipment/index.vue b/apps/web-antd/src/views/wms/order/shipment/index.vue index b0cd10526..6e3a6bfbb 100644 --- a/apps/web-antd/src/views/wms/order/shipment/index.vue +++ b/apps/web-antd/src/views/wms/order/shipment/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/apps/web-antdv-next/src/api/im/friend/request/index.ts b/apps/web-antdv-next/src/api/im/friend/request/index.ts index e57e4a5f2..7b72fb358 100644 --- a/apps/web-antdv-next/src/api/im/friend/request/index.ts +++ b/apps/web-antdv-next/src/api/im/friend/request/index.ts @@ -1,3 +1,5 @@ +import { isUndefined } from '@vben/utils'; + import { requestClient } from '#/api/request'; export namespace ImFriendRequestApi { @@ -55,7 +57,7 @@ export function refuseFriendRequest( /** 查询「我相关」的好友申请列表(游标分页:传 maxId 加载更多) */ export function getMyFriendRequestList(limit: number, maxId?: number) { const params: Record = { limit }; - if (maxId != null) { + if (!isUndefined(maxId)) { params.maxId = maxId; } return requestClient.get( diff --git a/apps/web-antdv-next/src/views/im/home/components/picker/conversation-picker-panel.vue b/apps/web-antdv-next/src/views/im/home/components/picker/conversation-picker-panel.vue index 24d8b62ac..d6a37ac4b 100644 --- a/apps/web-antdv-next/src/views/im/home/components/picker/conversation-picker-panel.vue +++ b/apps/web-antdv-next/src/views/im/home/components/picker/conversation-picker-panel.vue @@ -4,6 +4,7 @@ import type { Conversation } from '../../types'; import { computed, ref } from 'vue'; import { IconifyIcon as Icon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { Input, message } from 'antdv-next'; @@ -81,7 +82,7 @@ const recentForwardConversations = computed(() => .map((key) => byKey.value.get(key)) .filter( (c): c is Conversation => - c != null && !hideSet.value.has(getConversationKey(c)), + !isUndefined(c) && !hideSet.value.has(getConversationKey(c)), ), ); @@ -96,7 +97,7 @@ const selectedConversations = computed(() => .map((key) => byKey.value.get(key)) .filter( (conversation): conversation is Conversation => - conversation != null && + !isUndefined(conversation) && !hideSet.value.has(getConversationKey(conversation)), ), ); diff --git a/apps/web-antdv-next/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue b/apps/web-antdv-next/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue index b91e92113..2877fc218 100644 --- a/apps/web-antdv-next/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue +++ b/apps/web-antdv-next/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue @@ -7,6 +7,7 @@ import { computed, ref, watch } from 'vue'; import { confirm } from '@vben/common-ui'; import { CommonStatusEnum } from '@vben/constants'; import { IconifyIcon as Icon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { Button, Drawer, Input, message, Popover, Switch } from 'antdv-next'; @@ -88,13 +89,10 @@ const myId = computed(() => getCurrentUserId()); /** 历史退群群:禁所有群操作入口(邀请 / 移出 / 改资料 / 禁言 / 审批 / 退出等),只保留展示;props.group 是 GroupLite 无 joinStatus,回 store 取全量 */ const isQuitGroup = computed(() => { const id = props.group?.id; - return id != null && isGroupQuit(groupStore.getGroup(id)); + return !isUndefined(id) && isGroupQuit(groupStore.getGroup(id)); }); const isOwner = computed( - () => - !isQuitGroup.value && - props.group != null && - props.group.ownerId === myId.value, + () => !isQuitGroup.value && props.group?.ownerId === myId.value, ); /** 当前用户在群里的角色(来自 props.members 的 me 行);用于判定是否可移出他人 */ const myRole = computed( diff --git a/apps/web-antdv-next/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue b/apps/web-antdv-next/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue index 101e0c688..637902207 100644 --- a/apps/web-antdv-next/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue +++ b/apps/web-antdv-next/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue @@ -5,6 +5,7 @@ import { computed } from 'vue'; import { confirm } from '@vben/common-ui'; import { IconifyIcon as Icon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { Tag } from 'antdv-next'; @@ -86,7 +87,7 @@ const showSendName = computed(() => { return false; } const lastType = props.conversation.lastMessageType; - return lastType != null && isNormalMessage(lastType); + return !isUndefined(lastType) && isNormalMessage(lastType); }); /** 列表展示文案:草稿优先(对齐微信 PC:有草稿时盖掉最后一条预览)→ 撤回实时算 → lastContent 兜底 */ @@ -96,7 +97,7 @@ const lastContentDisplay = computed(() => { } if ( props.conversation.lastMessageType === ImContentType.RECALL && - props.conversation.lastSenderId != null + !isUndefined(props.conversation.lastSenderId) ) { return buildRecallTip( props.conversation.lastSenderId, diff --git a/apps/web-antdv-next/src/views/im/home/pages/conversation/components/message/message-item.vue b/apps/web-antdv-next/src/views/im/home/pages/conversation/components/message/message-item.vue index 4e8dae66d..eb2d068b2 100644 --- a/apps/web-antdv-next/src/views/im/home/pages/conversation/components/message/message-item.vue +++ b/apps/web-antdv-next/src/views/im/home/pages/conversation/components/message/message-item.vue @@ -13,6 +13,7 @@ import { computed, inject } from 'vue'; import { confirm } from '@vben/common-ui'; import { IconifyIcon as Icon } from '@vben/icons'; import { useUserStore } from '@vben/stores'; +import { isUndefined } from '@vben/utils'; import { useClipboard } from '@vueuse/core'; import { message as antdMessage, Tag } from 'antdv-next'; @@ -251,7 +252,7 @@ const redialRtcCall = inject(IM_RTC_REDIAL_KEY); /** 私聊 RTC_CALL_END 气泡点击:用同款 mediaType 重拨 */ function handleRtcCallBubbleClick() { const mediaType = rtcCallEndPrivatePayload.value?.mediaType; - if (mediaType == null) { + if (isUndefined(mediaType)) { return; } redialRtcCall?.(mediaType); diff --git a/apps/web-antdv-next/src/views/im/manager/group/components/select.vue b/apps/web-antdv-next/src/views/im/manager/group/components/select.vue index 4fe3bd2ac..1df7ff83b 100644 --- a/apps/web-antdv-next/src/views/im/manager/group/components/select.vue +++ b/apps/web-antdv-next/src/views/im/manager/group/components/select.vue @@ -4,6 +4,7 @@ import type { ImManagerGroupApi } from '#/api/im/manager/group'; import { computed, ref, useAttrs, watch } from 'vue'; import { IconifyIcon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { Input, Tooltip } from 'antdv-next'; @@ -47,13 +48,13 @@ const showClear = computed(() => { props.allowClear && !props.disabled && hovering.value && - props.modelValue != null + props.modelValue !== null ); }); /** 根据编号查询群信息(用于编辑回显) */ async function resolveItemById(id: number | undefined) { - if (id == null) { + if (isUndefined(id)) { selectedItem.value = undefined; return; } @@ -83,7 +84,9 @@ function handleClick(event: MouseEvent) { clearSelected(); return; } - dialogRef.value?.open(props.modelValue == null ? [] : [props.modelValue]); + dialogRef.value?.open( + isUndefined(props.modelValue) ? [] : [props.modelValue], + ); } /** 弹窗选中回调 */ diff --git a/apps/web-antdv-next/src/views/im/utils/pull.ts b/apps/web-antdv-next/src/views/im/utils/pull.ts index 76c9af1ec..6524af26b 100644 --- a/apps/web-antdv-next/src/views/im/utils/pull.ts +++ b/apps/web-antdv-next/src/views/im/utils/pull.ts @@ -1,3 +1,5 @@ +import { isUndefined } from '@vben/utils'; + import { getDb } from './db'; /** @@ -54,16 +56,15 @@ export async function runIncrementalPull( ): Promise { const storedCursor = await getPullCursor(cursorKey); const highWater = { ...storedCursor }; - let cursor = - storedCursor.lastUpdateTime == null - ? {} - : { - lastUpdateTime: Math.max( - 0, - storedCursor.lastUpdateTime - PULL_OVERLAP_MS, - ), - lastId: 0, - }; + let cursor = isUndefined(storedCursor.lastUpdateTime) + ? {} + : { + lastUpdateTime: Math.max( + 0, + storedCursor.lastUpdateTime - PULL_OVERLAP_MS, + ), + lastId: 0, + }; for (let page = 0; page < PULL_MAX_PAGES; page++) { if (isActive && !isActive()) { return; @@ -89,12 +90,12 @@ export async function runIncrementalPull( if (!last) { return; } - if (last.updateTime == null) { + if (isUndefined(last.updateTime)) { return; } cursor = { lastUpdateTime: last.updateTime, lastId: last.id }; if ( - highWater.lastUpdateTime == null || + isUndefined(highWater.lastUpdateTime) || cursor.lastUpdateTime > highWater.lastUpdateTime || (cursor.lastUpdateTime === highWater.lastUpdateTime && cursor.lastId > (highWater.lastId ?? 0)) @@ -154,14 +155,14 @@ export async function runMinIdPull(options: { // 本批最大消息 id 作为下次游标;无有效 id 则本批 apply 后停(无法继续翻页) const validIds = list .map((record) => record.id) - .filter((id): id is number => id != null); + .filter((id): id is number => id !== null); const nextMinId = validIds.length > 0 ? Math.max(...validIds) : undefined; // applyPage 返回 false:本页未落地(如入库失败),不推进游标并终止,避免漏消息 if ((await applyPage(list, nextMinId)) === false) { return; } // 无有效 id,或游标没前进(后端契约是 id > minId,理论不会出现):停,防御死翻 - if (nextMinId == null || nextMinId <= minId) { + if (isUndefined(nextMinId) || nextMinId <= minId) { return; } minId = nextMinId; diff --git a/apps/web-antdv-next/src/views/mall/product/spu/components/spu-showcase.vue b/apps/web-antdv-next/src/views/mall/product/spu/components/spu-showcase.vue index c124c613b..c0a44b5ba 100644 --- a/apps/web-antdv-next/src/views/mall/product/spu/components/spu-showcase.vue +++ b/apps/web-antdv-next/src/views/mall/product/spu/components/spu-showcase.vue @@ -58,7 +58,7 @@ watch( // 只有商品发生变化时才重新查询 if ( productSpus.value.length === 0 || - productSpus.value.some((spu) => spu.id == null || !ids.includes(spu.id)) + productSpus.value.some((spu) => spu.id === null || !ids.includes(spu.id)) ) { productSpus.value = await getSpuDetailList(ids); } diff --git a/apps/web-antdv-next/src/views/mall/promotion/combination/components/showcase.vue b/apps/web-antdv-next/src/views/mall/promotion/combination/components/showcase.vue index 908133c07..bf9d2a705 100644 --- a/apps/web-antdv-next/src/views/mall/promotion/combination/components/showcase.vue +++ b/apps/web-antdv-next/src/views/mall/promotion/combination/components/showcase.vue @@ -60,7 +60,7 @@ watch( if ( activityList.value.length === 0 || activityList.value.some( - (activity) => activity.id == null || !ids.includes(activity.id), + (activity) => activity.id === null || !ids.includes(activity.id), ) ) { activityList.value = await getCombinationActivityListByIds(ids); diff --git a/apps/web-antdv-next/src/views/wms/order/check/index.vue b/apps/web-antdv-next/src/views/wms/order/check/index.vue index c815ea808..4c01d1c62 100644 --- a/apps/web-antdv-next/src/views/wms/order/check/index.vue +++ b/apps/web-antdv-next/src/views/wms/order/check/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { message } from 'antdv-next'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/apps/web-antdv-next/src/views/wms/order/movement/index.vue b/apps/web-antdv-next/src/views/wms/order/movement/index.vue index a7d7d2319..a2a30c49e 100644 --- a/apps/web-antdv-next/src/views/wms/order/movement/index.vue +++ b/apps/web-antdv-next/src/views/wms/order/movement/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { message } from 'antdv-next'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/apps/web-antdv-next/src/views/wms/order/receipt/index.vue b/apps/web-antdv-next/src/views/wms/order/receipt/index.vue index b0c910658..ca402b521 100644 --- a/apps/web-antdv-next/src/views/wms/order/receipt/index.vue +++ b/apps/web-antdv-next/src/views/wms/order/receipt/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { message } from 'antdv-next'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/apps/web-antdv-next/src/views/wms/order/shipment/index.vue b/apps/web-antdv-next/src/views/wms/order/shipment/index.vue index 12e5bc60e..3e94eb983 100644 --- a/apps/web-antdv-next/src/views/wms/order/shipment/index.vue +++ b/apps/web-antdv-next/src/views/wms/order/shipment/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { message } from 'antdv-next'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/apps/web-ele/src/api/im/friend/request/index.ts b/apps/web-ele/src/api/im/friend/request/index.ts index e57e4a5f2..7b72fb358 100644 --- a/apps/web-ele/src/api/im/friend/request/index.ts +++ b/apps/web-ele/src/api/im/friend/request/index.ts @@ -1,3 +1,5 @@ +import { isUndefined } from '@vben/utils'; + import { requestClient } from '#/api/request'; export namespace ImFriendRequestApi { @@ -55,7 +57,7 @@ export function refuseFriendRequest( /** 查询「我相关」的好友申请列表(游标分页:传 maxId 加载更多) */ export function getMyFriendRequestList(limit: number, maxId?: number) { const params: Record = { limit }; - if (maxId != null) { + if (!isUndefined(maxId)) { params.maxId = maxId; } return requestClient.get( diff --git a/apps/web-ele/src/views/im/home/components/picker/conversation-picker-panel.vue b/apps/web-ele/src/views/im/home/components/picker/conversation-picker-panel.vue index 70b33d0a6..cf09b6998 100644 --- a/apps/web-ele/src/views/im/home/components/picker/conversation-picker-panel.vue +++ b/apps/web-ele/src/views/im/home/components/picker/conversation-picker-panel.vue @@ -4,6 +4,7 @@ import type { Conversation } from '../../types'; import { computed, ref } from 'vue'; import { IconifyIcon as Icon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { ElInput, ElMessage } from 'element-plus'; @@ -81,7 +82,7 @@ const recentForwardConversations = computed(() => .map((key) => byKey.value.get(key)) .filter( (c): c is Conversation => - c != null && !hideSet.value.has(getConversationKey(c)), + !isUndefined(c) && !hideSet.value.has(getConversationKey(c)), ), ); @@ -96,7 +97,7 @@ const selectedConversations = computed(() => .map((key) => byKey.value.get(key)) .filter( (conversation): conversation is Conversation => - conversation != null && + !isUndefined(conversation) && !hideSet.value.has(getConversationKey(conversation)), ), ); diff --git a/apps/web-ele/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue b/apps/web-ele/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue index 5277c6356..a634b3e28 100644 --- a/apps/web-ele/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue +++ b/apps/web-ele/src/views/im/home/pages/conversation/components/conversation/conversation-group-side.vue @@ -7,6 +7,7 @@ import { computed, ref, watch } from 'vue'; import { confirm } from '@vben/common-ui'; import { CommonStatusEnum } from '@vben/constants'; import { IconifyIcon as Icon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { ElButton, @@ -95,13 +96,10 @@ const myId = computed(() => getCurrentUserId()); /** 历史退群群:禁所有群操作入口(邀请 / 移出 / 改资料 / 禁言 / 审批 / 退出等),只保留展示;props.group 是 GroupLite 无 joinStatus,回 store 取全量 */ const isQuitGroup = computed(() => { const id = props.group?.id; - return id != null && isGroupQuit(groupStore.getGroup(id)); + return !isUndefined(id) && isGroupQuit(groupStore.getGroup(id)); }); const isOwner = computed( - () => - !isQuitGroup.value && - props.group != null && - props.group.ownerId === myId.value, + () => !isQuitGroup.value && props.group?.ownerId === myId.value, ); /** 当前用户在群里的角色(来自 props.members 的 me 行);用于判定是否可移出他人 */ const myRole = computed( diff --git a/apps/web-ele/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue b/apps/web-ele/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue index a0ddaf790..73be144cd 100644 --- a/apps/web-ele/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue +++ b/apps/web-ele/src/views/im/home/pages/conversation/components/conversation/conversation-item.vue @@ -5,6 +5,7 @@ import { computed } from 'vue'; import { confirm } from '@vben/common-ui'; import { IconifyIcon as Icon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { ElTag } from 'element-plus'; @@ -86,7 +87,7 @@ const showSendName = computed(() => { return false; } const lastType = props.conversation.lastMessageType; - return lastType != null && isNormalMessage(lastType); + return !isUndefined(lastType) && isNormalMessage(lastType); }); /** 列表展示文案:草稿优先(对齐微信 PC:有草稿时盖掉最后一条预览)→ 撤回实时算 → lastContent 兜底 */ @@ -96,7 +97,7 @@ const lastContentDisplay = computed(() => { } if ( props.conversation.lastMessageType === ImContentType.RECALL && - props.conversation.lastSenderId != null + !isUndefined(props.conversation.lastSenderId) ) { return buildRecallTip( props.conversation.lastSenderId, diff --git a/apps/web-ele/src/views/im/home/pages/conversation/components/message/message-item.vue b/apps/web-ele/src/views/im/home/pages/conversation/components/message/message-item.vue index 22d1a7c2b..3dcaec490 100644 --- a/apps/web-ele/src/views/im/home/pages/conversation/components/message/message-item.vue +++ b/apps/web-ele/src/views/im/home/pages/conversation/components/message/message-item.vue @@ -13,6 +13,7 @@ import { computed, inject } from 'vue'; import { confirm } from '@vben/common-ui'; import { IconifyIcon as Icon } from '@vben/icons'; import { useUserStore } from '@vben/stores'; +import { isUndefined } from '@vben/utils'; import { useClipboard } from '@vueuse/core'; import { ElMessage, ElTag } from 'element-plus'; @@ -251,7 +252,7 @@ const redialRtcCall = inject(IM_RTC_REDIAL_KEY); /** 私聊 RTC_CALL_END 气泡点击:用同款 mediaType 重拨 */ function handleRtcCallBubbleClick() { const mediaType = rtcCallEndPrivatePayload.value?.mediaType; - if (mediaType == null) { + if (isUndefined(mediaType)) { return; } redialRtcCall?.(mediaType); diff --git a/apps/web-ele/src/views/im/manager/group/components/select.vue b/apps/web-ele/src/views/im/manager/group/components/select.vue index a43baf2f9..df53910fd 100644 --- a/apps/web-ele/src/views/im/manager/group/components/select.vue +++ b/apps/web-ele/src/views/im/manager/group/components/select.vue @@ -4,6 +4,7 @@ import type { ImManagerGroupApi } from '#/api/im/manager/group'; import { computed, ref, useAttrs, watch } from 'vue'; import { IconifyIcon } from '@vben/icons'; +import { isUndefined } from '@vben/utils'; import { ElInput, ElTooltip } from 'element-plus'; @@ -47,13 +48,13 @@ const showClear = computed(() => { props.clearable && !props.disabled && hovering.value && - props.modelValue != null + props.modelValue !== null ); }); /** 根据编号查询群信息(用于编辑回显) */ async function resolveItemById(id: number | undefined) { - if (id == null) { + if (isUndefined(id)) { selectedItem.value = undefined; return; } @@ -83,7 +84,9 @@ function handleClick(event: MouseEvent) { clearSelected(); return; } - dialogRef.value?.open(props.modelValue == null ? [] : [props.modelValue]); + dialogRef.value?.open( + isUndefined(props.modelValue) ? [] : [props.modelValue], + ); } /** 弹窗选中回调 */ diff --git a/apps/web-ele/src/views/im/utils/pull.ts b/apps/web-ele/src/views/im/utils/pull.ts index 76c9af1ec..6524af26b 100644 --- a/apps/web-ele/src/views/im/utils/pull.ts +++ b/apps/web-ele/src/views/im/utils/pull.ts @@ -1,3 +1,5 @@ +import { isUndefined } from '@vben/utils'; + import { getDb } from './db'; /** @@ -54,16 +56,15 @@ export async function runIncrementalPull( ): Promise { const storedCursor = await getPullCursor(cursorKey); const highWater = { ...storedCursor }; - let cursor = - storedCursor.lastUpdateTime == null - ? {} - : { - lastUpdateTime: Math.max( - 0, - storedCursor.lastUpdateTime - PULL_OVERLAP_MS, - ), - lastId: 0, - }; + let cursor = isUndefined(storedCursor.lastUpdateTime) + ? {} + : { + lastUpdateTime: Math.max( + 0, + storedCursor.lastUpdateTime - PULL_OVERLAP_MS, + ), + lastId: 0, + }; for (let page = 0; page < PULL_MAX_PAGES; page++) { if (isActive && !isActive()) { return; @@ -89,12 +90,12 @@ export async function runIncrementalPull( if (!last) { return; } - if (last.updateTime == null) { + if (isUndefined(last.updateTime)) { return; } cursor = { lastUpdateTime: last.updateTime, lastId: last.id }; if ( - highWater.lastUpdateTime == null || + isUndefined(highWater.lastUpdateTime) || cursor.lastUpdateTime > highWater.lastUpdateTime || (cursor.lastUpdateTime === highWater.lastUpdateTime && cursor.lastId > (highWater.lastId ?? 0)) @@ -154,14 +155,14 @@ export async function runMinIdPull(options: { // 本批最大消息 id 作为下次游标;无有效 id 则本批 apply 后停(无法继续翻页) const validIds = list .map((record) => record.id) - .filter((id): id is number => id != null); + .filter((id): id is number => id !== null); const nextMinId = validIds.length > 0 ? Math.max(...validIds) : undefined; // applyPage 返回 false:本页未落地(如入库失败),不推进游标并终止,避免漏消息 if ((await applyPage(list, nextMinId)) === false) { return; } // 无有效 id,或游标没前进(后端契约是 id > minId,理论不会出现):停,防御死翻 - if (nextMinId == null || nextMinId <= minId) { + if (isUndefined(nextMinId) || nextMinId <= minId) { return; } minId = nextMinId; diff --git a/apps/web-ele/src/views/wms/order/check/index.vue b/apps/web-ele/src/views/wms/order/check/index.vue index cfe454e6a..efa2f3f8d 100644 --- a/apps/web-ele/src/views/wms/order/check/index.vue +++ b/apps/web-ele/src/views/wms/order/check/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { ElLoading, ElMessage } from 'element-plus'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/apps/web-ele/src/views/wms/order/movement/index.vue b/apps/web-ele/src/views/wms/order/movement/index.vue index 1684d5af4..ca8170718 100644 --- a/apps/web-ele/src/views/wms/order/movement/index.vue +++ b/apps/web-ele/src/views/wms/order/movement/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { ElLoading, ElMessage } from 'element-plus'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/apps/web-ele/src/views/wms/order/receipt/index.vue b/apps/web-ele/src/views/wms/order/receipt/index.vue index 22f706ec9..ed49bb015 100644 --- a/apps/web-ele/src/views/wms/order/receipt/index.vue +++ b/apps/web-ele/src/views/wms/order/receipt/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { ElLoading, ElMessage } from 'element-plus'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/apps/web-ele/src/views/wms/order/shipment/index.vue b/apps/web-ele/src/views/wms/order/shipment/index.vue index 4cebe1eed..12418cf4b 100644 --- a/apps/web-ele/src/views/wms/order/shipment/index.vue +++ b/apps/web-ele/src/views/wms/order/shipment/index.vue @@ -11,7 +11,11 @@ import { OrderStatusEnum, OrderUpdateStatusList, } from '@vben/constants'; -import { downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; +import { + downloadFileFromBlobPart, + formatDateTime, + isUndefined, +} from '@vben/utils'; import { ElLoading, ElMessage } from 'element-plus'; @@ -107,7 +111,7 @@ async function handleExpandChange( return; } const key = row.id; - if (key == null) { + if (isUndefined(key)) { return; } Reflect.deleteProperty(detailMap, key); diff --git a/packages/@core/ui-kit/form-ui/src/components/form-actions.vue b/packages/@core/ui-kit/form-ui/src/components/form-actions.vue index d09e1a606..95057672b 100644 --- a/packages/@core/ui-kit/form-ui/src/components/form-actions.vue +++ b/packages/@core/ui-kit/form-ui/src/components/form-actions.vue @@ -12,7 +12,7 @@ const { $t } = useSimpleLocale(); const [rootProps, form] = injectFormProps(); -const collapsed = defineModel({ default: false }); +const collapsed = defineModel({ default: false }); const resetButtonOptions = computed(() => { return { diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/collapsible/collapsible-params.vue b/packages/@core/ui-kit/shadcn-ui/src/components/collapsible/collapsible-params.vue index dd1cce797..a9341c1dd 100644 --- a/packages/@core/ui-kit/shadcn-ui/src/components/collapsible/collapsible-params.vue +++ b/packages/@core/ui-kit/shadcn-ui/src/components/collapsible/collapsible-params.vue @@ -31,8 +31,10 @@ const props = withDefaults(defineProps(), { const emits = defineEmits<{ 'update:value': [any, string] }>(); -const modelValue = defineModel('value', { - default: {} as Recordable, +const modelValue = defineModel< + Recordable +>('value', { + default: () => ({}), }); const visibleRefs = useTemplateRef('visibleRefs'); diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/collapsible/collapsible.vue b/packages/@core/ui-kit/shadcn-ui/src/components/collapsible/collapsible.vue index d6e4e2ccc..d17d6ba7d 100755 --- a/packages/@core/ui-kit/shadcn-ui/src/components/collapsible/collapsible.vue +++ b/packages/@core/ui-kit/shadcn-ui/src/components/collapsible/collapsible.vue @@ -30,7 +30,7 @@ const delegatedProps = computed(() => { const forwarded = useForwardPropsEmits(delegatedProps, emits); -const open = defineModel('open', { default: true }); +const open = defineModel('open', { default: true }); function toggle() { open.value = !open.value; diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/expandable-arrow/expandable-arrow.vue b/packages/@core/ui-kit/shadcn-ui/src/components/expandable-arrow/expandable-arrow.vue index 5cdf619a1..cabfa4af3 100644 --- a/packages/@core/ui-kit/shadcn-ui/src/components/expandable-arrow/expandable-arrow.vue +++ b/packages/@core/ui-kit/shadcn-ui/src/components/expandable-arrow/expandable-arrow.vue @@ -7,7 +7,7 @@ const props = defineProps<{ }>(); // 控制箭头展开/收起状态 -const collapsed = defineModel({ default: false }); +const collapsed = defineModel({ default: false });