feat: widget id
This commit is contained in:
@@ -88,6 +88,11 @@ export default function Widget() {
|
||||
</thead>
|
||||
<tbody>
|
||||
{[
|
||||
{
|
||||
paramKey: "id",
|
||||
paramDefault: "-",
|
||||
remarks: t("param_id")
|
||||
},
|
||||
{
|
||||
paramKey: "host-id",
|
||||
paramDefault: 1,
|
||||
|
||||
@@ -18,6 +18,7 @@ export interface User {
|
||||
webhook_url?: string;
|
||||
is_bot?: boolean;
|
||||
log_id?: number;
|
||||
widget_id?: string;
|
||||
}
|
||||
export type ContactAction = "add" | "remove" | "block" | "unblock";
|
||||
export type ContactStatus = "added" | "blocked" | "";
|
||||
|
||||
@@ -23,7 +23,7 @@ const randomText = () => (Math.random() + 1).toString(36).substring(7);
|
||||
const Login = () => {
|
||||
const { t } = useTranslation("widget");
|
||||
const dispatch = useDispatch();
|
||||
const { color, fgColor, from, autoReg, token } = useWidget();
|
||||
const { color, fgColor, from, autoReg, token, id } = useWidget();
|
||||
const { clientId } = useGoogleAuthConfig();
|
||||
const { config: githubAuthConfig } = useGithubAuthConfig();
|
||||
const [register, { isLoading, isSuccess, data, error }] = useRegisterMutation();
|
||||
|
||||
@@ -6,6 +6,7 @@ import { getContrastColor, isInIframe } from "../utils";
|
||||
import { shallowEqual } from "react-redux";
|
||||
|
||||
const query = new URLSearchParams(location.search);
|
||||
const id = decodeURIComponent(query.get("id") || "");
|
||||
const welcome = decodeURIComponent(query.get("welcome") || "");
|
||||
const autoReg = decodeURIComponent(query.get("autoReg") || "true") == "true";
|
||||
const token = decodeURIComponent(query.get("token") || "");
|
||||
@@ -14,6 +15,7 @@ const from = decodeURIComponent(query.get("from") || "widget.link");
|
||||
const fgColor = getContrastColor(color);
|
||||
const embed = isInIframe();
|
||||
const WidgetContext = createContext({
|
||||
id,
|
||||
token,
|
||||
autoReg,
|
||||
color,
|
||||
@@ -38,6 +40,7 @@ function WidgetProvider({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<WidgetContext.Provider
|
||||
value={{
|
||||
id,
|
||||
token,
|
||||
autoReg,
|
||||
welcome,
|
||||
|
||||
Reference in New Issue
Block a user