diff --git a/src/admin/index.ts b/src/admin/index.ts index b8c91b3..c69a8f8 100644 --- a/src/admin/index.ts +++ b/src/admin/index.ts @@ -2,3 +2,6 @@ import './router.ts'; import './manager.ts'; import './npm.ts'; import './core.ts'; +import { app, appendTo } from './app.ts'; + +export { app, appendTo }; diff --git a/src/admin/models/page.ts b/src/admin/models/page.ts new file mode 100644 index 0000000..0338fbd --- /dev/null +++ b/src/admin/models/page.ts @@ -0,0 +1,66 @@ +import { sequelize } from '../modules/sequelize.ts'; +import { DataTypes, Model } from 'sequelize'; + +type PageNodeData = { + id: string; + type: string; + data: { + label?: string; // 容器 开始 结束 + // 容器上的属性 + cid?: string; // 容器code id + }; + + [key: string]: any; +}; + +export interface RouterGraphData { + edges: any[]; + nodes: PageNodeData[]; + viewport: any; + [key: string]: any; +} + +/** + * 页面数据 + */ +export class RouterGraphModel extends Model { + declare id: string; + declare title: string; + declare description: string; + declare type: string; + declare data: RouterGraphData; +} +RouterGraphModel.init( + { + id: { + type: DataTypes.UUID, + primaryKey: true, + defaultValue: DataTypes.UUIDV4, + comment: 'id', + }, + title: { + type: DataTypes.STRING, + defaultValue: '', + }, + description: { + type: DataTypes.TEXT, + defaultValue: '', + }, + type: { + type: DataTypes.STRING, + defaultValue: '', + }, + data: { + type: DataTypes.JSON, + defaultValue: {}, + }, + }, + { + sequelize, + tableName: 'cf_router_graph', + paranoid: true, + }, +); +RouterGraphModel.sync({ alter: true, logging: false }).catch((e) => { + console.error('RouterGraphModel sync', e); +}); diff --git a/src/route.ts b/src/route.ts index 7c46c7a..4d10593 100644 --- a/src/route.ts +++ b/src/route.ts @@ -1,5 +1,5 @@ import './demo/index.ts'; -import './admin/index.ts'; +import { app as adminApp, appendTo } from './admin/index.ts'; import './routes/index.ts'; import { app } from './app.ts'; import { useConfig } from '@abearxiong/use-config'; @@ -11,3 +11,6 @@ createAuthRoute({ secret: config.tokenSecret, }); +// app.importApp(adminApp); + +appendTo(app);