change admin route

This commit is contained in:
xion 2024-10-26 18:48:09 +08:00
parent 7f410fbaaa
commit c6539439e9
3 changed files with 73 additions and 1 deletions

View File

@ -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 };

66
src/admin/models/page.ts Normal file
View File

@ -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);
});

View File

@ -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);