优化类型提示

This commit is contained in:
COOL 2023-04-15 18:27:11 +08:00
parent c4b1de03f6
commit 56c288324b
4 changed files with 8 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@cool-midway/core", "name": "@cool-midway/core",
"version": "6.0.2", "version": "6.0.3",
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "index.d.ts", "typings": "index.d.ts",

View File

@ -63,7 +63,7 @@ export interface CoolConfig {
qiniu?: QINIUConfig; qiniu?: QINIUConfig;
}; };
/** IOT 配置 */ /** IOT 配置 */
iot: CoolIotConfig; iot?: CoolIotConfig;
} }
export interface CoolRpcConfig { export interface CoolRpcConfig {

View File

@ -1,6 +1,6 @@
{ {
"name": "@cool-midway/core", "name": "@cool-midway/core",
"version": "6.0.2", "version": "6.0.3",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"typings": "index.d.ts", "typings": "index.d.ts",

View File

@ -1,6 +1,6 @@
import { App, Config, Inject, Middleware } from '@midwayjs/decorator'; import { App, Config, Inject, Middleware } from '@midwayjs/decorator';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { RESCODE } from '@cool-midway/core'; import { CoolCommException, RESCODE } from '@cool-midway/core';
import * as jwt from 'jsonwebtoken'; import * as jwt from 'jsonwebtoken';
import { NextFunction, Context } from '@midwayjs/koa'; import { NextFunction, Context } from '@midwayjs/koa';
import { IMiddleware, IMidwayApplication } from '@midwayjs/core'; import { IMiddleware, IMidwayApplication } from '@midwayjs/core';
@ -38,7 +38,10 @@ export class BaseAuthorityMiddleware
if (_.startsWith(url, adminUrl)) { if (_.startsWith(url, adminUrl)) {
try { try {
ctx.admin = jwt.verify(token, this.jwtConfig.jwt.secret); ctx.admin = jwt.verify(token, this.jwtConfig.jwt.secret);
} catch (err) {} } catch (err) {
throw new CoolCommException('登录失效~');
}
if (ctx.admin.isRefresh) throw new CoolCommException('登录失效~');
// 不需要登录 无需权限校验 // 不需要登录 无需权限校验
if ( if (
new RegExp(`^${adminUrl}?.*/open/`).test(url) || new RegExp(`^${adminUrl}?.*/open/`).test(url) ||