This commit is contained in:
14651
2025-08-13 09:19:28 +08:00
parent cbb8dc2ba6
commit 3743c72a54
22 changed files with 1472 additions and 43 deletions

View File

@@ -1,3 +1,4 @@
<!-- index/index.vue -->
<template>
<view class="index">
<!-- 头部个人信息 -->
@@ -32,17 +33,17 @@
</view>
</view>
</view>
</view>
</workbench>
<!-- AI 悬浮按钮 -->
<view class="ai-hover" @click="showAI">
<view class="ai-hover-content">
<view class="ai-hover-text">AI</view>
<!-- AI 悬浮按钮 -->
<view class="ai-hover" @click="toAI">
<view class="ai-hover-content">
<text class="ai-hover-text">AI</text>
</view>
</view>
</view>
<!-- <view>{{log}}</view> -->
<!-- <view>{{log}}</view> -->
</view>
</view>
</template>
@@ -169,7 +170,9 @@
// ]
log: "log"
log: "log",
// 新增AI聊天显示状态与聊天页同步
isAIChatVisible: true
}
},
onLoad(query) {
@@ -184,9 +187,27 @@
this.getQgzxLogExamineTotal()
this.getqgzxMenoyTotal();
}
// 从本地存储获取AI状态
const aiStatus = uni.getStorageSync('aiVisibleStatus');
if (aiStatus !== null && aiStatus !== undefined) {
this.isAIChatVisible = aiStatus;
} else {
// 默认显示
this.isAIChatVisible = true;
uni.setStorageSync('aiVisibleStatus', true);
}
},
onShow() {
// 检查token是否存在
if (!getToken()) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
uni.navigateTo({
url: '/pages/login/index'
});
return;
}
this.getUserInfo();
@@ -194,6 +215,9 @@
this.getUserRouters();
this.getQgzxLogExamineTotal()
this.getqgzxMenoyTotal();
// 页面显示时同步AI状态
this.isAIChatVisible = uni.getStorageSync('aiVisibleStatus') || true;
},
methods: {
getUserRouters() {
@@ -264,21 +288,13 @@
getImgUrl(name) {
return require('../../static/images/workbench/' + name + '.png');
},
async showAI() {
let userInfo = {
roleGroup: uni.getStorageSync("roles"),
nickName: this.nickName,
username: this.username,
avater: this.avater,
user_token: getToken()
}
//1.获取token
userInfo.accessToken = (await this.getAccessToken()).access_token;
userInfo.onRefreshToken = async () => (await this.getAccessToken()).accessToken;
// console.log("请求AI的信息", userInfo)
const sdk = await initCoze(userInfo);
sdk.showChatBot();
toAI() {
uni.navigateTo({
url: '/pages/aiChat/ai_index'
});
},
async getAccessToken() {
const res = await getAccessToken(); // 调用请求函数
const data = JSON.parse(res.data); // 解析数据
@@ -387,7 +403,6 @@
}
}
// ai悬停
.ai-hover {
position: fixed;
@@ -403,5 +418,24 @@
justify-content: center;
align-items: center;
cursor: pointer;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
transition: transform 0.2s;
}
.ai-hover-content {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.ai-hover-text {
font-size: 36rpx;
font-weight: bold;
}
.ai-hover:active {
transform: scale(0.95);
}
</style>