Commit 1a97ebc4 authored by nick zheng's avatar nick zheng

build: 基础路由路径调整

parent 1bb56c56
...@@ -4,6 +4,6 @@ VITE_APP_NAME = 'POC' ...@@ -4,6 +4,6 @@ VITE_APP_NAME = 'POC'
VITE_APP_THEME_COLOR = '#2468f2' VITE_APP_THEME_COLOR = '#2468f2'
VITE_PORT = 8848 VITE_PORT = 8848
VITE_PUBLIC_PATH = /fe VITE_PUBLIC_PATH = /fe
VITE_ROUTER_MODE = 'hash' VITE_ROUTER_MODE = 'h5'
VITE_VITEST = true VITE_VITEST = true
VITE_HIDE_HOME = false VITE_HIDE_HOME = false
...@@ -3,5 +3,5 @@ VITE_APP_NAME = 'POC' ...@@ -3,5 +3,5 @@ VITE_APP_NAME = 'POC'
VITE_APP_THEME_COLOR = '#2468f2' VITE_APP_THEME_COLOR = '#2468f2'
VITE_PUBLIC_PATH = /fe VITE_PUBLIC_PATH = /fe
VITE_ROUTER_MODE = 'hash' VITE_ROUTER_MODE = 'h5'
...@@ -4,6 +4,6 @@ export const BASE_URLS: Record<'DEV' | 'PROD', string> = { ...@@ -4,6 +4,6 @@ export const BASE_URLS: Record<'DEV' | 'PROD', string> = {
} }
export const INDEX_URLS: Record<'DEV' | 'PROD', string> = { export const INDEX_URLS: Record<'DEV' | 'PROD', string> = {
DEV: 'https://poc-sit.gsstcloud.com/fe#/', DEV: 'https://poc-sit.gsstcloud.com/fe/',
PROD: 'https://poc.gsstcloud.com/fe#/', PROD: 'https://poc.gsstcloud.com/fe/',
} }
...@@ -11,11 +11,13 @@ export interface MenuOption { ...@@ -11,11 +11,13 @@ export interface MenuOption {
} }
export function getHistoryMode(modeString: ViteEnv['VITE_ROUTER_MODE']): RouterHistory { export function getHistoryMode(modeString: ViteEnv['VITE_ROUTER_MODE']): RouterHistory {
const PUBLIC_PATH = import.meta.env.VITE_PUBLIC_PATH
if (modeString === 'h5') { if (modeString === 'h5') {
return createWebHistory() return createWebHistory(PUBLIC_PATH)
} }
return createWebHashHistory() return createWebHashHistory(PUBLIC_PATH)
} }
function menuSort(routes: RouteRecordRaw[]) { function menuSort(routes: RouteRecordRaw[]) {
......
...@@ -16,15 +16,18 @@ export interface Response<T> { ...@@ -16,15 +16,18 @@ export interface Response<T> {
pagingInfo?: PagingInfoParams & { totalPages: number; totalRows: number } pagingInfo?: PagingInfoParams & { totalPages: number; totalRows: number }
} }
const ENV = import.meta.env.VITE_APP_ENV
function handleLogout() { function handleLogout() {
const currentRoute = router.currentRoute.value const currentRoute = router.currentRoute.value
router.replace({ name: 'Login', query: { redirect: encodeURIComponent(currentRoute.fullPath) } }) router.replace({ name: 'Login', query: { redirect: encodeURIComponent(currentRoute.fullPath) } })
useUserStore().logout()
window.$message.warning('身份已过期,请重新登录') window.$message.warning('身份已过期,请重新登录')
} }
const service = axios.create({ const service = axios.create({
baseURL: `${BASE_URLS[window.ENV || 'DEV']}/api/rest`, baseURL: `${BASE_URLS[ENV]}/api/rest`,
timeout: 7000, timeout: 7000,
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
......
...@@ -10,6 +10,8 @@ const { pageContentWrapRef, tableContentY } = useTableScrollY() ...@@ -10,6 +10,8 @@ const { pageContentWrapRef, tableContentY } = useTableScrollY()
const router = useRouter() const router = useRouter()
const ENV = import.meta.env.VITE_APP_ENV
const channelPublishList = reactive([ const channelPublishList = reactive([
{ {
type: 'web', type: 'web',
...@@ -30,13 +32,13 @@ function handleClickChannelPublishTableAction(actionType: string) { ...@@ -30,13 +32,13 @@ function handleClickChannelPublishTableAction(actionType: string) {
} }
function handleAccessPage() { function handleAccessPage() {
const channleUrl = `${INDEX_URLS[window.ENV || 'DEV']}share/web_source/${router.currentRoute.value.params.agentId}` const channelUrl = `${INDEX_URLS[ENV]}share/web_source/${router.currentRoute.value.params.agentId}`
location.href = channleUrl location.href = channelUrl
} }
function handleCopyShareLink() { function handleCopyShareLink() {
const channleUrl = `${INDEX_URLS[window.ENV || 'DEV']}share/web_source/${router.currentRoute.value.params.agentId}` const channelUrl = `${INDEX_URLS[ENV]}share/web_source/${router.currentRoute.value.params.agentId}`
copyToClip(channleUrl) copyToClip(channelUrl)
window.$message.success('链接复制成功,快分享给你的好友吧!') window.$message.success('链接复制成功,快分享给你的好友吧!')
} }
</script> </script>
......
...@@ -32,6 +32,7 @@ export default defineConfig(({ command, mode }) => { ...@@ -32,6 +32,7 @@ export default defineConfig(({ command, mode }) => {
preprocessorOptions: { preprocessorOptions: {
scss: { scss: {
additionalData: '@use "@/styles/index.scss" as *;', additionalData: '@use "@/styles/index.scss" as *;',
api: 'modern-compiler',
}, },
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment