Skip to content

Commit 1de0ce5

Browse files
authored
fix: use the built-in logo file (nocobase#5032)
* fix: logo url * fix: logo with internal url * fix: tz * fix: improve code * fix: tz * fix: tz * fix: test case * fix: tz
1 parent 685f076 commit 1de0ce5

File tree

5 files changed

+36
-52
lines changed

5 files changed

+36
-52
lines changed
10.9 KB
Loading

packages/core/cli/src/util.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ function areTimeZonesEqual(timeZone1, timeZone2) {
313313
}
314314
timeZone1 = getTimezonesByOffset(timeZone1);
315315
timeZone2 = getTimezonesByOffset(timeZone2);
316-
return moment.tz(timeZone1).format() === moment.tz(timeZone2).format();
316+
return moment.tz(timeZone1).format('Z') === moment.tz(timeZone2).format('Z');
317317
}
318318

319319
exports.initEnv = function initEnv() {
@@ -406,6 +406,10 @@ exports.initEnv = function initEnv() {
406406
process.env.DB_TIMEZONE = process.env.TZ;
407407
}
408408

409+
if (!/^[+-]\d{1,2}:\d{2}$/.test(process.env.DB_TIMEZONE)) {
410+
process.env.DB_TIMEZONE = moment.tz(process.env.DB_TIMEZONE).format('Z');
411+
}
412+
409413
if (!areTimeZonesEqual(process.env.DB_TIMEZONE, process.env.TZ)) {
410414
throw new Error(
411415
`process.env.DB_TIMEZONE="${process.env.DB_TIMEZONE}" and process.env.TZ="${process.env.TZ}" are different`,

packages/plugins/@nocobase/plugin-collection-tree/src/server/__tests__/sync.test.ts

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* For more information, please refer to: https://www.nocobase.com/agreement.
88
*/
99

10+
import { Repository } from '@nocobase/database';
1011
import { MockDatabase, MockServer, createMockServer } from '@nocobase/test';
1112
import Migration from '../migrations/20240802141435-collection-tree';
12-
import { Repository } from '@nocobase/database';
1313

1414
describe('tree collection sync', async () => {
1515
let app: MockServer;
@@ -77,38 +77,25 @@ describe('collection tree migrate test', () => {
7777
{
7878
type: 'belongsTo',
7979
name: 'parent',
80+
foreignKey: 'parentId',
81+
target: 'test_tree',
8082
treeParent: true,
8183
},
8284
{
8385
type: 'hasMany',
8486
name: 'children',
87+
foreignKey: 'parentId',
88+
target: 'test_tree',
8589
treeChildren: true,
8690
},
8791
],
8892
},
93+
context: {},
8994
});
90-
const collection = db.collection({
91-
name: 'test_tree',
92-
tree: 'adjacency-list',
93-
fields: [
94-
{
95-
type: 'string',
96-
name: 'name',
97-
},
98-
{
99-
type: 'belongsTo',
100-
name: 'parent',
101-
treeParent: true,
102-
},
103-
{
104-
type: 'hasMany',
105-
name: 'children',
106-
treeChildren: true,
107-
},
108-
],
109-
});
110-
await collection.sync();
111-
await collection.repository.create({
95+
await app.db.getCollection('test_tree').model.truncate();
96+
await app.db.getCollection('main_test_tree_path').model.truncate();
97+
const repository = app.db.getRepository('test_tree');
98+
await repository.create({
11299
values: [
113100
{
114101
name: 'c1',
@@ -131,7 +118,6 @@ describe('collection tree migrate test', () => {
131118
});
132119

133120
afterEach(async () => {
134-
await app.db.clean({ drop: true });
135121
await app.destroy();
136122
});
137123

@@ -164,26 +150,7 @@ describe('collection tree migrate test', () => {
164150
},
165151
});
166152
expect(p.name).toBe('collection-tree');
167-
const collection1 = db.collection({
168-
name: 'test_tree',
169-
tree: 'adjacency-list',
170-
fields: [
171-
{
172-
type: 'string',
173-
name: 'name',
174-
},
175-
{
176-
type: 'belongsTo',
177-
name: 'parent',
178-
treeParent: true,
179-
},
180-
{
181-
type: 'hasMany',
182-
name: 'children',
183-
treeChildren: true,
184-
},
185-
],
186-
});
153+
const collection1 = db.getCollection('test_tree');
187154
const pathCollection1 = db.getCollection(name);
188155
expect(pathCollection1).toBeTruthy();
189156
expect(await pathCollection1.existsInDb()).toBeTruthy();
Loading

packages/plugins/@nocobase/plugin-system-settings/src/server/server.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* For more information, please refer to: https://www.nocobase.com/agreement.
88
*/
99

10+
import PluginFileManagerServer from '@nocobase/plugin-file-manager';
1011
import { InstallOptions, Plugin } from '@nocobase/server';
1112
import { resolve } from 'path';
1213

@@ -16,18 +17,30 @@ export class PluginSystemSettingsServer extends Plugin {
1617
}
1718

1819
async install(options?: InstallOptions) {
20+
const plugin = this.pm.get('file-manager') as PluginFileManagerServer;
21+
const logo = plugin
22+
? await plugin.createFileRecord({
23+
filePath: resolve(__dirname, './logo.png'),
24+
collectionName: 'attachments',
25+
values: {
26+
title: 'nocobase-logo',
27+
extname: '.png',
28+
mimetype: 'image/png',
29+
},
30+
})
31+
: {
32+
title: 'nocobase-logo',
33+
filename: '682e5ad037dd02a0fe4800a3e91c283b.png',
34+
extname: '.png',
35+
mimetype: 'image/png',
36+
url: '/nocobase.png',
37+
};
1938
await this.db.getRepository('systemSettings').create({
2039
values: {
2140
title: 'NocoBase',
2241
appLang: this.getInitAppLang(options),
2342
enabledLanguages: [this.getInitAppLang(options)],
24-
logo: {
25-
title: 'nocobase-logo',
26-
filename: '682e5ad037dd02a0fe4800a3e91c283b.png',
27-
extname: '.png',
28-
mimetype: 'image/png',
29-
url: 'https://nocobase.oss-cn-beijing.aliyuncs.com/682e5ad037dd02a0fe4800a3e91c283b.png',
30-
},
43+
logo,
3144
},
3245
});
3346
}

0 commit comments

Comments
 (0)