fix: lints

This commit is contained in:
xingyu4j
2025-11-02 12:32:36 +08:00
parent 2d51c652b2
commit c1777ffda0
9 changed files with 102 additions and 89 deletions

View File

@@ -1,4 +1,6 @@
<script lang="ts" setup>
defineOptions({ name: 'CardTitle' });
// TODO @jawe from xingyuhttps://gitee.com/yudaocode/yudao-ui-admin-vben/pulls/243/files#diff_note_47350213这个组件没有必要直接用antdv card 的slot去做就行了只有这一个地方用没有必要单独写一个组件
defineProps({
title: {
@@ -6,10 +8,6 @@ defineProps({
required: true,
},
});
defineComponent({
name: 'CardTitle',
});
</script>
<template>

View File

@@ -3,12 +3,16 @@ import type { MallKefuConversationApi } from '#/api/mall/promotion/kefu/conversa
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { confirm } from '@vben/common-ui';
import { IconifyIcon } from '@vben/icons';
import { formatPast, jsonParse } from '@vben/utils';
import { Avatar, Badge, message } from 'ant-design-vue';
import { Avatar, Badge, Layout, message } from 'ant-design-vue';
import * as KeFuConversationApi from '#/api/mall/promotion/kefu/conversation';
import {
deleteConversation,
updateConversationPinned,
} from '#/api/mall/promotion/kefu/conversation';
import { useMallKefuStore } from '#/store/mall/kefu';
import { KeFuMessageContentTypeEnum } from './tools/constants';
@@ -108,27 +112,29 @@ function closeRightMenu() {
}
/** 置顶会话 */
async function updateConversationPinned(adminPinned: boolean) {
async function updateConversationPinnedFn(pinned: boolean) {
// 1. 会话置顶/取消置顶
await KeFuConversationApi.updateConversationPinned({
await updateConversationPinned({
id: rightClickConversation.value.id,
adminPinned,
pinned,
});
message.success(adminPinned ? '置顶成功' : '取消置顶成功');
message.success(pinned ? '置顶成功' : '取消置顶成功');
// 2. 关闭右键菜单,更新会话列表
closeRightMenu();
await kefuStore.updateConversation(rightClickConversation.value.id);
}
/** 删除会话 */
async function deleteConversation() {
async function deleteConversationFn() {
// 1. 删除会话
// TODO @jave使用全局的 confirm这样 ele 和 antd 可以相对复用;
await message.confirm('您确定要删除该会话吗?');
await KeFuConversationApi.deleteConversation(rightClickConversation.value.id);
// 2. 关闭右键菜单,更新会话列表
closeRightMenu();
kefuStore.deleteConversation(rightClickConversation.value.id);
confirm({
content: '您确定要删除该会话吗?',
}).then(async () => {
await deleteConversation(rightClickConversation.value.id);
// 2. 关闭右键菜单,更新会话列表
closeRightMenu();
kefuStore.deleteConversation(rightClickConversation.value.id);
});
}
/** 监听右键菜单的显示状态,添加点击事件监听器 */
@@ -154,7 +160,7 @@ onBeforeUnmount(() => {
</script>
<template>
<a-layout-sider class="kefu h-full pt-[5px]" width="260px">
<Layout.Sider class="kefu h-full pt-[5px]" width="260px">
<div class="color-[#999] my-[10px] font-bold">
会话记录({{ kefuStore.getConversationList.length }})
</div>
@@ -206,7 +212,7 @@ onBeforeUnmount(() => {
<li
v-show="!rightClickConversation.adminPinned"
class="flex items-center"
@click.stop="updateConversationPinned(true)"
@click.stop="updateConversationPinnedFn(true)"
>
<IconifyIcon class="mr-[5px]" icon="ep:top" />
置顶会话
@@ -214,12 +220,12 @@ onBeforeUnmount(() => {
<li
v-show="rightClickConversation.adminPinned"
class="flex items-center"
@click.stop="updateConversationPinned(false)"
@click.stop="updateConversationPinnedFn(false)"
>
<IconifyIcon class="mr-[5px]" icon="ep:bottom" />
取消置顶
</li>
<li class="flex items-center" @click.stop="deleteConversation">
<li class="flex items-center" @click.stop="deleteConversationFn">
<IconifyIcon class="mr-[5px]" color="red" icon="ep:delete" />
删除会话
</li>
@@ -228,7 +234,7 @@ onBeforeUnmount(() => {
取消
</li>
</ul>
</a-layout-sider>
</Layout.Sider>
</template>
<style lang="scss" scoped>

View File

@@ -14,11 +14,22 @@ import { formatDate, isEmpty, jsonParse } from '@vben/utils';
import { vScroll } from '@vueuse/components';
import { useDebounceFn, useScroll } from '@vueuse/core';
import { Avatar, Empty, Image, notification } from 'ant-design-vue'; // 添加 Empty 组件导入
import {
Avatar,
Empty,
Image,
Layout,
notification,
Textarea,
} from 'ant-design-vue';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import * as KeFuMessageApi from '#/api/mall/promotion/kefu/message';
import {
getKeFuMessageList,
sendKeFuMessage,
updateKeFuMessageReadStatus,
} from '#/api/mall/promotion/kefu/message';
import { useMallKefuStore } from '#/store/mall/kefu';
import MessageItem from './message/MessageItem.vue';
@@ -56,18 +67,18 @@ const getMessageContent = computed(
/** 获得消息列表 */
// TODO @javeidea 的 linter 报错,处理下;
async function getMessageList() {
const res = await KeFuMessageApi.getKeFuMessageList(queryParams);
const res: any = await getKeFuMessageList(queryParams as any);
if (isEmpty(res)) {
// 当返回的是空列表说明没有消息或者已经查询完了历史消息
skipGetMessageList.value = true;
return;
}
queryParams.createTime = formatDate(res.at(-1).createTime) as any;
queryParams.createTime = formatDate((res as any).at(-1).createTime) as any;
// 情况一:加载最新消息
if (queryParams.createTime) {
// 情况二:加载历史消息
for (const item of res) {
for (const item of res as any) {
pushMessage(item);
}
} else {
@@ -184,7 +195,7 @@ async function handleSendMessage(event: any) {
/** 真正发送消息 【共用】*/
async function sendMessage(msg: MallKefuMessageApi.MessageSend) {
// 发送消息
await KeFuMessageApi.sendKeFuMessage(msg);
await sendKeFuMessage(msg);
message.value = '';
// 加载消息列表
await refreshMessageList();
@@ -211,7 +222,7 @@ async function scrollToBottom() {
// scrollbarRef.value!.setScrollTop(innerRef.value!.clientHeight)
showNewMessageTip.value = false;
// 2.2 消息已读
await KeFuMessageApi.updateKeFuMessageReadStatus(conversation.value.id);
await updateKeFuMessageReadStatus(conversation.value.id);
}
/** 查看新消息 */
@@ -268,11 +279,11 @@ function showTime(item: MallKefuMessageApi.Message, index: number) {
</script>
<template>
<a-layout v-if="showKeFuMessageList" class="kefu">
<a-layout-header class="kefu-header">
<Layout v-if="showKeFuMessageList()" class="kefu">
<Layout.Header class="kefu-header">
<div class="kefu-title">{{ conversation.userNickname }}</div>
</a-layout-header>
<a-layout-content class="kefu-content">
</Layout.Header>
<Layout.Content class="kefu-content">
<div
ref="scrollbarRef"
class="flex h-full overflow-y-auto"
@@ -396,8 +407,8 @@ function showTime(item: MallKefuMessageApi.Message, index: number) {
<span>有新消息</span>
<IconifyIcon class="ml-5px" icon="ep:bottom" />
</div>
</a-layout-content>
<a-layout-footer class="kefu-footer">
</Layout.Content>
<Layout.Footer class="kefu-footer">
<div class="chat-tools flex items-center">
<EmojiSelectPopover @select-emoji="handleEmojiSelect" />
<PictureSelectUpload
@@ -405,20 +416,20 @@ function showTime(item: MallKefuMessageApi.Message, index: number) {
@send-picture="handleSendPicture"
/>
</div>
<a-textarea
<Textarea
v-model:value="message"
:rows="6"
placeholder="输入消息Enter发送Shift+Enter换行"
style="border-style: none"
@keyup.enter.prevent="handleSendMessage"
/>
</a-layout-footer>
</a-layout>
<a-layout v-else class="kefu">
<a-layout-content>
</Layout.Footer>
</Layout>
<Layout v-else class="kefu">
<Layout.Content>
<Empty description="请选择左侧的一个会话后开始" class="mt-[50px]" />
</a-layout-content>
</a-layout>
</Layout.Content>
</Layout>
</template>
<style lang="scss" scoped>

View File

@@ -1,6 +1,8 @@
<!-- 右侧信息会员信息 + 最近浏览 + 交易订单 -->
<script lang="ts" setup>
import type { MallKefuConversationApi } from '#/api/mall/promotion/kefu/conversation';
import type { MemberUserApi } from '#/api/member/user';
import type { PayWalletApi } from '#/api/pay/wallet/balance';
import { computed, nextTick, ref } from 'vue';
@@ -9,11 +11,10 @@ import { isEmpty } from '@vben/utils';
// TODO @jawedebounce 是不是还是需要的哈;应该有 2 处需要;可以微信沟通哈;
// import { debounce } from 'lodash-es'
import { useDebounceFn } from '@vueuse/core';
import { Card, Empty, message } from 'ant-design-vue';
import { Card, Empty, Layout, message } from 'ant-design-vue';
import * as UserApi from '#/api/member/user';
import * as WalletApi from '#/api/pay/wallet/balance';
import { CardTitle } from '#/components/card-title';
import { getUser } from '#/api/member/user';
import { getWallet } from '#/api/pay/wallet/balance';
import AccountInfo from '#/views/member/user/detail/modules/account-info.vue';
import BasicInfo from '#/views/member/user/detail/modules/basic-info.vue';
@@ -91,12 +92,12 @@ async function initHistory(val: MallKefuConversationApi.Conversation) {
defineExpose({ initHistory });
/** 处理消息列表滚动事件(debounce 限流) */
const scrollbarRef = ref<InstanceType>();
const handleScroll = useDebounceFn(() => {
const scrollbarRef = ref<InstanceType<any>>();
const handleScroll = useDebounceFn(async () => {
const wrap = scrollbarRef.value?.wrapRef;
// 触底重置
if (Math.abs(wrap!.scrollHeight - wrap!.clientHeight - wrap!.scrollTop) < 1) {
loadMore();
await loadMore();
}
}, 200);
@@ -106,8 +107,8 @@ const WALLET_INIT_DATA = {
balance: 0,
totalExpense: 0,
totalRecharge: 0,
} as WalletApi.WalletVO; // 钱包初始化数据
const wallet = ref<WalletApi.WalletVO>(WALLET_INIT_DATA); // 钱包信息
} as PayWalletApi.Wallet; // 钱包初始化数据
const wallet = ref<PayWalletApi.Wallet>(WALLET_INIT_DATA); // 钱包信息
async function getUserWallet() {
if (!conversation.value.userId) {
@@ -115,21 +116,21 @@ async function getUserWallet() {
return;
}
wallet.value =
(await WalletApi.getWallet({ userId: conversation.value.userId })) ||
(await getWallet({ userId: conversation.value.userId })) ||
WALLET_INIT_DATA;
}
/** 获得用户 */
const loading = ref(true); // 加载中
const user = ref<UserApi.UserVO>({} as UserApi.UserVO);
const user = ref<MemberUserApi.User>({} as MemberUserApi.User);
async function getUserData() {
loading.value = true;
try {
const res = await UserApi.getUser(conversation.value.userId);
const res = await getUser(conversation.value.userId);
if (res) {
user.value = res;
} else {
user.value = {} as UserApi.UserVO;
user.value = {} as MemberUserApi.User;
message.error('会员不存在!');
}
} finally {
@@ -140,8 +141,8 @@ async function getUserData() {
<template>
<!-- TODO @javefrom xingyua- 换成大写的方式另外组件没有进行导入其他页面也有这个问题 -->
<a-layout class="kefu">
<a-layout-header class="kefu-header">
<Layout class="kefu">
<Layout.Header class="kefu-header">
<div
:class="{ 'kefu-header-item-activation': tabActivation('会员信息') }"
class="kefu-header-item flex cursor-pointer items-center justify-center"
@@ -163,13 +164,13 @@ async function getUserData() {
>
交易订单
</div>
</a-layout-header>
<a-layout-content class="kefu-content p-10px!">
</Layout.Header>
<Layout.Content class="kefu-content p-10px!">
<div v-if="!isEmpty(conversation)" v-loading="loading">
<!-- 基本信息 -->
<BasicInfo v-if="activeTab === '会员信息'" :user="user" mode="kefu">
<template #header>
<CardTitle title="基本信息" />
<template #title>
<span class="text-sm font-bold">基本信息</span>
</template>
</BasicInfo>
<!-- 账户信息 -->
@@ -178,8 +179,8 @@ async function getUserData() {
class="mt-10px h-full"
shadow="never"
>
<template #header>
<CardTitle title="账户信息" />
<template #title>
<span class="text-sm font-bold">账户信息</span>
</template>
<AccountInfo :column="1" :user="user" :wallet="wallet" />
</Card>
@@ -203,8 +204,8 @@ async function getUserData() {
description="请选择左侧的一个会话后开始"
class="mt-[50px]"
/>
</a-layout-content>
</a-layout>
</Layout.Content>
</Layout>
</template>
<style lang="scss" scoped>

View File

@@ -43,13 +43,9 @@ function openDetail(spuId: number) {
</script>
<template>
<div
class="product-warp"
style="cursor: pointer"
@click.stop="openDetail(spuId)"
>
<div class="product-warp cursor-pointer" @click.stop="openDetail(spuId)">
<!-- 左侧商品图片-->
<div class="product-warp-left mr-[24px]">
<div class="product-warp-left mr-6">
<Image
:initial-index="0"
:preview-src-list="[picUrl]"
@@ -63,8 +59,8 @@ function openDetail(spuId: number) {
<!-- 右侧商品信息 -->
<div class="product-warp-right">
<div class="description">{{ title }}</div>
<div class="my-[5px]">
<span class="mr-[20px]">库存: {{ stock || 0 }}</span>
<div class="my-1">
<span class="mr-5">库存: {{ stock || 0 }}</span>
<span>销量: {{ salesCount || 0 }}</span>
</div>
<div class="flex items-center justify-between">

View File

@@ -6,16 +6,15 @@ import { computed } from 'vue';
import { IconifyIcon } from '@vben/icons';
import { List } from 'ant-design-vue';
import { List, Popover } from 'ant-design-vue';
import { useEmoji } from './emoji';
defineOptions({ name: 'EmojiSelectPopover' });
/** 选择 emoji 表情 */
// TODO @jawe这里有 linter 告警,看看要不要处理下;
const emits = defineEmits<{
(e: 'selectEmoji', v: Emoji);
(e: 'selectEmoji', v: Emoji): void;
}>();
const { getEmojiList } = useEmoji();
const emojiList = computed(() => getEmojiList());
@@ -27,7 +26,7 @@ function handleSelect(item: Emoji) {
</script>
<template>
<a-popover :width="500" placement="top" trigger="click">
<Popover :width="500" placement="top" trigger="click">
<template #content>
<List height="300px">
<ul class="ml-2 flex flex-wrap px-2">
@@ -42,15 +41,15 @@ function handleSelect(item: Emoji) {
class="icon-item w-1/10 mr-2 mt-1 flex cursor-pointer items-center justify-center border border-solid p-2"
@click="handleSelect(item)"
>
<img :src="item.url" class="h-[24px] w-[24px]" />
<img :src="item.url" class="h-6 w-6" />
</li>
</ul>
</List>
</template>
<IconifyIcon
:size="30"
class="ml-[10px] cursor-pointer"
class="ml-2.5 cursor-pointer"
icon="twemoji:grinning-face"
/>
</a-popover>
</Popover>
</template>

View File

@@ -2,7 +2,7 @@
<script lang="ts" setup>
import { message } from 'ant-design-vue';
import * as FileApi from '#/api/infra/file';
import { uploadFile } from '#/api/infra/file';
import Picture from '#/views/mall/promotion/kefu/asserts/picture.svg';
defineOptions({ name: 'PictureSelectUpload' });
@@ -17,7 +17,7 @@ async function selectAndUpload() {
message.success('图片发送中请稍等。。。');
// TODO @jawe直接使用 updateFile不通过 FileApi。vben 这里的规范;
// TODO @jawe这里的上传看看能不能替换成 export function useUpload(directory?: string) {;它支持前端直传,更统一;
const res = await FileApi.updateFile({ file: files[0].file });
const res = await uploadFile({ file: files[0].file });
emits('sendPicture', res.data);
}

View File

@@ -65,7 +65,7 @@ export const useEmoji = () => {
const initStaticEmoji = async () => {
const pathList = import.meta.glob('../../asserts/*.{png,jpg,jpeg,svg}');
for (const path in pathList) {
const imageModule: any = await pathList[path]();
const imageModule: any = await pathList[path]?.();
emojiPathList.value.push({ path, src: imageModule.default });
}
};

View File

@@ -1,11 +1,13 @@
<script lang="ts" setup>
import type { MallKefuConversationApi } from '#/api/mall/promotion/kefu/conversation';
import { defineOptions, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { Page } from '@vben/common-ui';
import { useAccessStore } from '@vben/stores';
import { useWebSocket } from '@vueuse/core';
import { message } from 'ant-design-vue';
import { Layout, message } from 'ant-design-vue';
import { useMallKefuStore } from '#/store/mall/kefu';
@@ -81,10 +83,10 @@ watch(
const keFuChatBoxRef = ref<InstanceType<typeof KeFuMessageList>>();
const memberInfoRef = ref<InstanceType<typeof MemberInfo>>();
// TODO @jawe这里没导入
const handleChange = (conversation: KeFuConversationRespVO) => {
keFuChatBoxRef.value?.getNewMessageList(conversation);
function handleChange(conversation: MallKefuConversationApi.Conversation) {
keFuChatBoxRef.value?.getNewMessageList(conversation as any);
memberInfoRef.value?.initHistory(conversation);
};
}
const keFuConversationRef = ref<InstanceType<typeof KeFuConversationList>>();
/** 初始化 */
@@ -107,14 +109,14 @@ onBeforeUnmount(() => {
<template>
<Page>
<!-- TODO @jawestyle 使用 tailwindcssAI 友好 -->
<a-layout-content class="kefu-layout hrow">
<Layout.Content class="kefu-layout hrow">
<!-- 会话列表 -->
<KeFuConversationList ref="keFuConversationRef" @change="handleChange" />
<!-- 会话详情选中会话的消息列表 -->
<KeFuMessageList ref="keFuChatBoxRef" />
<!-- 会员信息选中会话的会员信息 -->
<MemberInfo ref="memberInfoRef" />
</a-layout-content>
</Layout.Content>
</Page>
</template>