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

@@ -80,7 +80,10 @@ export function getBase64(file: File | undefined | null): Promise<string | undef
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 = {
existImages: [],
newImagesBase64: [],

View File

@@ -6,10 +6,20 @@ import { apiFail } from '@/data/constants'
const cookie = useLocalStorage('JWT_Token', '')
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)
}
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)
url.search = getParams(params)
headers ??= []
@@ -36,7 +46,11 @@ export async function QueryPostAPIWithParams<T>(urlString: string, params?: any,
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)
url.search = getParams(params)
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>>> {
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)
}

View File

@@ -239,7 +239,9 @@ export default class DanmakuClient {
}
private sendHeartbeat() {
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) => {
if (data.code != 200) {
console.error('[OPEN-LIVE] 心跳失败')
@@ -425,7 +427,10 @@ export default class DanmakuClient {
}
private async getAuthInfo(): Promise<{ data: OpenLiveInfo | null; message: string }> {
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) {
console.log('[OPEN-LIVE] 已获取场次信息')
return {

View File

@@ -9,7 +9,12 @@ const builder = new XMLBuilder({
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)
.Select((d) => {
return {

View File

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

View File

@@ -2,7 +2,14 @@ import { VNode } from 'vue'
export type TemplateConfig<T> = {
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
}
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.heartbeatTimerId = setInterval(this.sendHeartbeat.bind(this), HEARTBEAT_INTERVAL)
this.refreshReceiveTimeoutTimer()
console.log('ws 已连接');
console.log('ws 已连接')
}
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 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 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 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 } }
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 } }
export const IndexTemplateMap = {
'': { name: '默认', compoent: DefaultIndexTemplateVue },

View File

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