feat: widget login with name and email

This commit is contained in:
Tristan Yang
2023-02-23 17:01:54 +08:00
parent f61748565f
commit a8773d3712
5 changed files with 66 additions and 9 deletions
+3 -2
View File
@@ -2,15 +2,16 @@ import { createContext, useContext, ReactNode } from 'react';
import { getContrastColor } from '../common/utils';
const color = decodeURIComponent(new URLSearchParams(location.search).get("themeColor") || "#1fe1f9");
const from = decodeURIComponent(new URLSearchParams(location.search).get("from") || "widget");
const fgColor = getContrastColor(color);
// 判断是否是iframe上下文
const embed = window.location !== window.parent.location;
const WidgetContext = createContext({ color, fgColor, embed });
const WidgetContext = createContext({ color, fgColor, embed, from });
function WidgetProvider({ children }: { children: ReactNode }) {
return <WidgetContext.Provider value={{ color, fgColor, embed }} >{children}</WidgetContext.Provider>;
return <WidgetContext.Provider value={{ color, fgColor, embed, from }} >{children}</WidgetContext.Provider>;
}
function useWidget() {