diff --git a/frontend/src/App.vue b/frontend/src/App.vue index e24de1a..9fd4fb5 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -10,14 +10,17 @@ import { } from '../wailsjs/runtime' import {h, onBeforeMount, onMounted, ref} from "vue"; import { RouterLink } from 'vue-router' -import {darkTheme, NGradientText, NIcon, NText,} from 'naive-ui' +import {darkTheme, NButton, NGradientText, NIcon, NText,} from 'naive-ui' import { SettingsOutline, ReorderTwoOutline, ExpandOutline, PowerOutline, LogoGithub, MoveOutline, WalletOutline, StarOutline, AlarmOutline, SparklesOutline, NewspaperOutline, } from '@vicons/ionicons5' -import {GetConfig} from "../wailsjs/go/main/App"; +import {GetConfig, GetGroupList} from "../wailsjs/go/main/App"; +import { useRouter } from 'vue-router' +const router = useRouter() + const enableNews= ref(false) const contentStyle = ref("") const enableFund = ref(false) @@ -28,6 +31,7 @@ const activeKey = ref('') const containerRef= ref({}) const realtimeProfit= ref(0) const telegraph= ref([]) +const groupList=ref([]) const menuOptions = ref([ { label: () => @@ -36,6 +40,10 @@ const menuOptions = ref([ { to: { name: 'stock', + query: { + groupName: '全部', + groupId: 0, + }, params: { }, } @@ -46,12 +54,36 @@ const menuOptions = ref([ icon: renderIcon(StarOutline), children:[ { - label: ()=> h(NText, {type:realtimeProfit.value>0?'error':'success'},{ default: () => '当日盈亏 '+realtimeProfit.value+"¥"}), - key: 'realtimeProfit', - show: realtimeProfit.value, - icon: renderIcon(WalletOutline), - }, - ] + label: () => + h( + 'a', + { + href: '#', + type: 'info', + onClick: ()=>{ + //console.log("push",item) + router.push({ + name: 'stock', + query: { + groupName: '全部', + groupId: 0, + }, + }) + EventsEmit("changeTab", {ID:0,name:'全部'}) + }, + to: { + name: 'stock', + query: { + groupName: '全部', + groupId: 0, + }, + } + }, + { default: () => '全部',} + ), + key: 0, + } + ], }, { label: () => @@ -214,8 +246,53 @@ window.onerror = function (msg, source, lineno, colno, error) { }; onBeforeMount(()=>{ + GetGroupList().then(result => { + groupList.value=result + menuOptions.value.map((item)=>{ + //console.log(item) + if(item.key==='stock'){ + item.children.push(...groupList.value.map(item=>{ + return { + label: () => + h( + 'a', + { + href: '#', + type: 'info', + onClick: ()=>{ + //console.log("push",item) + router.push({ + name: 'stock', + query: { + groupName: item.name, + groupId: item.ID, + }, + }) + setTimeout(()=>{ + EventsEmit("changeTab", item) + },100) + }, + to: { + name: 'stock', + query: { + groupName: item.name, + groupId: item.ID, + }, + } + }, + { default: () => item.name,} + ), + key: item.ID, + } + })) + } + }) + }) + + + GetConfig().then((res)=>{ - console.log(res) + //console.log(res) enableFund.value=res.enableFund menuOptions.value.filter((item)=>{ diff --git a/frontend/src/components/stock.vue b/frontend/src/components/stock.vue index 49b0918..73fd76c 100644 --- a/frontend/src/components/stock.vue +++ b/frontend/src/components/stock.vue @@ -56,6 +56,10 @@ import {asBlob} from 'html-docx-js-typescript'; import vueDanmaku from 'vue3-danmaku' import {keys, pad, padStart} from "lodash"; import {models} from "../../wailsjs/go/models"; +import {RouterLink} from "vue-router"; +import { useRoute } from 'vue-router' +const route = useRoute() + const danmus = ref([]) const ws = ref(null) const dialog = useDialog() @@ -122,7 +126,12 @@ const data = reactive({ changePercent:0 }) const feishiInterval= ref(null) + + const currentGroupId=ref(0) + + + const theme=computed(() => { return data.darkTheme ? 'dark' : 'light' }) @@ -155,9 +164,13 @@ const groupResults=computed(() => { }) onBeforeMount(()=>{ - GetGroupList().then(result => { groupList.value=result + if(route.query.groupId){ + message.success("切换分组:"+route.query.groupName) + currentGroupId.value=Number(route.query.groupId) + console.log("route.params",route.query) + } }) GetStockList("").then(result => { stockList.value = result @@ -304,6 +317,12 @@ EventsOn("newChatStream",async (msg) => { } }) +EventsOn("changeTab" ,async (msg) => { + //console.log("changeTab",msg) + currentGroupId.value=msg.ID + updateTab(currentGroupId.value) +}) + EventsOn("updateVersion",async (msg) => { const githubTimeStr = msg.published_at; @@ -473,7 +492,8 @@ function getStockList(value){ function blinkBorder(findId){ // 获取要滚动到的元素 - const element = document.getElementById(findId); + let element = document.getElementById(findId); + console.log("blinkBorder",findId,element) if (element) { // 滚动到该元素 element.scrollIntoView({ behavior: 'smooth'}); @@ -1552,11 +1572,11 @@ function delStockGroup(code,name,groupId){ - - + + - - + + diff --git a/frontend/src/router/router.js b/frontend/src/router/router.js index 79f82ba..d54a5fb 100644 --- a/frontend/src/router/router.js +++ b/frontend/src/router/router.js @@ -1,4 +1,4 @@ -import {createMemoryHistory, createRouter, createWebHashHistory} from 'vue-router' +import {createMemoryHistory, createRouter, createWebHashHistory, createWebHistory} from 'vue-router' import stockView from '../components/stock.vue' import settingsView from '../components/settings.vue' @@ -7,7 +7,7 @@ import fundView from "../components/fund.vue"; import market from "../components/market.vue"; const routes = [ - { path: '/', component: stockView,name: 'stock' }, + { path: '/', component: stockView,name: 'stock'}, { path: '/fund', component: fundView,name: 'fund' }, { path: '/settings', component: settingsView,name: 'settings' }, { path: '/about', component: about,name: 'about' }, @@ -15,7 +15,7 @@ const routes = [ ] const router = createRouter({ - history: createWebHashHistory(), + history: createWebHistory(), routes, })