diff --git a/packages/plugin-pages/src/actions/getView.ts b/packages/plugin-pages/src/actions/getView.ts index 58acca9a3..4f218a0ec 100644 --- a/packages/plugin-pages/src/actions/getView.ts +++ b/packages/plugin-pages/src/actions/getView.ts @@ -1,5 +1,6 @@ import { Model, ModelCtor, BELONGSTOMANY } from '@nocobase/database'; import { get, set, isString } from 'lodash'; +import { Op } from 'sequelize'; const transforms = { table: async (fields: Model[], context?: any) => { @@ -294,10 +295,14 @@ export default async (ctx, next) => { } const defaultTabs = await collection.getTabs({ where: { - default: true, + id : {[Op.in]: permissions.tabs}, }, + order: [['sort', 'asc']], }); - view.setDataValue('defaultTabName', get(defaultTabs, [0, 'name'])); + + const defaultTab = defaultTabs.find(tab => tab.default) || get(defaultTabs, [0]); + + view.setDataValue('defaultTabName', get(defaultTab, ['name'])); if (view.get('type') === 'table') { view.setDataValue('rowViewName', 'form'); }