Skip to content

Commit c6ad2fe

Browse files
committed
feat: add quick room watch action
1 parent 90c006d commit c6ad2fe

9 files changed

Lines changed: 514 additions & 8 deletions

File tree

app/globals.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4386,6 +4386,18 @@ textarea.config-input {
43864386
background: rgba(155, 134, 255, 0.045);
43874387
}
43884388

4389+
.room-card-actions .action-watch {
4390+
color: #61d7ca;
4391+
border-color: rgba(62, 231, 211, 0.12);
4392+
background: rgba(62, 231, 211, 0.035);
4393+
}
4394+
4395+
.room-card-actions .action-watch:hover {
4396+
color: #a4f5eb;
4397+
border-color: rgba(62, 231, 211, 0.24);
4398+
background: rgba(62, 231, 211, 0.07);
4399+
}
4400+
43894401
@media (max-width: 1120px) {
43904402
.config-field-grid {
43914403
grid-template-columns: 1fr;

components/Dashboard.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
Database,
1212
Eye,
1313
EyeOff,
14+
ExternalLink,
1415
Gauge,
1516
HardDrive,
1617
Info,
@@ -41,7 +42,7 @@ import {
4142
useRef,
4243
useState
4344
} from 'react';
44-
import { bilirecRequest } from '@/lib/api';
45+
import { bilirecRequest, openLiveRoom } from '@/lib/api';
4546
import ConfigurationCenter from '@/components/ConfigurationCenter';
4647
import RecordingLibrary from '@/components/RecordingLibrary';
4748
import UpdateCenter from '@/components/UpdateCenter';
@@ -153,14 +154,16 @@ function RoomCard({
153154
onAction,
154155
onDelete,
155156
onHistory,
156-
onConfigure
157+
onConfigure,
158+
onWatch
157159
}: {
158160
room: Room;
159161
busy: boolean;
160162
onAction: (room: Room, action: 'start' | 'stop' | 'split' | 'refresh') => void;
161163
onDelete: (room: Room) => void;
162164
onHistory: (room: Room) => void;
163165
onConfigure: (room: Room) => void;
166+
onWatch: (room: Room) => void;
164167
}) {
165168
const status = room.recording ? 'recording' : room.streaming ? 'live' : 'offline';
166169
const statusLabel = room.recording ? '录制中' : room.streaming ? '直播中' : '离线';
@@ -272,6 +275,15 @@ function RoomCard({
272275
<Settings2 size={15} />
273276
设置
274277
</button>
278+
<button
279+
className="room-action action-watch"
280+
type="button"
281+
onClick={() => onWatch(room)}
282+
title={`在线观看 ${room.name || room.roomId}`}
283+
>
284+
<ExternalLink size={15} />
285+
观看
286+
</button>
275287
{room.recording ? (
276288
<>
277289
<button
@@ -649,6 +661,19 @@ export default function Dashboard() {
649661
});
650662
};
651663

664+
const watchLiveRoom = async (room: Room) => {
665+
const url = `https://live.bilibili.com/${room.roomId}`;
666+
try {
667+
if ('__TAURI_INTERNALS__' in window) {
668+
await openLiveRoom(room.roomId);
669+
} else {
670+
window.open(url, '_blank', 'noopener,noreferrer');
671+
}
672+
} catch (error) {
673+
pushToast(error instanceof Error ? error.message : '无法打开直播间', 'error');
674+
}
675+
};
676+
652677
const executeConfirmed = async () => {
653678
if (!confirmState) return;
654679
setConfirmBusy(true);
@@ -970,6 +995,7 @@ export default function Dashboard() {
970995
onDelete={requestDeleteRoom}
971996
onHistory={(selectedRoom) => openLibrary(selectedRoom.roomId)}
972997
onConfigure={(selectedRoom) => openConfigCenter(selectedRoom.roomId)}
998+
onWatch={(selectedRoom) => void watchLiveRoom(selectedRoom)}
973999
/>
9741000
))}
9751001

lib/api.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ export function getMpvStatus() {
6161
return invoke<MpvStatus>('mpv_status');
6262
}
6363

64+
export function openLiveRoom(roomId: number) {
65+
return invoke<void>('open_live_room', { roomId });
66+
}
67+
6468
export function playRecordingWithMpv(
6569
connection: ConnectionSettings,
6670
fileUrl: string,

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bilirec-control",
3-
"version": "1.4.2",
3+
"version": "1.4.3",
44
"private": true,
55
"description": "基于 Tauri 2 与 Next.js 的录播姬本地控制中心",
66
"scripts": {

0 commit comments

Comments
 (0)