format code

This commit is contained in:
2024-02-21 12:05:28 +08:00
parent aa7fbd47a0
commit cc778d22b4
12 changed files with 1197 additions and 1061 deletions

View File

@@ -1 +1,11 @@
yarn test #!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# 自动修复 ESLint 检测到的问题
npx eslint --fix 'src/**/*.{js,jsx,ts,tsx}' || true
# 使用 Prettier 格式化代码
npx prettier --write 'src/**/*.{js,jsx,ts,tsx,json,css,md}'
# 可以加入一个Git命令来确保这些改动被包含在push中
git add .

View File

@@ -6,7 +6,7 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
"lint": "npx oxlint && vite lint", "lint": "vite lint",
"postinstall": "husky init", "postinstall": "husky init",
"prepare": "husky" "prepare": "husky"
}, },

View File

@@ -80,7 +80,10 @@ export function getBase64(file: File | undefined | null): Promise<string | undef
reader.onerror = (error) => reject(error) reader.onerror = (error) => reject(error)
}) })
} }
export async function getImageUploadModel(files: UploadFileInfo[] | undefined | null, maxSize: number = 10 * 1024 * 1024) { export async function getImageUploadModel(
files: UploadFileInfo[] | undefined | null,
maxSize: number = 10 * 1024 * 1024,
) {
const result = { const result = {
existImages: [], existImages: [],
newImagesBase64: [], newImagesBase64: [],

View File

@@ -6,10 +6,20 @@ import { apiFail } from '@/data/constants'
const cookie = useLocalStorage('JWT_Token', '') const cookie = useLocalStorage('JWT_Token', '')
let failCount = 0 let failCount = 0
export async function QueryPostAPI<T>(urlString: string, body?: unknown, headers?: [string, string][]): Promise<APIRoot<T>> { export async function QueryPostAPI<T>(
urlString: string,
body?: unknown,
headers?: [string, string][],
): Promise<APIRoot<T>> {
return await QueryPostAPIWithParams<T>(urlString, undefined, body, 'application/json', headers) return await QueryPostAPIWithParams<T>(urlString, undefined, body, 'application/json', headers)
} }
export async function QueryPostAPIWithParams<T>(urlString: string, params?: any, body?: any, contentType?: string, headers?: [string, string][]): Promise<APIRoot<T>> { export async function QueryPostAPIWithParams<T>(
urlString: string,
params?: any,
body?: any,
contentType?: string,
headers?: [string, string][],
): Promise<APIRoot<T>> {
const url = new URL(urlString) const url = new URL(urlString)
url.search = getParams(params) url.search = getParams(params)
headers ??= [] headers ??= []
@@ -36,7 +46,11 @@ export async function QueryPostAPIWithParams<T>(urlString: string, params?: any,
throw e throw e
} }
} }
export async function QueryGetAPI<T>(urlString: string, params?: any, headers?: [string, string][]): Promise<APIRoot<T>> { export async function QueryGetAPI<T>(
urlString: string,
params?: any,
headers?: [string, string][],
): Promise<APIRoot<T>> {
const url = new URL(urlString) const url = new URL(urlString)
url.search = getParams(params) url.search = getParams(params)
if (cookie.value) { if (cookie.value) {
@@ -72,6 +86,9 @@ function getParams(params?: [string, string][]) {
export async function QueryPostPaginationAPI<T>(url: string, body?: unknown): Promise<APIRoot<PaginationResponse<T>>> { export async function QueryPostPaginationAPI<T>(url: string, body?: unknown): Promise<APIRoot<PaginationResponse<T>>> {
return await QueryPostAPI<PaginationResponse<T>>(url, body) return await QueryPostAPI<PaginationResponse<T>>(url, body)
} }
export async function QueryGetPaginationAPI<T>(urlString: string, params?: unknown): Promise<APIRoot<PaginationResponse<T>>> { export async function QueryGetPaginationAPI<T>(
urlString: string,
params?: unknown,
): Promise<APIRoot<PaginationResponse<T>>> {
return await QueryGetAPI<PaginationResponse<T>>(urlString, params) return await QueryGetAPI<PaginationResponse<T>>(urlString, params)
} }

View File

@@ -239,7 +239,9 @@ export default class DanmakuClient {
} }
private sendHeartbeat() { private sendHeartbeat() {
if (this.client) { if (this.client) {
const query = this.authInfo ? QueryPostAPI<OpenLiveInfo>(OPEN_LIVE_API_URL + 'heartbeat', this.authInfo) : QueryGetAPI<OpenLiveInfo>(OPEN_LIVE_API_URL + 'heartbeat-internal') const query = this.authInfo
? QueryPostAPI<OpenLiveInfo>(OPEN_LIVE_API_URL + 'heartbeat', this.authInfo)
: QueryGetAPI<OpenLiveInfo>(OPEN_LIVE_API_URL + 'heartbeat-internal')
query.then((data) => { query.then((data) => {
if (data.code != 200) { if (data.code != 200) {
console.error('[OPEN-LIVE] 心跳失败') console.error('[OPEN-LIVE] 心跳失败')
@@ -425,7 +427,10 @@ export default class DanmakuClient {
} }
private async getAuthInfo(): Promise<{ data: OpenLiveInfo | null; message: string }> { private async getAuthInfo(): Promise<{ data: OpenLiveInfo | null; message: string }> {
try { try {
const data = await QueryPostAPI<OpenLiveInfo>(OPEN_LIVE_API_URL + 'start', this.authInfo?.Code ? this.authInfo : undefined) const data = await QueryPostAPI<OpenLiveInfo>(
OPEN_LIVE_API_URL + 'start',
this.authInfo?.Code ? this.authInfo : undefined,
)
if (data.code == 200) { if (data.code == 200) {
console.log('[OPEN-LIVE] 已获取场次信息') console.log('[OPEN-LIVE] 已获取场次信息')
return { return {

View File

@@ -9,7 +9,12 @@ const builder = new XMLBuilder({
format: true, format: true,
}) })
export function GetString(account: AccountInfo | undefined, live: ResponseLiveInfoModel, danmakus: DanmakuModel[], type: 'json' | 'xml' | 'csv') { export function GetString(
account: AccountInfo | undefined,
live: ResponseLiveInfoModel,
danmakus: DanmakuModel[],
type: 'json' | 'xml' | 'csv',
) {
const tempDanmakus = new List(danmakus) const tempDanmakus = new List(danmakus)
.Select((d) => { .Select((d) => {
return { return {

View File

@@ -1,2 +1 @@
import EasySpeech from 'easy-speech' import EasySpeech from 'easy-speech'

View File

@@ -2,7 +2,14 @@ import { VNode } from 'vue'
export type TemplateConfig<T> = { export type TemplateConfig<T> = {
name: string name: string
items: (TemplateConfigStringItem<T> | TemplateConfigNumberItem<T> | TemplateConfigStringArrayItem<T> | TemplateConfigNumberArrayItem<T> | TemplateConfigImageItem<T> | TemplateConfigRenderItem<T>)[] items: (
| TemplateConfigStringItem<T>
| TemplateConfigNumberItem<T>
| TemplateConfigStringArrayItem<T>
| TemplateConfigNumberArrayItem<T>
| TemplateConfigImageItem<T>
| TemplateConfigRenderItem<T>
)[]
onConfirm?: (arg0: T) => void onConfirm?: (arg0: T) => void
} }
interface TemplateConfigBase { interface TemplateConfigBase {

File diff suppressed because one or more lines are too long

View File

@@ -145,7 +145,7 @@ export default class ChatClientOfficialBase {
this.sendAuth() this.sendAuth()
this.heartbeatTimerId = setInterval(this.sendHeartbeat.bind(this), HEARTBEAT_INTERVAL) this.heartbeatTimerId = setInterval(this.sendHeartbeat.bind(this), HEARTBEAT_INTERVAL)
this.refreshReceiveTimeoutTimer() this.refreshReceiveTimeoutTimer()
console.log('ws 已连接'); console.log('ws 已连接')
} }
sendHeartbeat() { sendHeartbeat() {

View File

@@ -13,7 +13,8 @@ export const IMGUR_URL = FILE_BASE_URL + '/imgur/'
export const THINGS_URL = FILE_BASE_URL + '/things/' export const THINGS_URL = FILE_BASE_URL + '/things/'
export const apiFail = ref(false) export const apiFail = ref(false)
export const BASE_API = () => (process.env.NODE_ENV === 'development' ? debugAPI : apiFail.value ? failoverAPI : releseAPI) export const BASE_API = () =>
process.env.NODE_ENV === 'development' ? debugAPI : apiFail.value ? failoverAPI : releseAPI
export const FETCH_API = 'https://fetch.vtsuru.live/' export const FETCH_API = 'https://fetch.vtsuru.live/'
export const TURNSTILE_KEY = '0x4AAAAAAAETUSAKbds019h0' export const TURNSTILE_KEY = '0x4AAAAAAAETUSAKbds019h0'
@@ -40,12 +41,24 @@ export const POINT_API_URL = { toString: () => `${BASE_API()}point/` }
export const BILI_AUTH_API_URL = { toString: () => `${BASE_API()}bili-auth/` } export const BILI_AUTH_API_URL = { toString: () => `${BASE_API()}bili-auth/` }
export const ScheduleTemplateMap = { export const ScheduleTemplateMap = {
'': { name: '默认', compoent: defineAsyncComponent(() => import('@/views/view/scheduleTemplate/DefaultScheduleTemplate.vue')) }, '': {
pinky: { name: '粉粉', compoent: defineAsyncComponent(() => import('@/views/view/scheduleTemplate/PinkySchedule.vue')) }, name: '默认',
compoent: defineAsyncComponent(() => import('@/views/view/scheduleTemplate/DefaultScheduleTemplate.vue')),
},
pinky: {
name: '粉粉',
compoent: defineAsyncComponent(() => import('@/views/view/scheduleTemplate/PinkySchedule.vue')),
},
} as { [key: string]: { name: string; compoent: any } } } as { [key: string]: { name: string; compoent: any } }
export const SongListTemplateMap = { export const SongListTemplateMap = {
'': { name: '默认', compoent: defineAsyncComponent(() => import('@/views/view/songListTemplate/DefaultSongListTemplate.vue')) }, '': {
simple: { name: '简单', compoent: defineAsyncComponent(() => import('@/views/view/songListTemplate/SimpleSongListTemplate.vue')) }, name: '默认',
compoent: defineAsyncComponent(() => import('@/views/view/songListTemplate/DefaultSongListTemplate.vue')),
},
simple: {
name: '简单',
compoent: defineAsyncComponent(() => import('@/views/view/songListTemplate/SimpleSongListTemplate.vue')),
},
} as { [key: string]: { name: string; compoent: any } } } as { [key: string]: { name: string; compoent: any } }
export const IndexTemplateMap = { export const IndexTemplateMap = {
'': { name: '默认', compoent: DefaultIndexTemplateVue }, '': { name: '默认', compoent: DefaultIndexTemplateVue },

View File

@@ -1,16 +1,15 @@
import mitt, { Emitter } from 'mitt' import mitt, { Emitter } from 'mitt'
import { Music } from './store/useMusicRequest'; import { Music } from './store/useMusicRequest'
declare type MittType<T = any> = { declare type MittType<T = any> = {
onOpenTemplateSettings: { onOpenTemplateSettings: {
template: string, template: string
}
},
onMusicRequestPlayerEnded: { onMusicRequestPlayerEnded: {
music: Music music: Music
} }
onMusicRequestPlayNextWaitingMusic: never onMusicRequestPlayNextWaitingMusic: never
}; }
// 类型 // 类型
const emitter: Emitter<MittType> = mitt<MittType>() const emitter: Emitter<MittType> = mitt<MittType>()