优化后台收不到推送报错404
This commit is contained in:
@@ -35,6 +35,33 @@ export const getUrl = (): string => {
|
||||
return value == 'getCurrentDomain' ? window.location.protocol + '//' + window.location.host : value
|
||||
}
|
||||
|
||||
/**
|
||||
* Webman Push 在 API 上的 HTTP 根地址(私有频道 POST /plugin/webman/push/auth 等)。
|
||||
* 与 VITE_AXIOS_BASE_URL 一致;开发环境为空时用当前页面源,配合 Vite 对 /plugin 的代理。
|
||||
*/
|
||||
export function getPushHttpBase(): string {
|
||||
const api = getUrl()
|
||||
if (api) {
|
||||
return api.replace(/\/$/, '')
|
||||
}
|
||||
return window.location.protocol + '//' + window.location.host
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载 push.js 的绝对 URL:文件放在 web/public/plugin/webman/push/,随 dist 与后台同源发布,
|
||||
* 不依赖 API 站点是否暴露 /plugin/webman/push/push.js。
|
||||
*/
|
||||
export function getPushScriptUrl(): string {
|
||||
let base = import.meta.env.BASE_URL
|
||||
if (typeof base !== 'string' || base === '') {
|
||||
base = '/'
|
||||
}
|
||||
if (!base.endsWith('/')) {
|
||||
base = base + '/'
|
||||
}
|
||||
return window.location.origin + base + 'plugin/webman/push/push.js'
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据运行环境获取基础请求URL的端口
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user