go wails桌面应用开发:完成股票数据查询,股票数据API

go wails桌面应用开发、股票数据接口调用

前言

本文主要是介绍和分享go-wails开发的股票Api数据查看桌面应用,通过定时器,轮询请求股票Api获取股票交易数据和趋势图,
本示例仅是个人学习wails的demo,仅供学习使用,源代码可下载:

一、前期准备:

二、源代码块

1、股票数据布局和股票代码初始化:

  • 初始化股票代码列表(有默认)
  • 获取接口请求Key,并配置
  • 引入股票数据组件模块
<script>
import {
   
   GetStockList, GetStockInfo, ChangeStockConf} from '../../wailsjs/go/main/App'
import {
   
   SetStorage,GetStorage,GetAllStorage,RemoveStorage,ClearStorage} from '../config/localstorage'
import StockInfoComponent from '../components/StockInfoComponent.vue'

export default {
   
   
  data() {
   
   
    return {
   
   
      title:'go wails 股票查询新系统',
      name: "",
      url:'https://www.juhe.cn/s/sujmbk6wkw718a=',
      vipUrl:'https://www.juhe.cn/s/surjdal9mjdatr=',
      stocks:[],
      stockInfo:[],
      code:'',
      tabPosition:'left',
      addable :true,
      stockCode:'',
      appKey:'',
      defalutStocks:[
        {
   
   code: "sz002610", name: "爱康科技"},
        {
   
   code: "sz002665", name: "首行高科"},
        {
   
   code: "sh600339", name: "中油工程"}
      ],
      timer:null,
      apiEnable:false,
      addCode:'',
      removCode:''
    }
  },
  components:{
   
   
    StockInfoComponent
  },

  created(){
   
   
    this.initStockList()
    this.getStockList();
  },
  methods:{
   
   
    clickCopy(el,val){
   
   
      if(el ==='vip'){
   
   
        navigator.clipboard.writeText(this.vipUrl).then(() => {
   
   
           this.$message.success("链接复制成功")
        });
      } else {
   
   
        navigator.clipboard.writeText(this.url).then(() => {
   
   
           this.$message.success("链接复制成功")
        });
      }
    },
    // 获取股票列表信息
    getStockList() {
   
   
      console.log('getStockList',this.stocks)
      this.stocks = GetStorage('storcklist')

      console.log('getStockList2',this.stocks)

      if(this.stocks.length >0 ){
   
   
        this.stockCode = this.stocks[0].code
      }
      this.appKey = GetStorage('appkey')
      if(this.appKey) {
   
   
        this.changeApiKey()
      } else {
   
   
        this.$message.error('请先获取AppKey,并配置')
      }
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值