2025-05-23 01:37:30 +00:00
|
|
|
import { ref } from 'vue'
|
|
|
|
import { createGlobalState, useLocalStorage } from '@vueuse/core'
|
|
|
|
import axios from 'axios'
|
2025-05-23 02:39:23 +00:00
|
|
|
|
2025-05-23 01:37:30 +00:00
|
|
|
export const useStockQuote = createGlobalState(() => {
|
2025-05-23 02:39:23 +00:00
|
|
|
const stockQuote = useLocalStorage('stockQuote', {
|
|
|
|
"Open": "",
|
|
|
|
"Volume": "",
|
|
|
|
"DayRange": "",
|
|
|
|
"WeekRange": "",
|
|
|
|
"MarketCap": "",
|
|
|
|
"change": [
|
|
|
|
"",
|
|
|
|
""
|
|
|
|
]
|
|
|
|
})
|
2025-05-23 12:21:14 +00:00
|
|
|
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))
|
2025-05-23 01:37:30 +00:00
|
|
|
const getStockQuate= async()=>{
|
2025-05-23 06:55:12 +00:00
|
|
|
const res = await axios.get('https://saas-test.szjixun.cn/api/chart/forward/test')
|
2025-05-23 02:39:23 +00:00
|
|
|
stockQuote.value=res.data
|
2025-05-23 01:37:30 +00:00
|
|
|
}
|
|
|
|
return {
|
2025-05-23 12:21:14 +00:00
|
|
|
formatted,
|
2025-05-23 01:37:30 +00:00
|
|
|
getStockQuate,
|
|
|
|
stockQuote
|
|
|
|
}
|
|
|
|
})
|