@rxdrag/website-lib-core 0.0.49 → 0.0.51
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/package.json +10 -9
- package/src/astro/README.md +1 -0
- package/src/astro/animation.ts +146 -0
- package/src/astro/background.ts +53 -0
- package/src/astro/grid/consts.ts +80 -0
- package/src/astro/grid/index.ts +2 -0
- package/src/astro/grid/types.ts +35 -0
- package/src/astro/index.ts +7 -0
- package/src/astro/media.ts +109 -0
- package/src/astro/section/index.ts +12 -0
- package/src/entify/Entify.ts +32 -2
- package/src/entify/IEntify.ts +30 -6
- package/src/entify/lib/createUploadCredentials.ts +56 -0
- package/src/entify/lib/index.ts +30 -29
- package/src/entify/lib/newQueryProductOptions.ts +1 -0
- package/src/entify/lib/queryLangs.ts +5 -5
- package/src/entify/lib/queryLatestPosts.ts +9 -1
- package/src/entify/lib/queryOneTheme.ts +12 -12
- package/src/index.ts +1 -0
- package/src/react/components/Analytics/eventHandlers.ts +173 -0
- package/src/react/components/Analytics/index.tsx +21 -0
- package/src/react/components/Analytics/singleton.ts +214 -0
- package/src/react/components/Analytics/tracking.ts +221 -0
- package/src/react/components/Analytics/types.ts +60 -0
- package/src/react/components/Analytics/utils.ts +95 -0
- package/src/react/components/BackgroundHlsVideoPlayer.tsx +68 -0
- package/src/react/components/BackgroundVideoPlayer.tsx +32 -0
- package/src/react/components/ContactForm/ContactForm.tsx +286 -0
- package/src/react/components/ContactForm/FileUpload.tsx +430 -0
- package/src/react/components/ContactForm/Input.tsx +6 -10
- package/src/react/components/ContactForm/Input2.tsx +64 -0
- package/src/react/components/ContactForm/Submit.tsx +25 -10
- package/src/react/components/ContactForm/Textarea.tsx +7 -10
- package/src/react/components/ContactForm/Textarea2.tsx +64 -0
- package/src/react/components/ContactForm/factory.tsx +49 -0
- package/src/react/components/ContactForm/funcs.ts +64 -0
- package/src/react/components/ContactForm/index.ts +7 -0
- package/src/react/components/ContactForm/types.ts +67 -0
- package/src/react/components/ContactForm/useVisitorInfo.ts +31 -0
- package/src/react/components/index.ts +3 -0
- package/src/react/components/ContactForm/index.tsx +0 -351
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import { forwardRef
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { FieldConfig } from "./types";
|
|
2
3
|
|
|
3
|
-
export type InputProps = {
|
|
4
|
-
|
|
5
|
-
name: string;
|
|
6
|
-
required?: boolean;
|
|
7
|
-
className?: string;
|
|
8
|
-
labelClassName?: string;
|
|
9
|
-
inputClassName?: string;
|
|
10
|
-
type?: HTMLInputTypeAttribute;
|
|
11
|
-
autoFocus?: boolean;
|
|
4
|
+
export type InputProps = Omit<FieldConfig, "feildStyle"> & {
|
|
5
|
+
requiredClassName?: string;
|
|
12
6
|
value?: string;
|
|
13
7
|
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
14
8
|
error?: string;
|
|
@@ -19,6 +13,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>((props, ref) => {
|
|
|
19
13
|
label,
|
|
20
14
|
name,
|
|
21
15
|
required,
|
|
16
|
+
requiredClassName,
|
|
22
17
|
labelClassName,
|
|
23
18
|
inputClassName,
|
|
24
19
|
type,
|
|
@@ -33,6 +28,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>((props, ref) => {
|
|
|
33
28
|
<div {...rest}>
|
|
34
29
|
<label htmlFor={name} className={labelClassName}>
|
|
35
30
|
{label}
|
|
31
|
+
{required ? <span className={requiredClassName}>*</span> : ""}
|
|
36
32
|
</label>
|
|
37
33
|
<input
|
|
38
34
|
ref={ref}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import { forwardRef, useRef, useEffect, useState } from "react";
|
|
3
|
+
import { InputProps } from "./Input";
|
|
4
|
+
|
|
5
|
+
export const Input2 = forwardRef<HTMLInputElement, InputProps>((props, ref) => {
|
|
6
|
+
const {
|
|
7
|
+
label,
|
|
8
|
+
name,
|
|
9
|
+
required,
|
|
10
|
+
className,
|
|
11
|
+
labelClassName,
|
|
12
|
+
inputClassName,
|
|
13
|
+
type = "text",
|
|
14
|
+
autoFocus,
|
|
15
|
+
value,
|
|
16
|
+
placeholder,
|
|
17
|
+
onChange,
|
|
18
|
+
error,
|
|
19
|
+
...rest
|
|
20
|
+
} = props;
|
|
21
|
+
|
|
22
|
+
const labelRef = useRef<HTMLLabelElement>(null);
|
|
23
|
+
const [paddingLeft, setPaddingLeft] = useState("3.5rem"); // default fallback
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (labelRef.current) {
|
|
27
|
+
const width = labelRef.current.getBoundingClientRect().width;
|
|
28
|
+
setPaddingLeft(`${width + 16}px`); // extra 16px spacing
|
|
29
|
+
}
|
|
30
|
+
}, [label]);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className={clsx("relative w-full", className)} {...rest}>
|
|
34
|
+
<label
|
|
35
|
+
ref={labelRef}
|
|
36
|
+
htmlFor={name}
|
|
37
|
+
className={clsx(
|
|
38
|
+
"absolute left-3 top-1/2 -translate-y-1/2 mt-1 text-gray-400 opacity-70 text-sm pointer-events-none whitespace-nowrap",
|
|
39
|
+
labelClassName
|
|
40
|
+
)}
|
|
41
|
+
>
|
|
42
|
+
{label}
|
|
43
|
+
</label>
|
|
44
|
+
<input
|
|
45
|
+
ref={ref}
|
|
46
|
+
type={type}
|
|
47
|
+
id={name}
|
|
48
|
+
name={name}
|
|
49
|
+
required={required}
|
|
50
|
+
placeholder={placeholder}
|
|
51
|
+
className={clsx(
|
|
52
|
+
"w-full pr-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary-300 bg-transparent focus:bg-white transition-colors duration-200",
|
|
53
|
+
inputClassName
|
|
54
|
+
)}
|
|
55
|
+
style={{ paddingLeft }}
|
|
56
|
+
autoComplete={name}
|
|
57
|
+
autoFocus={autoFocus}
|
|
58
|
+
value={value}
|
|
59
|
+
onChange={onChange}
|
|
60
|
+
/>
|
|
61
|
+
{error && <p className="text-red-500 mt-1 text-sm">{error}</p>}
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
});
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export type SubmitProps = {
|
|
2
|
+
needClasses?: string;
|
|
2
3
|
title: string;
|
|
3
4
|
className?: string;
|
|
5
|
+
rawHtml?: string;
|
|
4
6
|
spinner?: React.ReactNode;
|
|
5
7
|
submitting?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
6
9
|
onClick?: (e: React.MouseEvent) => void;
|
|
7
10
|
};
|
|
8
11
|
|
|
@@ -12,19 +15,31 @@ export const Submit: React.FC<SubmitProps> = (props) => {
|
|
|
12
15
|
className,
|
|
13
16
|
spinner,
|
|
14
17
|
submitting,
|
|
18
|
+
disabled,
|
|
15
19
|
onClick,
|
|
20
|
+
rawHtml,
|
|
21
|
+
needClasses,
|
|
16
22
|
...rest
|
|
17
23
|
} = props;
|
|
18
24
|
return (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
<>
|
|
26
|
+
<button
|
|
27
|
+
type="button"
|
|
28
|
+
className={className}
|
|
29
|
+
disabled={disabled ?? submitting}
|
|
30
|
+
onClick={onClick}
|
|
31
|
+
{...rest}
|
|
32
|
+
>
|
|
33
|
+
{submitting && spinner}
|
|
34
|
+
{rawHtml ? (
|
|
35
|
+
<div dangerouslySetInnerHTML={{ __html: rawHtml }} />
|
|
36
|
+
) : (
|
|
37
|
+
title
|
|
38
|
+
)}
|
|
39
|
+
</button>
|
|
40
|
+
<span className="fixed -z-10 top-0 left-0 w-0 h-0 overflow-hidden opacity-0 pointer-events-none">
|
|
41
|
+
<span className={needClasses}></span>
|
|
42
|
+
</span>
|
|
43
|
+
</>
|
|
29
44
|
);
|
|
30
45
|
};
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { forwardRef } from "react";
|
|
2
|
+
import { FieldConfig } from "./types";
|
|
2
3
|
|
|
3
|
-
export type TextareaProps = {
|
|
4
|
-
|
|
5
|
-
name: string;
|
|
6
|
-
required?: boolean;
|
|
7
|
-
className?: string;
|
|
8
|
-
labelClassName?: string;
|
|
9
|
-
textareaClassName?: string;
|
|
10
|
-
rows?: number;
|
|
4
|
+
export type TextareaProps = Omit<FieldConfig, "feildStyle"> & {
|
|
5
|
+
requiredClassName?: string;
|
|
11
6
|
value?: string;
|
|
12
7
|
onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
13
8
|
error?: string;
|
|
@@ -19,8 +14,9 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
19
14
|
label,
|
|
20
15
|
name,
|
|
21
16
|
required,
|
|
17
|
+
requiredClassName,
|
|
22
18
|
labelClassName,
|
|
23
|
-
|
|
19
|
+
inputClassName,
|
|
24
20
|
rows = 8,
|
|
25
21
|
value,
|
|
26
22
|
onChange,
|
|
@@ -32,13 +28,14 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
32
28
|
<div {...rest}>
|
|
33
29
|
<label htmlFor={name} className={labelClassName}>
|
|
34
30
|
{label}
|
|
31
|
+
{required ? <span className={requiredClassName}>*</span> : ""}
|
|
35
32
|
</label>
|
|
36
33
|
<textarea
|
|
37
34
|
ref={ref}
|
|
38
35
|
id={name}
|
|
39
36
|
name={name}
|
|
40
37
|
required={required}
|
|
41
|
-
className={
|
|
38
|
+
className={inputClassName}
|
|
42
39
|
rows={rows}
|
|
43
40
|
value={value}
|
|
44
41
|
onChange={onChange}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { forwardRef, useRef, useEffect, useState } from "react";
|
|
2
|
+
import { TextareaProps } from "./Textarea";
|
|
3
|
+
|
|
4
|
+
export const Textarea2 = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
5
|
+
(props, ref) => {
|
|
6
|
+
const {
|
|
7
|
+
label,
|
|
8
|
+
name,
|
|
9
|
+
required,
|
|
10
|
+
labelClassName,
|
|
11
|
+
inputClassName,
|
|
12
|
+
className,
|
|
13
|
+
rows = 6,
|
|
14
|
+
value,
|
|
15
|
+
onChange,
|
|
16
|
+
error,
|
|
17
|
+
...rest
|
|
18
|
+
} = props;
|
|
19
|
+
|
|
20
|
+
const [paddingTop, setPaddingTop] = useState("2.5rem");
|
|
21
|
+
const labelRef = useRef<HTMLLabelElement>(null);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (labelRef.current) {
|
|
25
|
+
const height = labelRef.current.getBoundingClientRect().height;
|
|
26
|
+
setPaddingTop(`${height + 12}px`); // 留白 label 高度 + 12px 间距
|
|
27
|
+
}
|
|
28
|
+
}, [label]);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className={className} {...rest}>
|
|
32
|
+
<div className="relative w-full">
|
|
33
|
+
<label
|
|
34
|
+
ref={labelRef}
|
|
35
|
+
htmlFor={name}
|
|
36
|
+
className={`absolute left-3 top-2 text-gray-400 opacity-70 text-sm pointer-events-none ${
|
|
37
|
+
labelClassName || ""
|
|
38
|
+
}`}
|
|
39
|
+
>
|
|
40
|
+
{label}
|
|
41
|
+
</label>
|
|
42
|
+
<textarea
|
|
43
|
+
ref={ref}
|
|
44
|
+
id={name}
|
|
45
|
+
name={name}
|
|
46
|
+
required={required}
|
|
47
|
+
rows={rows}
|
|
48
|
+
value={value}
|
|
49
|
+
onChange={onChange}
|
|
50
|
+
autoComplete={name}
|
|
51
|
+
style={{ paddingTop }}
|
|
52
|
+
className={`w-full px-3 pb-2 border border-gray-300 rounded-md shadow-sm focus:outline-none
|
|
53
|
+
focus:ring-2 focus:ring-primary-300 focus:border-transparent resize-y bg-transparent focus:bg-white transition-colors duration-200 ${
|
|
54
|
+
inputClassName || ""
|
|
55
|
+
}`}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
{error && <p className="text-red-500 mt-1 text-sm">{error}</p>}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
Textarea2.displayName = "Textarea2";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FileUpload, FileUploadProps } from "./FileUpload";
|
|
2
|
+
import { Input } from "./Input";
|
|
3
|
+
import { Input2 } from "./Input2";
|
|
4
|
+
import { Textarea } from "./Textarea";
|
|
5
|
+
import { Textarea2 } from "./Textarea2";
|
|
6
|
+
import { FieldStyle } from "./types";
|
|
7
|
+
|
|
8
|
+
export const getControl = (controlName?: string, fieldStyle?: FieldStyle) => {
|
|
9
|
+
switch (controlName) {
|
|
10
|
+
case "Input":
|
|
11
|
+
return getInput(fieldStyle);
|
|
12
|
+
case "Textarea":
|
|
13
|
+
return getTextarea(fieldStyle);
|
|
14
|
+
default:
|
|
15
|
+
return getInput(fieldStyle);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const getInput = (fieldStyle?: FieldStyle) => {
|
|
20
|
+
if (fieldStyle === "default") {
|
|
21
|
+
return Input;
|
|
22
|
+
} else if (fieldStyle === "label-inline") {
|
|
23
|
+
return Input2;
|
|
24
|
+
} else {
|
|
25
|
+
return Input;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const getTextarea = (fieldStyle?: FieldStyle) => {
|
|
30
|
+
if (fieldStyle === "default") {
|
|
31
|
+
return Textarea;
|
|
32
|
+
} else if (fieldStyle === "label-inline") {
|
|
33
|
+
return Textarea2;
|
|
34
|
+
} else {
|
|
35
|
+
return Textarea;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const getFileUpload = (
|
|
40
|
+
fieldStyle?: FieldStyle
|
|
41
|
+
): React.FC<FileUploadProps> => {
|
|
42
|
+
if (fieldStyle === "default") {
|
|
43
|
+
return FileUpload;
|
|
44
|
+
} else if (fieldStyle === "label-inline") {
|
|
45
|
+
return FileUpload;
|
|
46
|
+
} else {
|
|
47
|
+
return FileUpload;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 简单的加密函数,用于生成防机器人的加密字段
|
|
3
|
+
* @param value 需要加密的值
|
|
4
|
+
* @returns 加密后的字符串
|
|
5
|
+
*/
|
|
6
|
+
export const encrypt = (value: string, formSalt: string): string => {
|
|
7
|
+
// 获取当前时间戳,精确到分钟级别(防止频繁变化)
|
|
8
|
+
const timestamp = Math.floor(Date.now() / (60 * 1000));
|
|
9
|
+
|
|
10
|
+
// 将时间戳与盐值和输入值组合
|
|
11
|
+
const dataToEncrypt = `${formSalt}:${timestamp}:${value}`;
|
|
12
|
+
|
|
13
|
+
// 使用简单的哈希算法
|
|
14
|
+
let hash = 0;
|
|
15
|
+
for (let i = 0; i < dataToEncrypt.length; i++) {
|
|
16
|
+
const char = dataToEncrypt.charCodeAt(i);
|
|
17
|
+
hash = (hash << 5) - hash + char;
|
|
18
|
+
hash = hash & hash; // 转换为32位整数
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 转换为16进制字符串并添加时间戳信息
|
|
22
|
+
return `${hash.toString(16)}_${timestamp}`;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 验证加密字段是否有效
|
|
27
|
+
* @param encryptedValue 加密后的字符串
|
|
28
|
+
* @param originalValue 原始值(如蜜罐字段的值)
|
|
29
|
+
* @param maxAgeMinutes 最大有效时间(分钟)
|
|
30
|
+
* @returns 是否有效
|
|
31
|
+
*/
|
|
32
|
+
export const verifyEncryption = (
|
|
33
|
+
formSalt: string,
|
|
34
|
+
encryptedValue: string = "",
|
|
35
|
+
originalValue: string = "",
|
|
36
|
+
maxAgeMinutes: number = 30
|
|
37
|
+
): boolean => {
|
|
38
|
+
// 解析加密值
|
|
39
|
+
const parts = encryptedValue.split("_");
|
|
40
|
+
if (parts.length !== 2) {
|
|
41
|
+
return false; // 格式不正确
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const [hashString, timestampString] = parts;
|
|
45
|
+
const timestamp = parseInt(timestampString, 10);
|
|
46
|
+
|
|
47
|
+
// 验证时间戳是否在有效期内
|
|
48
|
+
const currentTimestamp = Math.floor(Date.now() / (60 * 1000));
|
|
49
|
+
if (isNaN(timestamp) || currentTimestamp - timestamp > maxAgeMinutes) {
|
|
50
|
+
return false; // 时间戳无效或已过期
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 重新计算哈希值
|
|
54
|
+
const dataToEncrypt = `${formSalt}:${timestamp}:${originalValue}`;
|
|
55
|
+
let hash = 0;
|
|
56
|
+
for (let i = 0; i < dataToEncrypt.length; i++) {
|
|
57
|
+
const char = dataToEncrypt.charCodeAt(i);
|
|
58
|
+
hash = (hash << 5) - hash + char;
|
|
59
|
+
hash = hash & hash;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 比较哈希值
|
|
63
|
+
return hashString === hash.toString(16);
|
|
64
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { HTMLInputTypeAttribute } from "react";
|
|
2
|
+
|
|
3
|
+
export type FieldStyle = "default" | "label-inline" | string;
|
|
4
|
+
|
|
5
|
+
export type FieldConfig = {
|
|
6
|
+
name: string;
|
|
7
|
+
label: string;
|
|
8
|
+
controlName?: string;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
labelClassName?: string;
|
|
13
|
+
inputClassName?: string;
|
|
14
|
+
rows?: number;
|
|
15
|
+
type?: HTMLInputTypeAttribute;
|
|
16
|
+
autoFocus?: boolean;
|
|
17
|
+
feildStyle?: FieldStyle;
|
|
18
|
+
isExtends?: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type SubmitConfig = {
|
|
22
|
+
containerClassName?: string;
|
|
23
|
+
className?: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
rawHtml?: string;
|
|
26
|
+
//rawHtml模式时,用于触发tailwind编译
|
|
27
|
+
needClasses?: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type ContactFormProps = {
|
|
31
|
+
submit?: SubmitConfig;
|
|
32
|
+
actionUrl?: string;
|
|
33
|
+
formSalt: string;
|
|
34
|
+
className?: string;
|
|
35
|
+
classNames?: {
|
|
36
|
+
inputContainer?: string;
|
|
37
|
+
input?: string;
|
|
38
|
+
label?: string;
|
|
39
|
+
required?: string;
|
|
40
|
+
};
|
|
41
|
+
fields: FieldConfig[];
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export interface FileAttachment {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
size: number;
|
|
48
|
+
url: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface QuoteRequest {
|
|
52
|
+
name?: string;
|
|
53
|
+
email?: string;
|
|
54
|
+
company?: string;
|
|
55
|
+
message?: string;
|
|
56
|
+
fromCta?: string;
|
|
57
|
+
// 电话或者whatsapp
|
|
58
|
+
mobile?: string;
|
|
59
|
+
// 蜜罐字段,用于检测机器人
|
|
60
|
+
phone: string;
|
|
61
|
+
// 一个加密字段,用于防机器人,点击时附加一个加密的字符串
|
|
62
|
+
encryptedField?: string;
|
|
63
|
+
// 附件文件信息列表(包含 ID, 名称, 大小, URL)
|
|
64
|
+
attachments?: FileAttachment[];
|
|
65
|
+
extents?: Record<string, unknown>;
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export interface VisitorInfo {
|
|
4
|
+
visitorId: string | null;
|
|
5
|
+
sessionId: string | null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function useVisitorInfo() {
|
|
9
|
+
const [visitorInfo, setVisitorInfo] = useState<VisitorInfo>({
|
|
10
|
+
visitorId: null,
|
|
11
|
+
sessionId: null,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const getVisitorId = () => {
|
|
16
|
+
const match = document.cookie.match(/visitor_id=([^;]+)/);
|
|
17
|
+
return match ? match[1] : null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const getSessionId = () => {
|
|
21
|
+
return sessionStorage.getItem("session_id");
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
setVisitorInfo({
|
|
25
|
+
visitorId: getVisitorId(),
|
|
26
|
+
sessionId: getSessionId(),
|
|
27
|
+
});
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
return visitorInfo;
|
|
31
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./Analytics";
|
|
1
2
|
export * from "./AttachmentIcon";
|
|
2
3
|
export * from "./ContactForm";
|
|
3
4
|
export * from "./Icon";
|
|
@@ -8,3 +9,5 @@ export * from "./Share";
|
|
|
8
9
|
export * from "./Scroller";
|
|
9
10
|
export * from "./SearchInput";
|
|
10
11
|
export * from "./ToTop";
|
|
12
|
+
export * from "./BackgroundVideoPlayer";
|
|
13
|
+
export * from "./BackgroundHlsVideoPlayer";
|