temp 更新

This commit is contained in:
2025-03-06 18:32:14 +08:00
parent fe6ce9f97e
commit b5fc5d279e
6 changed files with 52 additions and 34 deletions

View File

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

View File

@@ -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,

View File

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

View File

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