xto-fronted 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,6 +43,11 @@ export declare function getApiBaseUrl(): string;
43
43
  * 获取应用基础路径(用于路由 base)
44
44
  */
45
45
  export declare function getBasePath(): string;
46
+ /**
47
+ * 拼接部署路径的静态资源地址(public 目录资源,如 logo)
48
+ * 部署在子路径(如 /lending)时,绝对路径 /vite.svg 会落到域名根路径 404,需自动补前缀
49
+ */
50
+ export declare function withBasePath(path: string): string;
46
51
  export declare const appConfig: {
47
52
  appId: import('vue').Ref<string, string>;
48
53
  clientId: import('vue').Ref<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xto-fronted",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "XTO 前端应用框架",
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, ref, onMounted, onUnmounted, watch } from 'vue'
3
+ import { withBasePath } from '@/utils/config'
3
4
  import { useRoute, useRouter } from 'vue-router'
4
5
  import { useMenuStore } from '@/stores/menu'
5
6
  import { useAppStore } from '@/stores/app'
@@ -13,7 +14,7 @@ import { Drawer } from '@xto/feedback'
13
14
  const props = withDefaults(defineProps<{
14
15
  logoSrc?: string
15
16
  }>(), {
16
- logoSrc: '/vite.svg'
17
+ logoSrc: withBasePath('/vite.svg')
17
18
  })
18
19
 
19
20
  const route = useRoute()
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, ref, watch } from 'vue'
3
+ import { withBasePath } from '@/utils/config'
3
4
  import { useRoute, useRouter } from 'vue-router'
4
5
  import { useMenuStore } from '@/stores/menu'
5
6
  import { useUserStore } from '@/stores/user'
@@ -20,7 +21,7 @@ const props = withDefaults(defineProps<{
20
21
  menuList: () => [],
21
22
  showLogo: true,
22
23
  showUser: true,
23
- logoSrc: '/vite.svg'
24
+ logoSrc: withBasePath('/vite.svg')
24
25
  })
25
26
 
26
27
  const route = useRoute()
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, ref, onMounted, onUnmounted } from 'vue'
3
+ import { withBasePath } from '@/utils/config'
3
4
  import { useRoute, useRouter } from 'vue-router'
4
5
  import { useMenuStore } from '@/stores/menu'
5
6
  import { useAppStore } from '@/stores/app'
@@ -13,7 +14,7 @@ import { Drawer } from '@xto/feedback'
13
14
  const props = withDefaults(defineProps<{
14
15
  logoSrc?: string
15
16
  }>(), {
16
- logoSrc: '/vite.svg'
17
+ logoSrc: withBasePath('/vite.svg')
17
18
  })
18
19
 
19
20
  const route = useRoute()
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { computed } from 'vue'
3
+ import { withBasePath } from '@/utils/config'
3
4
  import { useAppStore } from '@/stores/app'
4
5
  import { useMenuStore } from '@/stores/menu'
5
6
  import Sidebar from './Sidebar.vue'
@@ -11,7 +12,7 @@ import MixTopMenu from './MixTopMenu.vue'
11
12
  const props = withDefaults(defineProps<{
12
13
  logoSrc?: string
13
14
  }>(), {
14
- logoSrc: '/vite.svg'
15
+ logoSrc: withBasePath('/vite.svg')
15
16
  })
16
17
 
17
18
  const appStore = useAppStore()
@@ -6,7 +6,7 @@ import { createRouter as vueCreateRouter, createWebHistory } from 'vue-router'
6
6
  import type { RouteRecordRaw, Router } from 'vue-router'
7
7
  import { h, defineComponent } from 'vue'
8
8
  import Layout from '@/components/Layout/index.vue'
9
- import { getBasePath } from '@/utils/config'
9
+ import { getBasePath, withBasePath } from '@/utils/config'
10
10
 
11
11
  interface LayoutRouteOptions {
12
12
  indexPath?: string
@@ -28,7 +28,7 @@ export function createLayoutRoute(
28
28
  options: LayoutRouteOptions = {}
29
29
  ): RouteRecordRaw {
30
30
  const indexPath = options.indexPath || '/dashboard'
31
- const logoSrc = options.logoSrc || '/vite.svg'
31
+ const logoSrc = options.logoSrc || withBasePath('/vite.svg')
32
32
 
33
33
  // 添加 catch-all 路由,让404在Layout内部渲染,保持左侧菜单显示
34
34
  const catchAllRoute: RouteRecordRaw = {
@@ -152,6 +152,16 @@ export function getBasePath(): string {
152
152
  return basePath.value
153
153
  }
154
154
 
155
+ /**
156
+ * 拼接部署路径的静态资源地址(public 目录资源,如 logo)
157
+ * 部署在子路径(如 /lending)时,绝对路径 /vite.svg 会落到域名根路径 404,需自动补前缀
158
+ */
159
+ export function withBasePath(path: string): string {
160
+ if (!path) return path
161
+ const base = getBasePath().replace(/\/$/, '')
162
+ return path.startsWith('/') ? `${base}${path}` : `${base}/${path}`
163
+ }
164
+
155
165
  // 导出响应式引用(供特殊场景直接使用)
156
166
  export const appConfig = {
157
167
  appId,