From 770c09b9b2f400bc5aee6da1befb83c62c2030f0 Mon Sep 17 00:00:00 2001 From: lethdat Date: Sun, 25 Jan 2026 17:30:17 +0700 Subject: [PATCH] update ui --- src/api/client.ts | 9 +- src/api/httpClientAdapter.server.ts | 41 +++-- src/routes/notification/Notification.vue | 157 +++++++++++++++++- .../components/NotificationActions.vue | 53 ++++++ .../components/NotificationItem.vue | 109 ++++++++++++ .../components/NotificationList.vue | 69 ++++++++ .../components/NotificationTabs.vue | 49 ++++++ src/routes/plans/Plans.vue | 6 +- 8 files changed, 463 insertions(+), 30 deletions(-) create mode 100644 src/routes/notification/components/NotificationActions.vue create mode 100644 src/routes/notification/components/NotificationItem.vue create mode 100644 src/routes/notification/components/NotificationList.vue create mode 100644 src/routes/notification/components/NotificationTabs.vue diff --git a/src/api/client.ts b/src/api/client.ts index 6b8f2f2..528e28a 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -682,12 +682,5 @@ export class Api< export const client = new Api({ baseUrl: 'r', // baseUrl: 'https://api.pipic.fun', - customFetch: (url, options) => { - options.headers = { - ...options.headers, - "X-Forwarded-For": "[IP_ADDRESS]" - } - options.credentials = "include" - return fetch(url, options) - } + customFetch }); \ No newline at end of file diff --git a/src/api/httpClientAdapter.server.ts b/src/api/httpClientAdapter.server.ts index e87e533..73372e2 100644 --- a/src/api/httpClientAdapter.server.ts +++ b/src/api/httpClientAdapter.server.ts @@ -1,25 +1,40 @@ import { tryGetContext } from "hono/context-storage"; -export const customFetch = async (url: string, options: RequestInit) => { +export const customFetch = (url: string, options: RequestInit) => { options.credentials = "include"; if (import.meta.env.SSR) { const c = tryGetContext(); if (!c) { throw new Error("Hono context not found in SSR"); } - Object.assign(options, { - headers: c.req.header() - }); - console.log("url", url) - const res = await fetch(["https://api.pipic.fun", url.replace(/r\//, '')].join('/'), options); - if (url.includes("r/plans")) { - console.log("res", await res.json()) + // Merge headers properly - keep original options.headers and add request headers + const reqHeaders = new Headers(c.req.header()); + // Remove headers that shouldn't be forwarded + reqHeaders.delete("host"); + reqHeaders.delete("connection"); - } - res.headers.forEach((value, key) => { - c.header(key, value); + const mergedHeaders: Record = {}; + reqHeaders.forEach((value, key) => { + mergedHeaders[key] = value; + }); + options.headers = { + ...mergedHeaders, + ...(options.headers as Record) + }; + + const apiUrl = ["https://api.pipic.fun", url.replace(/^r/, '')].join(''); + // const res = await fetch(apiUrl, options); + + // Forward response headers to client (especially Set-Cookie) + // res.headers.forEach((value, key) => { + // c.header(key, value); + // }); + return fetch(apiUrl, options).then(res => { + // Forward response headers to client (especially Set-Cookie) + res.headers.forEach((value, key) => { + c.header(key, value); + }); + return res; }); - return res; } - return fetch(url, options); } \ No newline at end of file diff --git a/src/routes/notification/Notification.vue b/src/routes/notification/Notification.vue index 2524345..dc837ad 100644 --- a/src/routes/notification/Notification.vue +++ b/src/routes/notification/Notification.vue @@ -1,8 +1,157 @@ + + - \ No newline at end of file + \ No newline at end of file diff --git a/src/routes/notification/components/NotificationActions.vue b/src/routes/notification/components/NotificationActions.vue new file mode 100644 index 0000000..9114882 --- /dev/null +++ b/src/routes/notification/components/NotificationActions.vue @@ -0,0 +1,53 @@ + + + diff --git a/src/routes/notification/components/NotificationItem.vue b/src/routes/notification/components/NotificationItem.vue new file mode 100644 index 0000000..124090d --- /dev/null +++ b/src/routes/notification/components/NotificationItem.vue @@ -0,0 +1,109 @@ + + + + + diff --git a/src/routes/notification/components/NotificationList.vue b/src/routes/notification/components/NotificationList.vue new file mode 100644 index 0000000..eab1380 --- /dev/null +++ b/src/routes/notification/components/NotificationList.vue @@ -0,0 +1,69 @@ + + + diff --git a/src/routes/notification/components/NotificationTabs.vue b/src/routes/notification/components/NotificationTabs.vue new file mode 100644 index 0000000..c3b5753 --- /dev/null +++ b/src/routes/notification/components/NotificationTabs.vue @@ -0,0 +1,49 @@ + + + diff --git a/src/routes/plans/Plans.vue b/src/routes/plans/Plans.vue index f40f50a..43ed56d 100644 --- a/src/routes/plans/Plans.vue +++ b/src/routes/plans/Plans.vue @@ -43,11 +43,7 @@ const currentPlan = computed(() => { return plans.value.find(p => p.id === currentPlanId.value); }); -const { data, isLoading, mutate: mutatePlans } = useSWRV("r/plans", async () => { - console.log("plansList") - const res = await client.plans.plansList() - return res.data -}) +const { data, isLoading, mutate: mutatePlans } = useSWRV("r/plans", () => client.plans.plansList()) watch(data, (newValue) => { if (newValue) {