From 431b2972eacfdd6fd6b05ca7f6c4498840122bc0 Mon Sep 17 00:00:00 2001 From: ShuangYa Date: Wed, 3 Jul 2024 14:24:51 +0800 Subject: [PATCH] feat: add small size --- package.json | 4 +- pnpm-lock.yaml | 181 ++++++++++++------ src/pages/background/core/rules.ts | 28 +-- src/pages/popup/rule/rules.tsx | 97 +++++----- .../components/rule-content-switcher.tsx | 34 +++- src/share/components/rule-detail.tsx | 41 ++-- src/share/core/rule-history.ts | 8 - 7 files changed, 247 insertions(+), 146 deletions(-) delete mode 100644 src/share/core/rule-history.ts diff --git a/package.json b/package.json index c2878a72..5156baec 100644 --- a/package.json +++ b/package.json @@ -62,11 +62,11 @@ "ice.js": "^2.0.0", "lint-staged": "^13.2.2", "node-fetch": "^3.3.1", - "prettier": "^1.19.1", + "prettier": "^3.3.2", "publish-release": "^1.6.0", "sign-addon": "^6.0.0", "stylelint": "^13.7.2", - "typescript": "^3.7.3", + "typescript": "^4.9.5", "webpack-bundle-analyzer": "^4.8.0" }, "husky": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a1cbb38e..077ed178 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -72,7 +72,7 @@ dependencies: devDependencies: '@iceworks/spec': specifier: ^1.0.0 - version: 1.6.0(eslint@7.32.0)(stylelint@13.13.1)(typescript@3.9.10) + version: 1.6.0(eslint@7.32.0)(stylelint@13.13.1)(typescript@4.9.5) '@plasmo-corp/ewu': specifier: ^0.6.0 version: 0.6.0 @@ -111,7 +111,7 @@ devDependencies: version: 7.32.0 eslint-plugin-import: specifier: ^2.27.5 - version: 2.27.5(@typescript-eslint/parser@5.54.0)(eslint@7.32.0) + version: 2.27.5(eslint@7.32.0) eslint-plugin-unused-imports: specifier: ^2.0.0 version: 2.0.0(eslint@7.32.0) @@ -123,7 +123,7 @@ devDependencies: version: 3.1.0 ice.js: specifier: ^2.0.0 - version: 2.6.6(eslint@7.32.0)(react-dom@17.0.2)(react@17.0.2)(typescript@3.9.10) + version: 2.6.6(eslint@7.32.0)(react-dom@17.0.2)(react@17.0.2)(typescript@4.9.5) lint-staged: specifier: ^13.2.2 version: 13.2.2 @@ -131,8 +131,8 @@ devDependencies: specifier: ^3.3.1 version: 3.3.1 prettier: - specifier: ^1.19.1 - version: 1.19.1 + specifier: ^3.3.2 + version: 3.3.2 publish-release: specifier: ^1.6.0 version: 1.6.1 @@ -143,8 +143,8 @@ devDependencies: specifier: ^13.7.2 version: 13.13.1 typescript: - specifier: ^3.7.3 - version: 3.9.10 + specifier: ^4.9.5 + version: 4.9.5 webpack-bundle-analyzer: specifier: ^4.8.0 version: 4.8.0 @@ -240,6 +240,19 @@ packages: '@babel/types': 7.21.2 dev: true + /@babel/helper-compilation-targets@7.20.7: + resolution: {integrity: sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + dependencies: + '@babel/compat-data': 7.21.0 + '@babel/helper-validator-option': 7.21.0 + browserslist: 4.21.5 + lru-cache: 5.1.1 + semver: 6.3.0 + dev: true + /@babel/helper-compilation-targets@7.20.7(@babel/core@7.21.0): resolution: {integrity: sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ==} engines: {node: '>=6.9.0'} @@ -259,7 +272,7 @@ packages: peerDependencies: '@babel/core': ^7.4.0-0 dependencies: - '@babel/helper-compilation-targets': 7.20.7(@babel/core@7.21.0) + '@babel/helper-compilation-targets': 7.20.7 '@babel/helper-plugin-utils': 7.20.2 debug: 4.3.4 lodash.debounce: 4.0.8 @@ -684,7 +697,7 @@ packages: '@builder/swc-win32-x64-msvc': 0.1.3 dev: true - /@builder/user-config@2.2.5(eslint@7.32.0)(typescript@3.9.10): + /@builder/user-config@2.2.5(eslint@7.32.0)(typescript@4.9.5): resolution: {integrity: sha512-0hBKN9bWZEZ148wbQD96ABqCW4wJDmF7JMcyh15dOFuK2+mKLxfJqJ9HC2rddhR24CuzVojkqwHihQ7lZ7aBQA==} dependencies: '@babel/helper-module-imports': 7.18.6 @@ -699,7 +712,7 @@ packages: dotenv: 14.3.2 dotenv-expand: 6.0.1 eslint-webpack-plugin: 3.2.0(eslint@7.32.0) - fork-ts-checker-webpack-plugin: 5.2.1(eslint@7.32.0)(typescript@3.9.10) + fork-ts-checker-webpack-plugin: 5.2.1(eslint@7.32.0)(typescript@4.9.5) fs-extra: 8.1.0 loader-utils: 2.0.4 object-hash: 2.2.0 @@ -1077,10 +1090,10 @@ packages: - react-native dev: true - /@iceworks/eslint-plugin-best-practices@0.2.11(eslint@7.32.0)(stylelint@13.13.1)(typescript@3.9.10): + /@iceworks/eslint-plugin-best-practices@0.2.11(eslint@7.32.0)(stylelint@13.13.1)(typescript@4.9.5): resolution: {integrity: sha512-IsMqWijTyj1c8EBP8oZJhhghz01XUm8hh2AreUvQyi/eCgAcr0MgPXZ94NkXB+1OwCskkiVuXTa+fsooeP0IYA==} dependencies: - '@iceworks/spec': 1.6.0(eslint@7.32.0)(stylelint@13.13.1)(typescript@3.9.10) + '@iceworks/spec': 1.6.0(eslint@7.32.0)(stylelint@13.13.1)(typescript@4.9.5) '@mdn/browser-compat-data': 4.2.1 fs-extra: 9.1.0 glob: 7.2.3 @@ -1097,7 +1110,7 @@ packages: - typescript dev: true - /@iceworks/spec@1.6.0(eslint@7.32.0)(stylelint@13.13.1)(typescript@3.9.10): + /@iceworks/spec@1.6.0(eslint@7.32.0)(stylelint@13.13.1)(typescript@4.9.5): resolution: {integrity: sha512-fnBjaWKxcY1vv9soBhti3tNDMxKfWYd0vd94f0fvPnVOn6F+4jpcQl2Levs3AfWDh5mZAbW6ieH4qNeE33Zd/g==} peerDependencies: eslint: '>=7.5.0' @@ -1106,9 +1119,9 @@ packages: '@babel/core': 7.21.0 '@babel/eslint-parser': 7.19.1(@babel/core@7.21.0)(eslint@7.32.0) '@babel/preset-react': 7.18.6(@babel/core@7.21.0) - '@iceworks/eslint-plugin-best-practices': 0.2.11(eslint@7.32.0)(stylelint@13.13.1)(typescript@3.9.10) - '@typescript-eslint/eslint-plugin': 5.54.0(@typescript-eslint/parser@5.54.0)(eslint@7.32.0)(typescript@3.9.10) - '@typescript-eslint/parser': 5.54.0(eslint@7.32.0)(typescript@3.9.10) + '@iceworks/eslint-plugin-best-practices': 0.2.11(eslint@7.32.0)(stylelint@13.13.1)(typescript@4.9.5) + '@typescript-eslint/eslint-plugin': 5.54.0(@typescript-eslint/parser@5.54.0)(eslint@7.32.0)(typescript@4.9.5) + '@typescript-eslint/parser': 5.54.0(eslint@7.32.0)(typescript@4.9.5) commitlint-config-ali: 0.1.3 eslint: 7.32.0 eslint-config-ali: 13.1.0(eslint@7.32.0) @@ -1499,7 +1512,7 @@ packages: resolution: {integrity: sha512-If4EcaHzYTqcbNMp/FdReVdRmLL/Te42ivnJII551bYjhX19bWem5m14FERCqdJA732OloGuxCRvLBvcMGsn4A==} dev: true - /@typescript-eslint/eslint-plugin@5.54.0(@typescript-eslint/parser@5.54.0)(eslint@7.32.0)(typescript@3.9.10): + /@typescript-eslint/eslint-plugin@5.54.0(@typescript-eslint/parser@5.54.0)(eslint@7.32.0)(typescript@4.9.5): resolution: {integrity: sha512-+hSN9BdSr629RF02d7mMtXhAJvDTyCbprNYJKrXETlul/Aml6YZwd90XioVbjejQeHbb3R8Dg0CkRgoJDxo8aw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1510,10 +1523,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.54.0(eslint@7.32.0)(typescript@3.9.10) + '@typescript-eslint/parser': 5.54.0(eslint@7.32.0)(typescript@4.9.5) '@typescript-eslint/scope-manager': 5.54.0 - '@typescript-eslint/type-utils': 5.54.0(eslint@7.32.0)(typescript@3.9.10) - '@typescript-eslint/utils': 5.54.0(eslint@7.32.0)(typescript@3.9.10) + '@typescript-eslint/type-utils': 5.54.0(eslint@7.32.0)(typescript@4.9.5) + '@typescript-eslint/utils': 5.54.0(eslint@7.32.0)(typescript@4.9.5) debug: 4.3.4 eslint: 7.32.0 grapheme-splitter: 1.0.4 @@ -1521,13 +1534,13 @@ packages: natural-compare-lite: 1.4.0 regexpp: 3.2.0 semver: 7.3.8 - tsutils: 3.21.0(typescript@3.9.10) - typescript: 3.9.10 + tsutils: 3.21.0(typescript@4.9.5) + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@5.54.0(eslint@7.32.0)(typescript@3.9.10): + /@typescript-eslint/parser@5.54.0(eslint@7.32.0)(typescript@4.9.5): resolution: {integrity: sha512-aAVL3Mu2qTi+h/r04WI/5PfNWvO6pdhpeMRWk9R7rEV4mwJNzoWf5CCU5vDKBsPIFQFjEq1xg7XBI2rjiMXQbQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1539,10 +1552,10 @@ packages: dependencies: '@typescript-eslint/scope-manager': 5.54.0 '@typescript-eslint/types': 5.54.0 - '@typescript-eslint/typescript-estree': 5.54.0(typescript@3.9.10) + '@typescript-eslint/typescript-estree': 5.54.0(typescript@4.9.5) debug: 4.3.4 eslint: 7.32.0 - typescript: 3.9.10 + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true @@ -1555,7 +1568,7 @@ packages: '@typescript-eslint/visitor-keys': 5.54.0 dev: true - /@typescript-eslint/type-utils@5.54.0(eslint@7.32.0)(typescript@3.9.10): + /@typescript-eslint/type-utils@5.54.0(eslint@7.32.0)(typescript@4.9.5): resolution: {integrity: sha512-WI+WMJ8+oS+LyflqsD4nlXMsVdzTMYTxl16myXPaCXnSgc7LWwMsjxQFZCK/rVmTZ3FN71Ct78ehO9bRC7erYQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1565,12 +1578,12 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 5.54.0(typescript@3.9.10) - '@typescript-eslint/utils': 5.54.0(eslint@7.32.0)(typescript@3.9.10) + '@typescript-eslint/typescript-estree': 5.54.0(typescript@4.9.5) + '@typescript-eslint/utils': 5.54.0(eslint@7.32.0)(typescript@4.9.5) debug: 4.3.4 eslint: 7.32.0 - tsutils: 3.21.0(typescript@3.9.10) - typescript: 3.9.10 + tsutils: 3.21.0(typescript@4.9.5) + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true @@ -1580,7 +1593,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree@5.54.0(typescript@3.9.10): + /@typescript-eslint/typescript-estree@5.54.0(typescript@4.9.5): resolution: {integrity: sha512-X2rJG97Wj/VRo5YxJ8Qx26Zqf0RRKsVHd4sav8NElhbZzhpBI8jU54i6hfo9eheumj4oO4dcRN1B/zIVEqR/MQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1595,13 +1608,13 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.3.8 - tsutils: 3.21.0(typescript@3.9.10) - typescript: 3.9.10 + tsutils: 3.21.0(typescript@4.9.5) + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@5.54.0(eslint@7.32.0)(typescript@3.9.10): + /@typescript-eslint/utils@5.54.0(eslint@7.32.0)(typescript@4.9.5): resolution: {integrity: sha512-cuwm8D/Z/7AuyAeJ+T0r4WZmlnlxQ8wt7C7fLpFlKMR+dY6QO79Cq1WpJhvZbMA4ZeZGHiRWnht7ZJ8qkdAunw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1611,7 +1624,7 @@ packages: '@types/semver': 7.3.13 '@typescript-eslint/scope-manager': 5.54.0 '@typescript-eslint/types': 5.54.0 - '@typescript-eslint/typescript-estree': 5.54.0(typescript@3.9.10) + '@typescript-eslint/typescript-estree': 5.54.0(typescript@4.9.5) eslint: 7.32.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0(eslint@7.32.0) @@ -2413,13 +2426,13 @@ packages: fs-extra: 9.1.0 dev: true - /build-plugin-react-app@2.2.3(eslint@7.32.0)(react@17.0.2)(typescript@3.9.10): + /build-plugin-react-app@2.2.3(eslint@7.32.0)(react@17.0.2)(typescript@4.9.5): resolution: {integrity: sha512-uKzNgJVKTq2kBwOaBoeNMKs9k77oRa9lFcM12F5DeYxgdATZOnqyTo2vlBanPpF3re0/u/fIRGg6C+1GIWmx1w==} dependencies: '@builder/app-helpers': 2.5.4 '@builder/jest-config': 2.0.1 '@builder/pack': 0.6.7 - '@builder/user-config': 2.2.5(eslint@7.32.0)(typescript@3.9.10) + '@builder/user-config': 2.2.5(eslint@7.32.0)(typescript@4.9.5) '@builder/webpack-config': 2.1.1 chalk: 4.1.2 debug: 4.3.4 @@ -3831,7 +3844,35 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.54.0(eslint@7.32.0)(typescript@3.9.10) + '@typescript-eslint/parser': 5.54.0(eslint@7.32.0)(typescript@4.9.5) + debug: 3.2.7 + eslint: 7.32.0 + eslint-import-resolver-node: 0.3.7 + transitivePeerDependencies: + - supports-color + dev: true + + /eslint-module-utils@2.7.4(eslint-import-resolver-node@0.3.7)(eslint@7.32.0): + resolution: {integrity: sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==} + engines: {node: '>=4'} + peerDependencies: + '@typescript-eslint/parser': '*' + eslint: '*' + eslint-import-resolver-node: '*' + eslint-import-resolver-typescript: '*' + eslint-import-resolver-webpack: '*' + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true + eslint: + optional: true + eslint-import-resolver-node: + optional: true + eslint-import-resolver-typescript: + optional: true + eslint-import-resolver-webpack: + optional: true + dependencies: debug: 3.2.7 eslint: 7.32.0 eslint-import-resolver-node: 0.3.7 @@ -3849,7 +3890,7 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.54.0(eslint@7.32.0)(typescript@3.9.10) + '@typescript-eslint/parser': 5.54.0(eslint@7.32.0)(typescript@4.9.5) array-includes: 3.1.6 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 @@ -3872,6 +3913,38 @@ packages: - supports-color dev: true + /eslint-plugin-import@2.27.5(eslint@7.32.0): + resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==} + engines: {node: '>=4'} + peerDependencies: + '@typescript-eslint/parser': '*' + eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true + dependencies: + array-includes: 3.1.6 + array.prototype.flat: 1.3.1 + array.prototype.flatmap: 1.3.1 + debug: 3.2.7 + doctrine: 2.1.0 + eslint: 7.32.0 + eslint-import-resolver-node: 0.3.7 + eslint-module-utils: 2.7.4(eslint-import-resolver-node@0.3.7)(eslint@7.32.0) + has: 1.0.3 + is-core-module: 2.11.0 + is-glob: 4.0.3 + minimatch: 3.1.2 + object.values: 1.1.6 + resolve: 1.22.1 + semver: 6.3.0 + tsconfig-paths: 3.14.2 + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color + dev: true + /eslint-plugin-jsx-plus@0.1.0: resolution: {integrity: sha512-iANfZsPWwUWT2czz3A7Ti7B5Iun8YvIMDe6c7VYEZAVjCZyZkB+djflAxOv1XD/TwQeFoEYhCoqaBRWFk5/vIA==} engines: {node: '>=0.10.0'} @@ -4391,7 +4464,7 @@ packages: resolution: {integrity: sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==} dev: true - /fork-ts-checker-webpack-plugin@5.2.1(eslint@7.32.0)(typescript@3.9.10): + /fork-ts-checker-webpack-plugin@5.2.1(eslint@7.32.0)(typescript@4.9.5): resolution: {integrity: sha512-SVi+ZAQOGbtAsUWrZvGzz38ga2YqjWvca1pXQFUArIVXqli0lLoDQ8uS0wg0kSpcwpZmaW5jVCZXQebkyUQSsw==} engines: {node: '>=10', yarn: '>=1.0.0'} peerDependencies: @@ -4417,7 +4490,7 @@ packages: schema-utils: 2.7.0 semver: 7.3.8 tapable: 1.1.3 - typescript: 3.9.10 + typescript: 4.9.5 dev: true /form-data-encoder@1.7.1: @@ -4972,7 +5045,7 @@ packages: through2: 0.6.5 dev: true - /ice.js@2.6.6(eslint@7.32.0)(react-dom@17.0.2)(react@17.0.2)(typescript@3.9.10): + /ice.js@2.6.6(eslint@7.32.0)(react-dom@17.0.2)(react@17.0.2)(typescript@4.9.5): resolution: {integrity: sha512-cl9hEqLCyUU8fUGHzlhmp86YuYRGUqNLcGq4qPr/IvzPBXCIOYkPh/ZvybBeavAKREvX05V/bmV6i0SvryMEzw==} engines: {node: '>=12.22.0', npm: '>=3.0.0'} hasBin: true @@ -4990,7 +5063,7 @@ packages: build-plugin-ice-ssr: 3.1.4 build-plugin-ice-store: 2.0.8(react-dom@17.0.2)(react@17.0.2) build-plugin-pwa: 1.1.1 - build-plugin-react-app: 2.2.3(eslint@7.32.0)(react@17.0.2)(typescript@3.9.10) + build-plugin-react-app: 2.2.3(eslint@7.32.0)(react@17.0.2)(typescript@4.9.5) build-plugin-speed: 1.0.1 build-scripts: 1.3.0 chalk: 4.1.2 @@ -6893,18 +6966,18 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /prettier@1.19.1: - resolution: {integrity: sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==} - engines: {node: '>=4'} - hasBin: true - dev: true - /prettier@2.8.4: resolution: {integrity: sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==} engines: {node: '>=10.13.0'} hasBin: true dev: true + /prettier@3.3.2: + resolution: {integrity: sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==} + engines: {node: '>=14'} + hasBin: true + dev: true + /pretty-bytes@1.0.4: resolution: {integrity: sha512-LNisJvAjy+hruxp3GV4IkZZscTI34+ISfeM1hesB9V6ezIDfXYrBi9TIXVjjMcEB4QFN7tL+dFDEk4s8jMBMyA==} engines: {node: '>=0.10.0'} @@ -8524,14 +8597,14 @@ packages: /tslib@2.5.0: resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==} - /tsutils@3.21.0(typescript@3.9.10): + /tsutils@3.21.0(typescript@4.9.5): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' dependencies: tslib: 1.14.1 - typescript: 3.9.10 + typescript: 4.9.5 dev: true /tunnel-agent@0.6.0: @@ -8607,12 +8680,6 @@ packages: resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} dev: true - /typescript@3.9.10: - resolution: {integrity: sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==} - engines: {node: '>=4.2.0'} - hasBin: true - dev: true - /typescript@4.9.5: resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} engines: {node: '>=4.2.0'} diff --git a/src/pages/background/core/rules.ts b/src/pages/background/core/rules.ts index 85894f9f..aeebf4f0 100644 --- a/src/pages/background/core/rules.ts +++ b/src/pages/background/core/rules.ts @@ -123,7 +123,11 @@ async function save(o: Rule) { updateCache(tableName); notify.other({ method: APIs.ON_EVENT, event: EVENTs.RULE_UPDATE, from: originalRule, target: existsRule }); // Write history - if (prefs.get('rule-history') && [RULE_TYPE.MODIFY_RECV_HEADER, RULE_TYPE.MODIFY_SEND_HEADER, RULE_TYPE.REDIRECT].includes(o.ruleType)) { + if ( + prefs.get('rule-history') && + !o.isFunction && + [RULE_TYPE.MODIFY_RECV_HEADER, RULE_TYPE.MODIFY_SEND_HEADER, RULE_TYPE.REDIRECT].includes(o.ruleType) + ) { const writeValue = o.ruleType === RULE_TYPE.REDIRECT ? o.action : (o.action as RULE_ACTION_OBJ).value; const key = `rule_switch_${getVirtualKey(o)}`; const engine = getLocal(); @@ -167,16 +171,18 @@ function remove(tableName: TABLE_NAMES, id: number): Promise { updateCache(tableName); notify.other({ method: APIs.ON_EVENT, event: EVENTs.RULE_DELETE, table: tableName, id: Number(id) }); // check common mark - getLocal().get('common_rule').then((result) => { - const key = `${tableName}-${id}`; - if (Array.isArray(result.common_rule) && result.common_rule.includes(key)) { - const newKeys = [...result.common_rule]; - newKeys.splice(newKeys.indexOf(key), 1); - getLocal().set({ - common_rule: newKeys, - }); - } - }); + getLocal() + .get('common_rule') + .then((result) => { + const key = `${tableName}-${id}`; + if (Array.isArray(result.common_rule) && result.common_rule.includes(key)) { + const newKeys = [...result.common_rule]; + newKeys.splice(newKeys.indexOf(key), 1); + getLocal().set({ + common_rule: newKeys, + }); + } + }); resolve(); }; }); diff --git a/src/pages/popup/rule/rules.tsx b/src/pages/popup/rule/rules.tsx index d788616f..14f447b4 100644 --- a/src/pages/popup/rule/rules.tsx +++ b/src/pages/popup/rule/rules.tsx @@ -1,7 +1,8 @@ import React, { useEffect } from 'react'; import { useLatest, useRequest } from 'ahooks'; -import { Button, Popover, Switch, Table } from '@douyinfe/semi-ui'; +import { Button, Popover, Spin, Switch } from '@douyinfe/semi-ui'; import { IconBranch } from '@douyinfe/semi-icons'; +import { css, cx } from '@emotion/css'; import Api from '@/share/pages/api'; import { getVirtualKey, parseVirtualKey } from '@/share/core/utils'; import type { Rule } from '@/share/core/types'; @@ -68,56 +69,56 @@ const Rules = () => { } return ( - ( -
- { - item.enable = checked; - return Api.saveRule(item); - }} - /> -
- ), - }, - { - title: 'name', - dataIndex: 'name', - render: (value: string, item: Rule) => ( + +
.item { + display: flex; + flex-direction: row; + gap: 8px; + align-items: center; + background-color: #fff; + border-top: 1px solid var(--semi-color-border); + padding-left: 8px; + padding-right: 8px; + + > * { + flex-grow: 0; + flex-shrink: 0; + } + + > .name { + flex-grow: 1; + flex-shrink: 1; + font-size: 14px; + padding-top: 8px; + padding-bottom: 8px; + } + } + `} + > + {data.map((item) => ( +
+ Api.saveRule({ + ...item, + enable: checked, + })} + /> } style={{ maxWidth: '300px' }}> -
{value}
+
{item.name}
- ), - }, - { - title: 'action', - dataIndex: 'action', - className: 'cell-action', - width: 60, - render: (_, item: Rule) => ( - -
+ ))} +
+
); }; diff --git a/src/share/components/rule-content-switcher.tsx b/src/share/components/rule-content-switcher.tsx index e35676b7..150c42d6 100644 --- a/src/share/components/rule-content-switcher.tsx +++ b/src/share/components/rule-content-switcher.tsx @@ -1,6 +1,6 @@ import { ArrayField, Button, Dropdown, Form, Modal, Space } from '@douyinfe/semi-ui'; import { IconDelete, IconPlus } from '@douyinfe/semi-icons'; -import { css } from '@emotion/css'; +import { css, cx } from '@emotion/css'; import { useLatest } from 'ahooks'; import React, { FC, useMemo } from 'react'; import { RULE_TYPE } from '@/share/core/constant'; @@ -45,7 +45,9 @@ const RuleContentSwitcherEdit: FC = (props) => { + )} @@ -58,10 +60,18 @@ interface RuleContentSwitcherProps { type: RULE_TYPE; children?: any; rule: Rule; + size?: 'small' | 'default'; } +const smallStyle = css` + .semi-dropdown-item { + padding: 4px 8px; + font-size: 13px; + } +`; + const RuleContentSwitcher: FC = (props) => { - const { add = false, type, children, rule } = props; + const { add = false, type, children, rule, size } = props; const newestRule = useLatest(rule); const key = useMemo(() => getVirtualKey(rule), [rule]); @@ -126,15 +136,27 @@ const RuleContentSwitcher: FC = (props) => { return result; }, [add, value]); - if (!isEnable) { + if (!isEnable || menu.length === 0) { return null; } - if (![RULE_TYPE.MODIFY_SEND_HEADER, RULE_TYPE.MODIFY_RECV_HEADER, RULE_TYPE.REDIRECT].includes(type) || menu.length === 0) { + if ( + ![RULE_TYPE.MODIFY_SEND_HEADER, RULE_TYPE.MODIFY_RECV_HEADER, RULE_TYPE.REDIRECT].includes(type) || rule.isFunction + ) { return null; } - return {children}; + return ( + + {children} + + ); }; export default RuleContentSwitcher; diff --git a/src/share/components/rule-detail.tsx b/src/share/components/rule-detail.tsx index cf44259a..e1ac340d 100644 --- a/src/share/components/rule-detail.tsx +++ b/src/share/components/rule-detail.tsx @@ -1,32 +1,45 @@ import React, { Fragment } from 'react'; -import { css } from '@emotion/css'; +import { css, cx } from '@emotion/css'; import { t } from '@/share/core/utils'; import type { Rule } from '@/share/core/types'; interface RuleDetailProps { rule: Rule; + size?: 'small' | 'default'; } +const style = css` + display: flex; + flex-direction: column; + gap: 8px; + font-size: 14px; + p { + margin: 0; + overflow: hidden; + word-break: break-all; + text-overflow: ellipsis; + display: box; + box-orient: vertical; + line-clamp: 3; + } +`; + +const smallStyle = css` + gap: 4px; + font-size: 12px; +`; + const RuleDetail = (props: RuleDetailProps) => { - const { rule } = props; + const { rule, size } = props; const isModifyHeader = rule.ruleType === 'modifySendHeader' || (rule.ruleType === 'modifyReceiveHeader' && !rule.isFunction); return (

{t('matchType')}: {t(`match_${rule.matchType}`)} diff --git a/src/share/core/rule-history.ts b/src/share/core/rule-history.ts deleted file mode 100644 index a4316eaf..00000000 --- a/src/share/core/rule-history.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { getLocal } from './storage'; - -const addHistory = (key: string, value: string) => { - const engine = getLocal(); - engine.get(key).then((result) => { - engine.set({ [key]: result[key] }); - }); -};