Skip to content

Commit 04afce5

Browse files
committed
webpack 分包
1 parent b264644 commit 04afce5

File tree

13 files changed

+79
-43
lines changed

13 files changed

+79
-43
lines changed

.eslintrc.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,14 @@ module.exports = {
8989
"error",
9090
],
9191
"indent": [
92-
"error", "tab", { SwitchCase: 1 }],
92+
"error",
93+
"tab",
94+
{
95+
SwitchCase: 1,
96+
}],
9397
"quotes": [
94-
"error", "double",
98+
"error",
99+
"double",
95100
],
96101
"semi": [
97102
"error",
@@ -112,6 +117,10 @@ module.exports = {
112117
"error",
113118
"always-multiline",
114119
],
120+
"object-shorthand": [
121+
"error",
122+
"always",
123+
],
115124
"no-tabs": [
116125
"off",
117126
],

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,13 @@ MIUI广告清理工具
173173
- 小米钱包
174174
- 米币支付
175175
- 小米支付
176-
- 小米卡包
177176
- 小米金融(天星金融)
178177
- 小米金融(天星金融)- 安全组件
179178
- 小米金服安全组件
180179
- 银联可信服务安全组件小米版
180+
- NFC 应用
181+
- 小米卡包
182+
- 小米互联通信服务
181183
- 低使用频率 APP
182184
- 小米换机
183185
- 小米社区

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
"private": true,
55
"description": "MIUI广告清理工具",
66
"scripts": {
7-
"test:fix": "npm run test:lint -- --fix",
8-
"test:unit": "nyc mocha",
9-
"test:lint": "npx eslint *.js {src,test}/**/*.js",
10-
"test": "npm run test:lint && npm run test:unit",
7+
"lint:fix": "npm run pretest -- --fix",
8+
"pretest": "eslint *.js {src,test}/**/*.js",
9+
"test": "nyc mocha",
1110
"report-coverage": "codecov",
1211
"start": "npx webpack --config webpack.config.js --watch --mode=development",
1312
"build:pack": "npx webpack --config webpack.config.js --mode=production",

res/drawable/ic_done_white.png

466 Bytes
Loading

src/miui_cleaner_app/appDesc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ module.exports = {
3535
"com.mipay.wallet": "小米钱包",
3636
"com.xiaomi.payment": "米币支付",
3737
"com.miui.nextpay": "小米支付",
38-
"com.xiaomi.pass": "小米卡包",
3938
"com.xiaomi.jr": "小米金融/天星金融",
4039
"com.xiaomi.jr.security": "小米金融/天星金融-安全组件",
4140
"com.xiaomi.mifisecurity": "小米金服安全组件",
4241
"com.unionpay.tsmservice.mi": "银联可信服务安全组件小米版",
42+
43+
// NFC 应用
44+
"com.xiaomi.pass": "小米卡包",
45+
"com.xiaomi.mi_connect_service": "小米互联通信服务",
46+
4347
// 低使用频率 APP
4448
"com.miui.huanji": "小米换机",
4549
"com.xiaomi.vipaccount": "小米社区",

src/miui_cleaner_app/downApp.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const appList = [
1717
icon: "https://litiaotiao.cn/apple-touch-icon.png",
1818
packageName: "hello.litiaotiao.app",
1919
url: "https://www.123pan.com/s/ZYAZVv-TBYjd",
20-
filter: function (files) {
20+
filter (files) {
2121
return files.filter(file => {
2222
return /|MissLee/.test(file.fileName) && !file.fileName.includes("真实好友");
2323
});
@@ -67,7 +67,7 @@ const appList = [
6767
icon: "http://pic.danji100.com/upload/2022-4/20224261118377118.png",
6868
packageName: "com.miui.packageinstaller",
6969
url: "https://zisu.lanzoum.com/tp/iI7LGwn5xjc",
70-
filter: function (files) {
70+
filter (files) {
7171
files = files.map(file => {
7272
const miuiInst = file.fileName.match(/().*?([\d.]+)-(\d+).*?(\.\w+)$/);
7373
if (miuiInst) {
@@ -103,7 +103,7 @@ const appList = [
103103
icon: "https://cdn.gitmirror.com/gh/WangDaYeeeeee/GeometricWeather/master/app/src/main/res/drawable/ic_launcher.png",
104104
packageName: "wangdaye.com.geometricweather",
105105
url: "https://github.com/WangDaYeeeeee/GeometricWeather/releases/latest",
106-
filter: function (files) {
106+
filter (files) {
107107
const appInfo = this;
108108
files = files.filter(file => {
109109
const verInfo = file.url.match(/\/(.+?)\/.*?\.\1_(\w+)\.\w+$/);
@@ -158,7 +158,7 @@ const appList = [
158158
// url: "https://423down.lanzouo.com/b0f2lkafe",
159159
// url: "https://m.32r.com/app/80966.html",
160160
// https://www.423down.com/11775.html
161-
filter: function (files) {
161+
filter (files) {
162162
return files.filter(file => {
163163
return /.*/.test(file.fileName);
164164
});
@@ -172,7 +172,7 @@ const appList = [
172172
// url: "https://www.123pan.com/s/A6cA-gT9Jh",
173173
url: "https://423down.lanzouv.com/b0f1gksne",
174174
// https://www.423down.com/12235.html
175-
filter: function (files) {
175+
filter (files) {
176176
return files.filter(file => {
177177
return /.*/.test(file.fileName);
178178
});
@@ -185,7 +185,7 @@ const appList = [
185185
packageName: "com.youku.phone",
186186
url: "https://423down.lanzouv.com/b0f1avpib",
187187
// https://www.423down.com/8526.html
188-
filter: function (files) {
188+
filter (files) {
189189
return files.filter(file => {
190190
file.fileName = file.fileName.replace(/(?=)/g, "优");
191191
return file.fileName.includes("优酷视频");

src/miui_cleaner_app/fetch-polyfill/fetch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function fetch (url, options) {
6363
work.once("error", reject);
6464

6565
call.enqueue(new okhttp3.Callback({
66-
onResponse: function (call, okHttpRes) {
66+
onResponse (call, okHttpRes) {
6767
try {
6868
if (isAborted()) {
6969
return;
@@ -93,7 +93,7 @@ async function fetch (url, options) {
9393
work.emit("error", ex);
9494
}
9595
},
96-
onFailure: function (call, err) {
96+
onFailure (call, err) {
9797
work.emit("error", err);
9898
},
9999
}));

src/miui_cleaner_app/index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,20 @@ function regBack () {
8585
}
8686

8787
(() => {
88-
if (DEBUG) {
89-
const thisPackageName = context.getPackageName();
90-
console.log("DEBUG in", thisPackageName);
91-
if (thisPackageName === "com.github.gucong3000.miui.cleaner") {
92-
let entry = engines.myEngine().source.toString();
93-
if (!entry.startsWith("/")) {
94-
entry = `/storage/emulated/0/脚本/${thisPackageName}/${entry}`;
95-
if (files.exists(entry)) {
96-
engines.execScriptFile(entry);
97-
}
98-
return;
99-
}
100-
}
101-
}
88+
// if (DEBUG) {
89+
// const thisPackageName = context.getPackageName();
90+
// console.log("DEBUG in", thisPackageName);
91+
// if (thisPackageName === "com.github.gucong3000.miui.cleaner") {
92+
// let entry = engines.myEngine().source.toString();
93+
// if (!entry.startsWith("/")) {
94+
// entry = `/storage/emulated/0/脚本/${thisPackageName}/${entry}`;
95+
// if (files.exists(entry)) {
96+
// engines.execScriptFile(entry);
97+
// return;
98+
// }
99+
// }
100+
// }
101+
// }
102102
mainMenu();
103103
update.checkUpdate();
104104
})();

src/miui_cleaner_app/multiChoice.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function multiChoice (
3030
</card>
3131
</list>
3232
</vertical>
33-
<fab id="done" w="auto" h="auto" src="@drawable/ic_done_white_48dp" margin="0 32" layout_gravity="bottom|center" tint="#ffffff" />
33+
<fab id="done" w="auto" h="auto" src="file://res/drawable/ic_done_white.png" margin="0 32" layout_gravity="bottom|center" tint="#ffffff" />
3434
</frame>
3535
`);
3636

src/miui_cleaner_app/recycle.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function launchMarket () {
2626

2727
function getInstalledPackages () {
2828
const pm = context.getPackageManager();
29-
return Array.from(
29+
const list = Array.from(
3030
pm.getInstalledApplications(android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES),
3131
).map(appInfo => {
3232
if (app.getAppName(appInfo.packageName)) {
@@ -47,12 +47,16 @@ function getInstalledPackages () {
4747
};
4848
}).filter(Boolean).sort((app1, app2) => (
4949
app1.packageName.localeCompare(app2.packageName)
50-
)).concat({
51-
name: "其他",
52-
loadIcon: () => pm.getApplicationInfo(marketPackageName, 0).loadIcon(pm),
53-
fn: launchMarket,
54-
summary: "去应用商店下载其他小米官方应用",
55-
});
50+
));
51+
if (app.getAppName(marketPackageName)) {
52+
list.push({
53+
name: "其他",
54+
loadIcon: () => pm.getApplicationInfo(marketPackageName, 0).loadIcon(pm),
55+
fn: launchMarket,
56+
summary: "去应用商店下载其他小米官方应用",
57+
});
58+
}
59+
return list;
5660
}
5761
let requestInstallPackages;
5862
function recycle () {
@@ -61,7 +65,7 @@ function recycle () {
6165
itemList: {
6266
then: (...args) => Promise.resolve(getInstalledPackages()).then(...args),
6367
},
64-
fn: function (appInfo) {
68+
fn (appInfo) {
6569
if (!requestInstallPackages) {
6670
requestInstallPackages = settings.set("requestInstallPackages", true, "打开应用安装权限");
6771
}

src/miui_cleaner_app/services.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ const cleanerList = [
657657
{
658658
// 应用包管理组件
659659
packageName: "com.miui.packageinstaller",
660-
fn: function (options) {
660+
fn (options) {
661661
const googlePkgName = "com.google.android.packageinstaller";
662662
let googleAppName = app.getAppName(googlePkgName);
663663
const miuiPkgName = "com.miui.packageinstaller";

src/miui_cleaner_app/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ const settingProperties = {
194194
accessibilityServiceEnabled: {
195195
depend: "accessibility",
196196
enumerable: true,
197-
get: () => Boolean(auto.service),
197+
get: () => settings.accessibilityServices.has(accessServicesName),
198198
set: (value) => {
199199
if (value) {
200200
settings.accessibilityServices.add(accessServicesName);

webpack.config.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ const config = {
1616
clean: true,
1717
},
1818
target: "node",
19+
optimization: {
20+
runtimeChunk: "single",
21+
splitChunks: {
22+
chunks: "all",
23+
maxInitialRequests: Infinity,
24+
minSize: 0,
25+
cacheGroups: {
26+
node_modules: {
27+
test: /[\\/]node_modules[\\/]/,
28+
name (module) {
29+
// console.log(module);
30+
// 取得名称。例如 /node_modules/packageName/not/this/part.js
31+
// 或 /node_modules/packageName
32+
return module.context.replace(/\\/g, "/").replace(/^.*?(\/node_modules\/)/, "$1");
33+
},
34+
},
35+
},
36+
},
37+
},
1938
plugins: [
2039
new AutojsDeployPlugin({
2140
// {boolean|String|boolean[]|String[]} 添加`"ui";`前缀的chunk(output)名单,true代表project.json中定义的main,字符串代表文件名
@@ -50,20 +69,19 @@ const config = {
5069
},
5170
],
5271
},
72+
mode: "development",
5373
};
5474

5575
module.exports = (env, args) => {
5676
const isProduction = args.mode ? args.mode === "production" : env.WEBPACK_BUILD;
5777
if (isProduction) {
58-
config.mode = "production";
5978
config.devtool = false;
6079
config.plugins.push(
6180
new webpack.DefinePlugin({
6281
DEBUG: JSON.stringify(false),
6382
}),
6483
);
6584
} else {
66-
config.mode = "development";
6785
config.devtool = "source-map";
6886
config.plugins.push(
6987
new webpack.DefinePlugin({

0 commit comments

Comments
 (0)