修改pinyin-match引用,改为从preload中导入

This commit is contained in:
fofolee 2025-02-21 21:11:16 +08:00
parent d3795cd133
commit 84c47db7e0
8 changed files with 24 additions and 53 deletions

42
package-lock.json generated
View File

@ -15,7 +15,6 @@
"monaco-editor": "^0.33.0", "monaco-editor": "^0.33.0",
"monaco-editor-webpack-plugin": "^7.0.1", "monaco-editor-webpack-plugin": "^7.0.1",
"picture-compressor": "^1.1.0", "picture-compressor": "^1.1.0",
"pinyin-match": "^1.2.2",
"quasar": "^2.7.0", "quasar": "^2.7.0",
"raw-loader": "^4.0.2", "raw-loader": "^4.0.2",
"vue": "^3.0.0", "vue": "^3.0.0",
@ -5795,6 +5794,7 @@
"version": "2.3.2", "version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"optional": true, "optional": true,
"os": [ "os": [
@ -7837,14 +7837,6 @@
"resolved": "https://registry.npmmirror.com/picture-compressor/-/picture-compressor-1.1.0.tgz", "resolved": "https://registry.npmmirror.com/picture-compressor/-/picture-compressor-1.1.0.tgz",
"integrity": "sha512-yJNpdb97h1KXGxGh1JPav1wYXDEPtuCVryt2VIb74i7WGZu4RyU+gr8u2nmLf24MjwgT4oo3US+yxUCGeadRgg==" "integrity": "sha512-yJNpdb97h1KXGxGh1JPav1wYXDEPtuCVryt2VIb74i7WGZu4RyU+gr8u2nmLf24MjwgT4oo3US+yxUCGeadRgg=="
}, },
"node_modules/pinyin-match": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/pinyin-match/-/pinyin-match-1.2.2.tgz",
"integrity": "sha512-C0yOq4LkToJMkDHiQFKOY69El2GRcwdS2lVEjgWjIV8go3wE4mloGFNkVicGHFGYHDg523m2/lKzW8Hh+JR9nw==",
"dependencies": {
"rollup": "^2.44.0"
}
},
"node_modules/pkg-dir": { "node_modules/pkg-dir": {
"version": "7.0.0", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-7.0.0.tgz", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-7.0.0.tgz",
@ -9031,21 +9023,6 @@
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/rollup": {
"version": "2.79.2",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.2.tgz",
"integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==",
"license": "MIT",
"bin": {
"rollup": "dist/bin/rollup"
},
"engines": {
"node": ">=10.0.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
"node_modules/rtlcss": { "node_modules/rtlcss": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-4.0.0.tgz", "resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-4.0.0.tgz",
@ -15433,6 +15410,7 @@
"version": "2.3.2", "version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"optional": true "optional": true
}, },
"function-bind": { "function-bind": {
@ -16840,14 +16818,6 @@
"resolved": "https://registry.npmmirror.com/picture-compressor/-/picture-compressor-1.1.0.tgz", "resolved": "https://registry.npmmirror.com/picture-compressor/-/picture-compressor-1.1.0.tgz",
"integrity": "sha512-yJNpdb97h1KXGxGh1JPav1wYXDEPtuCVryt2VIb74i7WGZu4RyU+gr8u2nmLf24MjwgT4oo3US+yxUCGeadRgg==" "integrity": "sha512-yJNpdb97h1KXGxGh1JPav1wYXDEPtuCVryt2VIb74i7WGZu4RyU+gr8u2nmLf24MjwgT4oo3US+yxUCGeadRgg=="
}, },
"pinyin-match": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/pinyin-match/-/pinyin-match-1.2.2.tgz",
"integrity": "sha512-C0yOq4LkToJMkDHiQFKOY69El2GRcwdS2lVEjgWjIV8go3wE4mloGFNkVicGHFGYHDg523m2/lKzW8Hh+JR9nw==",
"requires": {
"rollup": "^2.44.0"
}
},
"pkg-dir": { "pkg-dir": {
"version": "7.0.0", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-7.0.0.tgz", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-7.0.0.tgz",
@ -17592,14 +17562,6 @@
"glob": "^7.1.3" "glob": "^7.1.3"
} }
}, },
"rollup": {
"version": "2.79.2",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.2.tgz",
"integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==",
"requires": {
"fsevents": "~2.3.2"
}
},
"rtlcss": { "rtlcss": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-4.0.0.tgz", "resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-4.0.0.tgz",

View File

@ -18,7 +18,6 @@
"monaco-editor": "^0.33.0", "monaco-editor": "^0.33.0",
"monaco-editor-webpack-plugin": "^7.0.1", "monaco-editor-webpack-plugin": "^7.0.1",
"picture-compressor": "^1.1.0", "picture-compressor": "^1.1.0",
"pinyin-match": "^1.2.2",
"quasar": "^2.7.0", "quasar": "^2.7.0",
"raw-loader": "^4.0.2", "raw-loader": "^4.0.2",
"vue": "^3.0.0", "vue": "^3.0.0",

View File

@ -12,6 +12,7 @@
"iconv-lite": "^0.6.3", "iconv-lite": "^0.6.3",
"marked": "^15.0.7", "marked": "^15.0.7",
"node-forge": "^1.3.1", "node-forge": "^1.3.1",
"pinyin-match": "^1.2.6",
"png2icons": "^2.0.1", "png2icons": "^2.0.1",
"ses": "^1.10.0", "ses": "^1.10.0",
"sm-crypto": "^0.3.13", "sm-crypto": "^0.3.13",
@ -184,6 +185,12 @@
"node": ">= 6.13.0" "node": ">= 6.13.0"
} }
}, },
"node_modules/pinyin-match": {
"version": "1.2.6",
"resolved": "https://registry.npmmirror.com/pinyin-match/-/pinyin-match-1.2.6.tgz",
"integrity": "sha512-d9fMSwZujH7UlMu+FO8MGXrgUYv0CwJtzpf3fQ8xgLJy1qfXlzOZsnQuL7Ej7msAiEtt37U7bE4dkVmyWaFfwA==",
"license": "SATA"
},
"node_modules/png2icons": { "node_modules/png2icons": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmmirror.com/png2icons/-/png2icons-2.0.1.tgz", "resolved": "https://registry.npmmirror.com/png2icons/-/png2icons-2.0.1.tgz",
@ -360,6 +367,11 @@
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz",
"integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==" "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA=="
}, },
"pinyin-match": {
"version": "1.2.6",
"resolved": "https://registry.npmmirror.com/pinyin-match/-/pinyin-match-1.2.6.tgz",
"integrity": "sha512-d9fMSwZujH7UlMu+FO8MGXrgUYv0CwJtzpf3fQ8xgLJy1qfXlzOZsnQuL7Ej7msAiEtt37U7bE4dkVmyWaFfwA=="
},
"png2icons": { "png2icons": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmmirror.com/png2icons/-/png2icons-2.0.1.tgz", "resolved": "https://registry.npmmirror.com/png2icons/-/png2icons-2.0.1.tgz",

View File

@ -7,6 +7,7 @@
"iconv-lite": "^0.6.3", "iconv-lite": "^0.6.3",
"marked": "^15.0.7", "marked": "^15.0.7",
"node-forge": "^1.3.1", "node-forge": "^1.3.1",
"pinyin-match": "^1.2.6",
"png2icons": "^2.0.1", "png2icons": "^2.0.1",
"ses": "^1.10.0", "ses": "^1.10.0",
"sm-crypto": "^0.3.13", "sm-crypto": "^0.3.13",

View File

@ -18,6 +18,7 @@ const md5 = (input) => {
}; };
window.lodashM = require("./lib/lodashMini"); window.lodashM = require("./lib/lodashMini");
window.pinyinMatch = require("pinyin-match");
const createTerminalCommand = require("./lib/createTerminalCommand"); const createTerminalCommand = require("./lib/createTerminalCommand");
const shortCodes = require("./lib/shortCodes"); const shortCodes = require("./lib/shortCodes");

