diff --git a/packages/plugins/@nocobase/plugin-client/src/server/server.ts b/packages/plugins/@nocobase/plugin-client/src/server/server.ts index 1f820d2521..772f268dae 100644 --- a/packages/plugins/@nocobase/plugin-client/src/server/server.ts +++ b/packages/plugins/@nocobase/plugin-client/src/server/server.ts @@ -11,12 +11,12 @@ import { Model, Transaction } from '@nocobase/database'; import PluginLocalizationServer from '@nocobase/plugin-localization'; import { Plugin } from '@nocobase/server'; import { tval } from '@nocobase/utils'; +import _ from 'lodash'; import * as process from 'node:process'; import { resolve } from 'path'; import { getAntdLocale } from './antd'; import { getCronLocale } from './cron'; import { getCronstrueLocale } from './cronstrue'; -import _ from 'lodash'; async function getLang(ctx) { const SystemSetting = ctx.db.getRepository('systemSettings'); @@ -221,7 +221,14 @@ export class PluginClientServer extends Plugin { const createModels = tabs .map((x) => !modelsByRouteId[x.get('id')] && { desktopRouteId: x.get('id'), roleName }) .filter(Boolean); - return await repository.create({ values: createModels, transaction }); + for (const values of createModels) { + await repository.firstOrCreate({ + values, + filterKeys: ['desktopRouteId', 'roleName'], + transaction, + }); + } + return; } if (action === 'remove') { diff --git a/packages/plugins/@nocobase/plugin-mobile/src/server/plugin.ts b/packages/plugins/@nocobase/plugin-mobile/src/server/plugin.ts index 497da23bb4..46f6e58bf1 100644 --- a/packages/plugins/@nocobase/plugin-mobile/src/server/plugin.ts +++ b/packages/plugins/@nocobase/plugin-mobile/src/server/plugin.ts @@ -8,8 +8,8 @@ */ import { Model, Transaction } from '@nocobase/database'; -import { Plugin } from '@nocobase/server'; import PluginLocalizationServer from '@nocobase/plugin-localization'; +import { Plugin } from '@nocobase/server'; import { tval } from '@nocobase/utils'; import _ from 'lodash'; @@ -94,7 +94,14 @@ export class PluginMobileServer extends Plugin { const createModels = tabs .map((x) => !modelsByRouteId[x.get('id')] && { mobileRouteId: x.get('id'), roleName }) .filter(Boolean); - return await repository.create({ values: createModels, transaction }); + for (const values of createModels) { + await repository.firstOrCreate({ + values, + filterKeys: ['mobileRouteId', 'roleName'], + transaction, + }); + } + return; } if (action === 'remove') {