api-paths.js 548 B

123456789101112131415
  1. import appSettings from './app-settings'
  2. /** 拼接业务 REST 路径(相对路径不含前缀斜杠) */
  3. export function buildRestPath(relative = '') {
  4. const base = appSettings.restPathPrefix.replace(/\/$/, '')
  5. const tail = String(relative).replace(/^\//, '')
  6. return tail ? `${base}/${tail}` : base
  7. }
  8. /** 静态资源 CDN 子路径 */
  9. export function buildCdnStaticPath(relative = '') {
  10. const base = appSettings.cdnStaticAddon.replace(/\/$/, '')
  11. const tail = String(relative).replace(/^\//, '')
  12. return tail ? `${base}/${tail}` : base
  13. }