feat: fetch quotes from server
This commit is contained in:
parent
5e58c9c994
commit
f629d7cdb3
@ -5,28 +5,10 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const quotes = [
|
||||
{
|
||||
id: 1,
|
||||
quote: 'Somna imanus it vorgenstra exa al termanum.',
|
||||
},
|
||||
{
|
||||
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',
|
||||
},
|
||||
]
|
||||
import useEngine from '@/composables/useEngine'
|
||||
const engine = useEngine()
|
||||
const quotes = await engine.getQuotes()
|
||||
console.log(quotes)
|
||||
</script>
|
||||
|
||||
<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 { start, stop } from '@/composables/engine/startStop'
|
||||
import { fetchUpdate } from '@/composables/engine/fetchUpdate'
|
||||
import { getQuotes } from '@/composables/engine/getQuotes'
|
||||
import type { Quotes } from '@/composables/engine.d'
|
||||
|
||||
interface EngineContext {
|
||||
isActive: boolean
|
||||
@ -20,6 +22,7 @@ export interface useEngine {
|
||||
start(): void
|
||||
stop(): void
|
||||
fetchUpdate(): void
|
||||
getQuotes(): Promise<Quotes>
|
||||
}
|
||||
|
||||
export default (): useEngine => {
|
||||
@ -41,5 +44,6 @@ export default (): useEngine => {
|
||||
start: () => start.apply(context),
|
||||
stop: () => stop.apply(context),
|
||||
fetchUpdate: () => fetchUpdate.apply(context),
|
||||
getQuotes: () => getQuotes.apply(context),
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user