提交代码

This commit is contained in:
jiang 2024-12-02 10:46:26 +08:00
parent 35a8146d97
commit bd2ad482b7
6 changed files with 108 additions and 51 deletions

View File

@ -7,3 +7,10 @@ export const getConfig = () => {
method: 'get'
})
}
export const getMinIoUrl = () => {
return request({
url: '/ai/getConfig',
method: 'get'
})
}

View File

@ -42,6 +42,7 @@ import { mapState } from 'vuex'
import variables from '@/assets/styles/variables.scss'
import { validateNewPassword } from '@/utils/validate'
import { updateUserPwd, checkPasswordStatus } from '@/api/system/user'
import {getMinioUrl } from '@/utils/config'
import { handleNoWarningLog } from '@/api/system/log'
import {MessageBox} from "element-ui";
@ -116,6 +117,7 @@ export default {
}
},
created() {
getMinioUrl();
this.checkPasswordStatus()
if (this.roles.includes("audit") || this.roles.includes("systemAdmin")) {
this.connectWebSocket();

View File

@ -1,11 +1,21 @@
import { getConfig } from '@/api/config';
import { getConfig,getMinIoUrl } from '@/api/config'
export function get() {
getConfig()
.then(response => {
console.log(response)
localStorage.setItem('systemConfig', JSON.stringify(response.data));
localStorage.setItem('systemConfig', JSON.stringify(response.data))
})
.catch(error => {
console.error('Failed to fetch config:', error);
});
console.error('Failed to fetch config:', error)
})
}
export function getMinioUrl() {
getMinIoUrl()
.then(response => {
localStorage.setItem('minIoUrl', JSON.stringify(response.data))
})
.catch(error => {
console.error('Failed to fetch config:', error)
})
}

View File

@ -28,12 +28,13 @@ export default {
return this.itemIndex;
},
set(value) {
this.$parent.updateItemIndex(value); //
this.$parent.updateItemIndex(value,this.label); //
}
}
},
data() {
return {
label:null,
labelStudio: null,
annotationsList: [] //
};
@ -130,6 +131,7 @@ export default {
annotation: JSON.stringify(formattedAnnotations),
url: this.fileUrl
});
this.label = JSON.stringify(formattedAnnotations)
this.index++; //
} catch (error) {
console.error('Failed to submit annotation:', error);

View File

@ -72,7 +72,7 @@
<ul>
<li v-for="(item, index) in images" :key="item.fileId" class="list-item">
<div @click="setItem(item, index)">
<input type="checkbox" :checked="item.fileAnnotationStatus==='1'" disabled>
<input type="checkbox" :checked="item.fileAnnotationStatus!=='0'" disabled>
<span :class="{'highlighted': itemIndex === index}" style="font-size: 14px; margin-left: 5px;"
>{{ item.fileName }}</span>
</div>
@ -83,7 +83,7 @@
</div>
<div class="bottom-content-center">
<div>
<custom-label-studio :annotations="annotationResult" :taskId="taskId" :item-index="itemIndex"
<custom-label-studio :annotations="annotationResult" :taskId="taskId || 0" :item-index="itemIndex"
:config="labelConfig" :id="task.id" :file-url="task.data.image"
@update-itemIndex="updateItemIndex"
></custom-label-studio>
@ -114,13 +114,6 @@ export default {
}
},
labelConfig: `
<View>
<Image name="image" value="$image"/>
<RectangleLabels name="label" toName="image">
<Label value="人" background="#ff0000"/>
<Label value="车" background="#00ff00"/>
</RectangleLabels>
</View>
`,
taskId: undefined, // ID
leftIcons: [
@ -137,67 +130,87 @@ export default {
}
},
created() {
this.loadTaskList(); //
this.loadTaskList() //
},
methods: {
//
updateItemIndex(val) {
const item = this.images[val];
this.images[val - 1].fileAnnotationStatus = '1';
this.itemIndex = val;
this.updateTaskData(item);
updateItemIndex(val, data) {
const item = this.images[val]
this.images[val - 1].fileAnnotationStatus = '1'
this.images[val - 1].annotationResult = data
this.itemIndex = val
this.updateTaskData(item)
},
//
loadTaskList() {
getMyNoAnnotatedTask().then(res => {
this.taskList = res.data;
});
this.taskList = res.data
})
},
// ID
selectTask(id) {
this.resetImages();
this.taskId = id;
this.fetchImages();
this.resetImages()
const result = this.taskList.find(item => item.taskId === id)
const labels = result.labels.split(',').map(role => role.trim())
const labelElements = labels
.map((label, index) => `<Label value="${label}" background="${this.getColor(index)}"/>`)
.join('')
this.labelConfig = `<View>
<Image name="image" value="$image"/>
<RectangleLabels name="label" toName="image">
${labelElements}
</RectangleLabels>
</View>`
this.taskId = id
this.fetchImages()
},
getColor(index) {
const randomColor = () => {
const r = Math.floor(Math.random() * 256); // 0-255
const g = Math.floor(Math.random() * 256); // 0-255
const b = Math.floor(Math.random() * 256); // 0-255
return `rgb(${r}, ${g}, ${b})`;
};
return randomColor();
},
//
toggleSelected(type) {
if (this.annotationType === type) return;
this.annotationType = type;
this.resetImages();
this.fetchImages();
if (this.annotationType === type) return
this.annotationType = type
this.resetImages()
this.fetchImages()
},
//
setItem(item, index) {
this.annotationResult = JSON.parse(item.annotationResult);
this.itemIndex = index;
this.updateTaskData(item);
this.annotationResult = JSON.parse(item.annotationResult)
this.itemIndex = index
this.updateTaskData(item)
},
//
resetImages() {
this.images = [];
//this.annotationType = 0;
this.images = []
},
// ID
fetchImages() {
if (!this.taskId) return;
if (!this.taskId) return
getMyAnnotationFiles(this.annotationType, this.taskId).then(response => {
this.itemIndex = 0;
this.images = response.data;
this.updateTaskData(this.images[this.itemIndex]);
});
this.itemIndex = 0
this.images = response.data
this.updateTaskData(this.images[this.itemIndex])
})
},
//
updateTaskData(item) {
this.task.data.image = `http://192.168.0.14:9090/bonus/${item.fileUrl}`;
this.task.id = item.fileId;
this.annotationResult = JSON.parse(item.annotationResult);
let url = JSON.parse(localStorage.getItem('minIoUrl'))
this.task.data.image = `${url.minioUrl}${item.fileUrl}`
this.task.id = item.fileId
this.annotationResult = JSON.parse(item.annotationResult)
}
}
}

