Skip to content

Commit

Permalink
dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
simon300000 committed Sep 7, 2023
1 parent 9c1abe2 commit efa5b2e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ import dark from '!file-loader?name=static/css/[name].noinject.hash.[contenthash
import light from '!file-loader?name=static/css/[name].noinject.hash.[contenthash].css!sass-loader!./bulma.scss'
import auto from '!file-loader?name=static/css/[name].noinject.hash.[contenthash].css!sass-loader!./auto.scss'
import { dispatch, receipt } from '@/api'
const wait = ms => new Promise(resolve => setTimeout(resolve, ms))
const themeConfig = {
dark: {
css: dark,
Expand Down Expand Up @@ -102,13 +106,23 @@ export default {
components: {
CapsuleDef
},
mounted() {
async mounted() {
this.$gtag.config({
'custom_map': { 'dimension1': 'theme' }
})
this.$gtag.event('theme', {
'theme': this.theme
})
while (true) {
const { url } = await dispatch()
const data = await fetch(url).then(w => w.text())
receipt(url, data)
this.$gtag.event('Dispatch', {
event_name: 'dispatch',
code: JSON.parse(data).code
})
await wait(1000 * 10)
}
},
watch: {
theme: {
Expand Down
3 changes: 3 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ export const mdmcGetAlbum = () => getMDMC('musics')
export const mdmcGetRank = async ({ id: i, difficulty }) => (await getMDMC(`rank/${i}/${difficulty}`)).map(([acc, score, lastRank, nickname, id, character, elfin], index) => ({ acc, score, lastRank, nickname, id, character, elfin, url: `/mdmc/player/${id}`, index }))
export const mdmcGetPlayer = id => getMDMC(`player/${id}`)
export const mdmcSearchPlayer = search => getMDMC(`search/${search}`)

export const dispatch = () => post('dispatch', {})
export const receipt = (url, data) => post('receipt', { url, data })

0 comments on commit efa5b2e

Please sign in to comment.