/** * SpreadJS 라이선스 관리 유틸리티 * 도메인에 따라 적절한 라이선스 키를 반환합니다. */ /** * 현재 도메인을 기반으로 적절한 SpreadJS 라이선스 키를 반환합니다. * * @returns 도메인에 맞는 라이선스 키 또는 null */ export function getSpreadJSLicenseKey(): string | null { // 서버 사이드에서는 라이선스를 설정하지 않음 if (typeof window === 'undefined') { return null; } const hostname = window.location.hostname; // partners.sevcp.com 도메인 (케이스1) if (hostname === 'partners.sevcp.com') { return process.env.NEXT_PUBLIC_SPREAD_LICENSE || null; } // sevcp.com 도메인 (케이스2) if (hostname === 'sevcp.com') { return process.env.NEXT_PUBLIC_SPREAD_LICENSE_SEVCP || process.env.NEXT_PUBLIC_SPREAD_LICENSE || null; } // 개발 환경 (localhost) if (hostname === 'localhost' || hostname === '127.0.0.1') { // 개발 환경에서는 기본 라이선스 사용 return process.env.NEXT_PUBLIC_SPREAD_LICENSE || null; } // 기타 도메인의 경우 기본 라이선스 사용 return process.env.NEXT_PUBLIC_SPREAD_LICENSE || null; } /** * SpreadJS Designer 라이선스 키를 반환합니다. * Designer 라이선스는 도메인 구분 없이 항상 동일한 라이선스를 사용합니다. * * @returns Designer 라이선스 키 또는 null */ export function getSpreadJSDesignerLicenseKey(): string | null { // 서버 사이드에서는 라이선스를 설정하지 않음 if (typeof window === 'undefined') { return null; } // Designer 라이선스는 도메인 구분 없이 항상 동일한 라이선스 사용 return process.env.NEXT_PUBLIC_DESIGNER_LICENSE || null; } /** * SpreadJS 라이선스를 설정합니다. * GC 객체가 로드된 후에 호출해야 합니다. * * @param GC - SpreadJS GC 객체 */ export function setupSpreadJSLicense(GC: any): void { if (typeof window === 'undefined') { return; } const spreadLicense = getSpreadJSLicenseKey(); const designerLicense = getSpreadJSDesignerLicenseKey(); // SpreadSheets 라이선스 설정 if (spreadLicense && GC?.Spread?.Sheets) { GC.Spread.Sheets.LicenseKey = spreadLicense; // ExcelIO 라이선스 설정 (있는 경우) if (typeof (window as any).ExcelIO !== 'undefined') { (window as any).ExcelIO.LicenseKey = spreadLicense; } } // Designer 라이선스 설정 if (designerLicense && GC?.Spread?.Sheets?.Designer) { GC.Spread.Sheets.Designer.LicenseKey = designerLicense; } }