feat: 添加微信按钮组件及优化AI聊天功能

refactor: 移除未使用的circle-btn组件引用
style: 更新图片资源路径及样式
fix: 修复axios请求配置及类型定义
docs: 添加mock-api.js模拟接口文件
This commit is contained in:
DESKTOP-RQ919RC\Pc
2025-08-25 17:54:08 +08:00
parent 397cdd2a53
commit ca8185df91
37 changed files with 865 additions and 156 deletions

View File

@@ -53,10 +53,10 @@ export default{
return axios.post('https://api.gter.net/v1/chat/history',params)
},
alChat:(params={})=>{// AI 发送信息
return axios.post('https://fangchat.x-php.com/api/v1/chat',params)
return axios.postV2('https://fangchat.x-php.com/api/v1/chat',params)
},
alResume:(params={})=>{// AI 恢复会话
return axios.post('https://fangchat.x-php.com/api/v1/chat/resume',params)
return axios.postV2('https://fangchat.x-php.com/api/v1/chat/resume',params)
},
alEnd:(params={})=>{// AI 结束会话
return axios.post('https://api.gter.net/v1/chat/end',params)

View File

@@ -1,69 +1,68 @@
import axios from "axios"
import QS from "qs"
import { goTologin } from "@/utils/util.js"
import { showFullScreenLoading, tryHideFullScreenLoading } from "./loading"
import store from "@/store/index"
import axios from "axios";
import QS from "qs";
import { goTologin } from "@/utils/util.js";
import { showFullScreenLoading, tryHideFullScreenLoading } from "./loading";
import store from "@/store/index";
axios.defaults.baseURL = "https://app.gter.net"
axios.defaults.emulateJSON = true
axios.defaults.withCredentials = true
// content-type 为 multipart/form-data
axios.defaults.baseURL = "https://app.gter.net";
axios.defaults.emulateJSON = true;
axios.defaults.withCredentials = true;
// axios.defaults.headers["Content-Type"] = "application/json";
axios.interceptors.request.use(
//响应拦截
async config => {
async (config) => {
// 不需要遮罩
let noMask = false
let noMask = false;
if (config.method == "get") noMask = config.params?.noMask || false
noMask = config.params?.noMask || config.noMask || false;
if (config.url != "/tenement/pc/api/user/operation" && !noMask) showFullScreenLoading()
if (config.url != "/tenement/pc/api/user/operation" && !noMask) showFullScreenLoading();
// 开发时登录用的,可以直接替换小程序的 authorization
if (process.env.NODE_ENV !== "production") {
const miucms_session = "01346a38444d71aaadb3adad52b52c39";
document.cookie = "miucms_session=" + miucms_session;
config["headers"]["authorization"] = miucms_session;
}
// 当 noMask == true 和 confing.method == 'get' 时,删除 config.params['noMask']
if (noMask && config.method == "get") delete config.params["noMask"]
return config
// 当 noMask == true 和 confing.method == 'get' 时,删除 config.params['noMask']
if (noMask && config.params) delete config.params["noMask"];
return config;
},
error => {
return Promise.error(error)
(error) => {
return Promise.error(error);
}
)
);
// 响应拦截器
axios.interceptors.response.use(
response => {
tryHideFullScreenLoading()
if (response.status === 200) return Promise.resolve(response) //进行中
else return Promise.reject(response) //失败
(response) => {
tryHideFullScreenLoading();
if (response.status === 200) return Promise.resolve(response); //进行中
else return Promise.reject(response); //失败
},
// 服务器状态码不是200的情况
error => {
tryHideFullScreenLoading()
(error) => {
tryHideFullScreenLoading();
if (error.response.status) {
switch (error.response.status) {
// 401: 未登录
case 401:
// goTologin() // 跳转登录页面
store.state.showloginmodal = true
break
store.state.showloginmodal = true;
break;
case 403:
// router.push('/login')
break
break;
// 404请求不存在
case 404:
break
break;
// 其他错误,直接抛出错误提示
default:
}
return Promise.reject(error.response)
return Promise.reject(error.response);
}
}
)
);
/**
* get方法对应get请求
* @param {String} url [请求的url地址]
@@ -75,14 +74,14 @@ const $get = (url, params) => {
.get(url, {
params: params,
})
.then(res => {
resolve(res.data)
.then((res) => {
resolve(res.data);
})
.catch(err => {
reject(err.data)
})
})
}
.catch((err) => {
reject(err.data);
});
});
};
/**
* post方法对应post请求
* @param {String} url [请求的url地址]
@@ -93,23 +92,40 @@ const $post = (url, params) => {
//是将对象 序列化成URL的形式以&进行拼接
axios
.post(url, QS.stringify(params))
.then(res => {
resolve(res.data)
.then((res) => {
resolve(res.data);
})
.catch(err => {
if (err.data.code == 401) resolve(err.data)
else reject(err.data)
.catch((err) => {
if (err.data.code == 401) resolve(err.data);
else reject(err.data);
});
});
};
const $postV2 = (url, params) => {
return new Promise((resolve, reject) => {
console.log("params", params);
axios
.post(url, JSON.stringify(params), { headers: { "Content-Type": "application/json" }, timeout: 100000, ...(params.noMask !== undefined ? { noMask: params.noMask } : {}) })
.then((res) => {
resolve(res.data);
})
})
}
.catch((err) => {
if (err.data.code == 401) resolve(err.data);
else reject(err.data);
});
});
};
//下面是vue3必须加的vue2不需要只需要暴露出去getpost方法就可以
export default {
get: $get,
post: $post,
install: app => {
app.config.globalProperties["$get"] = $get
app.config.globalProperties["$post"] = $post
app.config.globalProperties["$axios"] = axios
postV2: $postV2,
install: (app) => {
app.config.globalProperties["$get"] = $get;
app.config.globalProperties["$post"] = $post;
app.config.globalProperties["$axios"] = axios;
},
}
};