From 9cfc435c2cdd9f7a0d0dd082f39df3b45deaefce Mon Sep 17 00:00:00 2001 From: dhammena Date: Sun, 13 Mar 2022 09:28:03 +0800 Subject: [PATCH] refactoray --- abbr/index.ts | 3 ++- abbr/interfaces.ts | 5 +++++ assets/abbr/dict.mdx | Bin 5718 -> 5626 bytes assets/dppn/dict.mdx | Bin 373038 -> 373040 bytes assets/ncped/dict.mdx | Bin 765248 -> 765250 bytes assets/pts/dict.mdx | Bin 3852492 -> 3852300 bytes common/interfaces.ts | 28 +++++----------------------- config.ts | 24 ++++++++++++------------ dppn/index.ts | 3 ++- dppn/interfaces.ts | 4 ++++ ncped/index.ts | 3 ++- ncped/interfaces.ts | 6 ++++++ pts/index.ts | 3 ++- pts/interfaces.ts | 4 ++++ 14 files changed, 44 insertions(+), 39 deletions(-) create mode 100644 abbr/interfaces.ts create mode 100644 dppn/interfaces.ts create mode 100644 ncped/interfaces.ts create mode 100644 pts/interfaces.ts diff --git a/abbr/index.ts b/abbr/index.ts index 431f221..c48f447 100644 --- a/abbr/index.ts +++ b/abbr/index.ts @@ -2,8 +2,9 @@ import fs from "fs"; import { render } from "template-file"; import { MakerBase } from "../common/classes"; -import { IAbbr, IDictConf } from "../common/interfaces"; +import { IDictConf } from "../common/interfaces"; import { GeneratorByHand } from "../common/jsonFileGenerator"; +import { IAbbr } from "./interfaces"; import { FILENAME } from "../config"; export class Maker extends MakerBase { diff --git a/abbr/interfaces.ts b/abbr/interfaces.ts new file mode 100644 index 0000000..9a076be --- /dev/null +++ b/abbr/interfaces.ts @@ -0,0 +1,5 @@ +export interface IAbbr { + abbr: string; + text: string; + type: string; +} diff --git a/assets/abbr/dict.mdx b/assets/abbr/dict.mdx index 4c4254dd568ecfaf710000a95d785706b31f2e0f..eaa24e8b6db9594807733b1d49a590c32d2b2d9d 100644 GIT binary patch delta 128 zcmcbn^GlnBfr0tVMiwJRW6ow3jOojp=+l3*YA(^3+Ar~l{2h;D;X%G57d_gghfCW zOiYg<3#cO>s8Wp~hoNM0DwC>cE>K-I*e;Omd0^Sp$?;60lYcQ?V=>skvT*YiW;G!I Duv957 diff --git a/assets/dppn/dict.mdx b/assets/dppn/dict.mdx index d5172211a9ecef28ea2fbc6e26e9a8d17c0f8cff..1d55633d8da7e3886464ceb1230c1f3cf4f9a125 100644 GIT binary patch delta 54 zcmZ4YNNmF+F%|{}=3^UKj2M{>8H_iZGfre;QJJqI(0qou{R}fB5HkTWh|RM73^Qxe FS^&8H_iZGtOmV5n8x=ZSxK0_8ZKMK+FWhAT|pSvjQ<2 U5VHd@2M}`tG1vAR%-k6(0WG&1djJ3c delta 76 zcmX?fOYgufJr)KA<_jBHj2Ia$H(N5!Wny{0Ansc8E#~%H%#1+H1jHaV3lOscF&hxG S12G2>a{@8f_FK%{87l!h^&AEO diff --git a/assets/pts/dict.mdx b/assets/pts/dict.mdx index ea2bb5d1eef04131804333e0a5d40a33fb62dfaa..633c55fe80cfad8d1bc4dbc1b9037db76b810b2a 100644 GIT binary patch delta 364 zcmYk!NlpSm6vpwd>{4-_2b=&Ww6$rW!B(!~ssW=Uq9(Q{aN&l9h8y$^j3HjYrE3@7 zfN%-^?#Rn8^}ScG>gT<0+HZYhCFk$MmW)$W@EMxOT-~UtShspsO;u${G4-e?I-eT8 zFQ~2uwU{>8i%2b9>z?HEBGMgydCVG|b;X^o)3d)xuJ)4H*Tfo(z`=h%iZP5Mg$Ybz z3e%XuEaote1uS9-%UHoG*07E=Hn52;Y-0x*WRb%z_OOow93qb+9K*#4PT`>dA7?0{ TgaBn!aE=fcxco|N)%_j-w8(0j delta 523 zcmXxfIZnes6vpv4vDw1DgnbD+#KZx!B{>H*$RrjqWI=WibQBac6rgn60#R@QL`BI7 z+)(5a{5=t}e&hM(jo*x)p4;mCrL9a6^YzVil*+#sl&kIoaphLhQs&)6k$Ht#Q?4Z> z<#;-KY`GAh^@`lcIYRNMl%yebRy{r1I@kCnWJlb^Wu;S#yHs_hB-#J-PFbi?2z85q zROXNp$=8itj__#^Qi+eMajh!(jvTkm>FkT6(;2DBURy31xmc@_uu^gVE9!y%xw`J_ zQAxFu#*caO^=myu#$#kCBoNO{bfFtP=tUor=*IvCF@#}^U=(8*#{^QC#1y76gIUaB x9t&8+64F@43Rba(b!=c0Ti8Yh7Iu(@jU0Bd2M7B&z#)!sj64b-kx|Ti{sDF&n2`Vg diff --git a/common/interfaces.ts b/common/interfaces.ts index 4a47cc4..15b1396 100644 --- a/common/interfaces.ts +++ b/common/interfaces.ts @@ -1,3 +1,8 @@ +import { IPts } from "../pts/interfaces"; +import { IAbbr } from "../abbr/interfaces"; +import { IDppn } from "../dppn/interfaces"; +import { INcped } from "../ncped/interfaces"; + export interface IDictConf { jsonUrl?: string; fullName: string; @@ -15,29 +20,6 @@ export interface IFileName { mdx: string; // result mdict file } -export interface IPts { - word: string; - text: string; -} - -export interface INcped { - entry: string; - grammar?: string; - definition?: string | string[]; - xr?: string | string[]; // cross references -} - -export interface IDppn { - word: string; - text: string; -} - -export interface IAbbr { - abbr: string; - text: string; - type: string; -} - export type IEntry = IPts | INcped | IDppn | IAbbr; export interface IJsonFileGenerator { diff --git a/config.ts b/config.ts index 1eac41b..7567a3e 100644 --- a/config.ts +++ b/config.ts @@ -1,14 +1,4 @@ -import { IDictConf, IFileName as IFileName } from "./common/interfaces"; - -export const FILENAME: IFileName = { - entryTemplate: 'entry.html', - json: "dict.json", - css: "dict.css", - txt: "dict.txt", - title: "title.html", - description: "description.html", - mdx: "dict.mdx" -} +import { IDictConf, IFileName } from "./common/interfaces"; export enum DictEnum { PTS = "pts", @@ -17,9 +7,19 @@ export enum DictEnum { ABBR = "abbr" }; +type dictionary = Record; + export const ASSETS_DIR = `${__dirname}/assets`; -type dictionary = Record +export const FILENAME: IFileName = { + entryTemplate: "entry.html", + json: "dict.json", + css: "dict.css", + txt: "dict.txt", + title: "title.html", + description: "description.html", + mdx: "dict.mdx", +}; export const DICTIONARY: dictionary = { [DictEnum.PTS]: { diff --git a/dppn/index.ts b/dppn/index.ts index 3e154c9..bf9c39a 100644 --- a/dppn/index.ts +++ b/dppn/index.ts @@ -2,8 +2,9 @@ import fs from "fs"; import { render } from "template-file"; import { MakerBase } from "../common/classes"; -import { IDppn, IDictConf } from "../common/interfaces"; +import { IDictConf } from "../common/interfaces"; import { GeneratorByDownload } from "../common/jsonFileGenerator"; +import { IDppn } from "./interfaces"; import { FILENAME } from "../config"; export class Maker extends MakerBase { diff --git a/dppn/interfaces.ts b/dppn/interfaces.ts new file mode 100644 index 0000000..0b5f082 --- /dev/null +++ b/dppn/interfaces.ts @@ -0,0 +1,4 @@ +export interface IDppn { + word: string; + text: string; +} \ No newline at end of file diff --git a/ncped/index.ts b/ncped/index.ts index ee100b4..02087bd 100644 --- a/ncped/index.ts +++ b/ncped/index.ts @@ -2,8 +2,9 @@ import fs from "fs"; import { render } from "template-file"; import { MakerBase } from "../common/classes"; -import { INcped, IDictConf } from "../common/interfaces"; +import { IDictConf } from "../common/interfaces"; import { GeneratorByDownload } from "../common/jsonFileGenerator"; +import { INcped } from "./interfaces"; import { FILENAME } from "../config"; export class Maker extends MakerBase { diff --git a/ncped/interfaces.ts b/ncped/interfaces.ts new file mode 100644 index 0000000..d3b99c8 --- /dev/null +++ b/ncped/interfaces.ts @@ -0,0 +1,6 @@ +export interface INcped { + entry: string; + grammar?: string; + definition?: string | string[]; + xr?: string | string[]; // cross references +} diff --git a/pts/index.ts b/pts/index.ts index edcb300..0942411 100644 --- a/pts/index.ts +++ b/pts/index.ts @@ -2,8 +2,9 @@ import fs from "fs"; import { render } from "template-file"; import { MakerBase } from "../common/classes"; -import { IPts, IDictConf } from "../common/interfaces"; +import { IDictConf } from "../common/interfaces"; import { GeneratorByDownload } from "../common/jsonFileGenerator"; +import { IPts } from "./interfaces"; import { FILENAME } from "../config"; export class Maker extends MakerBase { diff --git a/pts/interfaces.ts b/pts/interfaces.ts new file mode 100644 index 0000000..71f0420 --- /dev/null +++ b/pts/interfaces.ts @@ -0,0 +1,4 @@ +export interface IPts { + word: string; + text: string; +} \ No newline at end of file