add obs checker

This commit is contained in:
2024-02-21 12:35:24 +08:00
parent cc778d22b4
commit 6317699f6c
10 changed files with 77 additions and 14 deletions

View File

@@ -1,9 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# 自动修复 ESLint 检测到的问题
npx eslint --fix 'src/**/*.{js,jsx,ts,tsx}' || true
# 使用 Prettier 格式化代码 # 使用 Prettier 格式化代码
npx prettier --write 'src/**/*.{js,jsx,ts,tsx,json,css,md}' npx prettier --write 'src/**/*.{js,jsx,ts,tsx,json,css,md}'

View File

@@ -52,6 +52,7 @@
"devDependencies": { "devDependencies": {
"@eslint/eslintrc": "^3.0.1", "@eslint/eslintrc": "^3.0.1",
"@types/eslint": "^8.56.2", "@types/eslint": "^8.56.2",
"@types/obs-studio": "^2.17.2",
"@types/uuid": "^9.0.8", "@types/uuid": "^9.0.8",
"@typescript-eslint/parser": "^7.0.1", "@typescript-eslint/parser": "^7.0.1",
"@vicons/ionicons5": "^0.12.0", "@vicons/ionicons5": "^0.12.0",

View File

@@ -20,7 +20,6 @@ interface LoginModel {
const message = useMessage() const message = useMessage()
const isRegister = ref(false)
const isLoading = ref(false) const isLoading = ref(false)
const registerModel = ref<RegisterModel>({} as RegisterModel) const registerModel = ref<RegisterModel>({} as RegisterModel)
@@ -148,7 +147,7 @@ function onLoginButtonClick() {
message.error(data.message) message.error(data.message)
} }
}) })
.catch((err) => { .catch(() => {
message.error('登陆失败') message.error('登陆失败')
}) })
.finally(() => { .finally(() => {
@@ -166,7 +165,7 @@ async function onForgetPassword() {
message.error(data.message) message.error(data.message)
} }
}) })
.catch((err) => { .catch(() => {
message.error('发生错误') message.error('发生错误')
}) })
.finally(() => { .finally(() => {

View File

@@ -3,14 +3,13 @@ import { SongFrom, SongsInfo } from '@/api/api-models'
import { QueryGetAPI } from '@/api/query' import { QueryGetAPI } from '@/api/query'
import { SONG_API_URL } from '@/data/constants' import { SONG_API_URL } from '@/data/constants'
import { NEmpty } from 'naive-ui' import { NEmpty } from 'naive-ui'
import { computed, ref, toRef, watch } from 'vue' import { computed, ref, watch } from 'vue'
import APlayer from 'vue3-aplayer' import APlayer from 'vue3-aplayer'
const props = defineProps<{ const props = defineProps<{
song: SongsInfo | undefined song: SongsInfo | undefined
isLrcLoading?: string isLrcLoading?: string
}>() }>()
const currentSong = toRef(props, 'song')
const emits = defineEmits(['update:isLrcLoading']) const emits = defineEmits(['update:isLrcLoading'])
const aplayerMusic = ref({ const aplayerMusic = ref({

View File

@@ -44,14 +44,25 @@ async function getUsers() {
} as UpdateLiveLotteryUsersModel } as UpdateLiveLotteryUsersModel
} }
const visiable = ref(true)
const active = ref(true)
let timer: any let timer: any
onMounted(() => { onMounted(() => {
timer = setInterval(async () => { timer = setInterval(async () => {
if (!visiable.value || !active.value) return
const r = await getUsers() const r = await getUsers()
if (r) { if (r) {
result.value = r result.value = r
} }
}, 2000) }, 2000)
//@ts-expect-error 这里获取不了
window.obsstudio.onVisibilityChange = function (visibility: boolean) {
visiable.value = visibility
}
//@ts-expect-error 这里获取不了
window.obsstudio.onActiveChange = function (a: boolean) {
active.value = a
}
}) })
onUnmounted(() => { onUnmounted(() => {
clearInterval(timer) clearInterval(timer)

View File

@@ -55,16 +55,27 @@ const isMoreThanContainer = computed(() => {
return originSongs.value.waiting.length * itemHeight > height.value return originSongs.value.waiting.length * itemHeight > height.value
}) })
async function update() { async function update() {
if (!visiable.value || !active.value) return
const r = await get() const r = await get()
if (r) { if (r) {
originSongs.value = r originSongs.value = r
} }
} }
const visiable = ref(true)
const active = ref(true)
let timer: any let timer: any
onMounted(() => { onMounted(() => {
update() update()
timer = setInterval(update, 2000) timer = setInterval(update, 2000)
//@ts-expect-error 这里获取不了
window.obsstudio.onVisibilityChange = function (visibility: boolean) {
visiable.value = visibility
}
//@ts-expect-error 这里获取不了
window.obsstudio.onActiveChange = function (a: boolean) {
active.value = a
}
}) })
onUnmounted(() => { onUnmounted(() => {
clearInterval(timer) clearInterval(timer)

View File

@@ -3,7 +3,7 @@ import { QAInfo, Setting_QuestionDisplay } from '@/api/api-models'
import { QueryGetAPI } from '@/api/query' import { QueryGetAPI } from '@/api/query'
import { QUESTION_API_URL } from '@/data/constants' import { QUESTION_API_URL } from '@/data/constants'
import { useRouteQuery } from '@vueuse/router' import { useRouteQuery } from '@vueuse/router'
import { onMounted, ref } from 'vue' import { onMounted, onUnmounted, ref } from 'vue'
import QuestionDisplayCard from '../manage/QuestionDisplayCard.vue' import QuestionDisplayCard from '../manage/QuestionDisplayCard.vue'
const hash = ref('') const hash = ref('')
@@ -44,10 +44,26 @@ async function getQuestionAndSetting() {
} }
} }
const visiable = ref(true)
const active = ref(true)
let timer: any
onMounted(() => { onMounted(() => {
setInterval(() => { timer = setInterval(() => {
if (!visiable.value || !active.value) return
checkIfChanged() checkIfChanged()
}, 1000) }, 1000)
//@ts-expect-error 这里获取不了
window.obsstudio.onVisibilityChange = function (visibility: boolean) {
visiable.value = visibility
}
//@ts-expect-error 这里获取不了
window.obsstudio.onActiveChange = function (a: boolean) {
active.value = a
}
})
onUnmounted(() => {
clearInterval(timer)
}) })
</script> </script>

View File

@@ -97,6 +97,7 @@ const allowGuardTypes = computed(() => {
return types return types
}) })
async function update() { async function update() {
if (!visiable.value || !active.value) return
const r = await get() const r = await get()
if (r) { if (r) {
queue.value = r.queue.sort((a, b) => { queue.value = r.queue.sort((a, b) => {
@@ -106,10 +107,21 @@ async function update() {
} }
} }
const visiable = ref(true)
const active = ref(true)
let timer: any let timer: any
onMounted(() => { onMounted(() => {
update() update()
timer = setInterval(update, 2000) timer = setInterval(update, 2000)
//@ts-expect-error 这里获取不了
window.obsstudio.onVisibilityChange = function (visibility: boolean) {
visiable.value = visibility
}
//@ts-expect-error 这里获取不了
window.obsstudio.onActiveChange = function (a: boolean) {
active.value = a
}
}) })
onUnmounted(() => { onUnmounted(() => {
clearInterval(timer) clearInterval(timer)

View File

@@ -76,6 +76,7 @@ const allowGuardTypes = computed(() => {
return types return types
}) })
async function update() { async function update() {
if (!visiable.value || !active.value) return
const r = await get() const r = await get()
if (r) { if (r) {
originSongs.value = r.songs.sort((a, b) => { originSongs.value = r.songs.sort((a, b) => {
@@ -85,10 +86,21 @@ async function update() {
} }
} }
const visiable = ref(true)
const active = ref(true)
let timer: any let timer: any
onMounted(() => { onMounted(() => {
update() update()
timer = setInterval(update, 2000) timer = setInterval(update, 2000)
//@ts-expect-error 这里获取不了
window.obsstudio.onVisibilityChange = function (visibility: boolean) {
visiable.value = visibility
}
//@ts-expect-error 这里获取不了
window.obsstudio.onActiveChange = function (a: boolean) {
active.value = a
}
}) })
onUnmounted(() => { onUnmounted(() => {
clearInterval(timer) clearInterval(timer)

View File

@@ -1018,6 +1018,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/obs-studio@npm:^2.17.2":
version: 2.17.2
resolution: "@types/obs-studio@npm:2.17.2"
checksum: 1c7a288532cbee075900882e845ef8b8038d096d77adc6daae13749d9e7f1d8699a87248406e834d70d264868f605c4dc09535fa2738334905d7aed2bfc4083e
languageName: node
linkType: hard
"@types/semver@npm:^7.5.0": "@types/semver@npm:^7.5.0":
version: 7.5.6 version: 7.5.6
resolution: "@types/semver@npm:7.5.6" resolution: "@types/semver@npm:7.5.6"
@@ -5327,6 +5334,7 @@ __metadata:
"@eslint/eslintrc": "npm:^3.0.1" "@eslint/eslintrc": "npm:^3.0.1"
"@types/eslint": "npm:^8.56.2" "@types/eslint": "npm:^8.56.2"
"@types/node": "npm:^20.11.19" "@types/node": "npm:^20.11.19"
"@types/obs-studio": "npm:^2.17.2"
"@types/uuid": "npm:^9.0.8" "@types/uuid": "npm:^9.0.8"
"@typescript-eslint/eslint-plugin": "npm:^7.0.1" "@typescript-eslint/eslint-plugin": "npm:^7.0.1"
"@typescript-eslint/parser": "npm:^7.0.1" "@typescript-eslint/parser": "npm:^7.0.1"