Vue.component("http-websocket-box", { props: ["v-websocket-ref", "v-websocket-config", "v-is-location"], data: function () { let websocketRef = this.vWebsocketRef if (websocketRef == null) { websocketRef = { isPrior: false, isOn: true, websocketId: 0 } } let websocketConfig = this.vWebsocketConfig if (websocketConfig == null) { websocketConfig = { id: 0, isOn: false, handshakeTimeout: { count: 30, unit: "second" }, allowAllOrigins: true, allowedOrigins: [], requestSameOrigin: true, requestOrigin: "" } } else { if (websocketConfig.handshakeTimeout == null) { websocketConfig.handshakeTimeout = { count: 30, unit: "second", } } if (websocketConfig.allowedOrigins == null) { websocketConfig.allowedOrigins = [] } } return { websocketRef: websocketRef, websocketConfig: websocketConfig, handshakeTimeoutCountString: websocketConfig.handshakeTimeout.count.toString(), advancedVisible: false } }, watch: { handshakeTimeoutCountString: function (v) { let count = parseInt(v) if (!isNaN(count) && count >= 0) { this.websocketConfig.handshakeTimeout.count = count } else { this.websocketConfig.handshakeTimeout.count = 0 } } }, methods: { isOn: function () { return (!this.vIsLocation || this.websocketRef.isPrior) && this.websocketRef.isOn }, changeAdvancedVisible: function (v) { this.advancedVisible = v }, createOrigin: function () { let that = this teaweb.popup("/servers/server/settings/websocket/createOrigin", { height: "12.5em", callback: function (resp) { that.websocketConfig.allowedOrigins.push(resp.data.origin) } }) }, removeOrigin: function (index) { this.websocketConfig.allowedOrigins.$remove(index) } }, template: `
是否启用配置
允许所有来源域(Origin)

选中表示允许所有的来源域。

允许的来源域列表(Origin)
{{origin}}

只允许在列表中的来源域名访问Websocket服务。

是否传递请求来源域

选中表示把接收到的请求中的Origin字段传递到源站。

指定传递的来源域

指定向源站传递的Origin字段值。

握手超时时间(Handshake)

0表示使用默认的时间设置。

` })