mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			94 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			94 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
Tea.context(function () {
 | 
						|
	this.moreOptionsVisible = false;
 | 
						|
	this.globalChangedClusters = [];
 | 
						|
 | 
						|
	this.$delay(function () {
 | 
						|
		if (this.$refs.focus != null) {
 | 
						|
			this.$refs.focus.focus();
 | 
						|
		}
 | 
						|
 | 
						|
		// 检查变更
 | 
						|
		this.checkClusterChanges()
 | 
						|
	});
 | 
						|
 | 
						|
	/**
 | 
						|
	 * 左侧子菜单
 | 
						|
	 */
 | 
						|
	this.showSubMenu = function (menu) {
 | 
						|
		if (menu.alwaysActive) {
 | 
						|
			return;
 | 
						|
		}
 | 
						|
		if (this.teaSubMenus.menus != null && this.teaSubMenus.menus.length > 0) {
 | 
						|
			this.teaSubMenus.menus.$each(function (k, v) {
 | 
						|
				if (menu.id == v.id) {
 | 
						|
					return;
 | 
						|
				}
 | 
						|
				v.isActive = false;
 | 
						|
			});
 | 
						|
		}
 | 
						|
		menu.isActive = !menu.isActive;
 | 
						|
	};
 | 
						|
 | 
						|
	/**
 | 
						|
	 * 检查集群变更
 | 
						|
	 */
 | 
						|
	this.checkClusterChanges = function () {
 | 
						|
		this.$get("/common/changedClusters")
 | 
						|
			.success(function (resp) {
 | 
						|
				this.globalChangedClusters = resp.data.clusters;
 | 
						|
			}).fail(function () {
 | 
						|
			this.globalChangedClusters = [];
 | 
						|
		})
 | 
						|
	};
 | 
						|
 | 
						|
	/**
 | 
						|
	 * 同步集群配置
 | 
						|
	 */
 | 
						|
	this.syncClustersConfigs = function () {
 | 
						|
		teaweb.confirm("确定要同步集群服务配置吗?", function () {
 | 
						|
			this.$post("/common/syncClusters")
 | 
						|
				.success(function () {
 | 
						|
					this.globalChangedClusters = [];
 | 
						|
				})
 | 
						|
		})
 | 
						|
	};
 | 
						|
});
 | 
						|
 | 
						|
window.NotifySuccess = function (message, url, params) {
 | 
						|
	if (typeof (url) == "string" && url.length > 0) {
 | 
						|
		if (url[0] != "/") {
 | 
						|
			url = Tea.url(url, params);
 | 
						|
		}
 | 
						|
	}
 | 
						|
	return function () {
 | 
						|
		teaweb.success(message, function () {
 | 
						|
			window.location = url;
 | 
						|
		});
 | 
						|
	};
 | 
						|
};
 | 
						|
 | 
						|
window.NotifyDelete = function (message, url, params) {
 | 
						|
	teaweb.confirm(message, function () {
 | 
						|
		Tea.Vue.$post(url)
 | 
						|
			.params(params)
 | 
						|
			.refresh();
 | 
						|
	});
 | 
						|
};
 | 
						|
 | 
						|
window.NotifyPopup = function (resp) {
 | 
						|
	window.parent.teaweb.popupFinish(resp);
 | 
						|
};
 | 
						|
 | 
						|
window.ChangePageSize = function (size) {
 | 
						|
	let url = window.location.toString();
 | 
						|
	if (url.indexOf("pageSize") > 0) {
 | 
						|
		url = url.replace(/pageSize=\d+/g, "pageSize=" + size);
 | 
						|
	} else {
 | 
						|
		if (url.indexOf("?") > 0) {
 | 
						|
			url += "&pageSize=" + size;
 | 
						|
		} else {
 | 
						|
			url += "?pageSize=" + size;
 | 
						|
		}
 | 
						|
	}
 | 
						|
	window.location = url;
 | 
						|
}; |