|
|
@ -1,52 +1,51 @@ |
|
|
|
|
|
|
|
import { defineStore } from 'pinia' |
|
|
|
import { ref, watch } from 'vue' |
|
|
|
import { useUserStore } from './userPessionCode' |
|
|
|
import { useLanguage } from '@/utils/languageService' |
|
|
|
import { dataListAPI } from '@/api/AIxiaocaishen' |
|
|
|
import { defineStore } from "pinia"; |
|
|
|
import { ref, watch } from "vue"; |
|
|
|
import { useUserStore } from "./userPessionCode"; |
|
|
|
import { useLanguage } from "@/utils/languageService"; |
|
|
|
import { dataListAPI } from "@/api/AIxiaocaishen"; |
|
|
|
// import { useSkeletonStore } from '@/utils/skeletonLoader'
|
|
|
|
import { useRoute } from 'vue-router' |
|
|
|
import { useRoute } from "vue-router"; |
|
|
|
// const skeletonStore = useSkeletonStore()
|
|
|
|
// const { t } = useLanguage()
|
|
|
|
|
|
|
|
export const useDataStore = defineStore('data', () => { |
|
|
|
const route = useRoute() |
|
|
|
console.log(route, '地址栏携带的参数。。。。。。') |
|
|
|
const userStore = useUserStore() |
|
|
|
const brainDataList = ref(null) |
|
|
|
const swordDataList = ref(null) |
|
|
|
const priceDataList = ref(null) |
|
|
|
const timeDataList = ref(null) |
|
|
|
const showALLData = ref(null) |
|
|
|
const HomePage = ref(null) |
|
|
|
const AIBull = ref(null) |
|
|
|
const AIGoldBull = ref(null) |
|
|
|
const AIRadar = ref(null) |
|
|
|
const loading = ref(false) |
|
|
|
const klineData = ref(null) |
|
|
|
const activeTabIndex = ref(null) |
|
|
|
const isFeedback = ref(false) // 用于控制是否显示反馈页面的标志
|
|
|
|
export const useDataStore = defineStore("data", () => { |
|
|
|
const route = useRoute(); |
|
|
|
console.log(route, "地址栏携带的参数。。。。。。"); |
|
|
|
const userStore = useUserStore(); |
|
|
|
const brainDataList = ref(null); |
|
|
|
const swordDataList = ref(null); |
|
|
|
const priceDataList = ref(null); |
|
|
|
const timeDataList = ref(null); |
|
|
|
const showALLData = ref(null); |
|
|
|
const HomePage = ref(null); |
|
|
|
const AIBull = ref(null); |
|
|
|
const AIGoldBull = ref(null); |
|
|
|
const AIRadar = ref(null); |
|
|
|
const loading = ref(false); |
|
|
|
const klineData = ref(null); |
|
|
|
const activeTabIndex = ref(null); |
|
|
|
const isFeedback = ref(false); // 用于控制是否显示反馈页面的标志
|
|
|
|
const setKlineData = (data) => { |
|
|
|
klineData.value = data |
|
|
|
} |
|
|
|
klineData.value = data; |
|
|
|
}; |
|
|
|
|
|
|
|
const setActiveTabIndex = (index) => { |
|
|
|
activeTabIndex.value = index |
|
|
|
} |
|
|
|
activeTabIndex.value = index; |
|
|
|
}; |
|
|
|
|
|
|
|
const getQueryVariable = (variable) => { |
|
|
|
const query = window.location.search.substring(1) |
|
|
|
const query = window.location.search.substring(1); |
|
|
|
// console.log(query,'query')
|
|
|
|
const vars = query.split('&') |
|
|
|
const vars = query.split("&"); |
|
|
|
// console.log(vars,'vars')
|
|
|
|
for (let i = 0; i < vars.length; i++) { |
|
|
|
const pair = vars[i].split('=') |
|
|
|
const pair = vars[i].split("="); |
|
|
|
if (pair[0] === variable) { |
|
|
|
return pair[1] |
|
|
|
} |
|
|
|
return pair[1]; |
|
|
|
} |
|
|
|
return '' |
|
|
|
} |
|
|
|
return ""; |
|
|
|
}; |
|
|
|
|
|
|
|
// const getAnswer = (result) => {
|
|
|
|
// const data = result.data;
|
|
|
@ -61,93 +60,112 @@ export const useDataStore = defineStore('data', () => { |
|
|
|
// }
|
|
|
|
|
|
|
|
// 使用示例,获取地址栏参数
|
|
|
|
// const token = ref(getQueryVariable('token'))
|
|
|
|
// const market = ref(getQueryVariable('market'))
|
|
|
|
// const code = ref(getQueryVariable('code'))
|
|
|
|
// console.log(token.value) // 输出 token 的值,例如 "111"
|
|
|
|
// const fetchChartData = async () => {
|
|
|
|
// const getTokenString = String(localStorage.getItem('localToken'))
|
|
|
|
// const getMarketString = String(localStorage.getItem('localMarket'))
|
|
|
|
// const getCodeString = String(localStorage.getItem('localCode'))
|
|
|
|
// // const getMarket = String()
|
|
|
|
// try {
|
|
|
|
// const res = await dataListAPI({
|
|
|
|
// token: getTokenString || '',
|
|
|
|
// market: getMarket() || getMarketString || 'gb',
|
|
|
|
// code: getQueryVariable('code') || getCodeString || 'NDX',
|
|
|
|
// language: 'cn', //t.value.suoxie,
|
|
|
|
// brainPrivilegeState: userStore.brainPerssion,
|
|
|
|
// swordPrivilegeState: userStore.swordPerssion,
|
|
|
|
// stockForecastPrivilegeState: userStore.pricePerssion,
|
|
|
|
// spaceForecastPrivilegeState: userStore.timePerssion,
|
|
|
|
// aibullPrivilegeState: userStore.aibullPerssion,
|
|
|
|
// aigoldBullPrivilegeState: userStore.aiGnbullPerssion,
|
|
|
|
// airadarPrivilegeState: userStore.airadarPerssion,
|
|
|
|
// marketList: userStore.aiGoldMarketList
|
|
|
|
// })
|
|
|
|
const token = ref(getQueryVariable("token")); |
|
|
|
const market = ref(getQueryVariable("market")); |
|
|
|
const code = ref(getQueryVariable("code")); |
|
|
|
console.log(token.value); // 输出 token 的值,例如 "111"
|
|
|
|
const fetchChartData = async (market,code) => { |
|
|
|
const getTokenString = String(localStorage.getItem("localToken")); |
|
|
|
// const getMarketString = String(localStorage.getItem("localMarket"));
|
|
|
|
// const getCodeString = String(localStorage.getItem("localCode"));
|
|
|
|
// const getMarket = String()
|
|
|
|
try { |
|
|
|
const res = await dataListAPI({ |
|
|
|
token: getTokenString || "", |
|
|
|
market: market || "gb", |
|
|
|
code: code || "NDX", |
|
|
|
language: "cn", //t.value.suoxie,
|
|
|
|
brainPrivilegeState: userStore.brainPerssion, |
|
|
|
swordPrivilegeState: userStore.swordPerssion, |
|
|
|
stockForecastPrivilegeState: userStore.pricePerssion, |
|
|
|
spaceForecastPrivilegeState: userStore.timePerssion, |
|
|
|
aibullPrivilegeState: userStore.aibullPerssion, |
|
|
|
aigoldBullPrivilegeState: userStore.aiGnbullPerssion, |
|
|
|
airadarPrivilegeState: userStore.airadarPerssion, |
|
|
|
marketList: userStore.aiGoldMarketList, |
|
|
|
}); |
|
|
|
|
|
|
|
// brainDataList.value = res.data.Brain
|
|
|
|
// swordDataList.value = res.data.Sword
|
|
|
|
// priceDataList.value = res.data.StockForecast
|
|
|
|
// timeDataList.value = res.data.SpaceForecast
|
|
|
|
// showALLData.value = res.data.ShowAll
|
|
|
|
// HomePage.value = res.data.HomePage
|
|
|
|
// AIBull.value = res.data.AIBull
|
|
|
|
// AIGoldBull.value = res.data.AIGoldBull
|
|
|
|
// AIRadar.value = res.data.AIRadar
|
|
|
|
// } catch (error) {
|
|
|
|
// console.error('获取图表数据出错:', error)
|
|
|
|
// } finally {
|
|
|
|
// loading.value = false
|
|
|
|
// console.log('数据获取过程结束')
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
brainDataList.value = res.data.Brain; |
|
|
|
swordDataList.value = res.data.Sword; |
|
|
|
priceDataList.value = res.data.StockForecast; |
|
|
|
timeDataList.value = res.data.SpaceForecast; |
|
|
|
showALLData.value = res.data.ShowAll; |
|
|
|
HomePage.value = res.data.HomePage; |
|
|
|
AIBull.value = res.data.AIBull; |
|
|
|
AIGoldBull.value = res.data.AIGoldBull; |
|
|
|
AIRadar.value = res.data.AIRadar; |
|
|
|
} catch (error) { |
|
|
|
console.error("获取图表数据出错:", error); |
|
|
|
} finally { |
|
|
|
loading.value = false; |
|
|
|
console.log("数据获取过程结束"); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 获取路径上market的值
|
|
|
|
const getMarket = () => { |
|
|
|
let market = '' |
|
|
|
const queryMarket = getQueryVariable('market') |
|
|
|
let market = ""; |
|
|
|
const queryMarket = getQueryVariable("market"); |
|
|
|
if (queryMarket) { |
|
|
|
if ( |
|
|
|
['sg', 'my', 'in', 'hk', 'th', 'vi', 'usa', 'can', 'gb', 'cn'].includes(queryMarket) |
|
|
|
["sg", "my", "in", "hk", "th", "vi", "usa", "can", "gb", "cn"].includes( |
|
|
|
queryMarket |
|
|
|
) |
|
|
|
) { |
|
|
|
return queryMarket |
|
|
|
return queryMarket; |
|
|
|
} else { |
|
|
|
switch (queryMarket) { |
|
|
|
case 'SGX': return 'sg' |
|
|
|
case 'BMB': return 'my' |
|
|
|
case 'IDX': return 'in' |
|
|
|
case 'HKEX': return 'hk' |
|
|
|
case 'SET': return 'th' |
|
|
|
case 'HN': return 'vi' |
|
|
|
case 'HONSE': return 'vi' |
|
|
|
case 'AMERA': return 'usa' |
|
|
|
case 'NYSE': return 'usa' |
|
|
|
case 'NASDAQ': return 'usa' |
|
|
|
case 'DLD': return 'can' |
|
|
|
case 'DLDCY': return 'can' |
|
|
|
case 'GINDEX': return 'gb' |
|
|
|
case 'BZ': return 'cn' |
|
|
|
case 'SH': return 'cn' |
|
|
|
case 'SZ': return 'cn' |
|
|
|
default: return '无市场数据' |
|
|
|
} |
|
|
|
case "SGX": |
|
|
|
return "sg"; |
|
|
|
case "BMB": |
|
|
|
return "my"; |
|
|
|
case "IDX": |
|
|
|
return "in"; |
|
|
|
case "HKEX": |
|
|
|
return "hk"; |
|
|
|
case "SET": |
|
|
|
return "th"; |
|
|
|
case "HN": |
|
|
|
return "vi"; |
|
|
|
case "HONSE": |
|
|
|
return "vi"; |
|
|
|
case "AMERA": |
|
|
|
return "usa"; |
|
|
|
case "NYSE": |
|
|
|
return "usa"; |
|
|
|
case "NASDAQ": |
|
|
|
return "usa"; |
|
|
|
case "DLD": |
|
|
|
return "can"; |
|
|
|
case "DLDCY": |
|
|
|
return "can"; |
|
|
|
case "GINDEX": |
|
|
|
return "gb"; |
|
|
|
case "BZ": |
|
|
|
return "cn"; |
|
|
|
case "SH": |
|
|
|
return "cn"; |
|
|
|
case "SZ": |
|
|
|
return "cn"; |
|
|
|
default: |
|
|
|
return "无市场数据"; |
|
|
|
} |
|
|
|
} |
|
|
|
return '' |
|
|
|
} |
|
|
|
return ""; |
|
|
|
}; |
|
|
|
|
|
|
|
const isLoading = ref(true) |
|
|
|
const isLoading = ref(true); |
|
|
|
const initData = async () => { |
|
|
|
isLoading.value = true |
|
|
|
isLoading.value = true; |
|
|
|
try { |
|
|
|
// 初始化逻辑
|
|
|
|
} catch (error) { |
|
|
|
console.error('Error loading data:', error) |
|
|
|
console.error("Error loading data:", error); |
|
|
|
} finally { |
|
|
|
isLoading.value = false |
|
|
|
} |
|
|
|
isLoading.value = false; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// watch(
|
|
|
|
// () => [userStore.isReady, t.value?.suoxie],
|
|
|
@ -160,17 +178,21 @@ export const useDataStore = defineStore('data', () => { |
|
|
|
// { immediate: true, deep: true }
|
|
|
|
// )
|
|
|
|
|
|
|
|
// watch(() => route.query, () => {
|
|
|
|
// if (route.query.market || route.query.code) {
|
|
|
|
// fetchChartData()
|
|
|
|
watch( |
|
|
|
() => window.location.ancestorOrigins, |
|
|
|
(newQuery, oldQuery) => { |
|
|
|
console.log("newQuery", newQuery); |
|
|
|
// if () {
|
|
|
|
// fetchChartData();
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
// watch(() => userStore.aibullPerssion, (newValue) => {
|
|
|
|
// if (newValue === 1) fetchChartData()
|
|
|
|
// })
|
|
|
|
|
|
|
|
initData() |
|
|
|
initData(); |
|
|
|
|
|
|
|
return { |
|
|
|
// brainDataList,
|
|
|
@ -178,12 +200,12 @@ export const useDataStore = defineStore('data', () => { |
|
|
|
// priceDataList,
|
|
|
|
// timeDataList,
|
|
|
|
// showALLData,
|
|
|
|
// HomePage,
|
|
|
|
HomePage, |
|
|
|
// AIBull,
|
|
|
|
// AIGoldBull,
|
|
|
|
AIGoldBull, |
|
|
|
// loading,
|
|
|
|
// AIRadar,
|
|
|
|
// fetchChartData,
|
|
|
|
fetchChartData, |
|
|
|
activeTabIndex, |
|
|
|
klineData, |
|
|
|
setKlineData, |
|
|
@ -191,6 +213,6 @@ export const useDataStore = defineStore('data', () => { |
|
|
|
getMarket, |
|
|
|
getQueryVariable, |
|
|
|
setActiveTabIndex, |
|
|
|
isFeedback |
|
|
|
} |
|
|
|
}) |
|
|
|
isFeedback, |
|
|
|
}; |
|
|
|
}); |