mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-28 16:17:02 +00:00
feat: image light ocr (#7224)
* feat: image light ocr * feat: optimize code * feat: update code * feat: update imagelight version --------- Co-authored-by: 杨国璇 <ygx@Hello-word.local>
This commit is contained in:
@@ -7,9 +7,7 @@ import { SYSTEM_FOLDERS } from '../../constants';
|
||||
import Column from '../model/column';
|
||||
import { normalizeFields } from '../components/metadata-details/utils';
|
||||
import { CellType, EVENT_BUS_TYPE, PREDEFINED_COLUMN_KEYS, PRIVATE_COLUMN_KEY } from '../constants';
|
||||
import { getCellValueByColumn, getOptionName, getColumnOptionNamesByIds, getColumnOptionNameById, getRecordIdFromRecord,
|
||||
getFileObjIdFromRecord
|
||||
} from '../utils/cell';
|
||||
import { getCellValueByColumn, getOptionName, getColumnOptionNamesByIds, getColumnOptionNameById, getRecordIdFromRecord } from '../utils/cell';
|
||||
import tagsAPI from '../../tag/api';
|
||||
import { getColumnByKey, getColumnOptions, getColumnOriginName } from '../utils/column';
|
||||
import ObjectUtils from '../utils/object-utils';
|
||||
@@ -59,19 +57,18 @@ export const MetadataDetailsProvider = ({ repoID, repoInfo, path, dirent, dirent
|
||||
|
||||
const onChange = useCallback((fieldKey, newValue) => {
|
||||
const field = getColumnByKey(originColumns, fieldKey);
|
||||
const fileName = getColumnOriginName(field);
|
||||
const columnName = getColumnOriginName(field);
|
||||
const recordId = getRecordIdFromRecord(record);
|
||||
const fileObjId = getFileObjIdFromRecord(record);
|
||||
let update = { [fileName]: newValue };
|
||||
let update = { [columnName]: newValue };
|
||||
if (field.type === CellType.SINGLE_SELECT) {
|
||||
update = { [fileName]: getColumnOptionNameById(field, newValue) };
|
||||
update = { [columnName]: getColumnOptionNameById(field, newValue) };
|
||||
} else if (field.type === CellType.MULTIPLE_SELECT) {
|
||||
update = { [fileName]: newValue ? getColumnOptionNamesByIds(field, newValue) : [] };
|
||||
update = { [columnName]: newValue ? getColumnOptionNamesByIds(field, newValue) : [] };
|
||||
}
|
||||
metadataAPI.modifyRecord(repoID, recordId, update, fileObjId).then(res => {
|
||||
metadataAPI.modifyRecord(repoID, { recordId }, update).then(res => {
|
||||
setRecord({ ...record, ...update });
|
||||
if (window?.sfMetadataContext?.eventBus) {
|
||||
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.LOCAL_RECORD_CHANGED, recordId, update);
|
||||
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.LOCAL_RECORD_CHANGED, { recordId }, update);
|
||||
}
|
||||
}).catch(error => {
|
||||
const errorMsg = Utils.getErrorMsg(error);
|
||||
@@ -98,7 +95,7 @@ export const MetadataDetailsProvider = ({ repoID, repoInfo, path, dirent, dirent
|
||||
const oldValue = getCellValueByColumn(record, newField) || [];
|
||||
update = { [fileName]: [...oldValue, newOption.name] };
|
||||
}
|
||||
return metadataAPI.modifyRecord(repoID, record._id, update, record._obj_id);
|
||||
return metadataAPI.modifyRecord(repoID, { recordId: record._id }, update);
|
||||
}).then(res => {
|
||||
setOriginColumns(newColumns);
|
||||
setRecord({ ...record, ...update });
|
||||
@@ -116,7 +113,7 @@ export const MetadataDetailsProvider = ({ repoID, repoInfo, path, dirent, dirent
|
||||
const update = { [PRIVATE_COLUMN_KEY.TAGS]: newValue };
|
||||
setRecord({ ...record, ...update });
|
||||
if (window?.sfMetadataContext?.eventBus) {
|
||||
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.LOCAL_RECORD_CHANGED, record_id, update);
|
||||
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.LOCAL_RECORD_CHANGED, { recordId: record_id }, update);
|
||||
}
|
||||
}).catch(error => {
|
||||
const errorMsg = Utils.getErrorMsg(error);
|
||||
@@ -164,7 +161,7 @@ export const MetadataDetailsProvider = ({ repoID, repoInfo, path, dirent, dirent
|
||||
if (!parentDir.startsWith('/')) {
|
||||
parentDir = '/' + parentDir;
|
||||
}
|
||||
metadataAPI.getMetadataRecordInfo(repoID, parentDir, fileName).then(res => {
|
||||
metadataAPI.getRecord(repoID, { parentDir, fileName }).then(res => {
|
||||
const { results, metadata } = res.data;
|
||||
const record = Array.isArray(results) && results.length > 0 ? results[0] : {};
|
||||
const columns = normalizeFields(metadata).map(field => new Column(field));
|
||||
|
Reference in New Issue
Block a user