Add I18N into the confirm quit option & you can now view articles from clicking on the "View article" button (but for now you can not view dynamic articles & also chnaged the path from /_assets/ to /n3a_assets/ & Made the title as the navbar thing

This commit is contained in:
吳元皓 2025-05-29 15:32:10 +08:00
parent 10158a390c
commit 937f8ad531
6 changed files with 87 additions and 46 deletions

View File

@ -18,9 +18,17 @@ async function CheckKidUnfriendlyContent(title: string, words: any[]) {
} }
} }
const emit = defineEmits(["close", "min", "restore"]); const emit = defineEmits([
"openArticles",
"openNewsSourcePage",
"windowopener",
]);
const staticid = computed(() => props.staticid); const staticid = computed(() => props.staticid);
const openNewWindow = (itemId: string) => {
emit("windowopener", "aboutNewsOrg");
};
const contentArray = ref([]); const contentArray = ref([]);
const errorr = ref(false); const errorr = ref(false);
const switchTabs = ref(false); const switchTabs = ref(false);
@ -163,11 +171,13 @@ const useArgFindRel = (title) => {
return similarities.sort((a, b) => b.similarity - a.similarity).slice(0, 3); return similarities.sort((a, b) => b.similarity - a.similarity).slice(0, 3);
}; };
const openNews = (url: string) => { const openNews = (url: string, titleName: string) => {
console.log(url); emit("openArticles", url, titleName);
}; };
const openPublisher = (text: string) => {}; const openPublisher = (text: string) => {
emit("openNewsSourcePage", text);
};
</script> </script>
<template> <template>
<div class="justify-center align-center text-center"> <div class="justify-center align-center text-center">
@ -247,7 +257,7 @@ const openPublisher = (text: string) => {};
<Tooltip> <Tooltip>
<TooltipTrigger> <TooltipTrigger>
<button <button
@click="openNews(item.url.hash)" @click="openNews(item.url.hash, item.title)"
class="flex flex-row p-1 bg-sky-300/50 hover:bg-sky-400/50 shadow-lg backdrop-blur-sm rounded transition-all duration-200" class="flex flex-row p-1 bg-sky-300/50 hover:bg-sky-400/50 shadow-lg backdrop-blur-sm rounded transition-all duration-200"
> >
<ScanEyeIcon class="w-6 h-6 p-1" /><span>觀看文章</span> <ScanEyeIcon class="w-6 h-6 p-1" /><span>觀看文章</span>
@ -260,25 +270,27 @@ const openPublisher = (text: string) => {};
</TooltipProvider> </TooltipProvider>
</div> </div>
<div> <div>
<div> <div>
<h3 class="text-lg">類似文章</h3> <h3 class="text-lg">類似文章</h3>
<div v-if="useArgFindRel(item.title).length > 0" class="space-y-2">
<div <div
v-for="similar in useArgFindRel(item.title)" v-if="useArgFindRel(item.title).length > 0"
:key="similar.item.id" class="space-y-2"
class="p-2 bg-gray-100 rounded text-sm cursor-pointer hover:bg-gray-200"
@click="openNews(similar.item.url.hash)"
> >
<div class="font-medium">{{ similar.title }}</div> <div
<div class="text-gray-500 text-xs"> v-for="similar in useArgFindRel(item.title)"
相似度: {{ (similar.similarity * 100).toFixed(1) }}% | {{ similar.item.publisher }} :key="similar.item.id"
class="p-2 bg-gray-100 rounded text-sm cursor-pointer hover:bg-gray-200"
@click="openNews(similar.item.url.hash, item.title)"
>
<div class="font-medium">{{ similar.title }}</div>
<div class="text-gray-500 text-xs">
相似度: {{ (similar.similarity * 100).toFixed(1) }}% |
{{ similar.item.publisher }}
</div>
</div> </div>
</div> </div>
<div v-else class="text-gray-500 text-sm">找不到類似文章</div>
</div> </div>
<div v-else class="text-gray-500 text-sm">
找不到類似文章
</div>
</div>
<!--<div v-for="item in findRel(item.title)"> <!--<div v-for="item in findRel(item.title)">
{{ item }} {{ item }}
</div>--> </div>-->

View File

@ -74,7 +74,8 @@
"starred": "Starred", "starred": "Starred",
"terminal": "Terminal", "terminal": "Terminal",
"aboutNewsOrg": "About this news organization", "aboutNewsOrg": "About this news organization",
"newsview": "News View" "newsview": "News View",
"areyousure": "Are you sure?",
}, },
"tools": { "tools": {
"title": "Tools", "title": "Tools",

View File

@ -74,7 +74,8 @@
"starred": "收藏", "starred": "收藏",
"terminal": "終端機", "terminal": "終端機",
"aboutNewsOrg": "關於這個新聞來源", "aboutNewsOrg": "關於這個新聞來源",
"newsview": "新聞" "newsview": "新聞",
"areyousure": "你確定?"
}, },
"tools": { "tools": {
"title": "工具", "title": "工具",

View File

@ -20,11 +20,13 @@ export default defineNuxtConfig({
}, },
"/api/**": { "/api/**": {
cors: true, cors: true,
headers: { headers: {
"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS", "Access-Control-Allow-Methods":
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With", "GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS",
}, "Access-Control-Allow-Headers":
"Content-Type, Authorization, X-Requested-With",
},
}, },
"/api/cached/**": { swr: 3600 }, "/api/cached/**": { swr: 3600 },
"/api/news/get": { swr: 3600 }, "/api/news/get": { swr: 3600 },
@ -58,7 +60,7 @@ export default defineNuxtConfig({
}, },
app: { app: {
buildAssetsDir: "/_assets/", buildAssetsDir: "/_n3a_assets/",
head: { head: {
title: "", title: "",
htmlAttrs: { htmlAttrs: {

View File

@ -227,7 +227,7 @@ onMounted(() => {
const openWindow = (windowName?: string) => { const openWindow = (windowName?: string) => {
if (windowName === "leave") { if (windowName === "leave") {
if (confirm("Are you sure?")) { if (confirm(t("app.areyousure"))) {
router.push(localePath("/home")); router.push(localePath("/home"));
} else { } else {
return; return;
@ -239,7 +239,9 @@ const openWindow = (windowName?: string) => {
}; };
const unMinWindow = (windowName?: string) => { const unMinWindow = (windowName?: string) => {
hiddenWindows.value = hiddenWindows.value.filter(window => window.name !== windowName); hiddenWindows.value = hiddenWindows.value.filter(
(window) => window.name !== windowName,
);
console.log(windowName); console.log(windowName);
}; };
@ -261,7 +263,7 @@ onMounted(async () => {
} }
}); });
const findAndOpenWindow = (windowName: string) => { const findAndOpenWindow = (windowName: string, windowTitle?: string) => {
const app = associAppWindow.find((app) => app.name === windowName); const app = associAppWindow.find((app) => app.name === windowName);
// Prevent dual logins // Prevent dual logins
@ -290,7 +292,7 @@ const findAndOpenWindow = (windowName: string) => {
absoluteId: abosluteId, absoluteId: abosluteId,
component: windowComponent, component: windowComponent,
name: windowName, name: windowName,
title: app.title, title: windowTitle || app.title,
width: app.width || "600px", width: app.width || "600px",
height: app.height || "400px", height: app.height || "400px",
black: app.black || false, black: app.black || false,
@ -299,13 +301,13 @@ const findAndOpenWindow = (windowName: string) => {
// Add to navbar // Add to navbar
const windowNameVal2 = const windowNameVal2 =
globalWindowVal.value.get(windowName).windowCount === 1 globalWindowVal.value.get(windowName).windowCount === 1
? windowName ? app.title
: windowName + : app.title +
"(" + "(" +
globalWindowVal.value.get(windowName).windowCount + globalWindowVal.value.get(windowName).windowCount +
")"; ")";
currentNavBar.value.push({ currentNavBar.value.push({
name: windowNameVal2, name: windowTitle || windowNameVal2,
icon: "anything", icon: "anything",
action: "idk", action: "idk",
flash: true, flash: true,
@ -348,9 +350,13 @@ const openNewWindowViaApp = (windowId: string) => {
}; };
const toggleMinWindow = (windowUUId: string) => { const toggleMinWindow = (windowUUId: string) => {
const windowInfo = currentNavBar.value.find(item => item.windowAssociated === windowUUId); const windowInfo = currentNavBar.value.find(
const activeWindow = activeWindows.value.find(window => window.absoluteId === windowUUId); (item) => item.windowAssociated === windowUUId,
// Add logic to store hidden windows. );
const activeWindow = activeWindows.value.find(
(window) => window.absoluteId === windowUUId,
);
// Add logic to store hidden windows.
if (windowInfo && activeWindow) { if (windowInfo && activeWindow) {
hiddenWindows.value.push({ hiddenWindows.value.push({
id: activeWindow.id, id: activeWindow.id,
@ -362,10 +368,11 @@ const toggleMinWindow = (windowUUId: string) => {
height: activeWindow.height, height: activeWindow.height,
black: activeWindow.black || false, black: activeWindow.black || false,
lastpositionw: "", lastpositionw: "",
lastpositionh: "" lastpositionh: "",
}); });
//activeWindows.value = activeWindows.value.filter(window => window.absoluteId !== windowUUId); //activeWindows.value = activeWindows.value.filter(window => window.absoluteId !== windowUUId);
} }
console.log(hiddenWindows.value);
}; };
// Title // Title
@ -420,14 +427,31 @@ watchEffect((cleanupFn) => {
cleanupFn(() => clearTimeout(timmmer)); cleanupFn(() => clearTimeout(timmmer));
}); });
const openArticles = async (slug: string) => { const openArticles = async (slug: string, titleName: string) => {
openArticlesArray.value.push({ openingAppViaAnApp.value = true;
id: openArticlesId.value, passedValues.value = slug;
slug: slug, const titleNameFinal = titleName + "&nbsp;" + t("app.newsview");
}); findAndOpenWindow("newsView", titleName);
openArticlesId.value += 1;
setTimeout(() => {
openingAppViaAnApp.value = false;
passedValues.value = null;
}, 1000);
}; };
const openNewsSourcePage = async (slug: string, titleName: string) => {
openingAppViaAnApp.value = true;
passedValues.value = slug;
const titleNameFinal = titleName + "&nbsp;" + t("app.aboutNewsOrg");
findAndOpenWindow("aboutNewsOrg", titleNameFinal);
setTimeout(() => {
openingAppViaAnApp.value = false;
passedValues.value = null;
}, 1000);
};
// Not used?
const getStaticArticleId = () => { const getStaticArticleId = () => {
storeStaticArticleId.value += 1; storeStaticArticleId.value += 1;
return storeStaticArticleId.value; return storeStaticArticleId.value;
@ -550,6 +574,7 @@ const getStaticArticleId = () => {
@windowopener="openNewWindowViaApp($event)" @windowopener="openNewWindowViaApp($event)"
@loadValue="" @loadValue=""
@openArticles="openArticles" @openArticles="openArticles"
@openNewsSourcePage="openNewsSourcePage"
:staticid="getStaticArticleId" :staticid="getStaticArticleId"
:values="passedValues" :values="passedValues"
/> />