提交 9ce4221f 作者: Hao

拉取最新代码

父级 cc9b12b0
NODE_ENV=development
VITE_USER_APP_API_URL=192.168.31.135
\ No newline at end of file
NODE_ENV=production
VITE_USER_APP_API_URL=192.168.31.101
\ No newline at end of file
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
"type": "module", "type": "module",
"license":"MIT", "license":"MIT",
"scripts": { "scripts": {
"build": "vue-tsc --noEmit && vite build", "build": "vue-tsc --noEmit && vite build --mode production",
"serve": "vite", "serve": "vite --mode development",
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
......
No preview for this file type
// axios.js // axios.js
import axios from "axios"; import axios from "axios";
let VUE_APP_API_URL = import.meta.env.VITE_USER_APP_API_URL;
const instance = axios.create({ const instance = axios.create({
baseURL: "http://192.168.31.123:8080", // 设置基础 URL baseURL: `http://${VUE_APP_API_URL}:8080`, // 设置基础 URL
// baseURL:'/api', // baseURL:'/api',
timeout: 1000, // 设置请求超时时间 timeout: 1000, // 设置请求超时时间
}); });
console.log(import.meta.env, "import.meta.env");
instance.interceptors.request.use( instance.interceptors.request.use(
(config: any) => { (config: any) => {
// 在发送请求之前做些什么,例如添加 token // 在发送请求之前做些什么,例如添加 token
const token = localStorage.getItem("token"); const token = localStorage.getItem("token");
if (token) { if (token) {
config.headers['X-Access-Token'] = `Bearer ${token}`; config.headers["X-Access-Token"] = `Bearer ${token}`;
} }
return config; return config;
}, },
...@@ -27,6 +28,7 @@ instance.interceptors.response.use( ...@@ -27,6 +28,7 @@ instance.interceptors.response.use(
}, },
(error: any) => { (error: any) => {
// 对响应错误做点什么 // 对响应错误做点什么
console.log(error);
return Promise.reject(error); return Promise.reject(error);
} }
); );
......
...@@ -44,7 +44,7 @@ const checkMesssages = (query: any) => { ...@@ -44,7 +44,7 @@ const checkMesssages = (query: any) => {
const getUploadConfigInfo = (query: any) => { const getUploadConfigInfo = (query: any) => {
return http({ return http({
url: "/getUploadConfigInfo", url: "/upload/getUploadConfigInfo",
method: "get", method: "get",
data: query, data: query,
}); });
...@@ -53,7 +53,7 @@ const getUploadConfigInfo = (query: any) => { ...@@ -53,7 +53,7 @@ const getUploadConfigInfo = (query: any) => {
const upload = (query: any) => { const upload = (query: any) => {
return http({ return http({
url: "/sys/common/upload", url: "/sys/common/upload",
method: "get", method: "post",
data: query, data: query,
}); });
}; };
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
ref="elAutocomplete" ref="elAutocomplete"
placeholder="输入信息" placeholder="输入信息"
contenteditable="true" contenteditable="true"
style="outline: none; height: 100%;" style="outline: none; "
@paste.prevent="handlePaste" @paste.prevent="handlePaste"
@focus="removeDefaultContent" @focus="removeDefaultContent"
@input="handleSelect" @input="handleSelect"
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
/> />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import emotion from './IndexComponent.vue' import emotion from './IndexComponent.vue'
import { ElLoading } from 'element-plus' import { ElLoading } from 'element-plus'
...@@ -97,6 +96,7 @@ const fileChange = () => { ...@@ -97,6 +96,7 @@ const fileChange = () => {
const handleSelect = (value: any) => { const handleSelect = (value: any) => {
inputVal.value = value.target.innerHTML inputVal.value = value.target.innerHTML
console.log(inputVal.value,'打印一下')
} }
const emit = defineEmits(['updateState']) const emit = defineEmits(['updateState'])
...@@ -223,7 +223,7 @@ defineExpose({ ...@@ -223,7 +223,7 @@ defineExpose({
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.auto-prompt { .auto-prompt {
padding: 20px; padding: 12px 28px;
} }
.textarea { .textarea {
&:after { &:after {
...@@ -236,8 +236,8 @@ defineExpose({ ...@@ -236,8 +236,8 @@ defineExpose({
} }
} }
.icon { .icon {
width: 24px; width: 20px;
height: 24px; height: 20px;
margin-right: 32px; margin-right: 32px;
} }
.chat-bar { .chat-bar {
...@@ -249,7 +249,7 @@ defineExpose({ ...@@ -249,7 +249,7 @@ defineExpose({
.el-autocomplete { .el-autocomplete {
width: 100%; width: 100%;
max-width: 100%; max-width: 100%;
max-height: 150px; height: calc(100vh - 732px);
overflow: auto; overflow: auto;
} }
.el-autocomplete img { .el-autocomplete img {
......
...@@ -7,7 +7,7 @@ import "./assets/css/reset.css"; ...@@ -7,7 +7,7 @@ import "./assets/css/reset.css";
import * as ElementPlusIconsVue from "@element-plus/icons-vue"; import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import translate from "i18n-jsautotranslate"; import translate from "i18n-jsautotranslate";
import UUID from "vue3-uuid"; import UUID from "vue3-uuid";
import "@/permission"; // permission control import "@/permission";
import "element-plus/dist/index.css"; import "element-plus/dist/index.css";
import "./mocks/mock"; import "./mocks/mock";
const app = createApp(App); const app = createApp(App);
......
import { reactive, watch, ref, defineEmits, defineExpose } from "vue"; import { reactive, watch, ref, defineEmits, defineExpose } from "vue";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { upload, getUploadConfigInfo } from "../axios/model/user"; import { upload, getUploadConfigInfo } from "../axios/model/user";
import axios from "axios";
import COS from "cos-js-sdk-v5"; import COS from "cos-js-sdk-v5";
interface UploadMixin { interface UploadMixin {
uploadMixinPath: string; uploadMixinPath: string;
uploadMixinType: string; uploadMixinType: string;
uploadMixinCredentials: any; uploadMixinCredentials: any;
uploadMixinTimeStamp: number; uploadMixinTimeStamp: number;
upLoadMixinResult: object;
} }
const uploadMixin: UploadMixin = { const uploadMixin: UploadMixin = {
uploadMixinPath: "", uploadMixinPath: "",
uploadMixinType: "", uploadMixinType: "",
uploadMixinCredentials: {}, uploadMixinCredentials: {},
uploadMixinTimeStamp: 0, uploadMixinTimeStamp: 0,
upLoadMixinResult: {},
}; };
interface CustomAxiosResponse { interface CustomAxiosResponse {
code: number; code: number;
...@@ -89,23 +92,28 @@ export const upLoadHander = async (obj: any) => { ...@@ -89,23 +92,28 @@ export const upLoadHander = async (obj: any) => {
//noCredentials变量控制是否走对象存储 //noCredentials变量控制是否走对象存储
if (noCredentials) { if (noCredentials) {
const query = {}; const query = {};
const res:any = await getUploadConfigInfo(query); const res: any = await getUploadConfigInfo(query);
// console.log(res1,'res')
// console.log(res);
if (res.code === 200 && res.result) { if (res.code === 200 && res.result) {
const result = res.result; const result = res.result;
uploadMixin.uploadMixinPath = result.upLoadPath; uploadMixin.uploadMixinPath = result.upLoadPath;
uploadMixin.uploadMixinType = result.uploadType; uploadMixin.uploadMixinType = result.uploadType;
staticDomain = result.staticDomain || "https://cdn.tikcos.cn"; staticDomain = result.staticDomain || "https://cdn.tikcos.cn";
if (uploadMixin.uploadMixinType === "txcos") { if (uploadMixin.uploadMixinType === "txcos") {
const credentials = result.credentials; console.log(result.response, " result.response");
const ress = res.result.response;
const credentials = ress.credentials;
uploadMixin.uploadMixinCredentials = { uploadMixin.uploadMixinCredentials = {
TmpSecretId: credentials?.tmpSecretId, TmpSecretId: credentials?.tmpSecretId,
TmpSecretKey: credentials?.tmpSecretKey, TmpSecretKey: credentials?.tmpSecretKey,
SecurityToken: credentials?.sessionToken, SecurityToken: credentials?.sessionToken,
StartTime: result.startTime, StartTime: ress?.startTime,
ExpiredTime: result.expiredTime, ExpiredTime: ress?.expiredTime,
}; };
console.log(result, "result");
console.log(
uploadMixin.uploadMixinCredentials,
" uploadMixin.uploadMixinCredentials"
);
} }
} else { } else {
resResult = false; resResult = false;
...@@ -114,51 +122,84 @@ export const upLoadHander = async (obj: any) => { ...@@ -114,51 +122,84 @@ export const upLoadHander = async (obj: any) => {
//resResult判断接口是否正常 //resResult判断接口是否正常
if (resResult) { if (resResult) {
const query = {}; const query = {};
const res:any = await getUploadConfigInfo(query); // const res: any = await getUploadConfigInfo(query);
if (uploadMixin.uploadMixinType == "txcos") { console.log(
uploadMixin.uploadMixinCredentials,
" console.log(uploadMixin.uploadMixinCredentials)"
);
const result: any = uploadMixin.upLoadMixinResult;
if (uploadMixin.uploadMixinType === "txcos") {
//走对象存储 //走对象存储
const cos = new COS({ const cos = new COS({
getAuthorization: (options: any, callback: any) => { getAuthorization: (options, callback) => {
callback(uploadMixin.uploadMixinCredentials); callback(uploadMixin.uploadMixinCredentials);
}, },
}); });
const tempFolder = fileInfo.biz === "temp" ? "" : `${fileInfo.biz}/`; const tempFolder = fileInfo.biz === "temp" ? "" : `${fileInfo.biz}/`;
const folder = `${fileInfo.fileName}_${new Date().getTime()}.${ const folder = `${fileInfo.fileName}_${new Date().getTime()}.${
fileInfo.fileTyle fileInfo.fileTyle
}`; }`;
const result = res.result || {};
cos.putObject( cos.putObject(
{ {
// FilePath: fileInfo.file,
Bucket: result.bucketName || "tikcos-1257774783", Bucket: result.bucketName || "tikcos-1257774783",
Region: result.regionid || "ap-guangzhou", Region: result.regionid || "ap-guangzhou",
Key: uploadMixin.uploadMixinPath + tempFolder + folder, Key: uploadMixin.uploadMixinPath + tempFolder + folder,
Body: fileInfo.file, Body: fileInfo.file,
onProgress: function (progressData: any) { onProgress: function (progressData) {
obj.onProgress && obj.onProgress(progressData); console.log(progressData, "ada");
obj.onProgress(progressData);
}, },
}, },
async (err: any, data: any) => { (err, data) => {
console.log(err, data, "打印一下");
console.log({ success: true });
console.log(
`${staticDomain}/${uploadMixin.uploadMixinPath}${tempFolder}${folder}`,
"打印一下,数据"
);
if (!err && data.statusCode === 200) { if (!err && data.statusCode === 200) {
const imgurl = `${staticDomain}/${uploadMixin.uploadMixinPath}${tempFolder}${folder}`; const imgurl = `${staticDomain}/${uploadMixin.uploadMixinPath}${tempFolder}${folder}`;
obj.onSuccess({
success: true, obj.onSuccess({ success: true, message: imgurl });
message: imgurl,
});
} else { } else {
obj.onError({ obj.onError({ success: false, message: err || "图片上传失败" });
success: false,
message: data.message || "图片上传失败",
});
} }
} }
); );
} else { } else {
// 其他存储类型暂不支持 //走系统上传
obj.onError({ let VUE_APP_API_URL = import.meta.env.VITE_USER_APP_API_URL;
success: false, let newFile = fileInfo.file;
message: "服务接口报错", if (/[\u4e00-\u9fa5]/.test(newFile.name)) {
}); const folder = newFile.name.replace(/[\u4e00-\u9fa5]{1,}/g, "_");
newFile = new File([newFile], folder, { type: newFile.type });
}
let formData = new FormData();
formData.append("biz", fileInfo.biz);
formData.append("file", newFile);
const uploadRes = await axios.post(`http://${VUE_APP_API_URL}:8080/sys/common/upload`,
formData,
{
headers: { ...obj.headers },
processData: false,
contentType: false,
async: false,
}
);
if (uploadRes.success && uploadRes.message) {
//保存绝对路径,不然小程序会有问题
let url = uploadRes.message;
url = uploadRes.message.replaceAll("//", "/");
const pre = url.startsWith("/") ? "" : "/";
url = `http://${VUE_APP_API_URL}/sys/common/static` + pre + url;
obj.onSuccess({ success: true, message: url });
} else {
obj.onError({
success: false,
message: uploadRes.message || "图片上传失败",
});
}
} }
} else { } else {
obj.onError({ obj.onError({
......
...@@ -14,7 +14,6 @@ export const useUserStore = defineStore("user", { ...@@ -14,7 +14,6 @@ export const useUserStore = defineStore("user", {
password: "", password: "",
token: "", token: "",
}, },
// userList: [],
}; };
}, },
actions: { actions: {
...@@ -37,9 +36,8 @@ export const useUserStore = defineStore("user", { ...@@ -37,9 +36,8 @@ export const useUserStore = defineStore("user", {
to: res.to, to: res.to,
id: res.id, id: res.id,
form: res.from, form: res.from,
userImg: userImg:"https://cdn.lirimall.com//lirigo/filetempImage/新鲜水果_1661668973048.png",
"https://cdn.lirimall.com//lirigo/filetempImage/新鲜水果_1661668973048.png", time: moment(res.createTime).format("HH:mm:ss"),
time: moment(res.createTime).format("YYYY-DD-MM HH:mm:ss"),
}; };
messages.push(obj); messages.push(obj);
this.customerInfo.messages = messages; this.customerInfo.messages = messages;
...@@ -51,7 +49,7 @@ export const useUserStore = defineStore("user", { ...@@ -51,7 +49,7 @@ export const useUserStore = defineStore("user", {
chatDatas.forEach((item: any) => { chatDatas.forEach((item: any) => {
item.userImg = item.userImg =
"https://cdn.lirimall.com//lirigo/filetempImage/新鲜水果_1661668973048.png"; "https://cdn.lirimall.com//lirigo/filetempImage/新鲜水果_1661668973048.png";
item.time = moment(res.createTime).format("YYYY-DD-MM HH:mm:ss"); item.time = moment(res.createTime).format("HH:mm:ss");
}); });
for (const index in chatDatas) { for (const index in chatDatas) {
const userId = chatDatas[index].from; const userId = chatDatas[index].from;
......
...@@ -46,7 +46,7 @@ export default defineConfig({ ...@@ -46,7 +46,7 @@ export default defineConfig({
], ],
server: { server: {
host: "0.0.0.0", host: "0.0.0.0",
port: 80, port: 8082,
open: false, open: false,
}, },
}); });
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论