diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts
index ce619e913..df7633d6b 100644
--- a/packages/api/src/index.ts
+++ b/packages/api/src/index.ts
@@ -63,7 +63,7 @@ const plugins = [
'@nocobase/plugin-file-manager',
'@nocobase/plugin-system-settings',
'@nocobase/plugin-users',
- '@nocobase/plugin-acl',
+ // '@nocobase/plugin-acl',
'@nocobase/plugin-china-region',
];
diff --git a/packages/app/src/pages/apiClient.ts b/packages/app/src/pages/apiClient.ts
index 47135015d..105a0033b 100644
--- a/packages/app/src/pages/apiClient.ts
+++ b/packages/app/src/pages/apiClient.ts
@@ -1,10 +1,9 @@
import { APIClient } from '@nocobase/client';
-import mock from './mock';
const apiClient = new APIClient({
- baseURL: `${location.protocol}//${location.host}/api/`,
+ baseURL: `http://localhost:3000/api/`,
});
-mock(apiClient);
+// mock(apiClient);
export default apiClient;
diff --git a/packages/app/src/pages/index.tsx b/packages/app/src/pages/index.tsx
index 593f97439..bc214801d 100644
--- a/packages/app/src/pages/index.tsx
+++ b/packages/app/src/pages/index.tsx
@@ -47,7 +47,7 @@ const providers = [
const App = compose(...providers)(() => {
const { data, loading } = useRequest({
- url: 'routes:getAccessible',
+ url: 'uiRoutes:getAccessible',
});
if (loading) {
return ;
diff --git a/packages/app/src/pages/mock.ts b/packages/app/src/pages/mock.ts
index 4399306d7..b6baf047a 100644
--- a/packages/app/src/pages/mock.ts
+++ b/packages/app/src/pages/mock.ts
@@ -9,7 +9,7 @@ export default (apiClient: APIClient) => {
data: { lang: 'en-US' },
});
- mock.onGet('/system_settings:get').reply(200, {
+ mock.onGet('/systemSettings:get/1').reply(200, {
data: {
title: 'NocoBase',
},
diff --git a/packages/client/src/application/demos/demo2/mock.ts b/packages/client/src/application/demos/demo2/mock.ts
index 1cc54e16d..fa9799184 100644
--- a/packages/client/src/application/demos/demo2/mock.ts
+++ b/packages/client/src/application/demos/demo2/mock.ts
@@ -9,7 +9,7 @@ export default (apiClient: APIClient) => {
data: { lang: 'en-US' },
});
- mock.onGet('/system_settings:get').reply(200, {
+ mock.onGet('/systemSettings:get/1').reply(200, {
data: {
title: 'NocoBase',
},
@@ -135,6 +135,33 @@ export default (apiClient: APIClient) => {
return [200, response];
});
+ mock.onGet(/\/ui_schemas\:getProperties\/(\w+)/).reply(function (config) {
+ // const name = config.url.split('/').pop();
+ // console.log(name);
+ // if (jsonSchema[name]) {
+ // return [200, { data: jsonSchema[name] }];
+ // }
+ const response = {
+ data: {
+ type: 'void',
+ name: uid(),
+ 'x-uid': uid(),
+ 'x-component': 'Page',
+ properties: {
+ [uid()]: {
+ type: 'void',
+ name: 'grid1',
+ 'x-component': 'Grid',
+ 'x-item-initializer': 'Grid.AddBlockItem',
+ 'x-uid': uid(),
+ properties: {},
+ },
+ },
+ },
+ };
+ return [200, response];
+ });
+
mock.onGet('/routes:getAccessible').reply(200, {
data: [
{
diff --git a/packages/client/src/route-switch/antd/admin-layout/index.tsx b/packages/client/src/route-switch/antd/admin-layout/index.tsx
index 0c6ef0ebc..517706f41 100644
--- a/packages/client/src/route-switch/antd/admin-layout/index.tsx
+++ b/packages/client/src/route-switch/antd/admin-layout/index.tsx
@@ -75,7 +75,7 @@ export function AdminLayout(props: any) {
-
+
diff --git a/packages/client/src/schema-component/antd/menu/Menu.tsx b/packages/client/src/schema-component/antd/menu/Menu.tsx
index 713dc9b94..c05a60647 100644
--- a/packages/client/src/schema-component/antd/menu/Menu.tsx
+++ b/packages/client/src/schema-component/antd/menu/Menu.tsx
@@ -20,7 +20,7 @@ const useSideMenuRef = () => {
return;
}
return scope[scopeKey];
-}
+};
export const Menu: ComposedMenu = observer((props) => {
let {
@@ -32,7 +32,6 @@ export const Menu: ComposedMenu = observer((props) => {
defaultOpenKeys: dOpenKeys,
...others
} = props;
- console.log('defaultSelectedUid', defaultSelectedUid)
const schema = useFieldSchema();
const sideMenuRef = useSideMenuRef();
const [defaultSelectedKeys, setDefaultSelectedKeys] = useState(() => {
@@ -52,8 +51,9 @@ export const Menu: ComposedMenu = observer((props) => {
return dOpenKeys;
});
const [sideMenuSchema, setSideMenuSchema] = useState(() => {
- if (mode === 'mix' && defaultSelectedKeys[0]) {
- const s = schema.properties?.[defaultSelectedKeys[0]];
+ const key = defaultSelectedKeys?.[0] || null;
+ if (mode === 'mix' && key) {
+ const s = schema.properties?.[key];
if (s['x-component'] === 'Menu.SubMenu') {
return s;
}
diff --git a/packages/client/src/schema-component/core/RemoteSchemaComponent.tsx b/packages/client/src/schema-component/core/RemoteSchemaComponent.tsx
index 718cc203b..e15884201 100644
--- a/packages/client/src/schema-component/core/RemoteSchemaComponent.tsx
+++ b/packages/client/src/schema-component/core/RemoteSchemaComponent.tsx
@@ -12,25 +12,24 @@ export interface RemoteSchemaComponentProps {
schemaTransform?: (schema: Schema) => Schema;
render?: any;
hidden?: any;
+ onlyRenderProperties?: boolean;
}
const defaultTransform = (s: Schema) => s;
const RequestSchemaComponent: React.FC = (props) => {
- const { hidden, scope, uid, onSuccess, schemaTransform = defaultTransform } = props;
+ const { onlyRenderProperties, hidden, scope, uid, onSuccess, schemaTransform = defaultTransform } = props;
const { reset } = useSchemaComponentContext();
- const { data, loading } = useRequest(
- {
- url: `/ui_schemas:getJsonSchema/${uid}`,
+ const conf = {
+ url: `/ui_schemas:${onlyRenderProperties ? 'getProperties' : 'getJsonSchema'}/${uid}`,
+ };
+ const { data, loading } = useRequest(conf, {
+ refreshDeps: [uid],
+ onSuccess(data) {
+ onSuccess && onSuccess(data);
+ reset && reset();
},
- {
- refreshDeps: [uid],
- onSuccess(data) {
- onSuccess && onSuccess(data);
- reset && reset();
- },
- },
- );
+ });
if (loading) {
return ;
diff --git a/packages/client/src/system-settings/SystemSettingsProvider.tsx b/packages/client/src/system-settings/SystemSettingsProvider.tsx
index d14c87283..a7ecbd2a6 100644
--- a/packages/client/src/system-settings/SystemSettingsProvider.tsx
+++ b/packages/client/src/system-settings/SystemSettingsProvider.tsx
@@ -11,11 +11,7 @@ export const useSystemSettings = () => {
export const SystemSettingsProvider: React.FC = (props) => {
const result = useRequest({
- resource: 'system_settings',
- action: 'get',
- params: {
- filterByTk: 1,
- },
+ url: 'systemSettings:get/1',
});
if (result.loading) {
return ;
diff --git a/packages/client/src/system-settings/demos/demo1.tsx b/packages/client/src/system-settings/demos/demo1.tsx
index 5fb03052d..535974319 100644
--- a/packages/client/src/system-settings/demos/demo1.tsx
+++ b/packages/client/src/system-settings/demos/demo1.tsx
@@ -16,7 +16,7 @@ const apiClient = new APIClient();
const mock = new MockAdapter(apiClient.axios);
-mock.onGet('/system_settings:get').reply(200, {
+mock.onGet('/systemSettings:get/1').reply(200, {
data: {
title: 'NocoBase',
},
diff --git a/packages/plugin-ui-routes-storage/src/index.ts b/packages/plugin-ui-routes-storage/src/index.ts
index d4975e388..12526c35e 100644
--- a/packages/plugin-ui-routes-storage/src/index.ts
+++ b/packages/plugin-ui-routes-storage/src/index.ts
@@ -45,6 +45,21 @@ export class UiRoutesStoragePlugin extends Plugin {
title: 'Menu Item u7',
'x-component': 'Menu.Item',
'x-component-props': {},
+ properties: {
+ page1: {
+ type: 'void',
+ 'x-component': 'Page',
+ 'x-async': true,
+ properties: {
+ grid1: {
+ type: 'void',
+ 'x-component': 'Grid',
+ 'x-item-initializer': 'Grid.AddBlockItem',
+ properties: {},
+ },
+ },
+ }
+ }
},
item8: {
type: 'void',
diff --git a/packages/plugin-ui-schema-storage/src/server.ts b/packages/plugin-ui-schema-storage/src/server.ts
index 830f22529..ca58f7c1b 100644
--- a/packages/plugin-ui-schema-storage/src/server.ts
+++ b/packages/plugin-ui-schema-storage/src/server.ts
@@ -1,5 +1,6 @@
import { MagicAttributeModel } from '@nocobase/database';
import { Plugin } from '@nocobase/server';
+import { uid } from '@nocobase/utils';
import path from 'path';
import { uiSchemaActions } from './actions/ui-schema-action';
import { UiSchemaModel } from './model';
@@ -27,6 +28,9 @@ export class UiSchemaStoragePlugin extends Plugin {
db.on('ui_schemas.beforeCreate', function setUid(model) {
model.set('uid', model.get('x-uid'));
+ if (!model.get('name')) {
+ model.set('name', uid());
+ }
});
db.on('ui_schemas.afterCreate', async function insertSchema(model, options) {