可信代码库-配置文件修复定向URL改为动态获取

This commit is contained in:
fmk1023
2025-08-26 17:52:32 +08:00
parent 9c58b289a2
commit 452eda019a
9 changed files with 22 additions and 11 deletions

View File

@@ -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();

View File

@@ -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';

View File

@@ -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)) {

View File

@@ -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;

View File

@@ -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();

View File

@@ -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();
}
}

View File

@@ -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}`;

View File

@@ -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: {

View File

@@ -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}`;
}
}
}