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