features: supports WeChat channel
This commit is contained in:
@@ -44,6 +44,7 @@ export function AddChatChannelDialog({
|
||||
const [token, setToken] = useState("")
|
||||
const [chatId, setChatId] = useState("")
|
||||
const [appId, setAppId] = useState("")
|
||||
const [baseUrl, setBaseUrl] = useState("https://ilinkai.weixin.qq.com")
|
||||
const [dailyReportEnabled, setDailyReportEnabled] = useState(false)
|
||||
const [dailyReportTime, setDailyReportTime] = useState("18:00")
|
||||
|
||||
@@ -53,6 +54,7 @@ export function AddChatChannelDialog({
|
||||
setToken("")
|
||||
setChatId("")
|
||||
setAppId("")
|
||||
setBaseUrl("https://ilinkai.weixin.qq.com")
|
||||
setDailyReportEnabled(false)
|
||||
setDailyReportTime("18:00")
|
||||
setError(null)
|
||||
@@ -71,11 +73,11 @@ export function AddChatChannelDialog({
|
||||
setError(t("nameRequired"))
|
||||
return
|
||||
}
|
||||
if (!token.trim()) {
|
||||
if (channelType !== "weixin" && !token.trim()) {
|
||||
setError(t("tokenRequired"))
|
||||
return
|
||||
}
|
||||
if (!chatId.trim()) {
|
||||
if (channelType !== "weixin" && !chatId.trim()) {
|
||||
setError(t("chatIdRequired"))
|
||||
return
|
||||
}
|
||||
@@ -84,9 +86,11 @@ export function AddChatChannelDialog({
|
||||
setError(null)
|
||||
try {
|
||||
const configJson =
|
||||
channelType === "lark"
|
||||
? JSON.stringify({ app_id: appId, chat_id: chatId })
|
||||
: JSON.stringify({ chat_id: chatId })
|
||||
channelType === "weixin"
|
||||
? JSON.stringify({ base_url: baseUrl })
|
||||
: channelType === "lark"
|
||||
? JSON.stringify({ app_id: appId, chat_id: chatId })
|
||||
: JSON.stringify({ chat_id: chatId })
|
||||
|
||||
const channel = await createChatChannel({
|
||||
name: name.trim(),
|
||||
@@ -97,7 +101,9 @@ export function AddChatChannelDialog({
|
||||
dailyReportTime: dailyReportEnabled ? dailyReportTime : null,
|
||||
})
|
||||
|
||||
await saveChatChannelToken(channel.id, token.trim())
|
||||
if (channelType !== "weixin" && token.trim()) {
|
||||
await saveChatChannelToken(channel.id, token.trim())
|
||||
}
|
||||
|
||||
handleOpenChange(false)
|
||||
onChannelAdded()
|
||||
@@ -113,6 +119,7 @@ export function AddChatChannelDialog({
|
||||
chatId,
|
||||
channelType,
|
||||
appId,
|
||||
baseUrl,
|
||||
dailyReportEnabled,
|
||||
dailyReportTime,
|
||||
handleOpenChange,
|
||||
@@ -149,6 +156,7 @@ export function AddChatChannelDialog({
|
||||
<SelectContent>
|
||||
<SelectItem value="telegram">Telegram</SelectItem>
|
||||
<SelectItem value="lark">{t("lark")}</SelectItem>
|
||||
<SelectItem value="weixin">{t("weixin")}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
@@ -164,30 +172,40 @@ export function AddChatChannelDialog({
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium">
|
||||
{channelType === "telegram" ? "Bot Token" : "App Secret"}
|
||||
</label>
|
||||
<Input
|
||||
type="password"
|
||||
value={token}
|
||||
onChange={(e) => setToken(e.target.value)}
|
||||
placeholder={
|
||||
channelType === "telegram" ? "123456:ABC-DEF..." : "xxxxx"
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
{channelType !== "weixin" && (
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium">
|
||||
{channelType === "telegram" ? "Bot Token" : "App Secret"}
|
||||
</label>
|
||||
<Input
|
||||
type="password"
|
||||
value={token}
|
||||
onChange={(e) => setToken(e.target.value)}
|
||||
placeholder={
|
||||
channelType === "telegram" ? "123456:ABC-DEF..." : "xxxxx"
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium">Chat ID</label>
|
||||
<Input
|
||||
value={chatId}
|
||||
onChange={(e) => setChatId(e.target.value)}
|
||||
placeholder={
|
||||
channelType === "telegram" ? "-100123456789" : "oc_xxxxx"
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
{channelType !== "weixin" && (
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium">Chat ID</label>
|
||||
<Input
|
||||
value={chatId}
|
||||
onChange={(e) => setChatId(e.target.value)}
|
||||
placeholder={
|
||||
channelType === "telegram" ? "-100123456789" : "oc_xxxxx"
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{channelType === "weixin" && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t("weixinScanDescription")}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<label className="text-xs font-medium">{t("dailyReport")}</label>
|
||||
|
||||
@@ -37,9 +37,14 @@ import {
|
||||
getChatChannelStatus,
|
||||
} from "@/lib/api"
|
||||
import { subscribe } from "@/lib/platform"
|
||||
import type { ChatChannelInfo, ChannelStatusInfo } from "@/lib/types"
|
||||
import type {
|
||||
ChatChannelInfo,
|
||||
ChannelStatusInfo,
|
||||
ChannelType,
|
||||
} from "@/lib/types"
|
||||
import { AddChatChannelDialog } from "./add-chat-channel-dialog"
|
||||
import { EditChatChannelDialog } from "./edit-chat-channel-dialog"
|
||||
import { WeixinQrcodeDialog } from "./weixin-qrcode-dialog"
|
||||
|
||||
export function ChannelListTab() {
|
||||
const t = useTranslations("ChatChannelSettings")
|
||||
@@ -50,6 +55,7 @@ export function ChannelListTab() {
|
||||
const [editTarget, setEditTarget] = useState<ChatChannelInfo | null>(null)
|
||||
const [deleteTarget, setDeleteTarget] = useState<ChatChannelInfo | null>(null)
|
||||
const [actionLoading, setActionLoading] = useState<number | null>(null)
|
||||
const [qrcodeChannelId, setQrcodeChannelId] = useState<number | null>(null)
|
||||
|
||||
const loadChannels = useCallback(async () => {
|
||||
try {
|
||||
@@ -114,12 +120,35 @@ export function ChannelListTab() {
|
||||
)
|
||||
|
||||
const handleConnect = useCallback(
|
||||
async (id: number) => {
|
||||
async (id: number, channelType?: ChannelType) => {
|
||||
setActionLoading(id)
|
||||
try {
|
||||
await connectChatChannel(id)
|
||||
toast.success(t("connectSuccess"))
|
||||
await loadChannels()
|
||||
} catch (err: unknown) {
|
||||
if (channelType === "weixin") {
|
||||
// No token or token expired — show QR code dialog
|
||||
setQrcodeChannelId(id)
|
||||
} else {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
toast.error(t("connectFailed") + ": " + msg)
|
||||
}
|
||||
} finally {
|
||||
setActionLoading(null)
|
||||
}
|
||||
},
|
||||
[loadChannels, t]
|
||||
)
|
||||
|
||||
const handleWeixinAuthSuccess = useCallback(
|
||||
async (channelId: number) => {
|
||||
setQrcodeChannelId(null)
|
||||
setActionLoading(channelId)
|
||||
try {
|
||||
await connectChatChannel(channelId)
|
||||
toast.success(t("connectSuccess"))
|
||||
await loadChannels()
|
||||
} catch (err: unknown) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
toast.error(t("connectFailed") + ": " + msg)
|
||||
@@ -270,7 +299,7 @@ export function ChannelListTab() {
|
||||
size="sm"
|
||||
title={t("connect")}
|
||||
disabled={isLoading || !ch.enabled}
|
||||
onClick={() => handleConnect(ch.id)}
|
||||
onClick={() => handleConnect(ch.id, ch.channel_type)}
|
||||
>
|
||||
{isLoading ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" />
|
||||
@@ -327,6 +356,15 @@ export function ChannelListTab() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{qrcodeChannelId !== null && (
|
||||
<WeixinQrcodeDialog
|
||||
open
|
||||
channelId={qrcodeChannelId}
|
||||
onOpenChange={(open) => !open && setQrcodeChannelId(null)}
|
||||
onAuthSuccess={handleWeixinAuthSuccess}
|
||||
/>
|
||||
)}
|
||||
|
||||
<AlertDialog
|
||||
open={!!deleteTarget}
|
||||
onOpenChange={(open) => !open && setDeleteTarget(null)}
|
||||
|
||||
@@ -44,6 +44,7 @@ export function EditChatChannelDialog({
|
||||
const [token, setToken] = useState("")
|
||||
const [chatId, setChatId] = useState(config.chat_id ?? "")
|
||||
const [appId, setAppId] = useState(config.app_id ?? "")
|
||||
const [baseUrl] = useState(config.base_url ?? "")
|
||||
const [dailyReportEnabled, setDailyReportEnabled] = useState(
|
||||
channel.daily_report_enabled
|
||||
)
|
||||
@@ -65,7 +66,7 @@ export function EditChatChannelDialog({
|
||||
setError(t("nameRequired"))
|
||||
return
|
||||
}
|
||||
if (!chatId.trim()) {
|
||||
if (channel.channel_type !== "weixin" && !chatId.trim()) {
|
||||
setError(t("chatIdRequired"))
|
||||
return
|
||||
}
|
||||
@@ -74,9 +75,11 @@ export function EditChatChannelDialog({
|
||||
setError(null)
|
||||
try {
|
||||
const configJson =
|
||||
channel.channel_type === "lark"
|
||||
? JSON.stringify({ app_id: appId, chat_id: chatId })
|
||||
: JSON.stringify({ chat_id: chatId })
|
||||
channel.channel_type === "weixin"
|
||||
? JSON.stringify({ base_url: baseUrl })
|
||||
: channel.channel_type === "lark"
|
||||
? JSON.stringify({ app_id: appId, chat_id: chatId })
|
||||
: JSON.stringify({ chat_id: chatId })
|
||||
|
||||
await updateChatChannel({
|
||||
id: channel.id,
|
||||
@@ -105,6 +108,7 @@ export function EditChatChannelDialog({
|
||||
chatId,
|
||||
channel,
|
||||
appId,
|
||||
baseUrl,
|
||||
dailyReportEnabled,
|
||||
dailyReportTime,
|
||||
onOpenChange,
|
||||
@@ -140,32 +144,45 @@ export function EditChatChannelDialog({
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium">
|
||||
{channel.channel_type === "telegram" ? "Bot Token" : "App Secret"}
|
||||
</label>
|
||||
<Input
|
||||
type="password"
|
||||
value={token}
|
||||
onChange={(e) => setToken(e.target.value)}
|
||||
placeholder={
|
||||
hasToken ? t("tokenPlaceholderKeep") : t("tokenRequired")
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
{channel.channel_type !== "weixin" && (
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium">
|
||||
{channel.channel_type === "telegram"
|
||||
? "Bot Token"
|
||||
: "App Secret"}
|
||||
</label>
|
||||
<Input
|
||||
type="password"
|
||||
value={token}
|
||||
onChange={(e) => setToken(e.target.value)}
|
||||
placeholder={
|
||||
hasToken ? t("tokenPlaceholderKeep") : t("tokenRequired")
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium">Chat ID</label>
|
||||
<Input
|
||||
value={chatId}
|
||||
onChange={(e) => setChatId(e.target.value)}
|
||||
placeholder={
|
||||
channel.channel_type === "telegram"
|
||||
? "-100123456789"
|
||||
: "oc_xxxxx"
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
{channel.channel_type !== "weixin" && (
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium">Chat ID</label>
|
||||
<Input
|
||||
value={chatId}
|
||||
onChange={(e) => setChatId(e.target.value)}
|
||||
placeholder={
|
||||
channel.channel_type === "telegram"
|
||||
? "-100123456789"
|
||||
: "oc_xxxxx"
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{channel.channel_type === "weixin" && baseUrl && (
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium">Base URL</label>
|
||||
<Input value={baseUrl} disabled />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<label className="text-xs font-medium">{t("dailyReport")}</label>
|
||||
|
||||
206
src/components/settings/weixin-qrcode-dialog.tsx
Normal file
206
src/components/settings/weixin-qrcode-dialog.tsx
Normal file
@@ -0,0 +1,206 @@
|
||||
"use client"
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from "react"
|
||||
import { ExternalLink, Loader2, RefreshCw } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog"
|
||||
import { weixinGetQrcode, weixinCheckQrcode } from "@/lib/api"
|
||||
|
||||
interface WeixinQrcodeDialogProps {
|
||||
open: boolean
|
||||
channelId: number
|
||||
onOpenChange: (open: boolean) => void
|
||||
onAuthSuccess: (channelId: number) => void
|
||||
}
|
||||
|
||||
function WeixinQrcodeContent({
|
||||
channelId,
|
||||
onAuthSuccess,
|
||||
onClose,
|
||||
}: {
|
||||
channelId: number
|
||||
onAuthSuccess: (channelId: number) => void
|
||||
onClose: () => void
|
||||
}) {
|
||||
const t = useTranslations("ChatChannelSettings")
|
||||
const [qrcodeImg, setQrcodeImg] = useState<string | null>(null)
|
||||
const [qrcodeUrl, setQrcodeUrl] = useState<string | null>(null)
|
||||
const [imgFailed, setImgFailed] = useState(false)
|
||||
const [qrcodeId, setQrcodeId] = useState<string | null>(null)
|
||||
const [status, setStatus] = useState<"loading" | "waiting" | "expired">(
|
||||
"loading"
|
||||
)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const pollingRef = useRef<ReturnType<typeof setInterval> | null>(null)
|
||||
|
||||
const stopPolling = useCallback(() => {
|
||||
if (pollingRef.current) {
|
||||
clearInterval(pollingRef.current)
|
||||
pollingRef.current = null
|
||||
}
|
||||
}, [])
|
||||
|
||||
const fetchQrcode = useCallback(async () => {
|
||||
setStatus("loading")
|
||||
setError(null)
|
||||
setQrcodeImg(null)
|
||||
setQrcodeUrl(null)
|
||||
setImgFailed(false)
|
||||
setQrcodeId(null)
|
||||
stopPolling()
|
||||
|
||||
try {
|
||||
const result = await weixinGetQrcode()
|
||||
setQrcodeId(result.qrcode_id)
|
||||
|
||||
if (result.qrcode_img_content) {
|
||||
const raw = result.qrcode_img_content
|
||||
// Keep the original URL for fallback link
|
||||
if (raw.startsWith("http")) {
|
||||
setQrcodeUrl(raw)
|
||||
}
|
||||
const imgSrc = raw.startsWith("data:")
|
||||
? raw
|
||||
: raw.startsWith("http")
|
||||
? raw
|
||||
: `data:image/png;base64,${raw}`
|
||||
setQrcodeImg(imgSrc)
|
||||
}
|
||||
|
||||
setStatus("waiting")
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
setError(msg)
|
||||
setStatus("expired")
|
||||
}
|
||||
}, [stopPolling])
|
||||
|
||||
// Fetch QR code on mount + cleanup polling on unmount
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect -- initial data fetch on mount
|
||||
fetchQrcode()
|
||||
return () => stopPolling()
|
||||
}, [fetchQrcode, stopPolling])
|
||||
|
||||
// Start polling when we have a qrcodeId
|
||||
useEffect(() => {
|
||||
if (!qrcodeId || status !== "waiting") return
|
||||
|
||||
pollingRef.current = setInterval(async () => {
|
||||
try {
|
||||
const result = await weixinCheckQrcode(channelId, qrcodeId)
|
||||
if (result.status === "confirmed") {
|
||||
stopPolling()
|
||||
onAuthSuccess(channelId)
|
||||
onClose()
|
||||
} else if (result.status === "expired") {
|
||||
stopPolling()
|
||||
setStatus("expired")
|
||||
}
|
||||
} catch {
|
||||
// Polling error — keep trying
|
||||
}
|
||||
}, 2000)
|
||||
|
||||
return () => stopPolling()
|
||||
}, [qrcodeId, status, channelId, stopPolling, onAuthSuccess, onClose])
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-4 py-4">
|
||||
<p className="text-sm text-muted-foreground text-center">
|
||||
{t("weixinScanDescription")}
|
||||
</p>
|
||||
|
||||
{status === "loading" && (
|
||||
<div className="flex h-48 w-48 items-center justify-center">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{status === "waiting" && qrcodeImg && (
|
||||
<>
|
||||
{!imgFailed ? (
|
||||
<>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img
|
||||
src={qrcodeImg}
|
||||
alt="WeChat QR Code"
|
||||
className="h-48 w-48 rounded-md"
|
||||
referrerPolicy="no-referrer"
|
||||
onError={() => setImgFailed(true)}
|
||||
/>
|
||||
</>
|
||||
) : qrcodeUrl ? (
|
||||
<a
|
||||
href={qrcodeUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex h-48 w-48 flex-col items-center justify-center gap-2 rounded-md border border-dashed text-sm text-muted-foreground hover:bg-muted"
|
||||
>
|
||||
<ExternalLink className="h-6 w-6" />
|
||||
{t("weixinOpenQrcode")}
|
||||
</a>
|
||||
) : null}
|
||||
<p className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<Loader2 className="h-3 w-3 animate-spin" />
|
||||
{t("weixinWaitingScan")}
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
|
||||
{status === "expired" && (
|
||||
<>
|
||||
<div className="flex h-48 w-48 items-center justify-center rounded-md bg-muted">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t("weixinQrcodeExpired")}
|
||||
</p>
|
||||
</div>
|
||||
<Button variant="outline" size="sm" onClick={fetchQrcode}>
|
||||
<RefreshCw className="h-3.5 w-3.5 mr-1" />
|
||||
{t("weixinRefreshQrcode")}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
|
||||
{error && (
|
||||
<div className="rounded-md border border-red-500/30 bg-red-500/5 px-3 py-2 text-xs text-red-400">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function WeixinQrcodeDialog({
|
||||
open,
|
||||
channelId,
|
||||
onOpenChange,
|
||||
onAuthSuccess,
|
||||
}: WeixinQrcodeDialogProps) {
|
||||
const t = useTranslations("ChatChannelSettings")
|
||||
const handleClose = useCallback(() => onOpenChange(false), [onOpenChange])
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{t("weixinScanTitle")}</DialogTitle>
|
||||
</DialogHeader>
|
||||
{open && (
|
||||
<WeixinQrcodeContent
|
||||
channelId={channelId}
|
||||
onAuthSuccess={onAuthSuccess}
|
||||
onClose={handleClose}
|
||||
/>
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -1687,6 +1687,7 @@
|
||||
"channelNamePlaceholder": "بوت Telegram الخاص بي",
|
||||
"channelType": "نوع القناة",
|
||||
"lark": "Lark (Feishu)",
|
||||
"weixin": "WeChat",
|
||||
"dailyReport": "التقرير اليومي",
|
||||
"dailyReportTime": "وقت التقرير",
|
||||
"nameRequired": "اسم القناة مطلوب.",
|
||||
@@ -1713,6 +1714,12 @@
|
||||
"editChannel": "تعديل القناة",
|
||||
"editSuccess": "تم تحديث القناة.",
|
||||
"tokenPlaceholderKeep": "اتركه فارغاً للاحتفاظ بالقيمة الحالية",
|
||||
"weixinScanTitle": "مسح رمز QR",
|
||||
"weixinScanDescription": "افتح WeChat وامسح رمز QR للاتصال.",
|
||||
"weixinQrcodeExpired": "انتهت صلاحية رمز QR.",
|
||||
"weixinRefreshQrcode": "تحديث",
|
||||
"weixinWaitingScan": "في انتظار المسح...",
|
||||
"weixinOpenQrcode": "فتح رمز QR في المتصفح",
|
||||
"connect": "اتصال",
|
||||
"disconnect": "قطع الاتصال",
|
||||
"test": "اختبار الاتصال",
|
||||
|
||||
@@ -1687,6 +1687,7 @@
|
||||
"channelNamePlaceholder": "Mein Telegram Bot",
|
||||
"channelType": "Kanaltyp",
|
||||
"lark": "Lark (Feishu)",
|
||||
"weixin": "WeChat",
|
||||
"dailyReport": "Tagesbericht",
|
||||
"dailyReportTime": "Berichtszeit",
|
||||
"nameRequired": "Kanalname ist erforderlich.",
|
||||
@@ -1713,6 +1714,12 @@
|
||||
"editChannel": "Kanal bearbeiten",
|
||||
"editSuccess": "Kanal aktualisiert.",
|
||||
"tokenPlaceholderKeep": "Leer lassen, um aktuellen Wert beizubehalten",
|
||||
"weixinScanTitle": "QR-Code scannen",
|
||||
"weixinScanDescription": "Öffnen Sie WeChat und scannen Sie den QR-Code, um eine Verbindung herzustellen.",
|
||||
"weixinQrcodeExpired": "QR-Code abgelaufen.",
|
||||
"weixinRefreshQrcode": "Aktualisieren",
|
||||
"weixinWaitingScan": "Warten auf Scan...",
|
||||
"weixinOpenQrcode": "QR-Code im Browser öffnen",
|
||||
"connect": "Verbinden",
|
||||
"disconnect": "Trennen",
|
||||
"test": "Verbindung testen",
|
||||
|
||||
@@ -1687,6 +1687,7 @@
|
||||
"channelNamePlaceholder": "My Telegram Bot",
|
||||
"channelType": "Channel Type",
|
||||
"lark": "Lark (Feishu)",
|
||||
"weixin": "WeChat",
|
||||
"dailyReport": "Daily Report",
|
||||
"dailyReportTime": "Report Time",
|
||||
"nameRequired": "Channel name is required.",
|
||||
@@ -1713,6 +1714,12 @@
|
||||
"editChannel": "Edit Channel",
|
||||
"editSuccess": "Channel updated.",
|
||||
"tokenPlaceholderKeep": "Leave blank to keep current",
|
||||
"weixinScanTitle": "Scan QR Code",
|
||||
"weixinScanDescription": "Open WeChat and scan the QR code to connect.",
|
||||
"weixinQrcodeExpired": "QR code expired.",
|
||||
"weixinRefreshQrcode": "Refresh",
|
||||
"weixinWaitingScan": "Waiting for scan...",
|
||||
"weixinOpenQrcode": "Open QR code in browser",
|
||||
"connect": "Connect",
|
||||
"disconnect": "Disconnect",
|
||||
"test": "Test Connection",
|
||||
|
||||
@@ -1687,6 +1687,7 @@
|
||||
"channelNamePlaceholder": "Mi bot de Telegram",
|
||||
"channelType": "Tipo de canal",
|
||||
"lark": "Lark (Feishu)",
|
||||
"weixin": "WeChat",
|
||||
"dailyReport": "Informe diario",
|
||||
"dailyReportTime": "Hora del informe",
|
||||
"nameRequired": "El nombre del canal es obligatorio.",
|
||||
@@ -1713,6 +1714,12 @@
|
||||
"editChannel": "Editar canal",
|
||||
"editSuccess": "Canal actualizado.",
|
||||
"tokenPlaceholderKeep": "Dejar vacío para mantener actual",
|
||||
"weixinScanTitle": "Escanear código QR",
|
||||
"weixinScanDescription": "Abra WeChat y escanee el código QR para conectarse.",
|
||||
"weixinQrcodeExpired": "El código QR ha expirado.",
|
||||
"weixinRefreshQrcode": "Actualizar",
|
||||
"weixinWaitingScan": "Esperando escaneo...",
|
||||
"weixinOpenQrcode": "Abrir código QR en el navegador",
|
||||
"connect": "Conectar",
|
||||
"disconnect": "Desconectar",
|
||||
"test": "Probar conexión",
|
||||
|
||||
@@ -1687,6 +1687,7 @@
|
||||
"channelNamePlaceholder": "Mon bot Telegram",
|
||||
"channelType": "Type de canal",
|
||||
"lark": "Lark (Feishu)",
|
||||
"weixin": "WeChat",
|
||||
"dailyReport": "Rapport quotidien",
|
||||
"dailyReportTime": "Heure du rapport",
|
||||
"nameRequired": "Le nom du canal est requis.",
|
||||
@@ -1713,6 +1714,12 @@
|
||||
"editChannel": "Modifier le canal",
|
||||
"editSuccess": "Canal mis à jour.",
|
||||
"tokenPlaceholderKeep": "Laisser vide pour conserver l'actuel",
|
||||
"weixinScanTitle": "Scanner le QR code",
|
||||
"weixinScanDescription": "Ouvrez WeChat et scannez le QR code pour vous connecter.",
|
||||
"weixinQrcodeExpired": "QR code expiré.",
|
||||
"weixinRefreshQrcode": "Actualiser",
|
||||
"weixinWaitingScan": "En attente du scan...",
|
||||
"weixinOpenQrcode": "Ouvrir le QR code dans le navigateur",
|
||||
"connect": "Connecter",
|
||||
"disconnect": "Déconnecter",
|
||||
"test": "Tester la connexion",
|
||||
|
||||
@@ -1687,6 +1687,7 @@
|
||||
"channelNamePlaceholder": "My Telegram Bot",
|
||||
"channelType": "チャンネルタイプ",
|
||||
"lark": "Lark(飛書)",
|
||||
"weixin": "WeChat",
|
||||
"dailyReport": "デイリーレポート",
|
||||
"dailyReportTime": "送信時刻",
|
||||
"nameRequired": "チャンネル名を入力してください。",
|
||||
@@ -1713,6 +1714,12 @@
|
||||
"editChannel": "チャンネルを編集",
|
||||
"editSuccess": "チャンネルを更新しました。",
|
||||
"tokenPlaceholderKeep": "空欄で現在の値を維持",
|
||||
"weixinScanTitle": "QRコードをスキャン",
|
||||
"weixinScanDescription": "WeChatを開いてQRコードをスキャンして接続してください。",
|
||||
"weixinQrcodeExpired": "QRコードの有効期限が切れました。",
|
||||
"weixinRefreshQrcode": "更新",
|
||||
"weixinWaitingScan": "スキャン待ち...",
|
||||
"weixinOpenQrcode": "ブラウザでQRコードを開く",
|
||||
"connect": "接続",
|
||||
"disconnect": "切断",
|
||||
"test": "接続テスト",
|
||||
|
||||
@@ -1687,6 +1687,7 @@
|
||||
"channelNamePlaceholder": "내 Telegram 봇",
|
||||
"channelType": "채널 유형",
|
||||
"lark": "Lark (飛書)",
|
||||
"weixin": "WeChat",
|
||||
"dailyReport": "일일 리포트",
|
||||
"dailyReportTime": "발송 시간",
|
||||
"nameRequired": "채널 이름을 입력하세요.",
|
||||
@@ -1713,6 +1714,12 @@
|
||||
"editChannel": "채널 편집",
|
||||
"editSuccess": "채널이 업데이트되었습니다.",
|
||||
"tokenPlaceholderKeep": "비워두면 현재 값 유지",
|
||||
"weixinScanTitle": "QR 코드 스캔",
|
||||
"weixinScanDescription": "WeChat을 열고 QR 코드를 스캔하여 연결하세요.",
|
||||
"weixinQrcodeExpired": "QR 코드가 만료되었습니다.",
|
||||
"weixinRefreshQrcode": "새로고침",
|
||||
"weixinWaitingScan": "스캔 대기 중...",
|
||||
"weixinOpenQrcode": "브라우저에서 QR 코드 열기",
|
||||
"connect": "연결",
|
||||
"disconnect": "연결 해제",
|
||||
"test": "연결 테스트",
|
||||
|
||||
@@ -1687,6 +1687,7 @@
|
||||
"channelNamePlaceholder": "Meu bot do Telegram",
|
||||
"channelType": "Tipo de canal",
|
||||
"lark": "Lark (Feishu)",
|
||||
"weixin": "WeChat",
|
||||
"dailyReport": "Relatório diário",
|
||||
"dailyReportTime": "Horário do relatório",
|
||||
"nameRequired": "O nome do canal é obrigatório.",
|
||||
@@ -1713,6 +1714,12 @@
|
||||
"editChannel": "Editar canal",
|
||||
"editSuccess": "Canal atualizado.",
|
||||
"tokenPlaceholderKeep": "Deixar em branco para manter atual",
|
||||
"weixinScanTitle": "Escanear código QR",
|
||||
"weixinScanDescription": "Abra o WeChat e escaneie o código QR para conectar.",
|
||||
"weixinQrcodeExpired": "Código QR expirado.",
|
||||
"weixinRefreshQrcode": "Atualizar",
|
||||
"weixinWaitingScan": "Aguardando escaneamento...",
|
||||
"weixinOpenQrcode": "Abrir código QR no navegador",
|
||||
"connect": "Conectar",
|
||||
"disconnect": "Desconectar",
|
||||
"test": "Testar conexão",
|
||||
|
||||
@@ -1687,6 +1687,7 @@
|
||||
"channelNamePlaceholder": "我的 Telegram 机器人",
|
||||
"channelType": "渠道类型",
|
||||
"lark": "飞书",
|
||||
"weixin": "微信",
|
||||
"dailyReport": "每日报告",
|
||||
"dailyReportTime": "推送时间",
|
||||
"nameRequired": "请输入渠道名称。",
|
||||
@@ -1713,6 +1714,12 @@
|
||||
"editChannel": "编辑渠道",
|
||||
"editSuccess": "渠道已更新。",
|
||||
"tokenPlaceholderKeep": "留空保持不变",
|
||||
"weixinScanTitle": "扫码登录",
|
||||
"weixinScanDescription": "打开微信扫描二维码以连接。",
|
||||
"weixinQrcodeExpired": "二维码已过期。",
|
||||
"weixinRefreshQrcode": "刷新二维码",
|
||||
"weixinWaitingScan": "等待扫码...",
|
||||
"weixinOpenQrcode": "在浏览器中打开二维码",
|
||||
"connect": "连接",
|
||||
"disconnect": "断开",
|
||||
"test": "测试连接",
|
||||
|
||||
@@ -1687,6 +1687,7 @@
|
||||
"channelNamePlaceholder": "我的 Telegram 機器人",
|
||||
"channelType": "頻道類型",
|
||||
"lark": "飛書",
|
||||
"weixin": "微信",
|
||||
"dailyReport": "每日報告",
|
||||
"dailyReportTime": "推送時間",
|
||||
"nameRequired": "請輸入頻道名稱。",
|
||||
@@ -1713,6 +1714,12 @@
|
||||
"editChannel": "編輯頻道",
|
||||
"editSuccess": "頻道已更新。",
|
||||
"tokenPlaceholderKeep": "留空保持不變",
|
||||
"weixinScanTitle": "掃碼登入",
|
||||
"weixinScanDescription": "打開微信掃描二維碼以連接。",
|
||||
"weixinQrcodeExpired": "二維碼已過期。",
|
||||
"weixinRefreshQrcode": "重新整理",
|
||||
"weixinWaitingScan": "等待掃碼...",
|
||||
"weixinOpenQrcode": "在瀏覽器中打開二維碼",
|
||||
"connect": "連線",
|
||||
"disconnect": "斷開",
|
||||
"test": "測試連線",
|
||||
|
||||
@@ -1440,3 +1440,23 @@ export async function getChatMessageLanguage(): Promise<string> {
|
||||
export async function setChatMessageLanguage(language: string): Promise<void> {
|
||||
return getTransport().call("set_chat_message_language", { language })
|
||||
}
|
||||
|
||||
// ─── WeChat QR Code Auth ───
|
||||
|
||||
export async function weixinGetQrcode(): Promise<{
|
||||
qrcode_id: string
|
||||
qrcode_img_content: string
|
||||
}> {
|
||||
return getTransport().call("weixin_get_qrcode")
|
||||
}
|
||||
|
||||
export async function weixinCheckQrcode(
|
||||
channelId: number,
|
||||
qrcode: string
|
||||
): Promise<{
|
||||
status: string
|
||||
bot_token?: string
|
||||
base_url?: string
|
||||
}> {
|
||||
return getTransport().call("weixin_check_qrcode", { channelId, qrcode })
|
||||
}
|
||||
|
||||
@@ -850,7 +850,7 @@ export interface PreflightResult {
|
||||
|
||||
// ─── Chat Channels ───
|
||||
|
||||
export type ChannelType = "lark" | "telegram"
|
||||
export type ChannelType = "lark" | "telegram" | "weixin"
|
||||
|
||||
export type ChannelConnectionStatus =
|
||||
| "connected"
|
||||
|
||||
Reference in New Issue
Block a user