Skip to content

Commit

Permalink
fix: 处理last rest 类型
Browse files Browse the repository at this point in the history
  • Loading branch information
pearone committed Oct 7, 2023
1 parent 1644173 commit 4531557
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/event/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dpdfe/event-utils",
"version": "0.0.23",
"version": "0.0.24",
"description": "通用方法",
"author": "pearone",
"homepage": "https://github.com/DPDFE/react-layout/tree/main/packages/event",
Expand Down
16 changes: 7 additions & 9 deletions packages/event/src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
* eg: log(type, name, {color: 'red'; background: 'blue'; version: '1.0.0'})
**/
export const log = (...args: any[]) => {
const style = args[args.length - 1] as {
const last_rest = args[args.length - 1];
const style: {
color: string;
background: string;
};
} = typeof last_rest === 'object' ? last_rest : {};

const _style = `color:${style.color}; background: ${style.background}; font-size: 12px`;

let version = 'v0.0.1';
if (
args[args.length - 1].color ||
args[args.length - 1].background ||
args[args.length - 1].version
) {
if (args[args.length - 1].version) {
version = args[args.length - 1].version;
if (last_rest.color || last_rest.background || last_rest.version) {
if (last_rest.version) {
version = last_rest.version;
}
args.pop();
}
Expand Down

0 comments on commit 4531557

Please sign in to comment.