mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
fix: use the built-in logo file (#5032)
* fix: logo url * fix: logo with internal url * fix: tz * fix: improve code * fix: tz * fix: tz * fix: test case * fix: tz
This commit is contained in:
parent
685f0764f1
commit
1de0ce5e1a
BIN
packages/core/app/client/public/nocobase.png
Normal file
BIN
packages/core/app/client/public/nocobase.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@ -313,7 +313,7 @@ function areTimeZonesEqual(timeZone1, timeZone2) {
|
|||||||
}
|
}
|
||||||
timeZone1 = getTimezonesByOffset(timeZone1);
|
timeZone1 = getTimezonesByOffset(timeZone1);
|
||||||
timeZone2 = getTimezonesByOffset(timeZone2);
|
timeZone2 = getTimezonesByOffset(timeZone2);
|
||||||
return moment.tz(timeZone1).format() === moment.tz(timeZone2).format();
|
return moment.tz(timeZone1).format('Z') === moment.tz(timeZone2).format('Z');
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.initEnv = function initEnv() {
|
exports.initEnv = function initEnv() {
|
||||||
@ -406,6 +406,10 @@ exports.initEnv = function initEnv() {
|
|||||||
process.env.DB_TIMEZONE = process.env.TZ;
|
process.env.DB_TIMEZONE = process.env.TZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!/^[+-]\d{1,2}:\d{2}$/.test(process.env.DB_TIMEZONE)) {
|
||||||
|
process.env.DB_TIMEZONE = moment.tz(process.env.DB_TIMEZONE).format('Z');
|
||||||
|
}
|
||||||
|
|
||||||
if (!areTimeZonesEqual(process.env.DB_TIMEZONE, process.env.TZ)) {
|
if (!areTimeZonesEqual(process.env.DB_TIMEZONE, process.env.TZ)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`process.env.DB_TIMEZONE="${process.env.DB_TIMEZONE}" and process.env.TZ="${process.env.TZ}" are different`,
|
`process.env.DB_TIMEZONE="${process.env.DB_TIMEZONE}" and process.env.TZ="${process.env.TZ}" are different`,
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Repository } from '@nocobase/database';
|
||||||
import { MockDatabase, MockServer, createMockServer } from '@nocobase/test';
|
import { MockDatabase, MockServer, createMockServer } from '@nocobase/test';
|
||||||
import Migration from '../migrations/20240802141435-collection-tree';
|
import Migration from '../migrations/20240802141435-collection-tree';
|
||||||
import { Repository } from '@nocobase/database';
|
|
||||||
|
|
||||||
describe('tree collection sync', async () => {
|
describe('tree collection sync', async () => {
|
||||||
let app: MockServer;
|
let app: MockServer;
|
||||||
@ -77,38 +77,25 @@ describe('collection tree migrate test', () => {
|
|||||||
{
|
{
|
||||||
type: 'belongsTo',
|
type: 'belongsTo',
|
||||||
name: 'parent',
|
name: 'parent',
|
||||||
|
foreignKey: 'parentId',
|
||||||
|
target: 'test_tree',
|
||||||
treeParent: true,
|
treeParent: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'hasMany',
|
type: 'hasMany',
|
||||||
name: 'children',
|
name: 'children',
|
||||||
|
foreignKey: 'parentId',
|
||||||
|
target: 'test_tree',
|
||||||
treeChildren: true,
|
treeChildren: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
context: {},
|
||||||
});
|
});
|
||||||
const collection = db.collection({
|
await app.db.getCollection('test_tree').model.truncate();
|
||||||
name: 'test_tree',
|
await app.db.getCollection('main_test_tree_path').model.truncate();
|
||||||
tree: 'adjacency-list',
|
const repository = app.db.getRepository('test_tree');
|
||||||
fields: [
|
await repository.create({
|
||||||
{
|
|
||||||
type: 'string',
|
|
||||||
name: 'name',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'belongsTo',
|
|
||||||
name: 'parent',
|
|
||||||
treeParent: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'hasMany',
|
|
||||||
name: 'children',
|
|
||||||
treeChildren: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
await collection.sync();
|
|
||||||
await collection.repository.create({
|
|
||||||
values: [
|
values: [
|
||||||
{
|
{
|
||||||
name: 'c1',
|
name: 'c1',
|
||||||
@ -131,7 +118,6 @@ describe('collection tree migrate test', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await app.db.clean({ drop: true });
|
|
||||||
await app.destroy();
|
await app.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -164,26 +150,7 @@ describe('collection tree migrate test', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(p.name).toBe('collection-tree');
|
expect(p.name).toBe('collection-tree');
|
||||||
const collection1 = db.collection({
|
const collection1 = db.getCollection('test_tree');
|
||||||
name: 'test_tree',
|
|
||||||
tree: 'adjacency-list',
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
type: 'string',
|
|
||||||
name: 'name',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'belongsTo',
|
|
||||||
name: 'parent',
|
|
||||||
treeParent: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'hasMany',
|
|
||||||
name: 'children',
|
|
||||||
treeChildren: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
const pathCollection1 = db.getCollection(name);
|
const pathCollection1 = db.getCollection(name);
|
||||||
expect(pathCollection1).toBeTruthy();
|
expect(pathCollection1).toBeTruthy();
|
||||||
expect(await pathCollection1.existsInDb()).toBeTruthy();
|
expect(await pathCollection1.existsInDb()).toBeTruthy();
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@ -7,6 +7,7 @@
|
|||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import PluginFileManagerServer from '@nocobase/plugin-file-manager';
|
||||||
import { InstallOptions, Plugin } from '@nocobase/server';
|
import { InstallOptions, Plugin } from '@nocobase/server';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
|
|
||||||
@ -16,18 +17,30 @@ export class PluginSystemSettingsServer extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async install(options?: InstallOptions) {
|
async install(options?: InstallOptions) {
|
||||||
|
const plugin = this.pm.get('file-manager') as PluginFileManagerServer;
|
||||||
|
const logo = plugin
|
||||||
|
? await plugin.createFileRecord({
|
||||||
|
filePath: resolve(__dirname, './logo.png'),
|
||||||
|
collectionName: 'attachments',
|
||||||
|
values: {
|
||||||
|
title: 'nocobase-logo',
|
||||||
|
extname: '.png',
|
||||||
|
mimetype: 'image/png',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
: {
|
||||||
|
title: 'nocobase-logo',
|
||||||
|
filename: '682e5ad037dd02a0fe4800a3e91c283b.png',
|
||||||
|
extname: '.png',
|
||||||
|
mimetype: 'image/png',
|
||||||
|
url: '/nocobase.png',
|
||||||
|
};
|
||||||
await this.db.getRepository('systemSettings').create({
|
await this.db.getRepository('systemSettings').create({
|
||||||
values: {
|
values: {
|
||||||
title: 'NocoBase',
|
title: 'NocoBase',
|
||||||
appLang: this.getInitAppLang(options),
|
appLang: this.getInitAppLang(options),
|
||||||
enabledLanguages: [this.getInitAppLang(options)],
|
enabledLanguages: [this.getInitAppLang(options)],
|
||||||
logo: {
|
logo,
|
||||||
title: 'nocobase-logo',
|
|
||||||
filename: '682e5ad037dd02a0fe4800a3e91c283b.png',
|
|
||||||
extname: '.png',
|
|
||||||
mimetype: 'image/png',
|
|
||||||
url: 'https://nocobase.oss-cn-beijing.aliyuncs.com/682e5ad037dd02a0fe4800a3e91c283b.png',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user