提交代码

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

View File

@ -1,11 +1,21 @@
import { getConfig } from '@/api/config'; import { getConfig,getMinIoUrl } from '@/api/config'
export function get() { export function get() {
getConfig() getConfig()
.then(response => { .then(response => {
console.log(response) localStorage.setItem('systemConfig', JSON.stringify(response.data))
localStorage.setItem('systemConfig', JSON.stringify(response.data));
}) })
.catch(error => { .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; return this.itemIndex;
}, },
set(value) { set(value) {
this.$parent.updateItemIndex(value); // this.$parent.updateItemIndex(value,this.label); //
} }
} }
}, },
data() { data() {
return { return {
label:null,
labelStudio: null, labelStudio: null,
annotationsList: [] // annotationsList: [] //
}; };
@ -130,6 +131,7 @@ export default {
annotation: JSON.stringify(formattedAnnotations), annotation: JSON.stringify(formattedAnnotations),
url: this.fileUrl url: this.fileUrl
}); });
this.label = JSON.stringify(formattedAnnotations)
this.index++; // this.index++; //
} catch (error) { } catch (error) {
console.error('Failed to submit annotation:', error); console.error('Failed to submit annotation:', error);

View File

@ -72,7 +72,7 @@
<ul> <ul>
<li v-for="(item, index) in images" :key="item.fileId" class="list-item"> <li v-for="(item, index) in images" :key="item.fileId" class="list-item">
<div @click="setItem(item, index)"> <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;" <span :class="{'highlighted': itemIndex === index}" style="font-size: 14px; margin-left: 5px;"
>{{ item.fileName }}</span> >{{ item.fileName }}</span>
</div> </div>
@ -83,7 +83,7 @@
</div> </div>
<div class="bottom-content-center"> <div class="bottom-content-center">
<div> <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" :config="labelConfig" :id="task.id" :file-url="task.data.image"
@update-itemIndex="updateItemIndex" @update-itemIndex="updateItemIndex"
></custom-label-studio> ></custom-label-studio>
@ -114,13 +114,6 @@ export default {
} }
}, },
labelConfig: ` 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 taskId: undefined, // ID
leftIcons: [ leftIcons: [
@ -137,67 +130,87 @@ export default {
} }
}, },
created() { created() {
this.loadTaskList(); // this.loadTaskList() //
}, },
methods: { methods: {
// //
updateItemIndex(val) { updateItemIndex(val, data) {
const item = this.images[val]; const item = this.images[val]
this.images[val - 1].fileAnnotationStatus = '1'; this.images[val - 1].fileAnnotationStatus = '1'
this.itemIndex = val; this.images[val - 1].annotationResult = data
this.updateTaskData(item); this.itemIndex = val
this.updateTaskData(item)
}, },
// //
loadTaskList() { loadTaskList() {
getMyNoAnnotatedTask().then(res => { getMyNoAnnotatedTask().then(res => {
this.taskList = res.data; this.taskList = res.data
}); })
}, },
// ID // ID
selectTask(id) { selectTask(id) {
this.resetImages(); this.resetImages()
this.taskId = id; const result = this.taskList.find(item => item.taskId === id)
this.fetchImages(); 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) { toggleSelected(type) {
if (this.annotationType === type) return; if (this.annotationType === type) return
this.annotationType = type; this.annotationType = type
this.resetImages(); this.resetImages()
this.fetchImages(); this.fetchImages()
}, },
// //
setItem(item, index) { setItem(item, index) {
this.annotationResult = JSON.parse(item.annotationResult); this.annotationResult = JSON.parse(item.annotationResult)
this.itemIndex = index; this.itemIndex = index
this.updateTaskData(item); this.updateTaskData(item)
}, },
// //
resetImages() { resetImages() {
this.images = []; this.images = []
//this.annotationType = 0;
}, },
// ID // ID
fetchImages() { fetchImages() {
if (!this.taskId) return; if (!this.taskId) return
getMyAnnotationFiles(this.annotationType, this.taskId).then(response => { getMyAnnotationFiles(this.annotationType, this.taskId).then(response => {
this.itemIndex = 0; this.itemIndex = 0
this.images = response.data; this.images = response.data
this.updateTaskData(this.images[this.itemIndex]); this.updateTaskData(this.images[this.itemIndex])
}); })
}, },
// //
updateTaskData(item) { updateTaskData(item) {
this.task.data.image = `http://192.168.0.14:9090/bonus/${item.fileUrl}`; let url = JSON.parse(localStorage.getItem('minIoUrl'))
this.task.id = item.fileId; this.task.data.image = `${url.minioUrl}${item.fileUrl}`
this.annotationResult = JSON.parse(item.annotationResult); this.task.id = item.fileId
this.annotationResult = JSON.parse(item.annotationResult)
} }
} }
} }

View File

@ -72,7 +72,7 @@
<ul> <ul>
<li v-for="(item, index) in images" :key="item.fileId" class="list-item"> <li v-for="(item, index) in images" :key="item.fileId" class="list-item">
<div @click="setItem(item, index)"> <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;" <span :class="{'highlighted': itemIndex === index}" style="font-size: 14px; margin-left: 5px;"
>{{ item.fileName }}</span> >{{ item.fileName }}</span>
</div> </div>
@ -83,7 +83,7 @@
</div> </div>
<div class="bottom-content-center"> <div class="bottom-content-center">
<div> <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" :config="labelConfig" :id="task.id" :file-url="task.data.image"
@update-itemIndex="updateItemIndex" @update-itemIndex="updateItemIndex"
></custom-label-studio> ></custom-label-studio>
@ -141,7 +141,7 @@ export default {
// //
updateItemIndex(val) { updateItemIndex(val) {
const item = this.images[val]; const item = this.images[val];
this.images[val - 1].fileAnnotationStatus = '1'; this.images[val - 1].fileAnnotationStatus = '2';
this.itemIndex = val; this.itemIndex = val;
this.updateTaskData(item); this.updateTaskData(item);
}, },
@ -154,10 +154,32 @@ export default {
}, },
// ID // ID
// ID
selectTask(id) { selectTask(id) {
this.resetImages(); this.resetImages()
this.taskId = id; const result = this.taskList.find(item => item.taskId === id)
this.fetchImages(); 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) { updateTaskData(item) {
if (item !== undefined){ 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.task.id = item.fileId;
this.annotationResult = JSON.parse(item.annotationResult); this.annotationResult = JSON.parse(item.annotationResult);
} }