### Start Coturn Container Source: https://github.com/galaxy-s10/billd-desk/blob/main/doc/本地环境.md Launches a Coturn container using the host network and mounting a local configuration file. ```bash LOCAL_DOCKER_COTURN_PATH=/Users/huangshuisheng/Desktop/docker/coturn \ && docker run -d --network=host \ --name billd-desk-coturn \ -v $LOCAL_DOCKER_COTURN_PATH/coturn.conf:/my/coturn.conf \ coturn/coturn -c /my/coturn.conf ``` -------------------------------- ### GET Request with Query Parameters Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/http-client.md Shows how to send a GET request with query parameters for filtering and pagination. The 'IPaging' and 'ILiveRoom' types should be defined. ```typescript import request from '@/utils/request'; // GET with query parameters const response = await request.get>( '/live_room/list', { params: { nowPage: 1, pageSize: 20, orderBy: 'desc' } } ); if (response.code === 200) { console.log('Total:', response.data.total); console.log('Rooms:', response.data.rows); } ``` -------------------------------- ### Simple GET Request Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/http-client.md Demonstrates a basic GET request to fetch user information. Ensure the 'IUser' type is defined elsewhere. ```typescript import request from '@/utils/request'; // Simple GET request const response = await request.get('/user/get_user_info'); ``` -------------------------------- ### Start MySQL Container with Custom Configuration Source: https://github.com/galaxy-s10/billd-desk/blob/main/doc/本地环境.md Launches a MySQL container, mapping ports, setting a root password, and mounting local configuration and data volumes. ```bash LOCAL_DOCKER_MYSQL_PATH=/Users/huangshuisheng/Desktop/docker/mysql \ && docker run -d \ -p 3306:3306 \ --name billd-desk-mysql \ -e MYSQL_ROOT_PASSWORD=mysql123. \ -v $LOCAL_DOCKER_MYSQL_PATH/conf/my.cnf:/etc/my.cnf \ -v $LOCAL_DOCKER_MYSQL_PATH/data:/var/lib/mysql/ \ mysql:8.0 ``` -------------------------------- ### Start Redis Container with Custom Configuration Source: https://github.com/galaxy-s10/billd-desk/blob/main/doc/本地环境.md Launches a Redis container, mapping ports, and mounting local data and configuration files. Ensure the conf and data directories are created locally. ```bash LOCAL_DOCKER_RESIS_PATH=/Users/huangshuisheng/Desktop/docker/redis \ && docker run -d \ -p 6379:6379 \ --name billd-desk-redis \ -v $LOCAL_DOCKER_RESIS_PATH/data:/data \ -v $LOCAL_DOCKER_RESIS_PATH/conf/redis.conf:/etc/redis/redis.conf \ -v $LOCAL_DOCKER_RESIS_PATH/conf/users.acl:/etc/redis/users.acl \ redis:7.0 redis-server /etc/redis/redis.conf ``` -------------------------------- ### POST Request with JSON Body Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/http-client.md Example of a POST request to log in a user, sending credentials in the request body. ```typescript import request from '@/utils/request'; // POST with JSON body const response = await request.post( '/user/login', { id: 'username', password: 'password' } ); ``` -------------------------------- ### useUpload Hook Usage Example Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/hooks.md Demonstrates how to use the useUpload hook in a Vue.js component to handle file selection and display upload progress. ```typescript import { useUpload } from '@/hooks/use-upload'; export default { setup() { const { uploadFile, uploadProgress, isUploading } = useUpload(); const handleFileSelect = async (event) => { const file = event.target.files[0]; try { const result = await uploadFile(file, { prefix: 'uploads/images', type: 'image' }); console.log('Upload complete:', result.url); } catch (error) { console.error('Upload failed:', error); } }; return { handleFileSelect, uploadProgress, isUploading }; } }; // Template ``` -------------------------------- ### useWebRtcLive Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/hooks.md Manages WebRTC connections for live streaming. Provides functionality to update configuration, start, and stop broadcasting. ```APIDOC ### useWebRtcLive Manages WebRTC connections for live streaming. ```typescript import { useWebRtcLive } from '@/hooks/webrtc/live'; export const useWebRtcLive = () => { return { webRtcLive: ref, updateWebRtcLiveConfig: (config: RTCConfig) => void, startBroadcast: () => Promise, stopBroadcast: () => Promise }; }; ``` ``` -------------------------------- ### Initiate WebRTC Publishing with SRS Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/streaming-api.md Use this function to start broadcasting a stream using the SRS protocol. It requires the SRS API endpoint, stream URL, and SDP offer from the local peer. ```typescript export function fetchRtcV1Publish(data: { api: string; clientip: string | null; sdp: string; streamurl: string; tid: string; }) ``` ```typescript import { fetchRtcV1Publish } from '@/api/srs'; const startWebRTCPublish = async (peerConnection, streamUrl) => { try { const offer = await peerConnection.createOffer(); await peerConnection.setLocalDescription(offer); const response = await fetchRtcV1Publish({ api: 'http://srs.example.com/api/v1/rtc/publish', clientip: null, sdp: peerConnection.localDescription.sdp, streamurl: streamUrl, tid: Date.now().toString() }); if (response.code === 200) { const answer = new RTCSessionDescription({ type: 'answer', sdp: response.data.sdp }); await peerConnection.setRemoteDescription(answer); console.log('Publishing to SRS'); } } catch (error) { console.error('Publish failed:', error); } }; ``` -------------------------------- ### Accessing Reactive State from useWebsocket Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/hooks.md Shows how to destructure and utilize reactive state variables like `connectStatus`, `roomLiving`, `isAnchor`, `liveUserList`, `damuList`, and `anchorInfo` from the `useWebsocket` hook. Includes examples of watching for changes in `connectStatus` and `liveUserList`. ```typescript const { connectStatus, // WsConnectStatusEnum roomLiving, // Is room currently broadcasting? isAnchor, // Is current user the broadcaster? liveUserList, // Array of online users damuList, // Array of chat messages anchorInfo // IUser - Broadcaster info } = useWebsocket(); watch(connectStatus, (status) => { if (status === WsConnectStatusEnum.connected) { console.log('Connected to live room'); } }); watch(liveUserList, (users) => { console.log(`${users.length} users online`); }); ``` -------------------------------- ### Fetch Server Information (TypeScript) Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/other-apis.md Retrieves backend server environment and version information. Use this to get details about the server's OS, Node.js, MySQL versions, and build commit hash. ```typescript export function fetchServerInfo() ``` ```typescript import { fetchServerInfo } from '@/api/other'; const response = await fetchServerInfo(); if (response.code === 200) { const info = response.data; console.log('Server OS:', info.server.uname); console.log('Node version:', info.server.nodeVersion); console.log('MySQL version:', info.server.mysqlVersion); console.log('Build hash:', info.billd.commitHash); } ``` -------------------------------- ### fetchRtcV1Publish Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/streaming-api.md Initiates WebRTC publishing (SRS protocol) to start broadcasting to a live room. It requires an API endpoint, client IP, SDP offer, stream URL, and a transaction ID. ```APIDOC ## fetchRtcV1Publish ### Description Initiates WebRTC publishing (SRS protocol) to start broadcasting to a live room. It requires an API endpoint, client IP, SDP offer, stream URL, and a transaction ID. ### Method POST (inferred from function call pattern) ### Endpoint `/api/v1/rtc/publish` (inferred from example) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **api** (string) - Required - SRS API endpoint URL - **clientip** (string | null) - Required - Client IP address for SRS logging - **sdp** (string) - Required - Session Description Protocol offer from local peer - **streamurl** (string) - Required - Stream URL/ID for the broadcast - **tid** (string) - Required - Transaction ID for tracking this publish session ### Request Example ```json { "api": "http://srs.example.com/api/v1/rtc/publish", "clientip": null, "sdp": "v=0\r\no=- 1234567890 1234567890 IN IP4 127.0.0.1\r\ns=- \r\nt=0 0\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 127 128 129 130 131 132\r\na=rtpmap:111 OPUS/48000/48\r\na=fmtp:111 minptime=20;useinbandfec=1\r\n...", "streamurl": "your_stream_url", "tid": "1678886400000" } ``` ### Response #### Success Response (200) - **code** (number) - HTTP status code, expected to be 200 on success. - **data** (object) - Contains the answer SDP and connection details. - **sdp** (string) - The answer SDP from the server. - **...** (other connection details may be present) #### Response Example ```json { "code": 200, "data": { "sdp": "v=0\r\no=- 997677494 2 IN IP4 127.0.0.1\r\ns=- \r\nt=0 0\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 127 128 129 130 131 132\r\na=rtpmap:111 OPUS/48000/48\r\na=fmtp:111 minptime=20;useinbandfec=1\r\n..." } } ``` ``` -------------------------------- ### Initiate WebRTC Playback with SRS Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/streaming-api.md Use this function to start receiving a stream using the SRS protocol. It requires the SRS API endpoint, stream URL, and SDP offer from the local peer. ```typescript export function fetchRtcV1Play(data: { api: string; clientip: string | null; sdp: string; streamurl: string; tid: string; }) ``` ```typescript import { fetchRtcV1Play } from '@/api/srs'; const startWebRTCPlayback = async (peerConnection, streamUrl, srsApi) => { try { const offer = await peerConnection.createOffer(); await peerConnection.setLocalDescription(offer); const response = await fetchRtcV1Play({ api: srsApi, clientip: null, sdp: peerConnection.localDescription.sdp, streamurl: streamUrl, tid: Date.now().toString() }); if (response.code === 200) { const answer = new RTCSessionDescription({ type: 'answer', sdp: response.data.sdp }); await peerConnection.setRemoteDescription(answer); console.log('Playing stream from SRS'); } } catch (error) { console.error('Playback failed:', error); } }; ``` -------------------------------- ### WEBSOCKET_URL Configuration Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/http-client.md Imports and shows the usage of the WEBSOCKET_URL constant, defining the WebSocket server URL. Examples for development and production environments are included. ```typescript import { WEBSOCKET_URL } from '@/constant'; // Development: 'ws://localhost:4300' // Production: 'wss://srs-pull.${prodDomain}' ``` -------------------------------- ### Custom Request Instance with DELETE Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/http-client.md Demonstrates using the 'instance' method to perform a DELETE request, for example, to remove Qiniu data. ```typescript import request from '@/utils/request'; // DELETE request example const response = await request.instance({ url: '/qiniu_data/delete/123', method: 'delete' }); ``` -------------------------------- ### Fetch Latest Desktop Version Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/other-apis.md Retrieves the latest available version information for the desktop application, including download URLs. Call this to get the most recent release details. ```typescript import { fetchDeskVersionLatest } from '@/api/deskVersion'; const response = await fetchDeskVersionLatest(); if (response.code === 200) { const version = response.data; console.log('Latest version:', version.show_version); console.log('Download: ', version.download_window_64_exe); } ``` -------------------------------- ### request.get Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/http-client.md Sends a GET request with optional parameters and configuration. It supports fetching data from a specified URL, with an option to include query parameters for filtering or sorting. ```APIDOC ## request.get(url, config?): MyAxiosPromise ### Description Sends a GET request with optional parameters and configuration. ### Method GET ### Endpoint [url] ### Parameters #### Query Parameters - **params** (object) - Optional - Query parameters to be sent with the request. ### Request Example ```typescript import request from '@/utils/request'; // Simple GET request const response = await request.get('/user/get_user_info'); // GET with query parameters const response = await request.get>( '/live_room/list', { params: { nowPage: 1, pageSize: 20, orderBy: 'desc' } } ); if (response.code === 200) { console.log('Total:', response.data.total); console.log('Rooms:', response.data.rows); } ``` ### Response #### Success Response (200) - **code** (number) - The status code of the response. - **data** (T) - The data returned from the request. - **message** (string) - A message describing the response. ``` -------------------------------- ### WsAnswerType Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/websocket-api.md Represents a WebRTC SDP answer message. Used to respond to an SDP offer and complete the peer-to-peer connection setup, including room and target socket ID. ```APIDOC ## WsAnswerType - WebRTC SDP answer ### Description Payload for a WebRTC SDP answer, used to respond to an SDP offer and complete connection setup. ### Fields - **live_room_id** (number | string) - Required - The associated room ID. - **socket_id** (string) - Required - The socket ID of the target peer. - **sdp** (string) - Required - The Session Description Protocol answer. ``` -------------------------------- ### AXIOS_BASEURL Configuration Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/http-client.md Imports and shows the usage of the AXIOS_BASEURL constant, which defines the base URL for all API requests. Examples for development and production environments are provided. ```typescript import { AXIOS_BASEURL } from '@/constant'; // Development: '/api' // Production: 'https://api-live.${prodDomain}' ``` -------------------------------- ### fetchRtcV1Play Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/streaming-api.md Initiates WebRTC playback (SRS protocol) to start receiving a broadcast stream. It requires an API endpoint, client IP, SDP offer, stream URL, and a transaction ID. ```APIDOC ## fetchRtcV1Play ### Description Initiates WebRTC playback (SRS protocol) to start receiving a broadcast stream. It requires an API endpoint, client IP, SDP offer, stream URL, and a transaction ID. ### Method POST (inferred from function call pattern) ### Endpoint `/api/v1/rtc/play` (inferred from example) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **api** (string) - Required - SRS API endpoint URL - **clientip** (string | null) - Required - Client IP address for SRS logging - **sdp** (string) - Required - Session Description Protocol offer from local peer - **streamurl** (string) - Required - Stream URL/ID to play - **tid** (string) - Required - Transaction ID for tracking this play session ### Request Example ```json { "api": "http://srs.example.com/api/v1/rtc/play", "clientip": null, "sdp": "v=0\r\no=- 1234567890 1234567890 IN IP4 127.0.0.1\r\ns=- \r\nt=0 0\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 127 128 129 130 131 132\r\na=rtpmap:111 OPUS/48000/48\r\na=fmtp:111 minptime=20;useinbandfec=1\r\n...", "streamurl": "your_stream_url", "tid": "1678886400000" } ``` ### Response #### Success Response (200) - **code** (number) - HTTP status code, expected to be 200 on success. - **data** (object) - Contains the answer SDP for the playback connection. - **sdp** (string) - The answer SDP from the server. #### Response Example ```json { "code": 200, "data": { "sdp": "v=0\r\no=- 997677494 2 IN IP4 127.0.0.1\r\ns=- \r\nt=0 0\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 127 128 129 130 131 132\r\na=rtpmap:111 OPUS/48000/48\r\na=fmtp:111 minptime=20;useinbandfec=1\r\n..." } } ``` ``` -------------------------------- ### Get User Info Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/stores.md Fetches the current authenticated user's full profile, including roles and permissions. Checks the response code for success and logs roles/permissions. ```typescript const userStore = useUserStore(); const response = await userStore.getUserInfo(); if (response.code === 200) { console.log('Roles:', userStore.roles); console.log('Permissions:', userStore.auths); } ``` -------------------------------- ### Request Native Operations with ipcRenderer Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/electron-ipc.md Send a request to the main process for native operations, such as retrieving system information. This example demonstrates using `ipcRenderer.send` for the request and `ipcRenderer.once` to handle the asynchronous response, ensuring the correct request is matched by `requestId`. ```typescript import { ipcRenderer } from 'electron'; import { IPC_EVENT } from '@/event'; // Request system information const getSystemInfo = async () => { return new Promise((resolve) => { const requestId = Date.now().toString(); // Send request ipcRenderer.send(IPC_EVENT.request_getSystemInfo, { windowId: window.windowId, channel: IPC_EVENT.request_getSystemInfo, requestId, data: {} }); // Listen for response ipcRenderer.once( IPC_EVENT.response_getSystemInfo, (event, response: IIpcRendererData) => { if (response.requestId === requestId) { resolve(response.data); } } ); }); }; const sysInfo = await getSystemInfo(); console.log('CPU cores:', sysInfo.cpuCores); console.log('Total memory:', sysInfo.totalMemory); ``` -------------------------------- ### Joining a Live Room with useWebsocket Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/hooks.md Demonstrates how to join a live room using the `joinRoom` method and log the connection status. Ensure proper error handling for connection failures. ```typescript const { joinRoom, connectStatus } = useWebsocket(); try { await joinRoom('42'); console.log('Joined room, status:', connectStatus.value); } catch (error) { console.error('Failed to join room'); } ``` -------------------------------- ### useAppStore Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/stores.md Global application state for UI, streaming, and device configuration. ```APIDOC ## State Properties ### version - **Type**: string - **Description**: Current application version ### windowId - **Type**: number - **Description**: Electron window identifier ### scaleFactor - **Type**: number - **Description**: Display scale factor (DPI awareness) ### workAreaSize - **Type**: object - **Description**: Available screen area size - **width** (number) - **height** (number) ### primaryDisplaySize - **Type**: object - **Description**: Primary monitor dimensions - **width** (number) - **height** (number) ### liveRoomInfo - **Type**: ILiveRoom - **Description**: Current live room being displayed ### allTrack - **Type**: TrackInfo[] - **Description**: All active media tracks (camera, screen, audio) ### liveLine - **Type**: LiveLineEnum - **Description**: Current streaming protocol (hls, flv, rtc) ### videoControls - **Type**: object - **Description**: UI control visibility flags ### playing - **Type**: boolean - **Description**: Whether video is currently playing ### videoRatio - **Type**: number - **Description**: Display aspect ratio (e.g., 16/9) ``` -------------------------------- ### joinRoom Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/hooks.md Establishes WebSocket connection and joins a live room. ```APIDOC ## joinRoom(roomId: string): Promise ### Description Establishes WebSocket connection and joins a live room. ### Method (Implicitly invoked by hook) ### Parameters #### Path Parameters - **roomId** (string) - Required - The ID of the room to join. ### Request Example ```typescript const { joinRoom, connectStatus } = useWebsocket(); try { await joinRoom('42'); console.log('Joined room, status:', connectStatus.value); } catch (error) { console.error('Failed to join room'); } ``` ### Response #### Success Response - (void) - Operation successful. #### Response Example (No specific response body for success, indicates connection established.) ``` -------------------------------- ### Get Track Information Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/stores.md Retrieves the count of active audio and video tracks. Use this to check the current media track status. ```typescript const appStore = useAppStore(); const { audio, video } = appStore.getTrackInfo(); console.log(`Active audio tracks: ${audio}`); console.log(`Active video tracks: ${video}`); ``` -------------------------------- ### fetchDeskUserCreate Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/deskuser-api.md Creates a new desk user account with a randomly generated UUID and password. This is the first step to setting up a new desk user. ```APIDOC ## fetchDeskUserCreate ### Description Creates a new desk user account with a randomly generated UUID. ### Method POST ### Endpoint /api/deskUser/create ### Response #### Success Response (200) - **data** (object) - The newly created desk user object - **data.uuid** (string) - The unique UUID for the new desk user - **data.password** (string) - The randomly generated password for the new desk user #### Response Example ```json { "code": 200, "data": { "uuid": "generated-uuid-xyz", "password": "generated-password-abc" } } ``` ``` -------------------------------- ### View MySQL Configuration File Content Source: https://github.com/galaxy-s10/billd-desk/blob/main/doc/本地环境.md Creates a temporary container to display the content of the default my.cnf file from the MySQL image. ```bash docker run --rm mysql cat /etc/my.cnf ``` -------------------------------- ### Find Specific Live Room Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/liveroom-api.md Retrieves detailed information about a specific live room using its ID. Use this to get comprehensive room details. ```typescript export function fetchFindLiveRoom(roomId: string) ``` ```typescript import { fetchFindLiveRoom } from '@/api/liveRoom'; const response = await fetchFindLiveRoom('12345'); if (response.code === 200) { const room = response.data; console.log('Room name:', room.name); console.log('Room type:', room.type); console.log('RTMP URL:', room.rtmp_url); console.log('HLS URL:', room.hls_url); console.log('WebRTC URL:', room.webrtc_url); } ``` -------------------------------- ### fetchVerifyPkKey Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/liveroom-api.md Verifies a PK (battle/duel) key for a live room. ```APIDOC ## fetchVerifyPkKey ### Description Verifies a PK (battle/duel) key for a live room. ### Method (Not specified, inferred as POST or PUT based on common API patterns for verification) ### Endpoint (Not specified) ### Parameters #### Request Body - **data.liveRoomId** (number) - Required - Live room identifier - **data.key** (string) - Required - PK verification key ### Response #### Success Response (200) (Details not specified, but indicates successful verification) ### Request Example ```typescript import { fetchVerifyPkKey } from '@/api/liveRoom'; try { const response = await fetchVerifyPkKey({ liveRoomId: 42, key: 'pk_secret_key_123' }); if (response.code === 200) { console.log('PK key verified successfully'); } } catch (error) { console.error('Invalid PK key'); } ``` ``` -------------------------------- ### fetchServerInfo Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/other-apis.md Retrieves backend server environment and version information. This function returns a promise that resolves to server details including Node, Redis, and MySQL versions, as well as build information. ```APIDOC ## fetchServerInfo ### Description Retrieves backend server environment and version information. This function returns a promise that resolves to server details including Node, Redis, and MySQL versions, as well as build information. ### Method GET ### Endpoint /server/info ### Response #### Success Response (200) - **data** (object) - Server details including OS, Node.js version, MySQL version, and build commit hash. ### Request Example ```typescript import { fetchServerInfo } from '@/api/other'; const response = await fetchServerInfo(); if (response.code === 200) { const info = response.data; console.log('Server OS:', info.server.uname); console.log('Node version:', info.server.nodeVersion); console.log('MySQL version:', info.server.mysqlVersion); console.log('Build hash:', info.billd.commitHash); } ``` ``` -------------------------------- ### Fetch Broadcast Area List Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/other-apis.md Retrieves a list of all available broadcast areas or categories. Use this function to get a comprehensive list of areas for filtering or display purposes. ```typescript export function fetchAreaList() ``` ```typescript import { fetchAreaList } from '@/api/area'; const response = await fetchAreaList(); if (response.code === 200) { response.data.forEach(area => { console.log('Area:', area.name, area.weight); }); } ``` -------------------------------- ### Copy MySQL Configuration to Local Machine Source: https://github.com/galaxy-s10/billd-desk/blob/main/doc/本地环境.md Copies the my.cnf file from a temporary MySQL container to a specified local directory. Ensure the local directory exists. ```bash LOCAL_DOCKER_MYSQL_PATH=/Users/huangshuisheng/Desktop/docker/mysql \ DOCKER_MYSQL_TMP=`docker run -d mysql:8.0` \ && docker cp $DOCKER_MYSQL_TMP:/etc/my.cnf $LOCAL_DOCKER_MYSQL_PATH/conf \ && docker stop $DOCKER_MYSQL_TMP \ && docker rm $DOCKER_MYSQL_TMP ``` -------------------------------- ### fetchFindLiveRoom Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/liveroom-api.md Retrieves detailed information about a specific live room. ```APIDOC ## fetchFindLiveRoom ### Description Retrieves detailed information about a specific live room. ### Method (Not specified, inferred as GET) ### Endpoint (Not specified) ### Parameters #### Path Parameters - **roomId** (string) - Required - Live room identifier ### Response #### Success Response (200) - **data** (ILiveRoom) - Complete live room information - **name** (string) - Room name - **type** (string) - Room type - **rtmp_url** (string) - RTMP streaming URL - **hls_url** (string) - HLS streaming URL - **webrtc_url** (string) - WebRTC streaming URL (Other fields may be present) ### Request Example ```typescript import { fetchFindLiveRoom } from '@/api/liveRoom'; const response = await fetchFindLiveRoom('12345'); if (response.code === 200) { const room = response.data; console.log('Room name:', room.name); console.log('Room type:', room.type); console.log('RTMP URL:', room.rtmp_url); console.log('HLS URL:', room.hls_url); console.log('WebRTC URL:', room.webrtc_url); } ``` ``` -------------------------------- ### Fetch Gift Record List Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/other-apis.md Retrieves individual gift or reward records. Use this to get a paginated list of gifts sent in a live room, optionally filtered by status. ```typescript export function fetchGiftRecordList(params: IList) ``` ```typescript import { fetchGiftRecordList } from '@/api/giftRecord'; const response = await fetchGiftRecordList({ live_room_id: 42, status: GiftRecordStatusEnum.ok, nowPage: 1, pageSize: 50 }); if (response.code === 200) { response.data.rows.forEach(record => { console.log(`${record.send_user_id} sent ${record.goods_nums}x`); }); } ``` -------------------------------- ### fetchDeskVersionLatest Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/other-apis.md Fetches the latest available version information for the desktop application, including download URLs. ```APIDOC ## fetchDeskVersionLatest ### Description Retrieves the latest available desktop application version. ### Method Signature ```typescript export function fetchDeskVersionLatest(): MyAxiosPromise ``` ### Returns A promise resolving to latest version information with download URLs. ### Example ```typescript import { fetchDeskVersionLatest } from '@/api/deskVersion'; const response = await fetchDeskVersionLatest(); if (response.code === 200) { const version = response.data; console.log('Latest version:', version.show_version); console.log('Download: ', version.download_window_64_exe); } ``` ``` -------------------------------- ### Accessing Configuration Programmatically Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/configuration.md Imports and retrieves configuration values like API base URL, WebSocket URL, and authentication token using utility functions. ```javascript import { getAxiosBaseUrl } from '@/utils/localStorage/app'; import { getWssUrl } from '@/utils/localStorage/app'; import { getToken } from '@/utils/localStorage/user'; const apiBase = getAxiosBaseUrl(); // Get current API base URL const wsUrl = getWssUrl(); // Get current WebSocket URL const token = getToken(); // Get auth token ``` -------------------------------- ### Fetch Sign-in List (TypeScript) Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/other-apis.md Retrieves paginated sign-in statistics and records. Filter results by live room ID, current page, and number of results per page. ```typescript export function fetchSigninList(params: IList) ``` ```typescript import { fetchSigninList } from '@/api/signin'; const response = await fetchSigninList({ live_room_id: 42, nowPage: 1, pageSize: 20 }); if (response.code === 200) { response.data.rows.forEach(stats => { console.log(`${stats.username}: ${stats.nums} consecutive days`); }); } ``` -------------------------------- ### Find MySQL Configuration File Path Source: https://github.com/galaxy-s10/billd-desk/blob/main/doc/本地环境.md Runs a temporary MySQL container to find the location of the my.cnf configuration file within the image. ```bash docker run --rm mysql:8.0 mysql --help | grep my.cnf ``` -------------------------------- ### fetchGoodsList Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/other-apis.md Retrieves all available goods/products with pagination. Allows filtering by type and sorting. ```APIDOC ## fetchGoodsList ### Description Retrieves all available goods/products with pagination. Allows filtering by type and sorting. ### Method POST ### Endpoint /api/goods/list ### Parameters #### Query Parameters - **params.nowPage** (number) - Optional - Page number - **params.pageSize** (number) - Optional - Results per page - **params.type** (GoodsTypeEnum) - Optional - Filter by type (support, sponsors, gift, recharge) - **params.orderName** (string) - Optional - Sort field - **params.orderBy** (string) - Optional - Sort direction ### Request Example ```json { "nowPage": 1, "pageSize": 20, "type": "gift" } ``` ### Response #### Success Response (200) - **data** (IPaging) - Paginated goods list #### Response Example ```json { "code": 200, "data": { "rows": [ { "name": "Example Good", "price": 100 } ] } } ``` ``` -------------------------------- ### fetchFindByTypeGoods Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/other-apis.md Retrieves a specific product by its type. This is a direct lookup for a single item. ```APIDOC ## fetchFindByTypeGoods ### Description Retrieves a specific product by type. This is a direct lookup for a single item. ### Method GET ### Endpoint /api/goods/type/{type} ### Parameters #### Path Parameters - **type** (GoodsTypeEnum) - Required - Goods type to fetch ### Response #### Success Response (200) - **data** (IGoods) - The goods object matching the specified type #### Response Example ```json { "code": 200, "data": { "name": "Recharge Product", "price": 50 } } ``` ``` -------------------------------- ### fetchLiveRoomList Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/liveroom-api.md Retrieves a paginated list of live rooms with optional filtering and sorting. ```APIDOC ## fetchLiveRoomList ### Description Retrieves a paginated list of live rooms with optional filtering and sorting. ### Method (Not specified, inferred as GET or POST based on common API patterns for list retrieval) ### Endpoint (Not specified) ### Parameters #### Query Parameters - **params.nowPage** (number) - Optional - Current page number for pagination - **params.pageSize** (number) - Optional - Number of results per page - **params.orderBy** (string) - Optional - Sort direction ('asc' or 'desc') - **params.orderName** (string) - Optional - Field to sort by (e.g., 'created_at', 'weight') - **params.keyWord** (string) - Optional - Search keyword to filter live rooms - **params.rangTimeType** ('created_at' | 'updated_at' | 'deleted_at') - Optional - Time range field to filter by - **params.rangTimeStart** (string) - Optional - Start time for range filter (ISO 8601) - **params.rangTimeEnd** (string) - Optional - End time for range filter (ISO 8601) ### Response #### Success Response (200) - **data** (IPaging) - Paginated live room list with metadata - **total** (number) - Total number of rooms - **rows** (ILiveRoom[]) - Array of live room objects ### Request Example ```typescript import { fetchLiveRoomList } from '@/api/liveRoom'; const response = await fetchLiveRoomList({ nowPage: 1, pageSize: 20, orderName: 'weight', orderBy: 'desc', keyWord: 'live' }); if (response.code === 200) { console.log('Total rooms:', response.data.total); console.log('Rooms:', response.data.rows); } ``` ``` -------------------------------- ### request.instance Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/http-client.md Sends a request with advanced configuration, allowing specification of HTTP method, headers, and other options. This is a versatile method for custom requests. ```APIDOC ## request.instance(config): MyAxiosPromise ### Description Sends a request with advanced configuration (method, headers, etc.). ### Method Configurable via `config.method` (e.g., 'get', 'post', 'put', 'delete'). ### Endpoint Configurable via `config.url`. ### Parameters #### Request Body - **config** (object) - Required - Configuration object for the request. - **url** (string) - Required - The endpoint URL. - **method** (string) - Required - The HTTP method (e.g., 'get', 'post', 'put', 'delete'). - **data** (any) - Optional - The request body data. - **timeout** (number) - Optional - Custom timeout for the request in milliseconds. - **headers** (object) - Optional - Custom headers for the request. ### Request Example ```typescript import request from '@/utils/request'; const response = await request.instance({ url: '/live_config/update/42', method: 'put', data: { key: 'config-key', value: 'config-value' } }); // DELETE request example const response = await request.instance({ url: '/qiniu_data/delete/123', method: 'delete' }); ``` ### Response #### Success Response (200) - **code** (number) - The status code of the response. - **data** (any) - The data returned from the request. - **message** (string) - A message describing the response. ``` -------------------------------- ### pwdLogin(credentials: { id: string; password: string }): Promise Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/stores.md Authenticates the user using their username/ID and password. Returns the authentication token upon successful login. ```APIDOC ## pwdLogin(credentials: { id: string; password: string }): Promise ### Description Authenticates with username/ID and password. ### Parameters #### Request Body - **credentials** (object) - Required - An object containing user credentials. - **id** (string) - Required - The user's username or ID. - **password** (string) - Required - The user's password. ### Request Example ```typescript const userStore = useUserStore(); try { const token = await userStore.pwdLogin({ id: 'myusername', password: 'mypassword' }); if (token) { console.log('Login successful'); } else { console.error('Login failed'); } } catch (error) { console.error('Authentication error'); } ``` ``` -------------------------------- ### fetchCreateSignin Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/other-apis.md Creates a new sign-in record for the user. It takes sign-in data and returns a promise that resolves to the created sign-in record. ```APIDOC ## fetchCreateSignin ### Description Creates a new sign-in record for the user. ### Method POST ### Endpoint /api/signin ### Parameters #### Request Body - **data.live_room_id** (number) - Required - Live room to sign in for ### Request Example ```json { "live_room_id": 42 } ``` ### Response #### Success Response (200) - **data** (object) - Created sign-in record ### Response Example ```json { "code": 200, "data": { "live_room_id": 42, "user_id": 123, "signin_time": "2023-10-27T10:00:00Z" } } ``` ``` -------------------------------- ### Leaving a Live Room with useWebsocket Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/hooks.md Shows how to disconnect from the current live room and close the WebSocket connection using the `leaveRoom` method. ```typescript const { leaveRoom } = useWebsocket(); await leaveRoom(); ``` -------------------------------- ### fetchUpdateLiveRoomKey Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/liveroom-api.md Updates the push key for the current live room. ```APIDOC ## fetchUpdateLiveRoomKey ### Description Updates the push key for the current live room. ### Method (Not specified, inferred as POST or PUT) ### Endpoint (Not specified) ### Parameters (None) ### Response #### Success Response (200) (Details not specified, but indicates the key has been updated) ### Request Example ```typescript import { fetchUpdateLiveRoomKey } from '@/api/liveRoom'; const response = await fetchUpdateLiveRoomKey(); if (response.code === 200) { console.log('Live room key updated'); } ``` ``` -------------------------------- ### Define App Store State and Actions Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/stores.md Defines the global application state, including version, window ID, work area size, live room info, track information, and streaming protocols. This store is intended for managing core application-level data. ```typescript import { useAppStore } from '@/store/app'; export const useAppStore = defineStore('app', { state: () => ({ version: string, windowId: number, workAreaSize: { width: number; height: number }, liveRoomInfo?: ILiveRoom, allTrack: TrackInfo[], liveLine: LiveLineEnum, videoControls: { ... }, // ... more state }), actions: { ... } }) ``` -------------------------------- ### Verify Live Room PK Key Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/liveroom-api.md Verifies a PK (battle/duel) key for a specific live room. Use this to authenticate access to special live room modes. ```typescript export function fetchVerifyPkKey(data: { liveRoomId: number; key }) ``` ```typescript import { fetchVerifyPkKey } from '@/api/liveRoom'; try { const response = await fetchVerifyPkKey({ liveRoomId: 42, key: 'pk_secret_key_123' }); if (response.code === 200) { console.log('PK key verified successfully'); } } catch (error) { console.error('Invalid PK key'); } ``` -------------------------------- ### Fetch Specific Goods by Type Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/other-apis.md Retrieves a single product based on its specified type. Use this when you need to display details for a particular category of goods. ```typescript export function fetchFindByTypeGoods(type) ``` ```typescript import { fetchFindByTypeGoods } from '@/api/goods'; const response = await fetchFindByTypeGoods(GoodsTypeEnum.recharge); if (response.code === 200) { console.log('Recharge product:', response.data.name); console.log('Price: ¥', response.data.price); } ``` -------------------------------- ### fetchLogin Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/api-reference/user-api.md Authenticates a user with username/ID and password. Returns a promise resolving to authentication response containing the user token. ```APIDOC ## fetchLogin ### Description Authenticates a user with username/ID and password. ### Method POST (inferred from typical login operations, not explicitly stated) ### Endpoint /api/login (inferred, not explicitly stated) ### Parameters #### Request Body - **id** (string) - Required - User ID or username - **password** (string) - Required - User password ### Request Example ```typescript import { fetchLogin } from '@/api/user'; const response = await fetchLogin({ id: 'myusername', password: 'mypassword' }); ``` ### Response #### Success Response (200) - **code** (number) - HTTP status code - **data** (object) - Authentication response containing the user token ### Response Example ```json { "code": 200, "data": { "token": "your_auth_token" } } ``` ``` -------------------------------- ### useUpload Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/hooks.md Handles file upload logic with progress tracking and Qiniu integration. Provides methods to upload files, monitor upload progress, check upload status, and cancel uploads. ```APIDOC ## useUpload Handles file upload logic with progress tracking and Qiniu integration. ```typescript import { useUpload } from '@/hooks/use-upload'; export const useUpload = () => { return { uploadFile: (file: File, options?: UploadOptions) => Promise, uploadProgress: ref, isUploading: ref, cancel: () => void }; }; ``` ### Usage ```typescript import { useUpload } from '@/hooks/use-upload'; export default { setup() { const { uploadFile, uploadProgress, isUploading } = useUpload(); const handleFileSelect = async (event) => { const file = event.target.files[0]; try { const result = await uploadFile(file, { prefix: 'uploads/images', type: 'image' }); console.log('Upload complete:', result.url); } catch (error) { console.error('Upload failed:', error); } }; return { handleFileSelect, uploadProgress, isUploading }; } }; // Template ``` **Source:** `src/hooks/use-upload.ts` ``` -------------------------------- ### setLiveRoomInfo Source: https://github.com/galaxy-s10/billd-desk/blob/main/_autodocs/stores.md Updates the current live room information. ```APIDOC ## setLiveRoomInfo(roomInfo: ILiveRoom) ### Description Updates the current live room information. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **roomInfo** (ILiveRoom) - Required - The new live room information object. ### Request Example ```typescript const appStore = useAppStore(); const response = await fetchFindLiveRoom('42'); appStore.setLiveRoomInfo(response.data); ``` ### Response #### Success Response (200) No specific response details provided, typically void or a success indicator. ```