View File

@ -72,7 +72,6 @@
<script> <script>
import { defineComponent } from "vue"; import { defineComponent } from "vue";
import { commandCategories } from "js/composer/composerConfig"; import { commandCategories } from "js/composer/composerConfig";
import pinyinMatch from "pinyin-match";
export default defineComponent({ export default defineComponent({
name: "ComposerList", name: "ComposerList",
@ -107,8 +106,8 @@ export default defineComponent({
commands: this.commands commands: this.commands
.filter( .filter(
(cmd) => (cmd) =>
(cmd.label && pinyinMatch.match(cmd.label, query)) || (cmd.label && window.pinyinMatch.match(cmd.label, query)) ||
(cmd.value && pinyinMatch.match(cmd.value, query)) (cmd.value && window.pinyinMatch.match(cmd.value, query))
) )
.filter((cmd) => cmd.type === category.label), .filter((cmd) => cmd.type === category.label),
})) }))
@ -151,7 +150,7 @@ export default defineComponent({
highlightText(text) { highlightText(text) {
if (!this.searchQuery) return text; if (!this.searchQuery) return text;
const matches = pinyinMatch.match(text, this.searchQuery); const matches = window.pinyinMatch.match(text, this.searchQuery);
if (!matches) return text; if (!matches) return text;
const [start, end] = matches; const [start, end] = matches;

View File

@ -63,7 +63,6 @@
<script> <script>
import CommandCard from "components/CommandCard.vue"; import CommandCard from "components/CommandCard.vue";
import draggable from "vuedraggable"; import draggable from "vuedraggable";
import pinyinMatch from "pinyin-match";
import { useCommandManager } from "js/commandManager.js"; import { useCommandManager } from "js/commandManager.js";
import { dbManager } from "js/utools.js"; import { dbManager } from "js/utools.js";
@ -153,7 +152,7 @@ export default {
commands.forEach((cmd) => { commands.forEach((cmd) => {
// //
let explain = cmd.features.explain; let explain = cmd.features.explain;
let matchedWordPositions = pinyinMatch.match( let matchedWordPositions = window.pinyinMatch.match(
explain, explain,
this.commandSearchKeyword this.commandSearchKeyword
); );

View File

@ -86,8 +86,6 @@
</template> </template>
<script> <script>
import pinyinMatch from "pinyin-match";
export default { export default {
data() { data() {
return { return {
@ -116,12 +114,12 @@ export default {
return this.items.filter((x) => { return this.items.filter((x) => {
if (this.is.json) { if (this.is.json) {
const titleMatch = pinyinMatch.match(x.title, this.searchWords); const titleMatch = window.pinyinMatch.match(x.title, this.searchWords);
const descMatch = const descMatch =
x.description && pinyinMatch.match(x.description, this.searchWords); x.description && window.pinyinMatch.match(x.description, this.searchWords);
return titleMatch || descMatch; return titleMatch || descMatch;
} else { } else {
return pinyinMatch.match(x, this.searchWords); return window.pinyinMatch.match(x, this.searchWords);
} }
}); });
}, },
@ -237,7 +235,7 @@ export default {
highlightText(text) { highlightText(text) {
if (!text || !this.searchWords) return text; if (!text || !this.searchWords) return text;
const matchInfo = pinyinMatch.match(text, this.searchWords); const matchInfo = window.pinyinMatch.match(text, this.searchWords);
if (!matchInfo) return text; if (!matchInfo) return text;
let result = text; let result = text;