修改一个bug
This commit is contained in:
18
.env
18
.env
@@ -2,3 +2,21 @@ WECHAT_APPID=wx364b8ebf17fe45fe
|
||||
WECHAT_SECRET=9b7476020991a2c71f1416da7f011d31
|
||||
|
||||
|
||||
|
||||
|
||||
# ## 公众号
|
||||
# ```json
|
||||
# APPID: wx364b8ebf17fe45fe
|
||||
# AppSecret: 9b7476020991a2c71f1416da7f011d31
|
||||
# ```
|
||||
|
||||
# ## 网站应用
|
||||
# ```json
|
||||
# APPID: wx0eeb7556d60121db
|
||||
# AppSecret: a01456fbccf15adf57ea0d3c702d4e31
|
||||
# ```
|
||||
|
||||
# ## 迈步
|
||||
# AppID:wx549f4ae0f85eb3ea
|
||||
# AppSecret:
|
||||
# 83208b88e65977419672a243fd3dc7a0
|
||||
36
index.html
36
index.html
@@ -13,7 +13,7 @@
|
||||
<!-- </script> -->
|
||||
<script src="./marked.min.js"></script>
|
||||
|
||||
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
|
||||
<!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script> -->
|
||||
|
||||
<style>
|
||||
* {
|
||||
@@ -70,12 +70,15 @@
|
||||
z-index: 10;
|
||||
height: 100%;
|
||||
left: 0px;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
}
|
||||
|
||||
.sidebar.collapsed {
|
||||
left: -260px;
|
||||
/* width: 0; */
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
@@ -161,6 +164,7 @@
|
||||
|
||||
/* 收起按钮(独立漂浮在左边) */
|
||||
.toggle-btn {
|
||||
position: fixed;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
@@ -180,6 +184,10 @@
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.sidebar.collapsed>.toggle-btn {
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
.toggle-btn:hover {
|
||||
background: #0046cc;
|
||||
}
|
||||
@@ -567,7 +575,7 @@
|
||||
left: 0px;
|
||||
}
|
||||
|
||||
.sidebar.sidebar.collapsed>.toggle-btn {
|
||||
.sidebar.collapsed>.toggle-btn {
|
||||
position: fixed;
|
||||
right: 10px !important;
|
||||
width: 28px;
|
||||
@@ -994,7 +1002,7 @@
|
||||
z-index: 999999;
|
||||
transition: all 0.3s ease-in-out;
|
||||
backdrop-filter: blur(2px);
|
||||
position: relative;
|
||||
/* position: relative; */
|
||||
|
||||
}
|
||||
|
||||
@@ -1060,6 +1068,11 @@
|
||||
border: none;
|
||||
}
|
||||
|
||||
#popupForm input {
|
||||
border: 1px solid #ccc !important;
|
||||
width: 94%;
|
||||
}
|
||||
|
||||
.options {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -1363,12 +1376,12 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<!-- <script>
|
||||
// 开启 vConsole 调试面板
|
||||
var vConsole = new VConsole();
|
||||
|
||||
console.log("✅ vConsole 已经启动");
|
||||
</script>
|
||||
</script> -->
|
||||
|
||||
|
||||
|
||||
@@ -1923,7 +1936,8 @@
|
||||
if (!toggleButton.contains(e.target) && !panel.contains(e.target)) {
|
||||
panel.classList.remove('show');
|
||||
}
|
||||
if (!sidebar.contains(e.target)) {
|
||||
const chatbox = document.querySelector(".chat-input");
|
||||
if (!sidebar.contains(e.target) && !chatbox.contains(e.target)) {
|
||||
if (!sidebar.classList.contains("collapsed")) {
|
||||
sidebar.classList.add("collapsed");
|
||||
toggleBtn.style.left = "10px"; // 收起后
|
||||
@@ -2413,6 +2427,16 @@
|
||||
|
||||
}
|
||||
const deleteSession = (sessionId, userId) => {
|
||||
if (activeChatId == sessionId) {
|
||||
if (controller) {
|
||||
controller.abort();
|
||||
controller = null;
|
||||
if (sendBtnImg.classList.contains('none')) {
|
||||
sendBtnImg.classList.remove('none');
|
||||
stopBtn.classList.add('none')
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
fetch(`https://serviceai.satabot.com/session?sessionId=${sessionId}&userId=${userId}`, {
|
||||
method: "DELETE"
|
||||
|
||||
18
middle.html
18
middle.html
@@ -10,18 +10,26 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<button onclick="handlelogin()">微信登录</button>
|
||||
<script>
|
||||
// 开启 vConsole 调试面板
|
||||
var vConsole = new VConsole();
|
||||
|
||||
// wx364b8ebf17fe45fe wx0eeb7556d60121db
|
||||
console.log("✅ vConsole 已经启动");
|
||||
const url = encodeURIComponent("https://ai.satabot.com?userid=6353rf")
|
||||
function handlelogin() {
|
||||
const APP_ID = 'wx364b8ebf17fe45fe';
|
||||
const REDIRECT_URI = encodeURIComponent("https://ai.satabot.com");
|
||||
const STATE = Math.random().toString(36).substring(2, 12);
|
||||
const SCOPE = 'snsapi_base';
|
||||
// const authUrl = `https://open.weixin.qq.com/connect/qrconnect?appid=${APP_ID}&redirect_uri=${REDIRECT_URI}&response_type=code&scope=${SCOPE}&state=${STATE}#wechat_redirect`;
|
||||
// window.location.href = authUrl; // 跳转后页面刷新,后续代码不执行
|
||||
window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${APP_ID}&redirect_uri=${REDIRECT_URI}&response_type=code&scope=${SCOPE}&forcePopup=false&state=${STATE}&connect_redirect=1#wechat_redirect`
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const url = encodeURIComponent(`https://ai.satabot.com?t=${Date.now()}`);
|
||||
const target = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx549f4ae0f85eb3ea&redirect_uri=${url}&response_type=code&scope=snsapi_userinfo&state=123&forcePopup=true#wechat_redirect`
|
||||
location.href = target
|
||||
console.log("跳转了吗")
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
134
server2.js
134
server2.js
@@ -16,7 +16,8 @@ const crypto = require('crypto');
|
||||
require('dotenv').config();
|
||||
|
||||
const app = express();
|
||||
const port =30009;
|
||||
const port = 30009;
|
||||
const TOKEN = 'my_token_123'; // 与公众号后台配置一致
|
||||
|
||||
|
||||
|
||||
@@ -177,22 +178,135 @@ app.get('/wechat/oauth/access-token', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
/*菜单部分 */
|
||||
|
||||
async function createMenu() {
|
||||
const accessToken = await getAccessToken();
|
||||
const url = `https://api.weixin.qq.com/cgi-bin/menu/create?access_token=${accessToken}`;
|
||||
const target = encodeURIComponent("https://ai.satabot.com/?from=weixin");
|
||||
|
||||
|
||||
// 创建菜单的接口
|
||||
app.post('/create-menu', async (req, res) => {
|
||||
const menuData = {
|
||||
"button": [
|
||||
{
|
||||
"name": "产品中心",
|
||||
"sub_button": [
|
||||
{
|
||||
"type": "view",
|
||||
"name": "整机产品",
|
||||
"url": "http://www.jsmaibu.com/products/"
|
||||
},
|
||||
{
|
||||
"type": "view",
|
||||
"name": "智能电控",
|
||||
"url": "http://www.jsmaibu.com/Products/%E6%8E%A7%E5%88%B6%E5%99%A8%20MC100.html"
|
||||
},
|
||||
{
|
||||
"type": "view",
|
||||
"name": "资料下载",
|
||||
"url": "http://www.jsmaibu.com/Support/Download.html"
|
||||
},
|
||||
{
|
||||
"type": "click",
|
||||
"name": "AI智能体",
|
||||
"key": "AI_INTELLIGENT"
|
||||
}
|
||||
// {
|
||||
// "type": "view",
|
||||
// "name": "AI智能体",
|
||||
// // "url":`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx364b8ebf17fe45fe&redirect_uri= encodeURIComponent("https://ai.satabot.com/?from=weixin")&response_type=code&scope=snsapi_login&state=123#wechat_redirect`,
|
||||
// "url": "https://ai.satabot.com/middle.html"
|
||||
|
||||
// }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "服务中心",
|
||||
"sub_button": [
|
||||
{
|
||||
"type": "view",
|
||||
"name": "解决方案",
|
||||
"url": "http://www.jsmaibu.com/Solution.html"
|
||||
},
|
||||
{
|
||||
"type": "view",
|
||||
"name": "培训视频",
|
||||
"url": "http://www.jsmaibu.com/Support/index.html"
|
||||
},
|
||||
{
|
||||
"type": "view",
|
||||
"name": "一键呼叫",
|
||||
"url": "http://www.jsmaibu.com/contact/"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "飒沓智能",
|
||||
"sub_button": [
|
||||
{
|
||||
"type": "view",
|
||||
"name": "关于我们",
|
||||
"url": "http://www.jsmaibu.com/about-us.html#start"
|
||||
},
|
||||
{
|
||||
"type": "view",
|
||||
"name": "加入我们",
|
||||
"url": "https://www.zhipin.com/gongsi/job/d1e30046e726d2d01nN72Ni4EFQ~.html?ka=all-jobs-hot"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
const res = await axios.post(url, menuData);
|
||||
if (res.data.errcode === 0) {
|
||||
console.log('✅ 菜单创建成功');
|
||||
} else {
|
||||
console.error('❌ 菜单创建失败:', res.data);
|
||||
}
|
||||
}
|
||||
// ========== 查询菜单 ==========
|
||||
async function getMenu() {
|
||||
const accessToken = await getAccessToken();
|
||||
const menuData = getMenuForPlatform(req); // 根据请求判断平台并获取菜单
|
||||
const url = `https://api.weixin.qq.com/cgi-bin/menu/get?access_token=${accessToken}`;
|
||||
const res = await axios.get(url);
|
||||
return res.data;
|
||||
}
|
||||
|
||||
const createMenuUrl = `https://api.weixin.qq.com/cgi-bin/menu/create?access_token=${accessToken}`;
|
||||
// ========== 删除菜单(可选)==========
|
||||
async function deleteMenu() {
|
||||
const accessToken = await getAccessToken();
|
||||
const url = `https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=${accessToken}`;
|
||||
const res = await axios.get(url);
|
||||
return res.data;
|
||||
}
|
||||
|
||||
app.get('/createMenu', async (req, res) => {
|
||||
try {
|
||||
const response = await axios.post(createMenuUrl, menuData);
|
||||
res.send(`菜单创建成功: ${JSON.stringify(response.data)}`);
|
||||
} catch (error) {
|
||||
res.status(500).send(`菜单创建失败: ${error}`);
|
||||
await createMenu();
|
||||
res.send('✅ 菜单创建成功!');
|
||||
} catch (err) {
|
||||
res.send('❌ 创建失败: ' + err.message);
|
||||
}
|
||||
});
|
||||
app.get('/getMenu', async (req, res) => {
|
||||
try {
|
||||
const data = await getMenu();
|
||||
res.json(data);
|
||||
} catch (err) {
|
||||
res.send('❌ 查询失败: ' + err.message);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/deleteMenu', async (req, res) => {
|
||||
try {
|
||||
const data = await deleteMenu();
|
||||
res.json(data);
|
||||
} catch (err) {
|
||||
res.send('❌ 删除失败: ' + err.message);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.post('/wechat', async (req, res) => {
|
||||
try {
|
||||
@@ -544,7 +658,7 @@ app.post("/getuserByopenid", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
const TOKEN = 'my_token_123'; // 与公众号后台配置一致
|
||||
|
||||
|
||||
|
||||
app.get('/wechat', (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user