From 9f29e62292eea49f591e23f0e8467728120f8aba Mon Sep 17 00:00:00 2001 From: Kazuya Umeki <108924738+umekikazuya@users.noreply.github.com> Date: Fri, 24 Apr 2026 02:05:07 +0900 Subject: [PATCH 01/12] =?UTF-8?q?refactor:=20=E3=83=95=E3=83=AD=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=A8=E3=83=B3=E3=83=89=E3=81=AE=E3=83=AB=E3=83=BC?= =?UTF-8?q?=E3=83=86=E3=82=A3=E3=83=B3=E3=82=B0=E3=81=AE=E8=B2=AC=E5=8B=99?= =?UTF-8?q?=E3=82=92=E6=98=8E=E6=96=87=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/package.json | 1 + frontend/src/components/app-admin-shell.ts | 11 +- frontend/src/components/app-root.ts | 337 +++--------------- frontend/src/contexts/article-context.ts | 8 + frontend/src/contexts/auth-context.ts | 23 ++ frontend/src/contexts/profile-context.ts | 21 ++ .../src/controllers/article-controller.ts | 25 ++ frontend/src/controllers/auth-controller.ts | 173 +++++++++ .../src/controllers/profile-controller.ts | 114 ++++++ frontend/src/pages/page-about.ts | 18 +- frontend/src/pages/page-admin-account.ts | 70 ++-- frontend/src/pages/page-admin-articles.ts | 38 +- frontend/src/pages/page-admin-login.ts | 47 +-- frontend/src/pages/page-admin-profile.ts | 76 ++-- frontend/src/pages/page-top.ts | 33 +- pnpm-lock.yaml | 10 + 16 files changed, 538 insertions(+), 467 deletions(-) create mode 100644 frontend/src/contexts/article-context.ts create mode 100644 frontend/src/contexts/auth-context.ts create mode 100644 frontend/src/contexts/profile-context.ts create mode 100644 frontend/src/controllers/article-controller.ts create mode 100644 frontend/src/controllers/auth-controller.ts create mode 100644 frontend/src/controllers/profile-controller.ts diff --git a/frontend/package.json b/frontend/package.json index 52c76e6..993d78f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -16,6 +16,7 @@ }, "dependencies": { "@lit-labs/router": "^0.1.4", + "@lit/context": "^1.1.6", "lit": "^3.3.2", "urlpattern-polyfill": "^10.1.0" }, diff --git a/frontend/src/components/app-admin-shell.ts b/frontend/src/components/app-admin-shell.ts index ef1ba77..903956f 100644 --- a/frontend/src/components/app-admin-shell.ts +++ b/frontend/src/components/app-admin-shell.ts @@ -1,13 +1,15 @@ +import { consume } from '@lit/context' import { css, html, LitElement } from 'lit' import { customElement, property } from 'lit/decorators.js' import { classMap } from 'lit/directives/class-map.js' +import { authContext, type AuthController } from '../contexts/auth-context.js' import type { RouteShellElement } from './route-shell.js' import { playLeaveTransition, routeShellStyles } from './route-shell.js' @customElement('app-admin-shell') export class AppAdminShell extends LitElement implements RouteShellElement { - @property({ type: Boolean }) - authenticated = false + @consume({ context: authContext, subscribe: true }) + auth!: AuthController @property() currentPath = '/admin' @@ -16,10 +18,11 @@ export class AppAdminShell extends LitElement implements RouteShellElement { busy = false render() { + const authenticated = this.auth.status === 'authenticated' return html` -
+ ${ + this.form.updatedAt + ? html`
最終更新: ${new Date(this.form.updatedAt).toLocaleString('ja-JP')}
` - : null} + : null + } ${p.adminError ? html`` : null} - ${p.adminSuccess - ? html`` - : null} + ${ + p.adminSuccess + ? html`` + : null + } - ${p.adminLoading - ? html`プロフィールを読み込み中...
` - : html` + ${ + p.adminLoading + ? html`プロフィールを読み込み中...
` + : html`