diff --git a/src/App.vue b/src/App.vue index 38fab93..6f56950 100644 --- a/src/App.vue +++ b/src/App.vue @@ -107,7 +107,9 @@ onMounted(() => { /** mobile暂定全部重定向为首页 */ addEventListener('notice', toNotice); window.addEventListener('message', (event) => { - if (event.origin === (import.meta as any).env.VITE_HOST) { + let VITE_HOST = window.location.origin + '/openRepoPortal'; + // if (event.origin === (import.meta as any).env.VITE_HOST) { + if (event.origin === VITE_HOST) { if (event.data.type === 'success') { if (isMountedModal()) { closeModal(); diff --git a/src/components/Animation/config.ts b/src/components/Animation/config.ts index bb4e699..c8b436f 100644 --- a/src/components/Animation/config.ts +++ b/src/components/Animation/config.ts @@ -5,7 +5,7 @@ import error404 from './data/error-404.json'; import error503 from './data/error-503.json'; // lottie动画图片资源路径 -export const assetsPath = `${import.meta.env.VITE_STATIC_HOST}/static/images/`; +export const assetsPath = `/openRepoPortal/static/images/`; export const defaultRender = 'canvas'; diff --git a/src/router/interceptor.ts b/src/router/interceptor.ts index 5670918..cc7bf74 100644 --- a/src/router/interceptor.ts +++ b/src/router/interceptor.ts @@ -77,7 +77,8 @@ export const injectRouter = (router) => { } // 上报ref设置 - const BASE_URL = (import.meta as any).env.VITE_HOST; + // const BASE_URL = (import.meta as any).env.VITE_HOST; + const BASE_URL = window.location.origin + '/openRepoPortal'; const beforeRef = sessionStorage.getItem('ref'); const ref = beforeRef || document.referrer || ''; if (!fromHomeWeb.includes(to.name)) { diff --git a/src/utils/index.ts b/src/utils/index.ts index a66f2f6..b30577b 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -409,7 +409,8 @@ export const xssPurify = (str: string) => DOMPurify.sanitize(str, purifyConfig); export const messageError = ({ error_message, message }) => Message.error(error_message || message); export const savePageRef = (fullPath:string) => { - const BASE_URL = (import.meta as any).env.VITE_HOST; + // const BASE_URL = (import.meta as any).env.VITE_HOST; + const BASE_URL = window.location.origin + '/openRepoPortal'; const beforeRef = sessionStorage.getItem('ref'); const ref = beforeRef || document.referrer || ''; window.page_ref = ref; diff --git a/src/views/Jyh/PersonalCenter/index.vue b/src/views/Jyh/PersonalCenter/index.vue index 3f4ea5d..444fe27 100644 --- a/src/views/Jyh/PersonalCenter/index.vue +++ b/src/views/Jyh/PersonalCenter/index.vue @@ -54,7 +54,8 @@ const { namespace } = getOrgInfo(); const avatarUrl = '/src/assets/imgs/avatar/male.png'; -const VITE_GOVERNANCE_HOST = import.meta.env.VITE_GOVERNANCE_HOST; +// const VITE_GOVERNANCE_HOST = import.meta.env.VITE_GOVERNANCE_HOST; +const VITE_GOVERNANCE_HOST = window.location.origin + '/governancePortal'; const selectTab = ref('yjtzlb'); const { accountInfo, RemoveInfo } = useAccount(); diff --git a/src/views/OAuth/callback.vue b/src/views/OAuth/callback.vue index eca6142..b5ce0a3 100644 --- a/src/views/OAuth/callback.vue +++ b/src/views/OAuth/callback.vue @@ -37,7 +37,8 @@ onMounted(async() => { const excRes = /(.*)_(.*)/.exec(state as string); if (excRes) { if (window.parent) { - window.opener?.postMessage({ fn: 'otho', type, code, state: excRes[1] }, (import.meta as any).env.VITE_HOST); + // window.opener?.postMessage({ fn: 'otho', type, code, state: excRes[1] }, (import.meta as any).env.VITE_HOST); + window.opener?.postMessage({ fn: 'otho', type, code, state: excRes[1] }, window.location.origin + '/openRepoPortal'); window?.close(); } return; @@ -94,7 +95,8 @@ const emitEvents = (type: 'success' | 'fail' = 'success', error_info?: string, p if (type === 'success') { // 登录后回到登录前页面 hack一下automgit跳转 if (route.query?.installation_id) { - window.location.href = `${(import.meta as any).env.VITE_HOST}${path || '/'}`; + // window.location.href = `${(import.meta as any).env.VITE_HOST}${path || '/'}`; + window.location.href = `${window.location.origin}/openRepoPortal${path || '/'}`; } else { url && localStorage.removeItem('loginReturnUrl'); url ? window.location.href = url : router.replace('/'); @@ -118,7 +120,8 @@ const emitEvents = (type: 'success' | 'fail' = 'success', error_info?: string, p type, message: error_info || type === 'success' ? '' : '你已取消授权', path - }, (import.meta as any).env.VITE_HOST); + // }, (import.meta as any).env.VITE_HOST); + }, window.location.origin + '/openRepoPortal'); window?.close(); } } diff --git a/src/views/OAuth/login.vue b/src/views/OAuth/login.vue index 9a29fb8..bf194e4 100644 --- a/src/views/OAuth/login.vue +++ b/src/views/OAuth/login.vue @@ -23,7 +23,8 @@ const login = () => { return; } else { const type = loginType.includes(route?.query?.type) ? route?.query?.type : 'csdn'; - const returnUrl = `${(import.meta as any).env.VITE_HOST}${redirectUrl}`; + // const returnUrl = `${(import.meta as any).env.VITE_HOST}${redirectUrl}`; + const returnUrl = `${window.location.origin}/openRepoPortal${redirectUrl}`; // 保存登录前页面地址 localStorage.setItem('loginReturnUrl', returnUrl || ''); const url = `${(import.meta as any).env.VITE_API_HOST}${(import.meta as any).env.VITE_PASSPORT_PREFIX || ''}/api/v1/oauth/login/${type}`; diff --git a/src/views/Org/Create/index.vue b/src/views/Org/Create/index.vue index 1c6973a..c94981f 100644 --- a/src/views/Org/Create/index.vue +++ b/src/views/Org/Create/index.vue @@ -141,7 +141,8 @@ const createOrgItem = { }, orgUrl: { label: '组织URL', - prefix: `${(import.meta as any).env.VITE_HOST}/`, + // prefix: `${(import.meta as any).env.VITE_HOST}/`, + prefix: `${window.location.origin}/openRepoPortal/`, placeholder: '请输入', occupied: 'namespace已被使用', ruleDesc: { diff --git a/vite.config.ts b/vite.config.ts index cbb070a..576af1a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -82,7 +82,8 @@ export default (config: any) => { { hostId, hostType, type }: { hostId: string, hostType: 'js' | 'css' | 'html', type: 'public' | 'asset'; } ) { if (type === 'asset') { - return env.VITE_STATIC_HOST + '/' + filename; + // return env.VITE_STATIC_HOST + '/' + filename; + return `/openRepoPortal/${filename}`; } } }