From 06dbee75e81920f1de277b4f50694b06780f6e75 Mon Sep 17 00:00:00 2001 From: fs-context Date: Sun, 15 Dec 2024 12:18:23 +0800 Subject: [PATCH] updated --- src/fs-context/internal.ts | 2 +- src/fs-context/structs.ts | 26 ++++++++++++++------------ src/fs-context/tools.ts | 4 ++-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/fs-context/internal.ts b/src/fs-context/internal.ts index d59ef75..7c6cbeb 100644 --- a/src/fs-context/internal.ts +++ b/src/fs-context/internal.ts @@ -41,7 +41,7 @@ export type ExtractField = { export interface BlockConfigA { method?: MethodFunction>; type?: BlockTypePlain; - opcode?: string; + opcode: string; } export interface BlockConfigB { arguments?: T; diff --git a/src/fs-context/structs.ts b/src/fs-context/structs.ts index 259f61c..097301b 100644 --- a/src/fs-context/structs.ts +++ b/src/fs-context/structs.ts @@ -68,9 +68,9 @@ export class Block { method: (this: O, args: any) => any = () => { }; arguments: ArgumentPart[] = []; type: BlockTypePlain = "command"; - private _opcode: string | null = null; + private _opcode: string = ""; get opcode(): string { - return this._opcode ? this._opcode : md5(JSON.stringify(this.arguments)); + return this._opcode; } get text(): string { let result: string = ""; @@ -104,7 +104,7 @@ export class Block { return new Block({ method: realMethod, type: realConfig.type, - opcode: method?.name + opcode: method?.name || Unnecessary.internalUUID.next() }, ...textLoaded); } constructor(config?: BlockConfigA<[]>, ...args: any[]) { @@ -123,15 +123,17 @@ export class Block { } this.arguments.push(currentPart); }; - const data = config || {}; - if (data.method) { - this.method = data.method; - }; - if (data.type) { - this.type = data.type; - }; - if (data.opcode) { - this._opcode = data.opcode; + if (config) { + const data = config; + if (data.method) { + this.method = data.method; + }; + if (data.type) { + this.type = data.type; + }; + if (data.opcode) { + this._opcode = data.opcode; + }; }; }; } diff --git a/src/fs-context/tools.ts b/src/fs-context/tools.ts index ad446f5..24e2710 100644 --- a/src/fs-context/tools.ts +++ b/src/fs-context/tools.ts @@ -1,4 +1,3 @@ -import md5 from "md5"; import { AcceptedInputType, ArgumentPart, @@ -107,7 +106,7 @@ export namespace Unnecessary { const result = []; for (let i = 0; i < this.length; i++) { this.last++; - result.push(md5(this.last + i.toString()).slice(0, 5)); + result.push(this.last.toString(32).slice(0, 5)); } return result.join('-'); } @@ -115,6 +114,7 @@ export namespace Unnecessary { this.length = length; } } + export const internalUUID = new UUIDAutoscalator(); export function splitArgBoxPart(str: string, substrings: string[]) { const filteredSubstrings = []; for (let i = 0; i < str.length; i++) {