fix(plugin-file-manager): increase url length (#6275)

* fix(plugin-file-manager): increase url length

* fix(client): fix null value
This commit is contained in:
Junyi 2025-02-24 22:53:57 +08:00 committed by GitHub
parent 7857993dcd
commit cdcea99e30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 58 additions and 1 deletions

View File

@ -389,7 +389,7 @@ export function Uploader({ rules, ...props }: UploadProps) {
if (pendingFiles.length) { if (pendingFiles.length) {
setUploadedList(valueList); setUploadedList(valueList);
} else { } else {
onChange?.([...value, ...valueList]); onChange?.([...(value || []), ...valueList]);
setUploadedList([]); setUploadedList([]);
} }
} }

View File

@ -104,6 +104,7 @@ export class FileCollectionTemplate extends CollectionTemplate {
type: 'string', type: 'string',
name: 'url', name: 'url',
deletable: false, deletable: false,
length: 1024,
uiSchema: { uiSchema: {
type: 'string', type: 'string',
title: `{{t("URL")}}`, title: `{{t("URL")}}`,

View File

@ -70,6 +70,7 @@ export default defineCollection({
comment: '网络访问地址', comment: '网络访问地址',
type: 'string', type: 'string',
name: 'url', name: 'url',
length: 1024,
// formula: '{{ storage.baseUrl }}{{ path }}/{{ filename }}' // formula: '{{ storage.baseUrl }}{{ path }}/{{ filename }}'
}, },
], ],

View File

@ -0,0 +1,55 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { DataTypes } from 'sequelize';
import { Migration } from '@nocobase/server';
export default class extends Migration {
on = 'afterLoad'; // 'beforeLoad' or 'afterLoad'
appVersion = '<1.5.14';
async up() {
const queryInterface = this.db.sequelize.getQueryInterface();
const CollectionRepo = this.db.getRepository('collections');
const FieldRepo = this.db.getRepository('fields');
await this.db.sequelize.transaction(async (transaction) => {
const collections = await CollectionRepo.find({
filter: {
'options.template': 'file',
},
transaction,
});
collections.push({
name: 'attachments',
});
for (const item of collections) {
const collection = this.db.getCollection(item.name) || this.db.collection(item);
const tableName = collection.getTableNameWithSchema();
await queryInterface.changeColumn(
tableName,
'url',
{
type: DataTypes.STRING(1024),
},
{ transaction },
);
await FieldRepo.update({
filter: {
collectionName: item.name,
name: 'url',
},
values: {
length: 1024,
},
transaction,
});
}
});
}
}