temp 更新
This commit is contained in:
@@ -287,7 +287,11 @@
|
||||
|
||||
// useContextKey('UserModel', () => UserServices);
|
||||
|
||||
import { User, UserServices, UserInit } from '@kevisual/code-center-module/models';
|
||||
export { User, UserServices };
|
||||
|
||||
UserInit();
|
||||
import { User, UserInit } from '@kevisual/code-center-module';
|
||||
export { User, UserInit };
|
||||
UserInit(null, null, {
|
||||
alter: true,
|
||||
logging: true,
|
||||
}).catch((e) => {
|
||||
console.error('User sync', e);
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ export interface AppData {
|
||||
orgs?: string[];
|
||||
};
|
||||
}
|
||||
export type AppType = 'web-single' | 'web-module';
|
||||
export type AppType = 'web-single' | 'web-module'; // 可以做到网页代理
|
||||
export enum AppStatus {
|
||||
running = 'running',
|
||||
stop = 'stop',
|
||||
@@ -32,6 +32,8 @@ export class AppModel extends Model {
|
||||
declare key: string;
|
||||
declare type: string;
|
||||
declare uid: string;
|
||||
declare pid: string;
|
||||
declare proxy: boolean;
|
||||
declare user: string;
|
||||
declare status: string;
|
||||
}
|
||||
@@ -79,6 +81,14 @@ AppModel.init(
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
pid: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
proxy: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false,
|
||||
},
|
||||
user: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UserServices } from '@/models/user.ts';
|
||||
import { User } from '@/models/user.ts';
|
||||
|
||||
import { app } from '@/app.ts';
|
||||
|
||||
@@ -12,7 +12,7 @@ app
|
||||
if (!password) {
|
||||
ctx.throw(500, 'root password are required');
|
||||
}
|
||||
const res = await UserServices.initializeUser(password);
|
||||
const res = await User.initializeUser(password);
|
||||
ctx.body = res;
|
||||
})
|
||||
.addTo(app);
|
||||
@@ -28,7 +28,7 @@ app
|
||||
if (!username && username.startsWith('demo')) {
|
||||
ctx.throw(500, 'username are required, and must start with demo');
|
||||
}
|
||||
const res = await UserServices.createDemoUser(username, password);
|
||||
const res = await User.createDemoUser(username, password);
|
||||
ctx.body = res;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { User } from '../models/user.ts';
|
||||
import { sequelize } from '../modules/sequelize.ts';
|
||||
import { User, UserInit } from '../models/user.ts';
|
||||
|
||||
// User.sync({ alter: true, logging: true }).then(() => {
|
||||
// console.log('sync user done');
|
||||
@@ -10,3 +11,16 @@ import { User } from '../models/user.ts';
|
||||
// console.log('sync user done');
|
||||
// }
|
||||
// }
|
||||
export const main = async () => {
|
||||
|
||||
await UserInit(null, null, {
|
||||
alter: true,
|
||||
logging: false,
|
||||
});
|
||||
const user = await User.findAll({});
|
||||
for (const u of user) {
|
||||
console.log(u.username, u.type);
|
||||
}
|
||||
};
|
||||
|
||||
main();
|
||||
|
||||
Reference in New Issue
Block a user