mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-24 05:24:23 +00:00
Add AI friendlly README for other people to reuse apis. and added one time fetch the api so the server doesn't break. Also make the newsView more prettier.
This commit is contained in:
parent
fe026214dc
commit
5dc5018aca
3 changed files with 152 additions and 8 deletions
|
@ -6,7 +6,18 @@ import {
|
|||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import CheckKidUnfriendlyContent from "~/components/checks/checkKidUnfriendlyContent";
|
||||
import { AhoCorasick } from "@monyone/aho-corasick";
|
||||
|
||||
async function CheckKidUnfriendlyContent(title: string, words: any[]) {
|
||||
try {
|
||||
const ac = new AhoCorasick(words);
|
||||
const kidfriendly = ac.hasKeywordInText(title);
|
||||
return kidfriendly;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
const emit = defineEmits(["close", "min", "restore"]);
|
||||
const staticid = computed(() => props.staticid);
|
||||
|
||||
|
@ -54,8 +65,19 @@ onMounted(async () => {
|
|||
await updateContent(primary.value, false);
|
||||
});
|
||||
const checkResults = ref(new Map());
|
||||
var words = <any[]>[];
|
||||
const pullWord = async () => {
|
||||
if (words.length === 0) {
|
||||
const req = await fetch("/api/contentcheck/kidunfriendlycontent");
|
||||
const res = await req.json();
|
||||
pullWord = res.words;
|
||||
return res.words
|
||||
}
|
||||
return pullWord;
|
||||
}
|
||||
const checks = async (title: string) => {
|
||||
const result = await CheckKidUnfriendlyContent(title);
|
||||
const wordss = await pullWord();
|
||||
const result = await CheckKidUnfriendlyContent(title, wordss);
|
||||
checkResults.value.set(title, result);
|
||||
return result;
|
||||
};
|
||||
|
@ -157,7 +179,7 @@ const openPublisher = (text: string) => {};
|
|||
</button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent class="rounded">
|
||||
會打開關於媒體的視窗
|
||||
會打開關於媒體({{ item.publisher }})的視窗
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { SparklesIcon } from "lucide-vue-next";
|
||||
import { SparklesIcon, UserIcon, NewspaperIcon } from "lucide-vue-next";
|
||||
const slug = "kEJjxKw";
|
||||
// FOR THIS MODULE DO NOT USE THE ?APPNAME URL TYPE, IT WILL FALL AT ALL TIMES, I HAVE NO CLUE WHY IS BEHAVIOR HAPPENING RN?
|
||||
const { data, error, pending } = useFetch(`/api/news/get/lt/${slug.trim()}`); //demo URL
|
||||
|
@ -37,8 +37,10 @@ const aiSummary = async () => {
|
|||
>
|
||||
<div class="flex flex-col">
|
||||
<h2 class="text-3xl text-bold">{{ data.title }}</h2>
|
||||
<span class="text-lg text-bold"
|
||||
>origin: {{ data.origin }} • author: {{ data.author }}</span
|
||||
<span
|
||||
class="text-lg text-bold flex flex-row justify-center text-center align-center"
|
||||
><NewspaperIcon class="w-7 h-7 p-1" />{{ data.origin }} •
|
||||
<UserIcon class="w-7 h-7 p-1" />{{ data.author }}</span
|
||||
>
|
||||
<div class="test-center" v-for="item in data.paragraph">{{ item }}</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue