Skip to content

Commit

Permalink
fix(版本文件): 解决版本文件访问失败问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hesetiema committed May 25, 2024
1 parent ef2fa66 commit 5bfef29
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/constant/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const VITE_BASE_PATH = '/vue-admin-complex/'
4 changes: 3 additions & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'

import HomeView from '@/views/HomeView.vue'

import { VITE_BASE_PATH } from '@/constant/index'

import { ElNotification } from 'element-plus'

const routes: RouteRecordRaw[] = [
Expand Down Expand Up @@ -175,7 +177,7 @@ const router = createRouter({
})

const checkUpdate = async () => {
return fetch(`/version.json?t=${Date.now()}`)
return fetch(`${VITE_BASE_PATH}/version.json?t=${Date.now()}`)
.then((response) => {
if (!response.ok) throw new Error(`Failed to fetch version.json`)

Expand Down
5 changes: 2 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vitePluginUpdateVersion from './plugins'

const prod = process.env.NODE_ENV === 'production'
import { VITE_BASE_PATH } from './src/constant/index'

Check failure on line 7 in vite.config.ts

View workflow job for this annotation

GitHub Actions / Deployment

File '/home/runner/work/vue-admin-complex/vue-admin-complex/src/constant/index.ts' is not listed within the file list of project '/home/runner/work/vue-admin-complex/vue-admin-complex/tsconfig.node.json'. Projects must list all files or use an 'include' pattern.

// https://vitejs.dev/config/
export default defineConfig({
base: prod ? '/vue-admin-complex/' : '/vue-admin-complex/',
base: VITE_BASE_PATH,
plugins: [vue(), vueJsx(), vitePluginUpdateVersion()],
resolve: {
alias: {
Expand Down

0 comments on commit 5bfef29

Please sign in to comment.