From 004028d7b5b96427d07f6c3933650b7951211c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B3=E5=85=83=E7=9A=93?= Date: Wed, 21 May 2025 10:20:41 +0800 Subject: [PATCH] Install some stuff. --- bun.lock | 6 ++--- .../checks/checkKidUnfriendlyContent.ts | 6 ++--- package.json | 2 +- pages/test.vue | 24 ------------------- pages/tools/checkweirdkeywords.vue | 10 ++++---- 5 files changed, 13 insertions(+), 35 deletions(-) delete mode 100644 pages/test.vue diff --git a/bun.lock b/bun.lock index d0be1e6..ba62d0c 100644 --- a/bun.lock +++ b/bun.lock @@ -8,6 +8,7 @@ "@fontsource/fira-code": "^5.2.6", "@fontsource/fira-sans": "^5.2.5", "@heroicons/vue": "^2.2.0", + "@monyone/aho-corasick": "^1.0.4", "@nuxt/image": "1.10.0", "@nuxtjs/i18n": "9.5.4", "@nuxtjs/robots": "5.2.10", @@ -17,7 +18,6 @@ "@tailwindcss/vite": "^4.1.5", "@uploadthing/nuxt": "^7.1.7", "@vueuse/core": "^13.1.0", - "ahocorasick": "^1.0.2", "animate.css": "^4.1.1", "argon2": "^0.43.0", "axios": "^1.9.0", @@ -327,6 +327,8 @@ "@miyaneee/rollup-plugin-json5": ["@miyaneee/rollup-plugin-json5@1.2.0", "", { "dependencies": { "@rollup/pluginutils": "^5.1.0", "json5": "^2.2.3" }, "peerDependencies": { "rollup": "^1.20.0 || ^2.0.0 || ^3.0.0 || ^4.0.0" } }, "sha512-JjTIaXZp9WzhUHpElrqPnl1AzBi/rvRs065F71+aTmlqvTMVkdbjZ8vfFl4nRlgJy+TPBw69ZK4pwFdmOAt4aA=="], + "@monyone/aho-corasick": ["@monyone/aho-corasick@1.0.4", "", {}, "sha512-e0BaPN1RE/eGXjXT/bwu8AAJtOnFxEKh/nDNnDixleD9N8citOKS4GBeGhxIP4OjFSnq6sQxRtb+RYBoYn1msg=="], + "@msgpackr-extract/msgpackr-extract-darwin-arm64": ["@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3", "", { "os": "darwin", "cpu": "arm64" }, "sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw=="], "@msgpackr-extract/msgpackr-extract-darwin-x64": ["@msgpackr-extract/msgpackr-extract-darwin-x64@3.0.3", "", { "os": "darwin", "cpu": "x64" }, "sha512-mdzd3AVzYKuUmiWOQ8GNhl64/IoFGol569zNRdkLReh6LRLHOXxU4U8eq0JwaD8iFHdVGqSy4IjFL4reoWCDFw=="], @@ -885,8 +887,6 @@ "agentkeepalive": ["agentkeepalive@4.6.0", "", { "dependencies": { "humanize-ms": "^1.2.1" } }, "sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ=="], - "ahocorasick": ["ahocorasick@1.0.2", "", {}, "sha512-hCOfMzbFx5IDutmWLAt6MZwOUjIfSM9G9FyVxytmE4Rs/5YDPWQrD/+IR1w+FweD9H2oOZEnv36TmkjhNURBVA=="], - "ajv": ["ajv@6.12.6", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g=="], "algoliasearch": ["algoliasearch@5.25.0", "", { "dependencies": { "@algolia/client-abtesting": "5.25.0", "@algolia/client-analytics": "5.25.0", "@algolia/client-common": "5.25.0", "@algolia/client-insights": "5.25.0", "@algolia/client-personalization": "5.25.0", "@algolia/client-query-suggestions": "5.25.0", "@algolia/client-search": "5.25.0", "@algolia/ingestion": "1.25.0", "@algolia/monitoring": "1.25.0", "@algolia/recommend": "5.25.0", "@algolia/requester-browser-xhr": "5.25.0", "@algolia/requester-fetch": "5.25.0", "@algolia/requester-node-http": "5.25.0" } }, "sha512-n73BVorL4HIwKlfJKb4SEzAYkR3Buwfwbh+MYxg2mloFph2fFGV58E90QTzdbfzWrLn4HE5Czx/WTjI8fcHaMg=="], diff --git a/components/checks/checkKidUnfriendlyContent.ts b/components/checks/checkKidUnfriendlyContent.ts index 75350c2..bb7dc43 100644 --- a/components/checks/checkKidUnfriendlyContent.ts +++ b/components/checks/checkKidUnfriendlyContent.ts @@ -1,14 +1,14 @@ // Trying out the ahocorasick algorithm // Recommended by: https://www.threads.com/@hsinspeng/post/DJ3yVGQxBg7 -import AhoCorasick from "ahocorasick"; +import { AhoCorasick } from "@monyone/aho-corasick"; async function checkUnsafeContent(title: string) { try { const req = await fetch("/api/contentcheck/kidunfriendlycontent"); const res = await req.json(); - console.log(res.words); + console.log(res); const ac = new AhoCorasick(res.words); - const kidfriendly = ac.search(title); + const kidfriendly = ac.hasKeywordInText(title); console.log(kidfriendly); return kidfriendly; } catch (e) { diff --git a/package.json b/package.json index 1614a9e..edb0272 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@fontsource/fira-code": "^5.2.6", "@fontsource/fira-sans": "^5.2.5", "@heroicons/vue": "^2.2.0", + "@monyone/aho-corasick": "^1.0.4", "@nuxt/image": "1.10.0", "@nuxtjs/i18n": "9.5.4", "@nuxtjs/robots": "5.2.10", @@ -29,7 +30,6 @@ "@tailwindcss/vite": "^4.1.5", "@uploadthing/nuxt": "^7.1.7", "@vueuse/core": "^13.1.0", - "ahocorasick": "^1.0.2", "animate.css": "^4.1.1", "argon2": "^0.43.0", "axios": "^1.9.0", diff --git a/pages/test.vue b/pages/test.vue deleted file mode 100644 index aa6d46b..0000000 --- a/pages/test.vue +++ /dev/null @@ -1,24 +0,0 @@ - - diff --git a/pages/tools/checkweirdkeywords.vue b/pages/tools/checkweirdkeywords.vue index 98fee1d..389af85 100644 --- a/pages/tools/checkweirdkeywords.vue +++ b/pages/tools/checkweirdkeywords.vue @@ -2,10 +2,9 @@ import CheckKidUnfriendlyContent from "~/components/checks/checkKidUnfriendlyContent"; const title = ref(""); const system = ref(false); -const testingReturn = ref(""); const checkTitle = async () => { if (!title.value) return; - testingReturn.value = await CheckKidUnfriendlyContent(title.value); + system.value = await CheckKidUnfriendlyContent(title.value); }; useSeoMeta({ title: "這個文章是不是使用偏色情的標體?", @@ -17,7 +16,11 @@ useSeoMeta({ >

這個文章是不是使用偏色情的標體?

- + @@ -25,6 +28,5 @@ useSeoMeta({ 不是
-
{{ testingReturn }}