import initCtx from "@/utils/ctx.js";

export default function () {
	const {utils, Tea} = initCtx(this)

	this.supportHTTPS = false
	this.requestHostType = 0
	this.requestHost = ""

	this.success = function (resp) {
		if (resp.data.hasOSS) {
			this.$NotifySuccess("保存成功", "/servers/server/settings/reverseProxy?serverId=" + resp.data.serverId)()
		} else {
			this.$NotifySuccess("保存成功", "/servers")()
		}
	}

	this.fail = function (resp) {
		let that = this
		utils.warn(resp.message, function () {
			if (resp.data.requireServerNames) {
				that.$refs.serverNameBox.addServerName()
			}
		})
	}

	/**
	 * 证书相关
	 */
	this.findServerNames = function () {
		return this.$refs.serverNameBox.allServerNames()
	}
}