Explorar o código

提取音频相关后端接口origin到config中;生产模式下也暂且使用http协议。

任一存 %!s(int64=2) %!d(string=hai) anos
pai
achega
6d3e14b160
Modificáronse 2 ficheiros con 17 adicións e 3 borrados
  1. 14 1
      web/src/config.js
  2. 3 2
      web/src/views/accessibility.vue

+ 14 - 1
web/src/config.js

@@ -9,9 +9,22 @@ switch (process.env.NODE_ENV) {
     break;
 }
 
-const version = 'v1013.1212'
+let ajaxOrigin = ''
+switch (process.env.NODE_ENV) {
+  case 'development':
+    ajaxOrigin = 'http://47.107.166.80:8008'
+    break;
+  case 'production':
+    ajaxOrigin = `http://47.107.166.80:8008`
+    break;
+  default:
+    break;
+}
+
+const version = 'v1013.1422'
 
 module.exports = {
   publicPath,
+  ajaxOrigin,
   version,
 }

+ 3 - 2
web/src/views/accessibility.vue

@@ -402,6 +402,7 @@ import utils from "/src/utils.js"
 import bigCursor from '/src/assets/images/accessibility/big-cursor.cur'
 import "/src/assets/css/ariaGlobalStyle.less"
 import assetUrls from '/src/assets/images/accessibility/index.js'
+import { ajaxOrigin } from "@/config.js";
 const config = require('/src/config.js')
 
 const speechRateFactors = [
@@ -740,7 +741,7 @@ export default {
           if (that.audioPlayer && !that.audioPlayer.ended) {
             that.audioPlayer.pause()
           }
-          that.audioPlayer = new Audio('http://47.107.166.80:8008' + res.msg)
+          that.audioPlayer = new Audio(ajaxOrigin + res.msg)
           that.audioPlayer.muted = that.ariaSettings.isMuted
           that.audioPlayer.playbackRate = speechRateFactors[that.ariaSettings.speechRateLevel]
           that.audioPlayer.oncanplaythrough = () => {
@@ -762,7 +763,7 @@ export default {
           }
         }
       }
-      XHR.open("POST", "http://47.107.166.80:8008/api/tts/toMp3")
+      XHR.open("POST", `${ajaxOrigin}/api/tts/toMp3`)
       XHR.setRequestHeader("Content-Type", "application/json;charset=UTF-8")
       XHR.send(JSON.stringify({
         content: text || this.elemType + (this.elemType ? ': ' : '') + this.elemDisc