fiee-official-website/src/store/stock-quote/index.js

40 lines
864 B
JavaScript
Raw Normal View History

import { ref } from 'vue'
import { createGlobalState, useLocalStorage } from '@vueuse/core'
import axios from 'axios'
export const useStockQuote = createGlobalState(() => {
const stockQuote = useLocalStorage('stockQuote', {
"Open": "",
"Volume": "",
"DayRange": "",
"WeekRange": "",
"MarketCap": "",
"change": [
"",
""
]
})
const date = new Date();
const options = {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: '2-digit',
hour12: true,
timeZone: 'America/New_York',
timeZoneName: 'short'
};
const formatted = ref(date.toLocaleString('en-US', options))
const getStockQuate= async()=>{
const res = await axios.get('https://saas-test.szjixun.cn/api/chart/forward/test')
stockQuote.value=res.data
}
return {
formatted,
getStockQuate,
stockQuote
}
})