修改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-webpack-plugin": "^7.0.1",
"picture-compressor": "^1.1.0",
"pinyin-match": "^1.2.2",
"quasar": "^2.7.0",
"raw-loader": "^4.0.2",
"vue": "^3.0.0",
@ -5795,6 +5794,7 @@
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
@ -7837,14 +7837,6 @@
"resolved": "https://registry.npmmirror.com/picture-compressor/-/picture-compressor-1.1.0.tgz",
"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": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-7.0.0.tgz",
@ -9031,21 +9023,6 @@
"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": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-4.0.0.tgz",
@ -15433,6 +15410,7 @@
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"optional": true
},
"function-bind": {
@ -16840,14 +16818,6 @@
"resolved": "https://registry.npmmirror.com/picture-compressor/-/picture-compressor-1.1.0.tgz",
"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": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-7.0.0.tgz",
@ -17592,14 +17562,6 @@
"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": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-4.0.0.tgz",

View File

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

View File

@ -12,6 +12,7 @@
"iconv-lite": "^0.6.3",
"marked": "^15.0.7",
"node-forge": "^1.3.1",
"pinyin-match": "^1.2.6",
"png2icons": "^2.0.1",
"ses": "^1.10.0",
"sm-crypto": "^0.3.13",
@ -184,6 +185,12 @@
"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": {
"version": "2.0.1",
"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",
"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": {
"version": "2.0.1",
"resolved": "https://registry.npmmirror.com/png2icons/-/png2icons-2.0.1.tgz",

View File

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

View File

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

View File

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

View File

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

View File

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