From 2b84bffa73b90d3e5ae84096d8bdbfb1a615ec45 Mon Sep 17 00:00:00 2001 From: 1518079148 <1518079148@qq.com> Date: Tue, 5 Sep 2023 16:25:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=9B=BE=E6=A0=87=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 单文件拆分/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/单文件拆分/index.ts b/单文件拆分/index.ts index b584452..67f5ede 100644 --- a/单文件拆分/index.ts +++ b/单文件拆分/index.ts @@ -1,8 +1,8 @@ import { resolve, join } from 'path' import FileUtil from './src/utils/FileUtil' -const siconUrl = resolve('E:/repo/code/wty-web-cloud-las-0/src/components/sicon') -const staticIconUrl = resolve('E:/repo/code/wty-web-cloud-las-0/public/static_res/sicon') +const siconUrl = resolve('E:/repo/test/ssly-admin/admin/public/static_res') +const staticIconUrl = resolve('E:/repo/test/ssly-admin/admin/public/static_res/sicon') const init = async () => { await FileUtil.deleteFileOrDirectory(staticIconUrl) @@ -18,13 +18,18 @@ const init = async () => { fstr = fstr.split(`export const ${filename}Name`)[0] fstr = fstr.split('=')[1] const ctx = JSON.parse(fstr.replaceAll("'", '"')) + + const keys = [] as any[] Object.keys(ctx).forEach((key) => { let _res = JSON.stringify(ctx[key]) - if(typeof ctx[key] === 'string'){ - _res = _res.substring(1,_res.length-1) + if (typeof ctx[key] === 'string') { + _res = _res.substring(1, _res.length - 1) } + key = key.replaceAll(':','-') + keys.push(key) FileUtil.writeFile(join(staticIconUrl, `./${filename}/${key}.json`), _res) }) + FileUtil.writeFile(join(staticIconUrl, `./${filename}/_keys.json`), JSON.stringify(keys)) } catch { console.log('处理失败', filename) }