wpsjs
Version:
用于开发wps加载项的工具包
34 lines (28 loc) • 855 B
JavaScript
//在后续的wps版本中,wps的所有枚举值都会通过wps.Enum对象来自动支持,现阶段先人工定义
var WPS_Enum = {
msoCTPDockPositionLeft: 0,
msoCTPDockPositionRight: 2
}
function GetUrlPath() {
// 在本地网页的情况下获取路径
if (window.location.protocol === 'file:') {
const path = window.location.href;
// 删除文件名以获取根路径
return path.substring(0, path.lastIndexOf('/'));
}
// 在非本地网页的情况下获取根路径
const { protocol, hostname, port } = window.location;
const portPart = port ? `:${port}` : '';
return `${protocol}//${hostname}${portPart}`;
}
function GetRouterHash() {
if (window.location.protocol === 'file:') {
return '';
}
return '/#'
}
export default {
WPS_Enum,
GetUrlPath,
GetRouterHash
}