mirror of
https://github.com/MrXujiang/h5-Dooring.git
synced 2025-12-12 18:22:51 +00:00
commit
2079f6209a
@ -66,7 +66,7 @@ const Container = (props: {
|
|||||||
return (type: any, text: string) => {
|
return (type: any, text: string) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{CpIcon[type]} {text}
|
{(CpIcon as any)[type]} {text}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
19
packages/ui/package-lock.json
generated
19
packages/ui/package-lock.json
generated
@ -2512,6 +2512,16 @@
|
|||||||
"csstype": "^3.0.2"
|
"csstype": "^3.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/react-color": {
|
||||||
|
"version": "3.0.5",
|
||||||
|
"resolved": "http://npm.yonghui.cn/repository/npm-group/@types/react-color/-/react-color-3.0.5.tgz",
|
||||||
|
"integrity": "sha1-uL3433CFvRV3ZY+zfZoY17o5Y7s=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"@types/reactcss": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@types/react-dom": {
|
"@types/react-dom": {
|
||||||
"version": "17.0.9",
|
"version": "17.0.9",
|
||||||
"resolved": "http://npm.yonghui.cn/repository/npm-group/@types/react-dom/-/react-dom-17.0.9.tgz",
|
"resolved": "http://npm.yonghui.cn/repository/npm-group/@types/react-dom/-/react-dom-17.0.9.tgz",
|
||||||
@ -2580,6 +2590,15 @@
|
|||||||
"@types/react-router": "*"
|
"@types/react-router": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/reactcss": {
|
||||||
|
"version": "1.2.4",
|
||||||
|
"resolved": "http://npm.yonghui.cn/repository/npm-group/@types/reactcss/-/reactcss-1.2.4.tgz",
|
||||||
|
"integrity": "sha1-ZsX2r+Ej/6GlDb5ySqH+aOufqwA=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/react": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@types/scheduler": {
|
"@types/scheduler": {
|
||||||
"version": "0.16.2",
|
"version": "0.16.2",
|
||||||
"resolved": "http://npm.yonghui.cn/repository/npm-group/@types/scheduler/-/scheduler-0.16.2.tgz",
|
"resolved": "http://npm.yonghui.cn/repository/npm-group/@types/scheduler/-/scheduler-0.16.2.tgz",
|
||||||
|
|||||||
@ -47,6 +47,7 @@
|
|||||||
"@types/dom-to-image": "^2.6.3",
|
"@types/dom-to-image": "^2.6.3",
|
||||||
"@types/lodash": "^4.14.172",
|
"@types/lodash": "^4.14.172",
|
||||||
"@types/react": "^17.0.0",
|
"@types/react": "^17.0.0",
|
||||||
|
"@types/react-color": "^3.0.5",
|
||||||
"@types/react-dom": "^17.0.0",
|
"@types/react-dom": "^17.0.0",
|
||||||
"@types/react-grid-layout": "^1.1.2",
|
"@types/react-grid-layout": "^1.1.2",
|
||||||
"@typescript-eslint/parser": "^4.28.2",
|
"@typescript-eslint/parser": "^4.28.2",
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import React, { memo, useEffect, useMemo, useRef, useState } from 'react';
|
|||||||
import ViewRender from '../../renderer/ViewRender';
|
import ViewRender from '../../renderer/ViewRender';
|
||||||
import domtoimage from 'dom-to-image';
|
import domtoimage from 'dom-to-image';
|
||||||
import req from '@/utils/req';
|
import req from '@/utils/req';
|
||||||
import { useGetScrollBarWidth } from '@/utils/tool';
|
import { getQueryString, useGetScrollBarWidth } from '@/utils/tool';
|
||||||
import type { LocationDescriptorObject } from 'history-with-query';
|
import type { LocationDescriptorObject } from 'history-with-query';
|
||||||
|
|
||||||
const isMac = navigator.platform.indexOf('Mac') === 0;
|
const isMac = navigator.platform.indexOf('Mac') === 0;
|
||||||
@ -13,13 +13,13 @@ interface PreviewPageProps {
|
|||||||
}
|
}
|
||||||
interface PointDataItem {
|
interface PointDataItem {
|
||||||
id: string;
|
id: string;
|
||||||
item: Record<string, any>;
|
item: Record<string, unknown>;
|
||||||
point: Record<string, any>;
|
point: Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PreviewPage = memo((props: PreviewPageProps) => {
|
const PreviewPage = memo((props: PreviewPageProps) => {
|
||||||
const [pointData, setPointData] = useState(() => {
|
const [pointData, setPointData] = useState(() => {
|
||||||
const pointDataStr = localStorage.getItem('pointData');
|
const pointDataStr = getQueryString('pointData') || localStorage.getItem('pointData');
|
||||||
let points;
|
let points;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -74,7 +74,7 @@ const PreviewPage = memo((props: PreviewPageProps) => {
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
generateImg((url: string) => {
|
generateImg((url: string) => {
|
||||||
parent.window.getFaceUrl(url);
|
(parent as any)?.(window as unknown).getFaceUrl(url);
|
||||||
});
|
});
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}, [props.location.query]);
|
}, [props.location.query]);
|
||||||
|
|||||||
@ -1,21 +1,22 @@
|
|||||||
import { RefObject, useEffect, useLayoutEffect, useState } from 'react';
|
/* eslint-disable no-param-reassign */
|
||||||
import { RGBColor } from 'react-color';
|
import type { RefObject } from 'react';
|
||||||
|
import { useEffect, useLayoutEffect, useState } from 'react';
|
||||||
|
import type { RGBColor } from 'react-color';
|
||||||
|
|
||||||
// 生成uuid
|
// 生成uuid
|
||||||
function uuid(len: number, radix: number) {
|
function uuid(len: number, radix: number) {
|
||||||
let chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
||||||
let uuid = [],
|
const uuid = [];
|
||||||
i;
|
const _radix = radix || chars.length;
|
||||||
radix = radix || chars.length;
|
|
||||||
|
|
||||||
if (len) {
|
if (len) {
|
||||||
for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)];
|
for (let i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * _radix)];
|
||||||
} else {
|
} else {
|
||||||
let r;
|
let r;
|
||||||
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
||||||
uuid[14] = '4';
|
uuid[14] = '4';
|
||||||
|
|
||||||
for (i = 0; i < 36; i++) {
|
for (let i = 0; i < 36; i++) {
|
||||||
if (!uuid[i]) {
|
if (!uuid[i]) {
|
||||||
r = 0 | (Math.random() * 16);
|
r = 0 | (Math.random() * 16);
|
||||||
uuid[i] = chars[i === 19 ? (r & 0x3) | 0x8 : r];
|
uuid[i] = chars[i === 19 ? (r & 0x3) | 0x8 : r];
|
||||||
@ -28,7 +29,7 @@ function uuid(len: number, radix: number) {
|
|||||||
|
|
||||||
// 将rgba字符串对象转化为rgba对象
|
// 将rgba字符串对象转化为rgba对象
|
||||||
function rgba2Obj(rgba = '') {
|
function rgba2Obj(rgba = '') {
|
||||||
let reg = /rgba\((\d+),(\d+),(\d+),(\d+)\)/g;
|
const reg = /rgba\((\d+),(\d+),(\d+),(\d+)\)/g;
|
||||||
let rgbaObj: RGBColor = { r: 0, g: 0, b: 0, a: 0 };
|
let rgbaObj: RGBColor = { r: 0, g: 0, b: 0, a: 0 };
|
||||||
|
|
||||||
rgba.replace(reg, (_m, r, g, b, a) => {
|
rgba.replace(reg, (_m, r, g, b, a) => {
|
||||||
@ -83,12 +84,10 @@ export function useAnimation(state: boolean, delay: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function unParams(params = '?a=1&b=2&c=3') {
|
export function unParams(params = '?a=1&b=2&c=3') {
|
||||||
let obj: any = {};
|
const obj: any = {};
|
||||||
params &&
|
params?.replace(/((\w*)=([\.a-z0-9A-Z]*)?)?/g, (m, a, b, c): any => {
|
||||||
// eslint-disable-next-line no-useless-escape
|
if (b || c) obj[b] = c;
|
||||||
params.replace(/((\w*)=([\.a-z0-9A-Z]*)?)?/g, (m, a, b, c): any => {
|
});
|
||||||
if (b || c) obj[b] = c;
|
|
||||||
});
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +118,7 @@ export function formatTime(fmt: string, dateObj: any) {
|
|||||||
if (/(y+)/.test(fmt)) {
|
if (/(y+)/.test(fmt)) {
|
||||||
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
|
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
|
||||||
}
|
}
|
||||||
for (var k in o) {
|
for (const k in o) {
|
||||||
if (new RegExp('(' + k + ')').test(fmt)) {
|
if (new RegExp('(' + k + ')').test(fmt)) {
|
||||||
fmt = fmt.replace(
|
fmt = fmt.replace(
|
||||||
RegExp.$1,
|
RegExp.$1,
|
||||||
@ -144,7 +143,16 @@ export function detectMobileBrowser(browserNavigatorMetaInfo: string): boolean {
|
|||||||
|
|
||||||
// note (@livs-ops): 获取浏览器元信息
|
// note (@livs-ops): 获取浏览器元信息
|
||||||
export function getBrowserNavigatorMetaInfo(): string {
|
export function getBrowserNavigatorMetaInfo(): string {
|
||||||
return window.navigator.userAgent || window.navigator.vendor || window.opera;
|
return window.navigator.userAgent || window.navigator.vendor || (window as any)?.opera;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const serverUrl = isDev ? 'http://192.16x.x.x:3000' : '你的服务器地址';
|
export const serverUrl = isDev ? 'http://192.16x.x.x:3000' : '你的服务器地址';
|
||||||
|
|
||||||
|
export function getQueryString(name: string) {
|
||||||
|
const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`, 'i');
|
||||||
|
const r = window.location.search.substr(1).match(reg);
|
||||||
|
if (r != null) {
|
||||||
|
return decodeURIComponent(r[2]);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user