fix: i18n

This commit is contained in:
chenos 2025-06-24 09:07:00 +08:00
parent cb208530db
commit 71b2ac3acf
5 changed files with 19 additions and 6 deletions

View File

@ -274,6 +274,9 @@ export class Application {
this.use(DataSourceApplicationProvider, { dataSourceManager: this.dataSourceManager });
this.use(OpenModeProvider);
this.flowEngine.context['app'] = this;
this.flowEngine.context['api'] = this.apiClient;
this.flowEngine.context['i18n'] = this.i18n;
this.flowEngine.context['t'] = this.i18n.t.bind(this.i18n);
this.use(FlowEngineProvider, { engine: this.flowEngine });
this.use(FlowEngineGlobalsContextProvider);
}

View File

@ -32,8 +32,6 @@ export class PluginFlowEngine extends Plugin {
this.flowEngine.registerActions(actions);
const dataSourceManager = new DataSourceManager();
this.flowEngine.context['flowEngine'] = this.flowEngine;
this.flowEngine.context['app'] = this.app;
this.flowEngine.context['api'] = this.app.apiClient;
this.flowEngine.context['dataSourceManager'] = dataSourceManager;
const mainDataSource = new DataSource({
key: 'main',

View File

@ -83,10 +83,10 @@ export class RecordActionModel extends ActionModel {
render() {
const props = { ...this.defaultProps, ...this.props };
const icon = <Icon type={props.icon as any} />;
const icon = props.icon ? <Icon type={props.icon as any} /> : undefined;
return (
<Button style={{ padding: 0, height: 'auto', gap: 0 }} {...props} icon={icon}>
<Button style={{ padding: 0, height: 'auto' }} {...props} icon={icon}>
{props.children || props.title}
</Button>
);

View File

@ -49,7 +49,7 @@ async function getDataSourcesWithCollections(model: FlowModel) {
// 转换为我们需要的格式
return allDataSources.map((dataSource: DataSource) => {
const key = dataSource.key;
const displayName = dataSource.options.displayName || dataSource.key;
const displayName = dataSource.displayName || dataSource.key;
// 从 collectionManager 获取 collections
const collections: Collection[] = dataSource.getCollections();

View File

@ -83,6 +83,14 @@ export class DataSource {
this.collectionManager = new CollectionManager(this);
}
get displayName() {
return this.options.displayName
? Schema.compile(this.options.displayName, {
t: (text) => text,
})
: this.key;
}
get key() {
return this.options.key;
}
@ -244,7 +252,11 @@ export class Collection {
}
get title() {
return this.options.title || this.name;
return this.options.title
? Schema.compile(this.options.title, {
t: (text) => text,
})
: this.name;
}
initInherits() {