fix: lang option for install command

This commit is contained in:
chenos 2022-04-24 23:17:42 +08:00
parent c1f94d3d1b
commit 3750484cbc
4 changed files with 19 additions and 10 deletions

View File

@ -4,11 +4,13 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import { useACLRoleContext } from '../acl';
import { useAPIClient } from '../api-client';
import { useCompile } from '../schema-component';
import { useCurrentUserContext } from './CurrentUserProvider';
const useCurrentRoles = () => {
const { allowAnonymous } = useACLRoleContext();
const { data } = useCurrentUserContext();
const compile = useCompile();
const options = (data?.data?.roles || []).map((item) => {
return {
title: item.title,
@ -21,7 +23,7 @@ const useCurrentRoles = () => {
name: 'anonymous',
});
}
return options;
return compile(options);
};
export const SwitchRole = () => {

View File

@ -1,7 +1,8 @@
export { AppManager } from './app-manager';
export * from './application';
export { PluginManager } from './plugin-manager';
export { Application as default } from './application';
export * as middlewares from './middlewares';
export * from './plugin';
export { Application as default } from './application';
export { AppManager } from './app-manager';
export * from './plugin-manager';
export * from './read-config';

View File

@ -9,14 +9,11 @@ export class ClientPlugin extends Plugin {
const cmd = this.app.findCommand('install');
if (cmd) {
cmd.option('--import-demo');
cmd.option('--lang [lang]');
}
this.app.on('afterInstall', async (app, options) => {
const [opts] = options?.cliArgs || [{}];
if (opts?.importDemo) {
}
if (opts?.lang) {
//
}
});
}

View File

@ -1,12 +1,14 @@
import { skip } from '@nocobase/acl';
import { Plugin } from '@nocobase/server';
import { InstallOptions, Plugin } from '@nocobase/server';
import { resolve } from 'path';
export class SystemSettingsPlugin extends Plugin {
async install() {
async install(options: InstallOptions) {
const [opts] = options.cliArgs;
await this.db.getRepository('systemSettings').create({
values: {
title: 'NocoBase',
appLang: opts?.lang || 'en-US',
logo: {
title: 'nocobase-logo',
filename: '682e5ad037dd02a0fe4800a3e91c283b.png',
@ -18,6 +20,13 @@ export class SystemSettingsPlugin extends Plugin {
});
}
beforeLoad() {
const cmd = this.app.findCommand('install');
if (cmd) {
cmd.option('--lang [lang]');
}
}
async load() {
await this.app.db.import({
directory: resolve(__dirname, 'collections'),