diff --git a/lib/core.ts b/lib/core.ts index 2a030bf..02314c4 100644 --- a/lib/core.ts +++ b/lib/core.ts @@ -253,6 +253,7 @@ export class Manager { export class User extends Model { public id!: number; public username!: string; + public nickname!: string; public admin!: number; public active!: number; public email!: string; @@ -303,6 +304,7 @@ export class User extends Model { const origin = { id: this.id, username: this.username, + nickname: this.nickname, admin: this.admin, active: this.active, email: this.email, @@ -313,10 +315,8 @@ export class User extends Model { // @ts-ignore update_time: this.updateTime }; - if (has(this, 'auths')) { - return { ...origin, auths: get(this, 'auths', []) }; - } else if (has(this, 'groupName')) { - return { ...origin, group_name: get(this, 'groupName', '') }; + if (has(this, 'auths') || has(this, 'groupName')) { + return { ...origin, auths: get(this, 'auths', []), group_name: get(this, 'groupName', '') }; } else { return origin; } diff --git a/lib/interface.ts b/lib/interface.ts index d653ec3..3fa8ee7 100644 --- a/lib/interface.ts +++ b/lib/interface.ts @@ -1,7 +1,5 @@ import Sequelize from 'sequelize'; -import { merge } from 'lodash'; import { UserAdmin, UserActive } from './enums'; -import dayjs from 'dayjs'; import { generate } from './password-hash'; import { config } from './config'; @@ -17,12 +15,10 @@ export let InfoCrudMixin = { paranoid: true, getterMethods: { createTime() { - // @ts-ignore - return dayjs(this.getDataValue('create_time')).unix() * 1000; + return new Date().getTime(); }, updateTime() { - // @ts-ignore - return dayjs(this.getDataValue('update_time')).unix() * 1000; + return new Date().getTime(); } } } @@ -54,7 +50,7 @@ export let UserInterface = { comment: '头像url', get() { // @ts-ignore - return this.getDataValue('avatar') ? config.getItem('siteDomain') + 'assets/' + this.getDataValue('avatar') : null; + return this.getDataValue('avatar') ? config.getItem('siteDomain').replace(/\/+$/, '') + '/assets/' + this.getDataValue('avatar') : null; } }, @@ -105,12 +101,10 @@ export let UserInterface = { return this.getDataValue('active') === UserActive.ACTIVE; }, createTime() { - // @ts-ignore - return dayjs(this.getDataValue('create_time')).unix() * 1000; + return new Date().getTime(); }, updateTime() { - // @ts-ignore - return dayjs(this.getDataValue('update_time')).unix() * 1000; + return new Date().getTime(); } } } @@ -208,8 +202,7 @@ export let LogInterface = { updatedAt: false, getterMethods: { time() { - // @ts-ignore - return dayjs(this.getDataValue('time')).unix() * 1000; + return new Date().getTime(); } } }