From 1a05f16299cc594c91afc36d17992cd0db1f49b7 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 4 Aug 2025 01:46:26 +0800 Subject: [PATCH] :sparkles: Post detail page --- .../Client/src/dy-prefetch.d.ts | 7 ++ .../Client/src/views/pfp/index.vue | 2 +- .../Wallet/SubscriptionController.cs | 6 +- .../Wallet/SubscriptionService.cs | 4 +- DysonNetwork.Sphere/Client/index.html | 1 + .../Client/src/dy-prefetch.d.ts | 7 ++ .../Client/src/router/index.ts | 5 + .../Client/src/views/index.vue | 9 +- .../Client/src/views/posts.vue | 100 ++++++++++++++++++ 9 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 DysonNetwork.Drive/Client/src/dy-prefetch.d.ts create mode 100644 DysonNetwork.Sphere/Client/src/dy-prefetch.d.ts create mode 100644 DysonNetwork.Sphere/Client/src/views/posts.vue diff --git a/DysonNetwork.Drive/Client/src/dy-prefetch.d.ts b/DysonNetwork.Drive/Client/src/dy-prefetch.d.ts new file mode 100644 index 0000000..ba91e69 --- /dev/null +++ b/DysonNetwork.Drive/Client/src/dy-prefetch.d.ts @@ -0,0 +1,7 @@ +export {} + +declare global { + interface Window { + DyPrefetch?: any + } +} diff --git a/DysonNetwork.Pass/Client/src/views/pfp/index.vue b/DysonNetwork.Pass/Client/src/views/pfp/index.vue index fff663f..badb225 100644 --- a/DysonNetwork.Pass/Client/src/views/pfp/index.vue +++ b/DysonNetwork.Pass/Client/src/views/pfp/index.vue @@ -183,7 +183,7 @@ async function fetchUser() { console.log('[Fetch] Using the API to load user data.') try { - const resp = await fetch(`/api/accounts/${route.params.name}`) + const resp = await fetch(`/api/accounts/${route.params.slug}`) user.value = await resp.json() } catch (err) { console.error(err) diff --git a/DysonNetwork.Pass/Wallet/SubscriptionController.cs b/DysonNetwork.Pass/Wallet/SubscriptionController.cs index 1e4efc4..7d04f39 100644 --- a/DysonNetwork.Pass/Wallet/SubscriptionController.cs +++ b/DysonNetwork.Pass/Wallet/SubscriptionController.cs @@ -43,13 +43,11 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay { if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized(); - var subs = await db.WalletSubscriptions + var subscription = await db.WalletSubscriptions .Where(s => s.AccountId == currentUser.Id && s.IsActive) .Where(s => EF.Functions.ILike(s.Identifier, prefix + "%")) .OrderByDescending(s => s.BegunAt) - .ToListAsync(); - if (subs.Count == 0) return NotFound(); - var subscription = subs.FirstOrDefault(s => s.IsAvailable); + .FirstOrDefaultAsync(); if (subscription is null) return NotFound(); return Ok(subscription); diff --git a/DysonNetwork.Pass/Wallet/SubscriptionService.cs b/DysonNetwork.Pass/Wallet/SubscriptionService.cs index 5f5db41..adcc365 100644 --- a/DysonNetwork.Pass/Wallet/SubscriptionService.cs +++ b/DysonNetwork.Pass/Wallet/SubscriptionService.cs @@ -400,9 +400,9 @@ public class SubscriptionService( .OrderByDescending(s => s.BegunAt) .FirstOrDefaultAsync(); - // Cache the result if found (with 30 minutes expiry) + // Cache the result if found (with 5 minutes expiry) if (subscription != null) - await cache.SetAsync(cacheKey, subscription, TimeSpan.FromMinutes(30)); + await cache.SetAsync(cacheKey, subscription, TimeSpan.FromMinutes(5)); return subscription; } diff --git a/DysonNetwork.Sphere/Client/index.html b/DysonNetwork.Sphere/Client/index.html index f18006e..59e2789 100644 --- a/DysonNetwork.Sphere/Client/index.html +++ b/DysonNetwork.Sphere/Client/index.html @@ -6,6 +6,7 @@ Solar Network +
diff --git a/DysonNetwork.Sphere/Client/src/dy-prefetch.d.ts b/DysonNetwork.Sphere/Client/src/dy-prefetch.d.ts new file mode 100644 index 0000000..ba91e69 --- /dev/null +++ b/DysonNetwork.Sphere/Client/src/dy-prefetch.d.ts @@ -0,0 +1,7 @@ +export {} + +declare global { + interface Window { + DyPrefetch?: any + } +} diff --git a/DysonNetwork.Sphere/Client/src/router/index.ts b/DysonNetwork.Sphere/Client/src/router/index.ts index 1d13263..b524dcd 100644 --- a/DysonNetwork.Sphere/Client/src/router/index.ts +++ b/DysonNetwork.Sphere/Client/src/router/index.ts @@ -10,6 +10,11 @@ const router = createRouter({ name: 'index', component: () => import('../views/index.vue'), }, + { + path: '/posts/:slug', + name: 'postDetail', + component: () => import('../views/posts.vue'), + }, ], }) diff --git a/DysonNetwork.Sphere/Client/src/views/index.vue b/DysonNetwork.Sphere/Client/src/views/index.vue index 0a25563..a73ba95 100644 --- a/DysonNetwork.Sphere/Client/src/views/index.vue +++ b/DysonNetwork.Sphere/Client/src/views/index.vue @@ -4,7 +4,11 @@
- +
@@ -40,11 +44,14 @@