@bikiran/utils 1.18.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +168 -102
- package/dist/components/Profile/authTypes.ts +21 -21
- package/dist/components/Profile/style/LoginBtn.module.css +6 -6
- package/dist/components/Profile/style/ProfileManage.module.css +6 -6
- package/dist/components/Profile/style/ProfileMenuList.module.css +50 -50
- package/dist/components/Profile/style/ProfileMenuPopup.module.css +30 -30
- package/dist/components/Profile/style/ProfileUserInformation.module.css +26 -26
- package/dist/components/Profile/style/ProfileView.module.css +12 -12
- package/dist/components/button-wrapper/style/style.module.css +18 -18
- package/dist/components/cookie-accept-popup/style/CookieAcceptPopup.module.css +12 -12
- package/dist/components/currency-selector/style/CurrencySelector.module.css +28 -28
- package/dist/components/custom-sidebar/style/CustomSidebar.module.css +21 -21
- package/dist/components/filter-wrapper/style/FilterBarWrapper.module.css +41 -41
- package/dist/components/header/header.css +61 -61
- package/dist/components/header/headerType.ts +15 -15
- package/dist/components/header/icons/icon-about-us-submenu.svg +6 -6
- package/dist/components/header/icons/icon-about-us.svg +5 -5
- package/dist/components/header/icons/icon-all-service.svg +11 -11
- package/dist/components/header/icons/icon-arrow-v2.svg +3 -3
- package/dist/components/header/icons/icon-bell-fill.svg +3 -3
- package/dist/components/header/icons/icon-bik-logo.svg +13 -13
- package/dist/components/header/icons/icon-contacts.svg +6 -6
- package/dist/components/header/icons/icon-domain.svg +4 -4
- package/dist/components/header/icons/icon-hosting.svg +5 -5
- package/dist/components/header/icons/icon-our-clients.svg +4 -4
- package/dist/components/header/sidebar/SidebarConstants.ts +55 -55
- package/dist/components/header/sidebar/sidebarStyle.css +32 -32
- package/dist/components/information-tooltip/icons.js +4 -4
- package/dist/components/information-tooltip/style/InfoTooltip.module.css +62 -62
- package/dist/components/loading-comp/style/LoadingComp.module.css +3 -3
- package/dist/components/pageLoading/style/PageLoading.module.css +7 -7
- package/dist/components/pagination2/style/Pagination.module.css +27 -27
- package/dist/components/project-selector/projectConstants.ts +23 -23
- package/dist/components/project-selector/projectTypes.ts +22 -22
- package/dist/components/project-selector/selector-icons/icon-arrow-down.svg +3 -3
- package/dist/components/project-selector/selector-icons/icon-default-app.svg +9 -9
- package/dist/components/services-popup/ServiceAppType.ts +10 -10
- package/dist/components/services-popup/icons/icon-account.svg +7 -7
- package/dist/components/services-popup/icons/icon-cross.svg +3 -3
- package/dist/components/services-popup/icons/icon-default-app.svg +9 -9
- package/dist/components/user-info/style/ToolTipUserInfo.module.css +28 -28
- package/dist/declaration.d.ts +9 -9
- package/dist/index.ts +15 -15
- package/dist/lib/types/GlobalType.ts +17 -17
- package/dist/lib/utils/Cookie.ts +58 -58
- package/dist/lib/utils/Copy.ts +37 -37
- package/dist/lib/utils/Env.ts +235 -235
- package/dist/lib/utils/capitalizeFirstLetter.ts +7 -7
- package/dist/lib/utils/cn.ts +4 -4
- package/dist/lib/utils/option.ts +7 -7
- package/dist/package.json +1 -1
- package/package.json +60 -60
package/dist/lib/utils/Cookie.ts
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { getBaseDomain } from "./Env";
|
|
2
|
-
|
|
3
|
-
class Cookie {
|
|
4
|
-
cname: string;
|
|
5
|
-
domain: string;
|
|
6
|
-
path: string;
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
9
|
-
cname: string,
|
|
10
|
-
domain: string = getBaseDomain(),
|
|
11
|
-
path: string = "/"
|
|
12
|
-
) {
|
|
13
|
-
this.cname = cname;
|
|
14
|
-
this.domain = domain;
|
|
15
|
-
this.path = path;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
setCookie(cValue: string, exDays: number): void {
|
|
19
|
-
if (typeof document !== "undefined") {
|
|
20
|
-
const d = new Date();
|
|
21
|
-
d.setTime(d.getTime() + exDays * 24 * 60 * 60 * 1000);
|
|
22
|
-
const expires = "expires=" + d.toUTCString();
|
|
23
|
-
document.cookie = `${this.cname}=${cValue};${expires};path=${this.path};domain=${this.domain};`;
|
|
24
|
-
} else {
|
|
25
|
-
console.warn("document is not available. Skipping cookie set.");
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
getCookie(): string {
|
|
30
|
-
if (typeof document !== "undefined") {
|
|
31
|
-
const name = this.cname + "=";
|
|
32
|
-
const decodedCookie = decodeURIComponent(document.cookie);
|
|
33
|
-
const ca = decodedCookie.split(";");
|
|
34
|
-
for (let i = 0; i < ca.length; i++) {
|
|
35
|
-
let c = ca[i].trim();
|
|
36
|
-
if (c.indexOf(name) === 0) {
|
|
37
|
-
return c.substring(name.length, c.length);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return "";
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
verifyCookie(cValue: string): boolean {
|
|
45
|
-
const cookieValue = this.getCookie();
|
|
46
|
-
return cookieValue === cValue;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
deleteCookie(): void {
|
|
50
|
-
if (typeof document !== "undefined") {
|
|
51
|
-
document.cookie = `${this.cname}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${this.path};domain=${this.domain};`;
|
|
52
|
-
} else {
|
|
53
|
-
console.warn("document is not available. Skipping cookie deletion.");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default Cookie;
|
|
1
|
+
import { getBaseDomain } from "./Env";
|
|
2
|
+
|
|
3
|
+
class Cookie {
|
|
4
|
+
cname: string;
|
|
5
|
+
domain: string;
|
|
6
|
+
path: string;
|
|
7
|
+
|
|
8
|
+
constructor(
|
|
9
|
+
cname: string,
|
|
10
|
+
domain: string = getBaseDomain(),
|
|
11
|
+
path: string = "/"
|
|
12
|
+
) {
|
|
13
|
+
this.cname = cname;
|
|
14
|
+
this.domain = domain;
|
|
15
|
+
this.path = path;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
setCookie(cValue: string, exDays: number): void {
|
|
19
|
+
if (typeof document !== "undefined") {
|
|
20
|
+
const d = new Date();
|
|
21
|
+
d.setTime(d.getTime() + exDays * 24 * 60 * 60 * 1000);
|
|
22
|
+
const expires = "expires=" + d.toUTCString();
|
|
23
|
+
document.cookie = `${this.cname}=${cValue};${expires};path=${this.path};domain=${this.domain};`;
|
|
24
|
+
} else {
|
|
25
|
+
console.warn("document is not available. Skipping cookie set.");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getCookie(): string {
|
|
30
|
+
if (typeof document !== "undefined") {
|
|
31
|
+
const name = this.cname + "=";
|
|
32
|
+
const decodedCookie = decodeURIComponent(document.cookie);
|
|
33
|
+
const ca = decodedCookie.split(";");
|
|
34
|
+
for (let i = 0; i < ca.length; i++) {
|
|
35
|
+
let c = ca[i].trim();
|
|
36
|
+
if (c.indexOf(name) === 0) {
|
|
37
|
+
return c.substring(name.length, c.length);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
verifyCookie(cValue: string): boolean {
|
|
45
|
+
const cookieValue = this.getCookie();
|
|
46
|
+
return cookieValue === cValue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
deleteCookie(): void {
|
|
50
|
+
if (typeof document !== "undefined") {
|
|
51
|
+
document.cookie = `${this.cname}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${this.path};domain=${this.domain};`;
|
|
52
|
+
} else {
|
|
53
|
+
console.warn("document is not available. Skipping cookie deletion.");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default Cookie;
|
package/dist/lib/utils/Copy.ts
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
|
|
4
|
-
// USAGE:
|
|
5
|
-
// call the copy function with the text you want to copy
|
|
6
|
-
/*
|
|
7
|
-
const { copy, isCopied } = Copy();
|
|
8
|
-
|
|
9
|
-
// call the copy function with the text you want to copy
|
|
10
|
-
onClick={() => copy("text to copy")}
|
|
11
|
-
|
|
12
|
-
// show a message if the text is copied
|
|
13
|
-
{isCopied && <div>Copied</div>}
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
function Copy() {
|
|
17
|
-
const [isCopied, setIsCopied] = useState(false);
|
|
18
|
-
|
|
19
|
-
const copy = (text: any) => {
|
|
20
|
-
navigator.clipboard
|
|
21
|
-
.writeText(text)
|
|
22
|
-
.then(() => {
|
|
23
|
-
// setMessage("Copied");
|
|
24
|
-
setIsCopied(true);
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
setIsCopied(false);
|
|
27
|
-
}, 1000);
|
|
28
|
-
})
|
|
29
|
-
.catch((error) => {
|
|
30
|
-
console.error("Error copying text to clipboard:", error);
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return { copy, isCopied };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default Copy;
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
|
|
4
|
+
// USAGE:
|
|
5
|
+
// call the copy function with the text you want to copy
|
|
6
|
+
/*
|
|
7
|
+
const { copy, isCopied } = Copy();
|
|
8
|
+
|
|
9
|
+
// call the copy function with the text you want to copy
|
|
10
|
+
onClick={() => copy("text to copy")}
|
|
11
|
+
|
|
12
|
+
// show a message if the text is copied
|
|
13
|
+
{isCopied && <div>Copied</div>}
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function Copy() {
|
|
17
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
18
|
+
|
|
19
|
+
const copy = (text: any) => {
|
|
20
|
+
navigator.clipboard
|
|
21
|
+
.writeText(text)
|
|
22
|
+
.then(() => {
|
|
23
|
+
// setMessage("Copied");
|
|
24
|
+
setIsCopied(true);
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
setIsCopied(false);
|
|
27
|
+
}, 1000);
|
|
28
|
+
})
|
|
29
|
+
.catch((error) => {
|
|
30
|
+
console.error("Error copying text to clipboard:", error);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return { copy, isCopied };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default Copy;
|
package/dist/lib/utils/Env.ts
CHANGED
|
@@ -1,236 +1,236 @@
|
|
|
1
|
-
export const SUB_DOMAIN_NAMES = {
|
|
2
|
-
WWW: "www",
|
|
3
|
-
ACCOUNT: "account",
|
|
4
|
-
DOMAIN: "domain",
|
|
5
|
-
ADMANAGE: "admanage",
|
|
6
|
-
DNS: "dns",
|
|
7
|
-
HOSTING: "hosting",
|
|
8
|
-
APPOCEAN: "appocean",
|
|
9
|
-
DOCS: "docs",
|
|
10
|
-
PROBACKUP: "probackup",
|
|
11
|
-
EDUSOFT: "edusoft",
|
|
12
|
-
SUPPORT: "support",
|
|
13
|
-
ICON: "icon",
|
|
14
|
-
DRIVE: "drive",
|
|
15
|
-
API: "io",
|
|
16
|
-
API2: "api2",
|
|
17
|
-
API3: "api3",
|
|
18
|
-
} as const;
|
|
19
|
-
|
|
20
|
-
const subDomainMap: Record<string, string> = {
|
|
21
|
-
www: `http://localhost:7201`,
|
|
22
|
-
account: `http://localhost:5000`,
|
|
23
|
-
domain: `http://localhost:7203`,
|
|
24
|
-
dns: `http://localhost:7204`,
|
|
25
|
-
hosting: `http://localhost:7205`,
|
|
26
|
-
appocean: `http://localhost:7206`,
|
|
27
|
-
docs: `http://localhost:7207`,
|
|
28
|
-
admanage: `http://localhost:7208`,
|
|
29
|
-
probackup: `http://localhost:7209`,
|
|
30
|
-
edusoft: `http://localhost:7210`,
|
|
31
|
-
icon: `http://localhost:7211`,
|
|
32
|
-
drive: `http://localhost:7212`,
|
|
33
|
-
support: `http://localhost:7216`,
|
|
34
|
-
api: `https://io.bikiran.win`,
|
|
35
|
-
api2:
|
|
36
|
-
process.env.NEXT_PUBLIC_LOCAL_API === "true"
|
|
37
|
-
? `http://localhost:5010`
|
|
38
|
-
: `https://api2.bikiran.win`,
|
|
39
|
-
api3:
|
|
40
|
-
process.env.NEXT_PUBLIC_LOCAL_API === "true"
|
|
41
|
-
? `http://localhost:7301`
|
|
42
|
-
: `https://api3.bikiran.win`,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const isDev = process.env.NEXT_PUBLIC_MODE === "dev";
|
|
46
|
-
export function getMode(): "dev" | "win" | "com" {
|
|
47
|
-
if (isDev) {
|
|
48
|
-
return "dev";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const isWin = process.env.NEXT_PUBLIC_MODE === "win";
|
|
52
|
-
if (isWin) {
|
|
53
|
-
return "win";
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return "com";
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const getDomain = (): string => {
|
|
60
|
-
return process.env.NEXT_PUBLIC_DOMAIN || "";
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
interface DomainObject {
|
|
64
|
-
sub: string;
|
|
65
|
-
name: string;
|
|
66
|
-
tld: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const getDomainObject = (): DomainObject => {
|
|
70
|
-
const domainParts = getDomain().split(".");
|
|
71
|
-
return {
|
|
72
|
-
sub: domainParts[0],
|
|
73
|
-
name: domainParts[1],
|
|
74
|
-
tld: domainParts[2],
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const getBaseDomain = (): string => {
|
|
79
|
-
const mode = getMode();
|
|
80
|
-
if (mode === "dev") {
|
|
81
|
-
return "localhost";
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const d = getDomainObject();
|
|
85
|
-
return `${d.name}.${mode}`;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// https://www.bikiran.com/
|
|
89
|
-
export function getBikiranUrl(): string {
|
|
90
|
-
const d = getDomainObject();
|
|
91
|
-
const mode = getMode();
|
|
92
|
-
if (mode === "dev") {
|
|
93
|
-
return subDomainMap.www;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return `https://${SUB_DOMAIN_NAMES.WWW}.${d.name}.${mode}`;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// https://www.hosting.bikiran.com/
|
|
100
|
-
export function getHostingUrl(): string {
|
|
101
|
-
const d = getDomainObject();
|
|
102
|
-
const mode = getMode();
|
|
103
|
-
if (mode === "dev") {
|
|
104
|
-
return subDomainMap.hosting;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return `https://${SUB_DOMAIN_NAMES.HOSTING}.${d.name}.${mode}`;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// https://www.domain.bikiran.com/
|
|
111
|
-
export function getDomainUrl(): string {
|
|
112
|
-
const d = getDomainObject();
|
|
113
|
-
const mode = getMode();
|
|
114
|
-
if (mode === "dev") {
|
|
115
|
-
return subDomainMap.domain;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return `https://${SUB_DOMAIN_NAMES.DOMAIN}.${d.name}.${mode}`;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// https://www.appocean.bikiran.com/
|
|
122
|
-
export function getAppoceanUrl(): string {
|
|
123
|
-
const d = getDomainObject();
|
|
124
|
-
const mode = getMode();
|
|
125
|
-
if (mode === "dev") {
|
|
126
|
-
return subDomainMap.appocean;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return `https://${SUB_DOMAIN_NAMES.APPOCEAN}.${d.name}.${mode}`;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// https://www.admanage.bikiran.com/
|
|
133
|
-
export function getAdManageUrl(): string {
|
|
134
|
-
const d = getDomainObject();
|
|
135
|
-
const mode = getMode();
|
|
136
|
-
if (mode === "dev") {
|
|
137
|
-
return subDomainMap.admanage;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return `https://${SUB_DOMAIN_NAMES.ADMANAGE}.${d.name}.${mode}`;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// https://www.support.bikiran.com/
|
|
144
|
-
export function getSupportUrl(): string {
|
|
145
|
-
const d = getDomainObject();
|
|
146
|
-
const mode = getMode();
|
|
147
|
-
if (mode === "dev") {
|
|
148
|
-
return subDomainMap.support;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return `https://${SUB_DOMAIN_NAMES.SUPPORT}.${d.name}.${mode}`;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function getSiteUrl(): string {
|
|
155
|
-
const d = getDomainObject();
|
|
156
|
-
const mode = getMode();
|
|
157
|
-
if (mode === "dev") {
|
|
158
|
-
return subDomainMap[d.sub];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return `https://${d.sub}.${d.name}.${mode}`;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function getApiUrl(): string {
|
|
165
|
-
const d = getDomainObject();
|
|
166
|
-
const mode = getMode();
|
|
167
|
-
if (mode === "dev") {
|
|
168
|
-
return subDomainMap.api;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return `https://${SUB_DOMAIN_NAMES.API}.${d.name}.${mode}`;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export function getApi2Url(): string {
|
|
175
|
-
const d = getDomainObject();
|
|
176
|
-
const mode = getMode();
|
|
177
|
-
if (mode === "dev") {
|
|
178
|
-
return subDomainMap.api2;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return `https://${SUB_DOMAIN_NAMES.API2}.${d.name}.${mode}`;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export function getApi3Url(): string {
|
|
185
|
-
const d = getDomainObject();
|
|
186
|
-
const mode = getMode();
|
|
187
|
-
if (mode === "dev") {
|
|
188
|
-
return subDomainMap.api3;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return `https://${SUB_DOMAIN_NAMES.API3}.${d.name}.${mode}`;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export function getAccountUrl(): string {
|
|
195
|
-
const d = getDomainObject();
|
|
196
|
-
const mode = getMode();
|
|
197
|
-
if (mode === "dev") {
|
|
198
|
-
return subDomainMap.account;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return `https://${SUB_DOMAIN_NAMES.ACCOUNT}.${d.name}.${mode}`;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export function getDocsUrl(): string {
|
|
205
|
-
const d = getDomainObject();
|
|
206
|
-
const mode = getMode();
|
|
207
|
-
if (mode === "dev") {
|
|
208
|
-
return subDomainMap.docs;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return `https://${SUB_DOMAIN_NAMES.DOCS}.${d.name}.${mode}`;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export function generateAnyUrl(subDomain: string): string {
|
|
215
|
-
const d = getDomainObject();
|
|
216
|
-
const mode = getMode();
|
|
217
|
-
if (mode === "dev") {
|
|
218
|
-
return subDomainMap[d.sub];
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return `https://${subDomain}.${d.name}.${mode}`;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export function getDBConnectionString(): string {
|
|
225
|
-
const mode = getMode();
|
|
226
|
-
if (mode === "dev") {
|
|
227
|
-
return process.env.DATABASE_URL_DEV || "";
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (mode === "win") {
|
|
231
|
-
return process.env.DATABASE_URL_WIN || "";
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return process.env.DATABASE_URL_COM || "";
|
|
235
|
-
}
|
|
1
|
+
export const SUB_DOMAIN_NAMES = {
|
|
2
|
+
WWW: "www",
|
|
3
|
+
ACCOUNT: "account",
|
|
4
|
+
DOMAIN: "domain",
|
|
5
|
+
ADMANAGE: "admanage",
|
|
6
|
+
DNS: "dns",
|
|
7
|
+
HOSTING: "hosting",
|
|
8
|
+
APPOCEAN: "appocean",
|
|
9
|
+
DOCS: "docs",
|
|
10
|
+
PROBACKUP: "probackup",
|
|
11
|
+
EDUSOFT: "edusoft",
|
|
12
|
+
SUPPORT: "support",
|
|
13
|
+
ICON: "icon",
|
|
14
|
+
DRIVE: "drive",
|
|
15
|
+
API: "io",
|
|
16
|
+
API2: "api2",
|
|
17
|
+
API3: "api3",
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
const subDomainMap: Record<string, string> = {
|
|
21
|
+
www: `http://localhost:7201`,
|
|
22
|
+
account: `http://localhost:5000`,
|
|
23
|
+
domain: `http://localhost:7203`,
|
|
24
|
+
dns: `http://localhost:7204`,
|
|
25
|
+
hosting: `http://localhost:7205`,
|
|
26
|
+
appocean: `http://localhost:7206`,
|
|
27
|
+
docs: `http://localhost:7207`,
|
|
28
|
+
admanage: `http://localhost:7208`,
|
|
29
|
+
probackup: `http://localhost:7209`,
|
|
30
|
+
edusoft: `http://localhost:7210`,
|
|
31
|
+
icon: `http://localhost:7211`,
|
|
32
|
+
drive: `http://localhost:7212`,
|
|
33
|
+
support: `http://localhost:7216`,
|
|
34
|
+
api: `https://io.bikiran.win`,
|
|
35
|
+
api2:
|
|
36
|
+
process.env.NEXT_PUBLIC_LOCAL_API === "true"
|
|
37
|
+
? `http://localhost:5010`
|
|
38
|
+
: `https://api2.bikiran.win`,
|
|
39
|
+
api3:
|
|
40
|
+
process.env.NEXT_PUBLIC_LOCAL_API === "true"
|
|
41
|
+
? `http://localhost:7301`
|
|
42
|
+
: `https://api3.bikiran.win`,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const isDev = process.env.NEXT_PUBLIC_MODE === "dev";
|
|
46
|
+
export function getMode(): "dev" | "win" | "com" {
|
|
47
|
+
if (isDev) {
|
|
48
|
+
return "dev";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const isWin = process.env.NEXT_PUBLIC_MODE === "win";
|
|
52
|
+
if (isWin) {
|
|
53
|
+
return "win";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return "com";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const getDomain = (): string => {
|
|
60
|
+
return process.env.NEXT_PUBLIC_DOMAIN || "";
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
interface DomainObject {
|
|
64
|
+
sub: string;
|
|
65
|
+
name: string;
|
|
66
|
+
tld: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const getDomainObject = (): DomainObject => {
|
|
70
|
+
const domainParts = getDomain().split(".");
|
|
71
|
+
return {
|
|
72
|
+
sub: domainParts[0],
|
|
73
|
+
name: domainParts[1],
|
|
74
|
+
tld: domainParts[2],
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const getBaseDomain = (): string => {
|
|
79
|
+
const mode = getMode();
|
|
80
|
+
if (mode === "dev") {
|
|
81
|
+
return "localhost";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const d = getDomainObject();
|
|
85
|
+
return `${d.name}.${mode}`;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// https://www.bikiran.com/
|
|
89
|
+
export function getBikiranUrl(): string {
|
|
90
|
+
const d = getDomainObject();
|
|
91
|
+
const mode = getMode();
|
|
92
|
+
if (mode === "dev") {
|
|
93
|
+
return subDomainMap.www;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return `https://${SUB_DOMAIN_NAMES.WWW}.${d.name}.${mode}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// https://www.hosting.bikiran.com/
|
|
100
|
+
export function getHostingUrl(): string {
|
|
101
|
+
const d = getDomainObject();
|
|
102
|
+
const mode = getMode();
|
|
103
|
+
if (mode === "dev") {
|
|
104
|
+
return subDomainMap.hosting;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return `https://${SUB_DOMAIN_NAMES.HOSTING}.${d.name}.${mode}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// https://www.domain.bikiran.com/
|
|
111
|
+
export function getDomainUrl(): string {
|
|
112
|
+
const d = getDomainObject();
|
|
113
|
+
const mode = getMode();
|
|
114
|
+
if (mode === "dev") {
|
|
115
|
+
return subDomainMap.domain;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return `https://${SUB_DOMAIN_NAMES.DOMAIN}.${d.name}.${mode}`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// https://www.appocean.bikiran.com/
|
|
122
|
+
export function getAppoceanUrl(): string {
|
|
123
|
+
const d = getDomainObject();
|
|
124
|
+
const mode = getMode();
|
|
125
|
+
if (mode === "dev") {
|
|
126
|
+
return subDomainMap.appocean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return `https://${SUB_DOMAIN_NAMES.APPOCEAN}.${d.name}.${mode}`;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// https://www.admanage.bikiran.com/
|
|
133
|
+
export function getAdManageUrl(): string {
|
|
134
|
+
const d = getDomainObject();
|
|
135
|
+
const mode = getMode();
|
|
136
|
+
if (mode === "dev") {
|
|
137
|
+
return subDomainMap.admanage;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return `https://${SUB_DOMAIN_NAMES.ADMANAGE}.${d.name}.${mode}`;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// https://www.support.bikiran.com/
|
|
144
|
+
export function getSupportUrl(): string {
|
|
145
|
+
const d = getDomainObject();
|
|
146
|
+
const mode = getMode();
|
|
147
|
+
if (mode === "dev") {
|
|
148
|
+
return subDomainMap.support;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return `https://${SUB_DOMAIN_NAMES.SUPPORT}.${d.name}.${mode}`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function getSiteUrl(): string {
|
|
155
|
+
const d = getDomainObject();
|
|
156
|
+
const mode = getMode();
|
|
157
|
+
if (mode === "dev") {
|
|
158
|
+
return subDomainMap[d.sub];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return `https://${d.sub}.${d.name}.${mode}`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function getApiUrl(): string {
|
|
165
|
+
const d = getDomainObject();
|
|
166
|
+
const mode = getMode();
|
|
167
|
+
if (mode === "dev") {
|
|
168
|
+
return subDomainMap.api;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return `https://${SUB_DOMAIN_NAMES.API}.${d.name}.${mode}`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function getApi2Url(): string {
|
|
175
|
+
const d = getDomainObject();
|
|
176
|
+
const mode = getMode();
|
|
177
|
+
if (mode === "dev") {
|
|
178
|
+
return subDomainMap.api2;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return `https://${SUB_DOMAIN_NAMES.API2}.${d.name}.${mode}`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function getApi3Url(): string {
|
|
185
|
+
const d = getDomainObject();
|
|
186
|
+
const mode = getMode();
|
|
187
|
+
if (mode === "dev") {
|
|
188
|
+
return subDomainMap.api3;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return `https://${SUB_DOMAIN_NAMES.API3}.${d.name}.${mode}`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function getAccountUrl(): string {
|
|
195
|
+
const d = getDomainObject();
|
|
196
|
+
const mode = getMode();
|
|
197
|
+
if (mode === "dev") {
|
|
198
|
+
return subDomainMap.account;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return `https://${SUB_DOMAIN_NAMES.ACCOUNT}.${d.name}.${mode}`;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function getDocsUrl(): string {
|
|
205
|
+
const d = getDomainObject();
|
|
206
|
+
const mode = getMode();
|
|
207
|
+
if (mode === "dev") {
|
|
208
|
+
return subDomainMap.docs;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return `https://${SUB_DOMAIN_NAMES.DOCS}.${d.name}.${mode}`;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function generateAnyUrl(subDomain: string): string {
|
|
215
|
+
const d = getDomainObject();
|
|
216
|
+
const mode = getMode();
|
|
217
|
+
if (mode === "dev") {
|
|
218
|
+
return subDomainMap[d.sub];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return `https://${subDomain}.${d.name}.${mode}`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function getDBConnectionString(): string {
|
|
225
|
+
const mode = getMode();
|
|
226
|
+
if (mode === "dev") {
|
|
227
|
+
return process.env.DATABASE_URL_DEV || "";
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (mode === "win") {
|
|
231
|
+
return process.env.DATABASE_URL_WIN || "";
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return process.env.DATABASE_URL_COM || "";
|
|
235
|
+
}
|
|
236
236
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function capitalizeFirstLetter(string: string): string {
|
|
2
|
-
if (!string) return "";
|
|
3
|
-
const result = string.charAt(0).toUpperCase() + string.slice(1);
|
|
4
|
-
return result || string || "";
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default capitalizeFirstLetter;
|
|
1
|
+
function capitalizeFirstLetter(string: string): string {
|
|
2
|
+
if (!string) return "";
|
|
3
|
+
const result = string.charAt(0).toUpperCase() + string.slice(1);
|
|
4
|
+
return result || string || "";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default capitalizeFirstLetter;
|