From 0e98f484ef67b0886217e8aa28a99cec2e81a08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Wed, 4 Jun 2025 21:37:26 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=89=8D=E7=AB=AF=E8=B7=91=E4=B8=80?= =?UTF-8?q?=E9=81=8D=20format=E3=80=81lint=EF=BC=8C=E5=B0=9D=E8=AF=95?= =?UTF-8?q?=E5=9C=A8=20ci=20=E4=B8=AD=E5=8A=A0=E5=85=A5=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=20lint=20=E6=A3=80=E6=9F=A5=20(#353)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr-check.yaml | 31 ++++++++++++++++++++--- web/src/lib/components/app-sidebar.svelte | 2 +- web/src/lib/components/video-card.svelte | 4 +-- web/src/lib/stores/filter.ts | 20 +++++++++------ web/src/lib/types.ts | 2 +- web/src/routes/+page.svelte | 12 ++------- 6 files changed, 45 insertions(+), 26 deletions(-) diff --git a/.github/workflows/pr-check.yaml b/.github/workflows/pr-check.yaml index 968c658..0d26edf 100644 --- a/.github/workflows/pr-check.yaml +++ b/.github/workflows/pr-check.yaml @@ -5,7 +5,7 @@ on: branches: - main pull_request: - types: ['opened', 'reopened', 'synchronize', 'ready_for_review'] + types: ["opened", "reopened", "synchronize", "ready_for_review"] concurrency: # Allow only one workflow per any non-`main` branch. @@ -18,8 +18,8 @@ env: RUST_BACKTRACE: 1 jobs: - tests: - name: Run Clippy and tests + check-backend: + name: Run backend checks runs-on: ubuntu-24.04 if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} steps: @@ -41,3 +41,28 @@ jobs: - name: cargo test run: cargo test + check-frontend: + name: Run frontend checks + runs-on: ubuntu-24.04 + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + defaults: + run: + working-directory: web + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Setup bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - name: Install dependencies + run: bun install --frozen-lockfile + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.bun/install/cache + key: ${{ runner.os }}-bun-${{ hashFiles('docs/bun.lockb') }} + restore-keys: | + ${{ runner.os }}-bun- + - name: Check Frontend + run: bun run lint diff --git a/web/src/lib/components/app-sidebar.svelte b/web/src/lib/components/app-sidebar.svelte index f4fedc7..13115f2 100644 --- a/web/src/lib/components/app-sidebar.svelte +++ b/web/src/lib/components/app-sidebar.svelte @@ -62,7 +62,7 @@
视频来源 diff --git a/web/src/lib/components/video-card.svelte b/web/src/lib/components/video-card.svelte index 6c45ded..f5b6a3c 100644 --- a/web/src/lib/components/video-card.svelte +++ b/web/src/lib/components/video-card.svelte @@ -3,14 +3,12 @@ import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card/index.js'; import { Button } from '$lib/components/ui/button/index.js'; import * as AlertDialog from '$lib/components/ui/alert-dialog/index.js'; - import type { ApiError, VideoInfo } from '$lib/types'; + import type { VideoInfo } from '$lib/types'; import RotateCcwIcon from '@lucide/svelte/icons/rotate-ccw'; import InfoIcon from '@lucide/svelte/icons/info'; import UserIcon from '@lucide/svelte/icons/user'; import { goto } from '$app/navigation'; - import api from '$lib/api'; import * as Tooltip from '$lib/components/ui/tooltip/index.js'; - import { toast } from 'svelte-sonner'; export let video: VideoInfo; export let showActions: boolean = true; // 控制是否显示操作按钮 diff --git a/web/src/lib/stores/filter.ts b/web/src/lib/stores/filter.ts index 1e90edd..8d3c2c3 100644 --- a/web/src/lib/stores/filter.ts +++ b/web/src/lib/stores/filter.ts @@ -12,7 +12,7 @@ export interface AppState { export const appStateStore = writable({ query: '', currentPage: 0, - videoSource: null, + videoSource: null }); export const ToQuery = (state: AppState): string => { @@ -41,36 +41,40 @@ export const setQuery = (query: string) => { export const setVideoSourceFilter = (filter: { type: string; id: string }) => { appStateStore.update((state) => ({ ...state, - videoSource: filter, + videoSource: filter })); }; export const clearVideoSourceFilter = () => { appStateStore.update((state) => ({ ...state, - videoSource: null, + videoSource: null })); }; export const setCurrentPage = (page: number) => { appStateStore.update((state) => ({ ...state, - currentPage: page, + currentPage: page })); }; export const resetCurrentPage = () => { appStateStore.update((state) => ({ ...state, - currentPage: 0, + currentPage: 0 })); }; -export const setAll = (query: string, currentPage: number, videoSource: { type: string; id: string } | null) => { +export const setAll = ( + query: string, + currentPage: number, + videoSource: { type: string; id: string } | null +) => { appStateStore.set({ query, currentPage, - videoSource, + videoSource }); }; @@ -78,6 +82,6 @@ export const clearAll = () => { appStateStore.set({ query: '', currentPage: 0, - videoSource: null, + videoSource: null }); }; diff --git a/web/src/lib/types.ts b/web/src/lib/types.ts index 086bc52..5bc773b 100644 --- a/web/src/lib/types.ts +++ b/web/src/lib/types.ts @@ -61,7 +61,7 @@ export interface VideoResponse { // 重置视频响应类型 export interface ResetVideoResponse { resetted: boolean; - video: VideoInfo, + video: VideoInfo; pages: PageInfo[]; } diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelte index 4234c0c..cb8c0bf 100644 --- a/web/src/routes/+page.svelte +++ b/web/src/routes/+page.svelte @@ -6,16 +6,11 @@ import * as AlertDialog from '$lib/components/ui/alert-dialog/index.js'; import RotateCcwIcon from '@lucide/svelte/icons/rotate-ccw'; import api from '$lib/api'; - import type { - VideosResponse, - VideoSourcesResponse, - ApiError, - ResetAllVideosResponse - } from '$lib/types'; + import type { VideosResponse, VideoSourcesResponse, ApiError } from '$lib/types'; import { onMount } from 'svelte'; import { page } from '$app/stores'; import { goto } from '$app/navigation'; - import { setVideoSources, videoSourceStore } from '$lib/stores/video-source'; + import { videoSourceStore } from '$lib/stores/video-source'; import { VIDEO_SOURCES } from '$lib/consts'; import { setBreadcrumb } from '$lib/stores/breadcrumb'; import { @@ -24,12 +19,9 @@ resetCurrentPage, setAll, setCurrentPage, - setQuery, - setVideoSourceFilter, ToQuery } from '$lib/stores/filter'; import { toast } from 'svelte-sonner'; - import { Title } from '$lib/components/ui/card'; const pageSize = 20;