summaryrefslogtreecommitdiff
path: root/lib/spread-js/license-utils.ts
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-08-27 09:46:36 +0000
committerjoonhoekim <26rote@gmail.com>2025-08-27 09:46:36 +0000
commita0c94e1d019339babf8bd45b1ff192ade47fc6e7 (patch)
tree6b7b5887daf143d9a0c3b07a51fdc7583dbd99b0 /lib/spread-js/license-utils.ts
parentb203a0017f4b7150333024a1b1a5d1d9d21dea76 (diff)
(김준회) 호스트네임에 따른 도메인별 spreadjs 라이선스 적용 처리 및 운영용 환경변수 주석으로 추가
Diffstat (limited to 'lib/spread-js/license-utils.ts')
-rw-r--r--lib/spread-js/license-utils.ts83
1 files changed, 83 insertions, 0 deletions
diff --git a/lib/spread-js/license-utils.ts b/lib/spread-js/license-utils.ts
new file mode 100644
index 00000000..1f586c50
--- /dev/null
+++ b/lib/spread-js/license-utils.ts
@@ -0,0 +1,83 @@
+/**
+ * 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;
+ }
+}