From 5da0382a254f982acd84da3253660abc39b65d01 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 29 Apr 2025 12:07:11 +0800 Subject: [PATCH] =?UTF-8?q?reactor=EF=BC=9A=E8=A7=A3=E5=86=B3=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=9A=84=E3=80=8C=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=B4=A8=E9=87=8F=E3=80=8D=E5=9C=A8=E3=80=8CJS=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E3=80=8D=E6=8F=90=E7=A4=BA=EF=BC=9A=E4=B8=BB?= =?UTF-8?q?=E5=8C=85=E5=86=85=EF=BC=8C=E4=B8=8D=E5=BA=94=E8=AF=A5=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E4=B8=BB=E5=8C=85=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84?= =?UTF-8?q?=20JS=20=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sheep/api/index.js | 11 +++++++++++ sheep/api/migration/index.js | 10 ---------- sheep/index.js | 2 ++ 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 sheep/api/index.js delete mode 100644 sheep/api/migration/index.js diff --git a/sheep/api/index.js b/sheep/api/index.js new file mode 100644 index 00000000..1affd1ed --- /dev/null +++ b/sheep/api/index.js @@ -0,0 +1,11 @@ +// 目的:解决微信小程序的「代码质量」在「JS 文件」提示:主包内,不应该存在主包未使用的 JS 文件 +const files = import.meta.glob('./*/*.js', { eager: true }); +let api = {}; +Object.keys(files).forEach((key) => { + api = { + ...api, + [key.replace(/(.*\/)*([^.]+).*/gi, '$2')]: files[key].default, + }; +}); + +export default api; diff --git a/sheep/api/migration/index.js b/sheep/api/migration/index.js deleted file mode 100644 index ac436e8b..00000000 --- a/sheep/api/migration/index.js +++ /dev/null @@ -1,10 +0,0 @@ -const files = import.meta.glob('./*.js', { eager: true }); -let api = {}; -Object.keys(files).forEach((key) => { - api = { - ...api, - [key.replace(/(.*\/)*([^.]+).*/gi, '$2')]: files[key].default, - }; -}); -// TODO @芋艿:要不要删除 -export default api; diff --git a/sheep/index.js b/sheep/index.js index 81b0a1bf..c135334f 100644 --- a/sheep/index.js +++ b/sheep/index.js @@ -1,3 +1,4 @@ +import $api from '@/sheep/api'; import $url from '@/sheep/url'; import $router from '@/sheep/router'; import $platform from '@/sheep/platform'; @@ -14,6 +15,7 @@ dayjs.extend(relativeTime); dayjs.extend(duration); const sheep = { + $api, $store, $url, $router,