chore: 前端跑一遍 format、lint,尝试在 ci 中加入前端 lint 检查 (#353)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2025-06-04 21:37:26 +08:00
committed by GitHub
parent 6226fa7c4d
commit 0e98f484ef
6 changed files with 45 additions and 26 deletions

View File

@@ -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

View File

@@ -62,7 +62,7 @@
<div class="flex-1">
<Sidebar.Group>
<Sidebar.GroupLabel
class="text-muted-foreground mb-2 px-2 text-xs font-medium uppercase tracking-wider"
class="text-muted-foreground mb-2 px-2 text-xs font-medium tracking-wider uppercase"
>
视频来源
</Sidebar.GroupLabel>

View File

@@ -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; // 控制是否显示操作按钮

View File

@@ -12,7 +12,7 @@ export interface AppState {
export const appStateStore = writable<AppState>({
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
});
};

View File

@@ -61,7 +61,7 @@ export interface VideoResponse {
// 重置视频响应类型
export interface ResetVideoResponse {
resetted: boolean;
video: VideoInfo,
video: VideoInfo;
pages: PageInfo[];
}

View File

@@ -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;