mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
update
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
const debugAPI = import.meta.env.VITE_DEBUG_API
|
||||
const releseAPI = `${document.location.protocol}//api.vtsuru.live/`
|
||||
|
||||
export const isBackendUsable = ref(true)
|
||||
|
||||
export const BASE_API = process.env.NODE_ENV === 'development' ? debugAPI : releseAPI
|
||||
export const FETCH_API = 'https://fetch.vtsuru.live/'
|
||||
export const FIVESING_SEARCH_API = 'http://search.5sing.kugou.com/home/json?sort=1&page=1&filter=3&type=0&keyword='
|
||||
|
||||
@@ -1,22 +1,33 @@
|
||||
import { QueryGetAPI } from '@/api/query'
|
||||
import { useRequest } from 'vue-request'
|
||||
import { NOTIFACTION_API_URL } from './constants'
|
||||
import { NOTIFACTION_API_URL, isBackendUsable } from './constants'
|
||||
import { NotifactionInfo } from '@/api/api-models'
|
||||
import { useAccount } from '@/api/account'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const account = useAccount()
|
||||
const { data, run } = useRequest(get, {
|
||||
errorRetryCount: 5,
|
||||
pollingInterval: 5000,
|
||||
pollingWhenHidden: false,
|
||||
})
|
||||
const n = ref<NotifactionInfo>()
|
||||
let isLoading = false
|
||||
function get() {
|
||||
return QueryGetAPI<NotifactionInfo>(NOTIFACTION_API_URL + 'get')
|
||||
if (isLoading) return
|
||||
QueryGetAPI<NotifactionInfo>(NOTIFACTION_API_URL + 'get')
|
||||
.then((data) => {
|
||||
if (data.code == 200) {
|
||||
n.value = data.data
|
||||
isBackendUsable.value = true
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
isBackendUsable.value = false
|
||||
})
|
||||
.finally(() => {
|
||||
isLoading = false
|
||||
})
|
||||
}
|
||||
|
||||
export const notifactions = () => data
|
||||
export const notifactions = () => n
|
||||
export const GetNotifactions = () => {
|
||||
if (account) {
|
||||
run()
|
||||
setInterval(get, 5000)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user