Commit 374833cc authored by xinzhedeai's avatar xinzhedeai

fix: 导入上传问题处理

parent 10aec2f3
......@@ -74,10 +74,10 @@ VITE_STORAGE_PREFIX=SOY_
# ============================================ old
# 开发环境 - 视频流地址
VITE_VIDEO_URL=ws://192.168.2.14:9999
VITE_VIDEO_URL=ws://192.168.2.16:9999
# 开发环境 - 所有服务接口地址
VITE_SERVICE_URL=http://192.168.2.14:9998
VITE_SERVICE_URL=http://192.168.2.16:9998
# 开发环境 - WebSocket 全局地址
VITE_WEBSOCKET_URL=ws://192.168.2.14:9998
VITE_WEBSOCKET_URL=ws://192.168.2.16:9998
......@@ -85,6 +85,7 @@ const tableColumn = [
minWidth: 160,
align: 'center',
render: (row: any) => {
console.log('preview', row.preview)
return h(NImage, {
width: '70',
lazy: true,
......@@ -560,7 +561,7 @@ const modifyAreaNode = async () => {
// 图片上传 - 结束回调
const handleFinish = ({ file, event }: { file: UploadFileInfo; event?: ProgressEvent }) => {
const res = event?.target && event?.target?.response && JSON.parse(event?.target?.response);
console.log(res, 'handleFinish----》')
if (res.code === 200) {
formWebCam.value.preview = res.data;
message.success('图片上传成功!');
......@@ -572,7 +573,7 @@ const handleFinish = ({ file, event }: { file: UploadFileInfo; event?: ProgressE
// 文件上传 - 结束回调
const handleFinishFile = ({ file, event }: { file: UploadFileInfo; event?: ProgressEvent }) => {
console.log(JSON.parse(event?.target.response));
console.log('evnet 上传结束事件', event, file);
const res = JSON.parse(event?.target.response);
if (res.code === 200) {
......@@ -580,13 +581,16 @@ const handleFinishFile = ({ file, event }: { file: UploadFileInfo; event?: Progr
formWebCam.value.preview = res.data;
message.success('文件上传成功!');
getCameraList();
return file;
}else{
message.error(res.msg);
}
// message.success((event?.target as XMLHttpRequest).response);
// const ext = file.name.split('.')[1];
// file.name = `更名.${ext}`;
// file.url = '__HTTPS__://www.mocky.io/v2/5e4bafc63100007100d8b70f';
return file;
};
const selectWebCaM = ref([]);
......@@ -655,20 +659,18 @@ const realTimeMonitoring = (url: string | undefined) => {
// 图片上传前-钩子
function beforeUpload(data: { file: UploadFileInfo; fileList: UploadFileInfo[] }) {
// if (data.file.file?.type !== 'image/png') {
// message.error('仅支持JPEG/JPG/PNG三种图片格式上传');
// return false;
// }
console.log('校验大虾', data)
const maxSizeInBytes = 1024 * 1024 * 2.5; // 限制为 2MB(你可以根据需要调整这个值)
if (data?.file?.file?.size > maxSizeInBytes) {
message.error('文件大小不能超过 2.5MB');
return false; // 返回 false 阻止上传或执行其他逻辑处理大文件情况
}
// if (data.file.file?.type !== 'image/jpg') {
// message.error('仅支持JPEG/JPG/PNG三种图片格式上传');
// return false;
// }
if (data.file.file?.type !== 'image/png' && data.file.file?.type !== 'image/jpg' && data.file.file?.type !== 'image/jpeg') {
message.error('仅支持JPEG/JPG/PNG三种图片格式上传');
return false;
}
// if (data.file.file?.type !== 'image/jpeg') {
// message.error('仅支持JPEG/JPG/PNG三种图片格式上传');
// return false;
// }
return true;
}
......@@ -791,7 +793,7 @@ const showRealTimeVideoPlayer = () => {
font-size: 13px;
line-height: 19px;
display: inline-block;
">
`` ">
* 按模板文件的格式进行填写
</div>
</NFormItem>
......@@ -803,7 +805,7 @@ const showRealTimeVideoPlayer = () => {
<!-- <NImage lazy width="100" src="https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg" /> -->
<NSpace>
<!-- <NButton strong secondary>上传图片</NButton> -->
<NUpload :max="1" action="/v1/export/upload" :headers="{
<NUpload :max="1" action="/v1/export/upload" accept=".xlsx,.xls" :headers="{
'naive-info': 'hello!'
}" :data="{
'naive-data': 'cool! naive!'
......@@ -822,7 +824,7 @@ const showRealTimeVideoPlayer = () => {
<!-- <div style="border: 1px solid red; width: 100%; height: 200px"></div> -->
<!-- <template #footer> -->
<NSpace justify="end">
<NButton @click="impWebCamModal = false" type="primary">确定</NButton>
<NButton @click="impWebCamModal = false" type="primary">关闭</NButton>
</NSpace>
<!-- </template> -->
</NModal>
......@@ -896,7 +898,7 @@ const showRealTimeVideoPlayer = () => {
<NFormItem label="图片初始化" path="selectValue">
<NSpace justify="space-between" style="width: 100%;">
<NSpace justify="start">
<NUpload :max="1" action="/v1/common/upload" :headers="{
<NUpload :max="1" action="/v1/common/upload" accept="image/png,image/jpeg,image/jpg" :headers="{
'naive-info': 'hello!'
}" :data="{
'naive-data': 'cool! naive!'
......@@ -1112,6 +1114,16 @@ const showRealTimeVideoPlayer = () => {
</template>
<style lang="scss" scoped>
:deep .n-upload-file-info__action.n-upload-file-info__action--text-type{
right:-24px !important;
}
:deep .n-upload-file-list.n-upload-file.n-upload-file-info.n-upload-file-info__action{
right:-64px !important;
}
#algorithmconfiguration {
#canvas-4 {
position: absolute;
......
......@@ -4,22 +4,22 @@ import { defineConfig, loadEnv } from 'vite';
import { setupVitePlugins } from './build/plugins';
import { createViteProxy, getBuildTime } from './build/config';
// export const proxyTarget = 'http://192.168.3.248:9996';
// export const proxyTarget = 'http://192.168.2.14:9998';
export const proxyTarget = 'http://192.168.2.14:9998';
// export const proxyTarget = 'http://192.168.2.16:9996';
// export const proxyTarget = 'http://192.168.2.16:9998';
export const proxyTarget = 'http://192.168.2.16:9998';
// export const proxyTarget = 'http://192.168.1.119:9996';
// export const proxyTarget = 'http://192.168.1.119:9996';
// 视频地址
export const videdUrl = 'ws://192.168.2.14:9999';
export const videdUrl = 'ws://192.168.2.16:9999';
// 固定接口地址
export const apiUrl = 'http://192.168.2.14:9998';
export const apiUrl = 'http://192.168.2.16:9998';
// WS 地址
export const wsUrl = 'ws://192.168.2.14:9999';
export const wsUrl = 'ws://192.168.2.16:9999';
export default defineConfig(configEnv => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment