From 29760dda96cb988cc06c6e91a7b89efc2a5b8497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B3=E5=85=83=E7=9A=93?= Date: Sat, 7 Jun 2025 23:51:05 +0800 Subject: [PATCH] Made a working settings panel & includes the user's info, what is missing? well, all the actions that requires the data to be sent to the server is still not there yet. Tried to add onboarding, but I have just no idea how to do it (Maybe I can do it w/ a video? --- README.ZH_TW.md | 4 + components/app/windows/settings.vue | 170 +++++++++++------- pages/desktop.vue | 82 +++++++++ ...erInfo.post.ts => sendUserChanges.post.ts} | 5 +- server/api/user/validateUserToken.ts | 1 + server/components/customgroqsystem.ts | 2 +- 6 files changed, 201 insertions(+), 63 deletions(-) rename server/api/user/{sendUserInfo.post.ts => sendUserChanges.post.ts} (93%) diff --git a/README.ZH_TW.md b/README.ZH_TW.md index 51b99fe..3ac0c78 100644 --- a/README.ZH_TW.md +++ b/README.ZH_TW.md @@ -21,6 +21,10 @@ Reverse engineering 文檔: [about](/about/) ## Note for developing The desktop enviroment is super unstable when even using a beefy computer, even so, the desktop will lag when opening the newsView, like it's just hates being in a dev env. Prod app works tho, so you can demo it using `bun run build && bun run preview` for demoing. Please don't file a issue request for this matter. If you have the fix, please contribute using Github PRs. +## 如果要開發,你需要 +- 一個 Postgres 資料庫 (你可以用 Zeabur 跑開發用資料庫,可以用我的 [優惠連結(?](https://zeabur.com/referral?referralCode=hpware),你可以拿到大約150塊的試用金額 +- 一個 Groq 的 API + ## 為什麼? 我們使用這個新聞來舉例: diff --git a/components/app/windows/settings.vue b/components/app/windows/settings.vue index a5ec556..3cd9a7c 100644 --- a/components/app/windows/settings.vue +++ b/components/app/windows/settings.vue @@ -1,57 +1,6 @@ diff --git a/pages/desktop.vue b/pages/desktop.vue index 3a3325e..2b5dc16 100644 --- a/pages/desktop.vue +++ b/pages/desktop.vue @@ -220,6 +220,88 @@ const associAppWindow = [ }, ]; +// OnBoarding +// Feedback from: https://hackclub.slack.com/archives/C090DPG6681/p1749303838738019 +const currentStep = ref(0); +const showOnboarding = ref(true); +onMounted(() => { + showOnboarding.value = !localStorage.getItem("onboardingComplete"); +}); +const nextStep = () => { + currentStep.value++; +}; +const finishOnboarding = () => { + showOnboarding.value = false; + localStorage.setItem("onboardingComplete", "true"); +}; +/*const onBoarding = [ + { + step: 0, + point: "none", + text: "Hi! Welcome to the news analyze desktop enviroment!", + buttons: [ + "bypass": nextStep, + "contuine": nextStep + ] + }, + { + step: 1, + point: "top-left", + text: "Click here to open applications", + buttons: [ + "ok": nextStep + ] + }, + { + step: 2, + point: "left-navbar-1", + text: "Click here to open the news window", + buttons: [ + "ok": nextStep + ] + }, + { + step: 3, + point: "center", + text: "Click here open a news article", + buttons: [ + "ok": nextStep + ] + }, + { + step: 4, + point: "center-close-translate-left", + text: "Click here to translate the page.", + buttons: [ + "ok": nextStep + ] + }, + { + step: 5, + point: "center-close-x-left", + text: "Click here to close the window", + buttons: [ + "ok": nextStep + ] + }, + { + step: 6, + point: "more-top-right-3", + text: "Click here to change the app's language. (YOU WILL LOSE ALL YOUR WINDOWS)", + buttons: [ + "ok": nextStep + ] + }, + { + step: 7, + point: "none", + text: "That's it, welcome! If you want to learn more, you can go to yhw.tw/newsanalyzedocs.", + buttons: [ + "ok": finishOnboarding + ] + }, + ];*/ + // Confeti const successcanvas = ref(); const confetiActive = ref(false); diff --git a/server/api/user/sendUserInfo.post.ts b/server/api/user/sendUserChanges.post.ts similarity index 93% rename from server/api/user/sendUserInfo.post.ts rename to server/api/user/sendUserChanges.post.ts index eea2c34..adaa36f 100644 --- a/server/api/user/sendUserInfo.post.ts +++ b/server/api/user/sendUserChanges.post.ts @@ -1,7 +1,7 @@ import sql from "~/server/components/postgres"; export default defineEventHandler(async (event) => { const body = await readBody(event); - const { request_change } = body; + /* const userToken = getCookie(event, "token"); if (!userToken) { return { @@ -19,5 +19,6 @@ export default defineEventHandler(async (event) => { } if (request_change === "groq_api_key") { const updateListing = await sql``; - } + }*/ + return { body: body }; }); diff --git a/server/api/user/validateUserToken.ts b/server/api/user/validateUserToken.ts index a41a940..0f378ce 100644 --- a/server/api/user/validateUserToken.ts +++ b/server/api/user/validateUserToken.ts @@ -39,6 +39,7 @@ export default defineEventHandler(async (event) => { } return { userAccount: fetchViaSQL[0].username, + firstName: fetchViaSQL[0].firstName, requested_action: "CONTINUE", email: fetchViaSQL[0].email, avatarURL: fetchViaSQL[0].avatarurl, diff --git a/server/components/customgroqsystem.ts b/server/components/customgroqsystem.ts index 6995d7f..e6bc578 100644 --- a/server/components/customgroqsystem.ts +++ b/server/components/customgroqsystem.ts @@ -19,7 +19,7 @@ export async function checkIfUserHasCustomGroqKey(token?: string) { } const fetchUserToken = await sql` select groq_api_key from user_other_data - where username=${checkRealToken[0].username}`; + where username = ${checkRealToken[0].username}`; if (fetchUserToken.length === 0) { return { status: false,