fix(qq): add gateway-free QR connection gallery preview
This commit is contained in:
1 parent
6741acb391
commit
3ba93ba8e3
16 files changed
+156
-32
No files matched your search
@@ -1,9 +1,8 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import type { ChannelPluginConnectFlowProps } from "@/channel-plugins/types";
|
||||
import { channelTranslator } from "@/channel-plugins/i18n";
|
||||
import { ChannelQrConnectFlow } from "@/components/settings/channels/ChannelQrConnectFlow";
|
||||
|
||||
import { QQConnectFlowView, useQQConnectLabels } from "./QQConnectFlowView";
|
||||
|
||||
export function QQConnectFlow({
|
||||
token,
|
||||
feature,
|
||||
@@ -11,12 +10,7 @@ export function QQConnectFlow({
|
||||
connectRequestId,
|
||||
onFeaturesUpdate,
|
||||
}: ChannelPluginConnectFlowProps) {
|
||||
const { t } = useTranslation();
|
||||
const tx = channelTranslator(t, "qq");
|
||||
// Every scan rotates the App Secret, so warn before the user scans again.
|
||||
const rescanWarning = feature.configured
|
||||
? tx("custom.scanAgainWarning", "")
|
||||
: "";
|
||||
const labels = useQQConnectLabels();
|
||||
return (
|
||||
<ChannelQrConnectFlow
|
||||
token={token}
|
||||
@@ -25,28 +19,9 @@ export function QQConnectFlow({
|
||||
connectRequestId={connectRequestId}
|
||||
autoStart={!feature.configured}
|
||||
forceOnRepeat
|
||||
renderActions={(connectButton) => (
|
||||
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||
{rescanWarning ? (
|
||||
<p className="max-w-[22rem] text-[11.5px] leading-5 text-muted-foreground">
|
||||
{rescanWarning}
|
||||
</p>
|
||||
) : null}
|
||||
{connectButton}
|
||||
</div>
|
||||
)}
|
||||
labels={{
|
||||
qrAlt: tx("custom.qrAlt", "QQ login QR code"),
|
||||
scanTitle: tx("custom.scanTitle", "Scan with mobile QQ"),
|
||||
scanDescription: "",
|
||||
waiting: tx("custom.waiting", "Waiting for QQ scan..."),
|
||||
connected: tx("custom.connected", "QQ is connected."),
|
||||
stopped: tx("custom.stopped", "QQ login stopped."),
|
||||
connecting: tx("custom.connecting", "Connecting..."),
|
||||
scanAgain: t("settings.channels.scanAgain", { defaultValue: "Scan again" }),
|
||||
connect: t("settings.channels.connect", { defaultValue: "Connect" }),
|
||||
}}
|
||||
labels={labels}
|
||||
onFeaturesUpdate={onFeaturesUpdate}
|
||||
renderView={(props) => <QQConnectFlowView {...props} configured={feature.configured} />}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { channelTranslator } from "@/channel-plugins/i18n";
|
||||
import { ChannelQrConnectFlowView, type ChannelQrConnectFlowViewProps, type ChannelQrConnectLabels } from "@/components/settings/channels/ChannelQrConnectFlowView";
|
||||
|
||||
export type QQConnectFlowViewProps = Omit<ChannelQrConnectFlowViewProps, "labels"> & {
|
||||
configured?: boolean;
|
||||
};
|
||||
|
||||
export function useQQConnectLabels(): ChannelQrConnectLabels {
|
||||
const { t } = useTranslation();
|
||||
const tx = channelTranslator(t, "qq");
|
||||
return {
|
||||
qrAlt: tx("custom.qrAlt", "QQ login QR code"),
|
||||
scanTitle: tx("custom.scanTitle", "Scan with mobile QQ"),
|
||||
scanDescription: "",
|
||||
waiting: tx("custom.waiting", "Waiting for QQ scan..."),
|
||||
connected: tx("custom.connected", "QQ is connected."),
|
||||
stopped: tx("custom.stopped", "QQ login stopped."),
|
||||
connecting: tx("custom.connecting", "Connecting..."),
|
||||
scanAgain: t("settings.channels.scanAgain", { defaultValue: "Scan again" }),
|
||||
connect: t("settings.channels.connect", { defaultValue: "Connect" }),
|
||||
};
|
||||
}
|
||||
|
||||
export function QQConnectFlowView({ configured, ...props }: QQConnectFlowViewProps) {
|
||||
const { t } = useTranslation();
|
||||
const tx = channelTranslator(t, "qq");
|
||||
const labels = useQQConnectLabels();
|
||||
const rescanWarning = configured ? tx("custom.scanAgainWarning", "") : "";
|
||||
return <ChannelQrConnectFlowView {...props} labels={labels}
|
||||
renderActions={(connectButton) => (
|
||||
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||
{rescanWarning ? (
|
||||
<p className="max-w-[22rem] text-[11.5px] leading-5 text-muted-foreground">
|
||||
{rescanWarning}
|
||||
</p>
|
||||
) : null}
|
||||
{connectButton}
|
||||
</div>
|
||||
)}
|
||||
/>;
|
||||
}
|
||||
Reference in new issue
Block a user