feat: fetch quotes from server
This commit is contained in:
parent
5e58c9c994
commit
f629d7cdb3
@ -5,28 +5,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const quotes = [
|
import useEngine from '@/composables/useEngine'
|
||||||
{
|
const engine = useEngine()
|
||||||
id: 1,
|
const quotes = await engine.getQuotes()
|
||||||
quote: 'Somna imanus it vorgenstra exa al termanum.',
|
console.log(quotes)
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
quote: 'Kerbositus con vai quel verendenguum. Abtanosi con vai stice vermadostuos, na tum gehomo asbabasictnem orb eterum (phlegtum aka iborn).',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
quote: 'blah! #1',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 4,
|
|
||||||
quote: 'blah! #2',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 5,
|
|
||||||
quote: 'blah! #3',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
6
client/src/composables/engine.d.ts
vendored
Normal file
6
client/src/composables/engine.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export type Quote = {
|
||||||
|
id: string
|
||||||
|
quote: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Quotes = Array<Quote>
|
11
client/src/composables/engine/getQuotes.ts
Normal file
11
client/src/composables/engine/getQuotes.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import type { Quotes } from '@/composables/engine.d'
|
||||||
|
import { useUserinfoStore } from "@/stores/UserinfoStore"
|
||||||
|
|
||||||
|
export async function getQuotes(): Promise<Quotes> {
|
||||||
|
const userInfoStore = useUserinfoStore()
|
||||||
|
const response = await this.callApi('/api/getQuotes', {
|
||||||
|
g: userInfoStore.gameId,
|
||||||
|
})
|
||||||
|
|
||||||
|
return response.quotes
|
||||||
|
}
|
@ -2,6 +2,8 @@ import { Ref, ref } from 'vue'
|
|||||||
import { callApi, QueryParams } from '@/composables/engine/callApi'
|
import { callApi, QueryParams } from '@/composables/engine/callApi'
|
||||||
import { start, stop } from '@/composables/engine/startStop'
|
import { start, stop } from '@/composables/engine/startStop'
|
||||||
import { fetchUpdate } from '@/composables/engine/fetchUpdate'
|
import { fetchUpdate } from '@/composables/engine/fetchUpdate'
|
||||||
|
import { getQuotes } from '@/composables/engine/getQuotes'
|
||||||
|
import type { Quotes } from '@/composables/engine.d'
|
||||||
|
|
||||||
interface EngineContext {
|
interface EngineContext {
|
||||||
isActive: boolean
|
isActive: boolean
|
||||||
@ -20,6 +22,7 @@ export interface useEngine {
|
|||||||
start(): void
|
start(): void
|
||||||
stop(): void
|
stop(): void
|
||||||
fetchUpdate(): void
|
fetchUpdate(): void
|
||||||
|
getQuotes(): Promise<Quotes>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (): useEngine => {
|
export default (): useEngine => {
|
||||||
@ -41,5 +44,6 @@ export default (): useEngine => {
|
|||||||
start: () => start.apply(context),
|
start: () => start.apply(context),
|
||||||
stop: () => stop.apply(context),
|
stop: () => stop.apply(context),
|
||||||
fetchUpdate: () => fetchUpdate.apply(context),
|
fetchUpdate: () => fetchUpdate.apply(context),
|
||||||
|
getQuotes: () => getQuotes.apply(context),
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user