View File

@ -72,7 +72,7 @@
<ul>
<li v-for="(item, index) in images" :key="item.fileId" class="list-item">
<div @click="setItem(item, index)">
<input type="checkbox" :checked="item.fileAnnotationStatus==='1'" disabled>
<input type="checkbox" :checked="item.fileAnnotationStatus==='2' || item.fileAnnotationStatus==='3' " disabled>
<span :class="{'highlighted': itemIndex === index}" style="font-size: 14px; margin-left: 5px;"
>{{ item.fileName }}</span>
</div>
@ -83,7 +83,7 @@
</div>
<div class="bottom-content-center">
<div>
<custom-label-studio :annotations="annotationResult" :taskId="taskId" :item-index="itemIndex"
<custom-label-studio :annotations="annotationResult" :taskId="taskId || 0" :item-index="itemIndex"
:config="labelConfig" :id="task.id" :file-url="task.data.image"
@update-itemIndex="updateItemIndex"
></custom-label-studio>
@ -141,7 +141,7 @@ export default {
//
updateItemIndex(val) {
const item = this.images[val];
this.images[val - 1].fileAnnotationStatus = '1';
this.images[val - 1].fileAnnotationStatus = '2';
this.itemIndex = val;
this.updateTaskData(item);
},
@ -154,10 +154,32 @@ export default {
},
// ID
// ID
selectTask(id) {
this.resetImages();
this.taskId = id;
this.fetchImages();
this.resetImages()
const result = this.taskList.find(item => item.taskId === id)
console.log(result)
const labels = result.labels.split(',').map(role => role.trim())
const labelElements = labels
.map((label, index) => `<Label value="${label}" background="${this.getColor(index)}"/>`)
.join('')
this.labelConfig = `<View>
<Image name="image" value="$image"/>
<RectangleLabels name="label" toName="image">
${labelElements}
</RectangleLabels>
</View>`
this.taskId = id
this.fetchImages()
},
getColor(index) {
const randomColor = () => {
const r = Math.floor(Math.random() * 256); // 0-255
const g = Math.floor(Math.random() * 256); // 0-255
const b = Math.floor(Math.random() * 256); // 0-255
return `rgb(${r}, ${g}, ${b})`;
};
return randomColor();
},
//
@ -197,7 +219,8 @@ export default {
//
updateTaskData(item) {
if (item !== undefined){
this.task.data.image = `http://192.168.0.14:9090/bonus/${item.fileUrl}`;
let url = JSON.parse(localStorage.getItem('minIoUrl'))
this.task.data.image = `${url.minioUrl}${item.fileUrl}`;
this.task.id = item.fileId;
this.annotationResult = JSON.parse(item.annotationResult);
}