fix: 隐藏文件上传按钮,去除不必要的log打印
This commit is contained in:
@@ -3,7 +3,6 @@ import { get, post } from '@/utils/request';
|
|||||||
|
|
||||||
// 发送消息
|
// 发送消息
|
||||||
export const send = (data: SendDTO) => post<null>('/ai-chat/send', data);
|
export const send = (data: SendDTO) => post<null>('/ai-chat/send', data);
|
||||||
// export const send = (data: SendDTO) => post<null>('/chat/send', data);
|
|
||||||
|
|
||||||
// 新增对应会话聊天记录
|
// 新增对应会话聊天记录
|
||||||
export function addChat(data: ChatMessageVo) {
|
export function addChat(data: ChatMessageVo) {
|
||||||
|
|||||||
BIN
Yi.Ai.Vue3/src/assets/images/user.png
Normal file
BIN
Yi.Ai.Vue3/src/assets/images/user.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 100 KiB |
@@ -35,7 +35,6 @@ const { reset, open, onChange } = useFileDialog({
|
|||||||
onChange((files) => {
|
onChange((files) => {
|
||||||
if (!files)
|
if (!files)
|
||||||
return;
|
return;
|
||||||
console.log('files', files);
|
|
||||||
const arr = [] as FilesList[];
|
const arr = [] as FilesList[];
|
||||||
for (let i = 0; i < files!.length; i++) {
|
for (let i = 0; i < files!.length; i++) {
|
||||||
const file = files![i];
|
const file = files![i];
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ const { copy } = useClipboard();
|
|||||||
|
|
||||||
const name = ref('');
|
const name = ref('');
|
||||||
const iconList = ref(icons);
|
const iconList = ref(icons);
|
||||||
console.log(icons);
|
|
||||||
|
|
||||||
function filterIcons() {
|
function filterIcons() {
|
||||||
iconList.value = JSON.parse(JSON.stringify(icons));
|
iconList.value = JSON.parse(JSON.stringify(icons));
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ async function handleSubmit() {
|
|||||||
try {
|
try {
|
||||||
await formRef.value?.validate();
|
await formRef.value?.validate();
|
||||||
const res = await login(formModel);
|
const res = await login(formModel);
|
||||||
console.log(res, 'res');
|
|
||||||
res.data.token && userStore.setToken(res.data.token);
|
res.data.token && userStore.setToken(res.data.token);
|
||||||
res.data.userInfo && userStore.setUserInfo(res.data.userInfo);
|
res.data.userInfo && userStore.setUserInfo(res.data.userInfo);
|
||||||
ElMessage.success('登录成功');
|
ElMessage.success('登录成功');
|
||||||
|
|||||||
@@ -57,9 +57,7 @@ async function checkConfirmStatus() {
|
|||||||
// 模拟登录逻辑 如果在客户端已确认,则会调用这个方法进行登录
|
// 模拟登录逻辑 如果在客户端已确认,则会调用这个方法进行登录
|
||||||
async function mockLogin() {
|
async function mockLogin() {
|
||||||
// 模拟登录成功逻辑
|
// 模拟登录成功逻辑
|
||||||
console.log('模拟调用登录接口...');
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 500));
|
await new Promise(resolve => setTimeout(resolve, 500));
|
||||||
console.log('模拟调用登录成功...');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 停止所有轮询 */
|
/** 停止所有轮询 */
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ function onAfterLeave() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleThirdPartyLogin() {
|
function handleThirdPartyLogin() {
|
||||||
console.log('SSO_SEVER_URL', SSO_SEVER_URL);
|
|
||||||
console.log('import.meta.env', import.meta.env);
|
|
||||||
const redirectUri = encodeURIComponent(`${window.location.origin}/chat`);
|
const redirectUri = encodeURIComponent(`${window.location.origin}/chat`);
|
||||||
const popup = window.open(
|
const popup = window.open(
|
||||||
`${SSO_SEVER_URL}/login?client_id=${SSO_CLIENT_ID}&redirect_uri=${redirectUri}`,
|
`${SSO_SEVER_URL}/login?client_id=${SSO_CLIENT_ID}&redirect_uri=${redirectUri}`,
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ function handleModelClick(item: GetSessionListVO) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('handleClick--', item);
|
|
||||||
modelStore.setCurrentModelInfo(item);
|
modelStore.setCurrentModelInfo(item);
|
||||||
popoverRef.value?.hide?.();
|
popoverRef.value?.hide?.();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,11 +34,9 @@ export function useWindowWidthObserver(
|
|||||||
designStore.setCollapse(false);
|
designStore.setCollapse(false);
|
||||||
if (isAbove) {
|
if (isAbove) {
|
||||||
// 大于的时候执行关闭动画 (豆包是有的,第一版本暂未添加)
|
// 大于的时候执行关闭动画 (豆包是有的,第一版本暂未添加)
|
||||||
console.log('执行关闭动画');
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 小于的时候执行打开动画 (豆包是有的,第一版本暂未添加)
|
// 小于的时候执行打开动画 (豆包是有的,第一版本暂未添加)
|
||||||
console.log('小于的时候执行打开动画');
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'narrowExpandWideCollapse':
|
case 'narrowExpandWideCollapse':
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import Popover from '@/components/Popover/index.vue';
|
|||||||
import SvgIcon from '@/components/SvgIcon/index.vue';
|
import SvgIcon from '@/components/SvgIcon/index.vue';
|
||||||
import { useUserStore } from '@/stores';
|
import { useUserStore } from '@/stores';
|
||||||
import { useSessionStore } from '@/stores/modules/session';
|
import { useSessionStore } from '@/stores/modules/session';
|
||||||
|
import { userProfilePicture } from '@/utils/user';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@@ -82,14 +83,11 @@ function handleClick(item: any) {
|
|||||||
switch (item.key) {
|
switch (item.key) {
|
||||||
case '1':
|
case '1':
|
||||||
ElMessage.warning('暂未开放');
|
ElMessage.warning('暂未开放');
|
||||||
console.log('点击了收藏夹');
|
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
ElMessage.warning('暂未开放');
|
ElMessage.warning('暂未开放');
|
||||||
console.log('点击了设置');
|
|
||||||
break;
|
break;
|
||||||
case '5':
|
case '5':
|
||||||
console.log('点击了用户中心');
|
|
||||||
openDialog();
|
openDialog();
|
||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
@@ -207,13 +205,13 @@ function openVipGuide() {
|
|||||||
:popover-style="popoverStyle"
|
:popover-style="popoverStyle"
|
||||||
>
|
>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<el-avatar :src="src" :size="28" fit="fit" shape="circle" />
|
<el-avatar :src="userProfilePicture" :size="28" fit="fit" shape="circle" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div class="popover-content-box shadow-lg">
|
<div class="popover-content-box shadow-lg">
|
||||||
<!-- 用户信息 -->
|
<!-- 用户信息 -->
|
||||||
<div class="user-info-box flex items-center gap-8px p-8px rounded-lg mb-2">
|
<div class="user-info-box flex items-center gap-8px p-8px rounded-lg mb-2">
|
||||||
<el-avatar :src="src" :size="32" fit="fit" shape="circle" />
|
<el-avatar :src="userProfilePicture" :size="32" fit="fit" shape="circle" />
|
||||||
<div class="flex flex-col text-sm">
|
<div class="flex flex-col text-sm">
|
||||||
<div class="font-semibold text-gray-800">
|
<div class="font-semibold text-gray-800">
|
||||||
{{ userStore.userInfo?.user.nick ?? '未登录用户' }}
|
{{ userStore.userInfo?.user.nick ?? '未登录用户' }}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<!-- 默认消息列表页 -->
|
<!-- 默认消息列表页 -->
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { FilesCardProps } from 'vue-element-plus-x/types/FilesCard';
|
import type { FilesCardProps } from 'vue-element-plus-x/types/FilesCard';
|
||||||
import FilesSelect from '@/components/FilesSelect/index.vue';
|
|
||||||
import ModelSelect from '@/components/ModelSelect/index.vue';
|
import ModelSelect from '@/components/ModelSelect/index.vue';
|
||||||
import WelecomeText from '@/components/WelecomeText/index.vue';
|
import WelecomeText from '@/components/WelecomeText/index.vue';
|
||||||
import { useUserStore } from '@/stores';
|
import { useUserStore } from '@/stores';
|
||||||
@@ -97,7 +96,7 @@ watch(
|
|||||||
</template>
|
</template>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<div class="flex-1 flex items-center gap-8px flex-none w-fit overflow-hidden">
|
<div class="flex-1 flex items-center gap-8px flex-none w-fit overflow-hidden">
|
||||||
<FilesSelect />
|
<!-- <FilesSelect /> -->
|
||||||
<ModelSelect />
|
<ModelSelect />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -6,17 +6,18 @@ import type { BubbleProps } from 'vue-element-plus-x/types/Bubble';
|
|||||||
import type { BubbleListInstance } from 'vue-element-plus-x/types/BubbleList';
|
import type { BubbleListInstance } from 'vue-element-plus-x/types/BubbleList';
|
||||||
import type { FilesCardProps } from 'vue-element-plus-x/types/FilesCard';
|
import type { FilesCardProps } from 'vue-element-plus-x/types/FilesCard';
|
||||||
import type { ThinkingStatus } from 'vue-element-plus-x/types/Thinking';
|
import type { ThinkingStatus } from 'vue-element-plus-x/types/Thinking';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue';
|
||||||
|
import { ElIcon, ElMessage } from 'element-plus';
|
||||||
import { useHookFetch } from 'hook-fetch/vue';
|
import { useHookFetch } from 'hook-fetch/vue';
|
||||||
import { ref } from 'vue';
|
import { computed, nextTick, ref, watch } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { send } from '@/api';
|
import { send } from '@/api';
|
||||||
import FilesSelect from '@/components/FilesSelect/index.vue';
|
|
||||||
import ModelSelect from '@/components/ModelSelect/index.vue';
|
import ModelSelect from '@/components/ModelSelect/index.vue';
|
||||||
import { useChatStore } from '@/stores/modules/chat';
|
import { useChatStore } from '@/stores/modules/chat';
|
||||||
import { useFilesStore } from '@/stores/modules/files';
|
import { useFilesStore } from '@/stores/modules/files';
|
||||||
import { useModelStore } from '@/stores/modules/model';
|
import { useModelStore } from '@/stores/modules/model';
|
||||||
import { useUserStore } from '@/stores/modules/user';
|
import { useUserStore } from '@/stores/modules/user';
|
||||||
|
import { systemProfilePicture, userProfilePicture } from '@/utils/user.ts';
|
||||||
import '@/styles/github-markdown.css';
|
import '@/styles/github-markdown.css';
|
||||||
import '@/styles/yixin-markdown.scss';
|
import '@/styles/yixin-markdown.scss';
|
||||||
|
|
||||||
@@ -61,6 +62,7 @@ const { stream, loading: isLoading, cancel } = useHookFetch({
|
|||||||
userStore.openLoginDialog();
|
userStore.openLoginDialog();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
// 记录进入思考中
|
// 记录进入思考中
|
||||||
let isThinking = false;
|
let isThinking = false;
|
||||||
@@ -121,7 +123,6 @@ function handleDataChunk(chunk: AnyObject) {
|
|||||||
|
|
||||||
// 另一种思考中形式,content中有 <think></think> 的格式
|
// 另一种思考中形式,content中有 <think></think> 的格式
|
||||||
// 一开始匹配到 <think> 开始,匹配到 </think> 结束,并处理标签中的内容为思考内容
|
// 一开始匹配到 <think> 开始,匹配到 </think> 结束,并处理标签中的内容为思考内容
|
||||||
console.log(chunk.choices, 'chunk.choices');
|
|
||||||
const parsedChunk = chunk.choices?.[0].delta.content;
|
const parsedChunk = chunk.choices?.[0].delta.content;
|
||||||
if (parsedChunk) {
|
if (parsedChunk) {
|
||||||
const thinkStart = parsedChunk.includes('<think>');
|
const thinkStart = parsedChunk.includes('<think>');
|
||||||
@@ -166,8 +167,6 @@ function handleError(err: any) {
|
|||||||
|
|
||||||
async function startSSE(chatContent: string) {
|
async function startSSE(chatContent: string) {
|
||||||
try {
|
try {
|
||||||
// 添加用户输入的消息
|
|
||||||
// console.log('chatContent', chatContent);
|
|
||||||
// 清空输入框
|
// 清空输入框
|
||||||
inputValue.value = '';
|
inputValue.value = '';
|
||||||
addMessage(chatContent, true);
|
addMessage(chatContent, true);
|
||||||
@@ -176,23 +175,14 @@ async function startSSE(chatContent: string) {
|
|||||||
// 这里有必要调用一下 BubbleList 组件的滚动到底部 手动触发 自动滚动
|
// 这里有必要调用一下 BubbleList 组件的滚动到底部 手动触发 自动滚动
|
||||||
bubbleListRef.value?.scrollToBottom();
|
bubbleListRef.value?.scrollToBottom();
|
||||||
|
|
||||||
console.log('bubbleItems.value--', bubbleItems.value);
|
// 使用 for-await 处理流式响应
|
||||||
for await (const chunk of stream({
|
for await (const chunk of stream({
|
||||||
// messages: bubbleItems.value
|
messages: bubbleItems.value.slice(0, -1).slice(-6).map((item: MessageItem) => ({
|
||||||
// .filter((item: any) => item.role === 'user')
|
role: item.role,
|
||||||
// .map((item: any) => ({
|
content: (item.role === 'ai' || item.role === 'assistant') && item.content.length > 2000
|
||||||
// role: item.role,
|
? `${item.content.substring(0, 2000)}...(内容过长,已省略)`
|
||||||
// content: item.content,
|
: item.content,
|
||||||
// })),
|
})),
|
||||||
messages: bubbleItems.value
|
|
||||||
.slice(0, -1) // 去掉最后1条(即排除最新那条)
|
|
||||||
.slice(-6) // 然后取倒数第2到第7条(总共6条)
|
|
||||||
.map((item: MessageItem) => ({
|
|
||||||
role: item.role,
|
|
||||||
content: (item.role === 'ai' || item.role === 'assistant') && item.content.length > 2000
|
|
||||||
? `${item.content.substring(0, 2000)}...(内容过长,已省略)`
|
|
||||||
: item.content,
|
|
||||||
})),
|
|
||||||
sessionId: route.params?.id !== 'not_login' ? String(route.params?.id) : undefined,
|
sessionId: route.params?.id !== 'not_login' ? String(route.params?.id) : undefined,
|
||||||
userId: userStore.userInfo?.userId,
|
userId: userStore.userInfo?.userId,
|
||||||
model: modelStore.currentModelInfo.modelId ?? '',
|
model: modelStore.currentModelInfo.modelId ?? '',
|
||||||
@@ -201,11 +191,14 @@ async function startSSE(chatContent: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.log('33---');
|
if (err.name === 'AbortError') {
|
||||||
handleError(err);
|
console.log('用户中止请求'); // 正常中止,无需提示
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
handleError(err); // 其他错误
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
console.log('数据接收完毕');
|
|
||||||
// 停止打字器状态
|
// 停止打字器状态
|
||||||
if (bubbleItems.value.length) {
|
if (bubbleItems.value.length) {
|
||||||
bubbleItems.value[bubbleItems.value.length - 1].typing = false;
|
bubbleItems.value[bubbleItems.value.length - 1].typing = false;
|
||||||
@@ -215,10 +208,14 @@ async function startSSE(chatContent: string) {
|
|||||||
|
|
||||||
// 中断请求
|
// 中断请求
|
||||||
async function cancelSSE() {
|
async function cancelSSE() {
|
||||||
cancel();
|
try {
|
||||||
// 结束最后一条消息打字状态
|
cancel(); // 直接调用,无需参数
|
||||||
if (bubbleItems.value.length) {
|
if (bubbleItems.value.length) {
|
||||||
bubbleItems.value[bubbleItems.value.length - 1].typing = false;
|
bubbleItems.value[bubbleItems.value.length - 1].typing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
handleError(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,8 +225,8 @@ function addMessage(message: string, isUser: boolean) {
|
|||||||
const obj: MessageItem = {
|
const obj: MessageItem = {
|
||||||
key: i,
|
key: i,
|
||||||
avatar: isUser
|
avatar: isUser
|
||||||
? avatar.value
|
? userProfilePicture
|
||||||
: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
: systemProfilePicture,
|
||||||
avatarSize: '32px',
|
avatarSize: '32px',
|
||||||
role: isUser ? 'user' : 'assistant',
|
role: isUser ? 'user' : 'assistant',
|
||||||
placement: isUser ? 'end' : 'start',
|
placement: isUser ? 'end' : 'start',
|
||||||
@@ -269,7 +266,6 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
function markdownContent(item: any) {
|
function markdownContent(item: any) {
|
||||||
console.log('item---', item);
|
|
||||||
return item.content;
|
return item.content;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -305,9 +301,9 @@ function markdownContent(item: any) {
|
|||||||
class="prev-next-btn left-8px flex-center w-22px h-22px rounded-8px border-1px border-solid border-[rgba(0,0,0,0.08)] c-[rgba(0,0,0,.4)] hover:bg-#f3f4f6 bg-#fff font-size-10px"
|
class="prev-next-btn left-8px flex-center w-22px h-22px rounded-8px border-1px border-solid border-[rgba(0,0,0,0.08)] c-[rgba(0,0,0,.4)] hover:bg-#f3f4f6 bg-#fff font-size-10px"
|
||||||
@click="onScrollLeft"
|
@click="onScrollLeft"
|
||||||
>
|
>
|
||||||
<el-icon>
|
<ElIcon>
|
||||||
<ArrowLeftBold />
|
<ArrowLeftBold />
|
||||||
</el-icon>
|
</ElIcon>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -317,9 +313,9 @@ function markdownContent(item: any) {
|
|||||||
class="prev-next-btn right-8px flex-center w-22px h-22px rounded-8px border-1px border-solid border-[rgba(0,0,0,0.08)] c-[rgba(0,0,0,.4)] hover:bg-#f3f4f6 bg-#fff font-size-10px"
|
class="prev-next-btn right-8px flex-center w-22px h-22px rounded-8px border-1px border-solid border-[rgba(0,0,0,0.08)] c-[rgba(0,0,0,.4)] hover:bg-#f3f4f6 bg-#fff font-size-10px"
|
||||||
@click="onScrollRight"
|
@click="onScrollRight"
|
||||||
>
|
>
|
||||||
<el-icon>
|
<ElIcon>
|
||||||
<ArrowRightBold />
|
<ArrowRightBold />
|
||||||
</el-icon>
|
</ElIcon>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Attachments>
|
</Attachments>
|
||||||
@@ -327,7 +323,7 @@ function markdownContent(item: any) {
|
|||||||
</template>
|
</template>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<div class="flex-1 flex items-center gap-8px flex-none w-fit overflow-hidden">
|
<div class="flex-1 flex items-center gap-8px flex-none w-fit overflow-hidden">
|
||||||
<FilesSelect />
|
<!-- <FilesSelect /> -->
|
||||||
<ModelSelect />
|
<ModelSelect />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -177,7 +177,6 @@ function openContact() {
|
|||||||
dangerouslyUseHTMLString: true,
|
dangerouslyUseHTMLString: true,
|
||||||
customClass: 'wechat-message-box',
|
customClass: 'wechat-message-box',
|
||||||
callback: () => {
|
callback: () => {
|
||||||
console.log('用户已查看微信信息');
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -125,7 +125,6 @@ export const useSessionStore = defineStore('session', () => {
|
|||||||
// msg: "操作成功",
|
// msg: "操作成功",
|
||||||
// data: "1935711019560206338"
|
// data: "1935711019560206338"
|
||||||
// };
|
// };
|
||||||
console.log('create_session---res--', res);
|
|
||||||
// 创建会话后立刻查询列表会话
|
// 创建会话后立刻查询列表会话
|
||||||
// 1. 先找到被修改会话在 sessionList 中的索引(假设 sessionList 是按服务端排序的完整列表)
|
// 1. 先找到被修改会话在 sessionList 中的索引(假设 sessionList 是按服务端排序的完整列表)
|
||||||
const targetIndex = sessionList.value.findIndex(session => session.id === `${res.data}`);
|
const targetIndex = sessionList.value.findIndex(session => session.id === `${res.data}`);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ export const useUserStore = defineStore(
|
|||||||
const userInfo = ref<any>();
|
const userInfo = ref<any>();
|
||||||
const setUserInfo = (value: any) => {
|
const setUserInfo = (value: any) => {
|
||||||
userInfo.value = value;
|
userInfo.value = value;
|
||||||
console.log('userInfo', userInfo.value);
|
|
||||||
};
|
};
|
||||||
const clearUserInfo = () => {
|
const clearUserInfo = () => {
|
||||||
userInfo.value = void 0;
|
userInfo.value = void 0;
|
||||||
|
|||||||
@@ -102,8 +102,6 @@ function jwtPlugin(): {
|
|||||||
return response;
|
return response;
|
||||||
|
|
||||||
if (response.result?.code === 403) {
|
if (response.result?.code === 403) {
|
||||||
console.log('2222---');
|
|
||||||
|
|
||||||
router.replace({ name: '403' });
|
router.replace({ name: '403' });
|
||||||
ElMessage.error(response.result?.msg);
|
ElMessage.error(response.result?.msg);
|
||||||
return Promise.reject(response);
|
return Promise.reject(response);
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
import { useUserStore } from '@/stores/index.js';
|
|
||||||
|
|
||||||
const userStore = useUserStore();
|
|
||||||
|
|
||||||
// 获取用户角色信息
|
|
||||||
const userRoles = userStore.userInfo?.roles ?? [];
|
|
||||||
const isUserVip = userRoles.some(role => role.roleCode === 'YiXinAi-Vip');
|
|
||||||
export {
|
|
||||||
isUserVip,
|
|
||||||
};
|
|
||||||
18
Yi.Ai.Vue3/src/utils/user.ts
Normal file
18
Yi.Ai.Vue3/src/utils/user.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { useUserStore } from '@/stores/index.js';
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
// 获取用户角色信息
|
||||||
|
const userRoles = userStore.userInfo?.roles ?? [];
|
||||||
|
const isUserVip = userRoles.some((role: any) => role.roleCode === 'YiXinAi-Vip');
|
||||||
|
|
||||||
|
// 用户头像
|
||||||
|
const userProfilePicture = userStore.userInfo?.user?.icon ? `${import.meta.env.VITE_WEB_BASE_API}/file/${userStore.userInfo.user.icon}` : `@/assets/images/user.png`;
|
||||||
|
// 系统头像
|
||||||
|
const systemProfilePicture = `@/assets/images/user.png`;
|
||||||
|
|
||||||
|
export {
|
||||||
|
isUserVip,
|
||||||
|
systemProfilePicture,
|
||||||
|
userProfilePicture,
|
||||||
|
};
|
||||||
@@ -39,7 +39,6 @@ export default defineConfig((cnf) => {
|
|||||||
bypass(req, res, options) {
|
bypass(req, res, options) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const proxyUrl = new URL(options.rewrite(req.url) || '',(options.target)as string)?.href || '';
|
const proxyUrl = new URL(options.rewrite(req.url) || '',(options.target)as string)?.href || '';
|
||||||
console.log(proxyUrl);
|
|
||||||
req.headers['x-req-proxyUrl'] = proxyUrl
|
req.headers['x-req-proxyUrl'] = proxyUrl
|
||||||
res.setHeader('x-res-proxyUrl',proxyUrl)
|
res.setHeader('x-res-proxyUrl',proxyUrl)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user