域账户一键登录

博客围绕Websocket网络协议展开,虽暂无具体内容,但可推测会涉及该协议相关信息技术知识,如原理、应用等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  /**
       * 域账户一键登录
       */
      initWebSocket () { // 初始化weosocket
        if (window['WebSocket']) {
          if (this.websock !== null && this.websock.readyState === 1) {
            this.websock.send('ad')
            return
          }
          // websocket主要分为四步
          // 1.打开数据
          // 2.接收数据
          // 3.断开连接
          // 4.连接失败
          // this.wsUri:这里是websocket接口地址
          this.websock = new WebSocket(this.wsUri) //这里面的this都指向vue
          this.websock.onmessage = this.websocketonmessage //客户端接收服务端数据时触发
          this.websock.onerror = this.websocketonerror  //通信发生错误时触发
          this.websock.onopen = this.websocketonopen  //连接建立时触发
        } else {
          this.$showNotification('error', '信息', '当前浏览器不支持websocket协议,建议使用Chrome浏览器')
        }
      },

      /**
       * 打开链接
       */
      websocketonopen () {
        console.log('链接成功!')
        this.websock.send('ad')
      },

      send () {
        this.websock.send('ad')
      },

      /**
       * 连接失败
       */
      websocketonerror () {
        this.notInstallPlugin = true
        console.log('链接异常!')
        // this.$showNotification('error', '信息', '请检查一键登录插件安装情况')
        this.isLoginError = true
        this.errMsg = '请检查一键登录插件安装情况'
      },

      /**
       * 数据接收
       */
      websocketonmessage (e) {
        const data = e.data
        if (data === '获取失败') {
          // this.$showNotification('error', '信息', '数据获取异常,请检查插件状态或使用账号密码登录')
          this.isLoginError = true
          this.errMsg = '数据获取异常,请检查插件状态或使用账号密码登录'
        } else {
          // 数据链接的方法
          const {
            ADLogin
          } = this
          ADLogin({ 'account': data })
            .then((res) => this.loginSuccess(res))
            .catch(err => this.requestFailed(err))
            .finally(() => {
            })
        }
      },

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值