first commit
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Sync to CNB / sync (push) Has been cancelled
Delete old workflow runs / del_runs (push) Has been cancelled
Upstream Sync / Sync latest commits from upstream repo (push) Has been cancelled

This commit is contained in:
2026-01-30 16:57:44 +08:00
commit 3d175d75af
119 changed files with 35834 additions and 0 deletions

View File

@@ -0,0 +1,172 @@
"use client";
import { useState, useEffect } from "react";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { toast } from "sonner";
import { Car, Phone, Bell, Info } from "lucide-react";
export default function MoveCarDisplay() {
const [plateNumber, setPlateNumber] = useState("");
const [phoneNumber, setPhoneNumber] = useState("");
const [token, setToken] = useState("");
const [uid, setUid] = useState("");
const [newEnergy, setNewEnergy] = useState(false);
useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);
setPlateNumber(urlParams.get("plateNumber") || "");
setPhoneNumber(urlParams.get("phoneNumber") || "");
setToken(urlParams.get("token") || "");
setUid(urlParams.get("uid") || "");
setNewEnergy(urlParams.get("new") === "true");
}, []);
const notifyOwner = () => {
const currentTime = new Date().getTime();
const lastNotifyTimeKey = "lastNotifyTime" + plateNumber;
const lastNotifyTime = localStorage.getItem(lastNotifyTimeKey);
const timeDifference = lastNotifyTime
? (currentTime - parseInt(lastNotifyTime)) / 1000
: 0;
if (lastNotifyTime && timeDifference < 60) {
toast.warning("您已发送过通知请1分钟后再次尝试。");
return;
}
const promise = fetch("https://wxpusher.zjiecode.com/api/send/message", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
appToken: token,
content: "您好,有人需要您挪车,请及时处理。",
contentType: 1,
uids: [uid],
}),
})
.then((response) => response.json())
.then((data) => {
if (data.code === 1000) {
localStorage.setItem(lastNotifyTimeKey, currentTime.toString());
return "通知已发送!";
} else {
throw new Error("通知发送失败");
}
});
toast.promise(promise, {
loading: '正在发送通知...',
success: (data) => data,
error: '通知发送失败,请稍后重试',
});
};
const callNumber = () => {
window.location.href = "tel:" + phoneNumber;
};
return (
<div className="space-y-4 max-w-md mx-auto pt-4 px-2">
{/* 车牌展示区域 */}
<div className="flex justify-center py-2">
<div
className={`relative flex h-32 w-full items-center justify-center overflow-hidden rounded-lg border-[3px] shadow-xl ${
newEnergy
? "border-black/80 bg-linear-to-b from-[#F0F3F5] to-[#42C063] text-black"
: "border-white bg-[#003399] text-white"
}`}
>
{/* 装饰性反光效果 */}
<div className="pointer-events-none absolute inset-0 bg-linear-to-br from-white/20 to-transparent opacity-50" />
{/* 车牌边框内饰线 (仅蓝牌显示) */}
{!newEnergy && (
<div className="absolute inset-1 rounded-md border border-white/50" />
)}
<div className="relative z-10 flex items-center gap-1 font-mono text-5xl font-bold tracking-widest">
<span>{plateNumber.slice(0, 2)}</span>
{newEnergy ? (
<span className="mx-1 h-2 w-2 rounded-full bg-current opacity-20" />
) : (
<span className="mx-2 h-2 w-2 rounded-full bg-current opacity-80" />
)}
<span>{plateNumber.slice(2)}</span>
</div>
{/* 新能源标志水印 (仅绿牌显示) */}
{newEnergy && (
<div className="absolute -bottom-6 -right-6 rotate-12 opacity-10">
<Car className="h-24 w-24" />
</div>
)}
</div>
</div>
{/* 车辆信息 */}
<Card>
<CardHeader className="pb-2">
<CardTitle className="text-sm font-medium flex items-center gap-2 text-muted-foreground">
<Info className="h-4 w-4" />
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="grid grid-cols-3 gap-2 text-sm">
<div className="text-muted-foreground"></div>
<div className="col-span-2 font-medium"></div>
<div className="text-muted-foreground"></div>
<div className="col-span-2 font-medium font-mono">{plateNumber}</div>
<div className="text-muted-foreground"></div>
<div className="col-span-2 font-medium font-mono">{phoneNumber}</div>
</div>
</CardContent>
</Card>
{/* 操作按钮 */}
<Card className="border-t-4 border-t-primary/20">
<CardHeader>
<CardTitle className="text-center"></CardTitle>
</CardHeader>
<CardContent className="space-y-3">
{uid && token && (
<Button
size="lg"
className={`w-full gap-2 text-lg h-14 ${
newEnergy
? "bg-emerald-600 hover:bg-emerald-700 shadow-emerald-200 dark:shadow-none"
: "bg-blue-600 hover:bg-blue-700 shadow-blue-200 dark:shadow-none"
} shadow-xl transition-all hover:scale-[1.02] active:scale-[0.98]`}
onClick={notifyOwner}
>
<Bell className="h-5 w-5" />
</Button>
)}
<Button
size="lg"
variant={uid && token ? "outline" : "default"}
className={`w-full gap-2 text-lg h-14 ${!(uid && token) ? (newEnergy
? "bg-emerald-600 hover:bg-emerald-700 shadow-emerald-200 dark:shadow-none shadow-xl transition-all hover:scale-[1.02] active:scale-[0.98]"
: "bg-blue-600 hover:bg-blue-700 shadow-blue-200 dark:shadow-none shadow-xl transition-all hover:scale-[1.02] active:scale-[0.98]") : ""}`}
onClick={callNumber}
>
<Phone className="h-5 w-5" />
</Button>
</CardContent>
</Card>
{/* 温馨提示 */}
<div className="px-4 py-2 bg-muted/50 rounded-lg text-xs text-center text-muted-foreground">
💡
</div>
</div>
);
}

347
app/move-car/page.tsx Normal file
View File

@@ -0,0 +1,347 @@
"use client";
import { useState } from "react";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import * as z from "zod";
import { QRCodeSVG } from "qrcode.react";
import { Car, MessageSquare, QrCode, Info, Copy, Zap, RotateCcw } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { toast } from "sonner";
const formSchema = z.object({
plateNumber: z.string().min(1, "请输入车牌号"),
phoneNumber: z
.string()
.min(1, "请输入联系电话")
.regex(/^1[3-9]\d{9}$/, "请输入有效的手机号"),
token: z.string(),
uid: z.string(),
newEnergy: z.boolean(),
});
type FormValues = z.infer<typeof formSchema>;
export default function MoveCar() {
const [generatedUrl, setGeneratedUrl] = useState("");
const form = useForm<FormValues>({
resolver: zodResolver(formSchema),
defaultValues: {
plateNumber: "",
phoneNumber: "",
token: "",
uid: "",
newEnergy: false,
},
});
const onSubmit = (values: FormValues) => {
const url = new URL(window.location.href + "/display");
url.searchParams.append("plateNumber", values.plateNumber);
url.searchParams.append("phoneNumber", values.phoneNumber);
if (values.token) url.searchParams.append("token", values.token);
if (values.uid) url.searchParams.append("uid", values.uid);
if (values.newEnergy) url.searchParams.append("new", "true");
setGeneratedUrl(url.toString());
toast.success("码牌生成成功");
};
const copyUrl = async () => {
try {
await navigator.clipboard.writeText(generatedUrl);
toast.success("链接已复制到剪贴板");
} catch {
toast.error("复制失败");
}
};
const resetForm = () => {
form.reset();
setGeneratedUrl("");
};
return (
<div className="space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500">
{/* Page Header */}
<div className="flex items-center space-x-4 border-b pb-4">
<div className="flex h-12 w-12 items-center justify-center rounded-xl bg-linear-to-br from-amber-400 to-amber-600 shadow-lg">
<Car className="h-6 w-6 text-white" />
</div>
<div>
<h1 className="text-2xl font-bold tracking-tight"></h1>
<p className="text-muted-foreground">
</p>
</div>
</div>
<div className="grid gap-6 lg:grid-cols-2">
{/* Left: Form */}
<div>
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2 text-base">
<Car className="h-4 w-4" />
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<FormField
control={form.control}
name="plateNumber"
render={({ field }) => (
<FormItem>
<FormLabel></FormLabel>
<FormControl>
<Input placeholder="如京A12345" {...field} className="text-lg" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="phoneNumber"
render={({ field }) => (
<FormItem>
<FormLabel></FormLabel>
<FormControl>
<Input placeholder="如13800138000" {...field} className="text-lg" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="newEnergy"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-4 shadow-sm">
<div className="space-y-0.5">
<FormLabel className="text-base flex items-center gap-2">
<Zap className="h-4 w-4 text-emerald-500" />
</FormLabel>
<FormDescription>
</FormDescription>
</div>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
</FormItem>
)}
/>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2 text-base">
<MessageSquare className="h-4 w-4" />
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<Alert className="bg-blue-50/50 dark:bg-blue-950/20 text-blue-900 dark:text-blue-200 border-blue-200 dark:border-blue-800">
<Info className="h-4 w-4" />
<AlertTitle></AlertTitle>
<AlertDescription>
</AlertDescription>
</Alert>
<div className="grid grid-cols-2 gap-4">
<FormField
control={form.control}
name="token"
render={({ field }) => (
<FormItem>
<FormLabel className="flex items-center gap-1">
Token
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<Info className="h-3 w-3 text-muted-foreground" />
</TooltipTrigger>
<TooltipContent>
<p>WxPusher的应用Token</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</FormLabel>
<FormControl>
<Input placeholder="应用Token" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="uid"
render={({ field }) => (
<FormItem>
<FormLabel className="flex items-center gap-1">
UID
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<Info className="h-3 w-3 text-muted-foreground" />
</TooltipTrigger>
<TooltipContent>
<p>UID</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</FormLabel>
<FormControl>
<Input placeholder="用户UID" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="text-xs text-muted-foreground text-right">
<a
href="https://wxpusher.zjiecode.com/docs/#/"
target="_blank"
rel="noopener noreferrer"
className="text-primary hover:underline ml-1"
>
</a>
</div>
</CardContent>
</Card>
<div className="flex gap-4">
<Button type="submit" size="lg" className="flex-1 gap-2">
<QrCode className="h-4 w-4" />
</Button>
<Button type="button" variant="outline" size="lg" onClick={resetForm} className="gap-2">
<RotateCcw className="h-4 w-4" />
</Button>
</div>
</form>
</Form>
</div>
{/* Right: Preview */}
<div>
<Card className="h-full flex flex-col">
<CardHeader>
<CardTitle className="flex items-center gap-2 text-base">
<QrCode className="h-4 w-4" />
{generatedUrl ? "生成成功" : "预览区域"}
</CardTitle>
</CardHeader>
<CardContent className="flex-1 flex flex-col justify-center">
{generatedUrl ? (
<div className="space-y-6">
<Alert variant="default" className="border-emerald-200 bg-emerald-50 dark:bg-emerald-950/20 text-emerald-900 dark:text-emerald-200">
<Info className="h-4 w-4" />
<AlertTitle></AlertTitle>
<AlertDescription>
</AlertDescription>
</Alert>
<div className="flex flex-col items-center gap-4 p-8 bg-white rounded-xl shadow-sm border mx-auto">
<QRCodeSVG value={generatedUrl} size={200} />
<span className="text-sm text-muted-foreground"></span>
</div>
<div className="space-y-2">
<span className="text-sm font-medium"></span>
<div className="p-3 bg-muted rounded-md break-all text-xs font-mono">
{generatedUrl}
</div>
<Button onClick={copyUrl} className="w-full gap-2" variant="secondary">
<Copy className="h-4 w-4" />
</Button>
</div>
</div>
) : (
<div className="flex flex-col items-center justify-center py-12 text-muted-foreground space-y-4">
<QrCode className="h-16 w-16 opacity-20" />
<p></p>
</div>
)}
</CardContent>
</Card>
</div>
</div>
{/* Info Card */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2 text-base">
<span className="text-xl">💡</span> 使
</CardTitle>
</CardHeader>
<CardContent>
<div className="grid gap-6 md:grid-cols-3">
<div className="space-y-2">
<h4 className="font-medium text-sm"></h4>
<ul className="list-disc pl-4 text-xs text-muted-foreground space-y-1">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
<div className="space-y-2">
<h4 className="font-medium text-sm">使</h4>
<ol className="list-decimal pl-4 text-xs text-muted-foreground space-y-1">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ol>
</div>
<div className="space-y-2">
<h4 className="font-medium text-sm"></h4>
<ul className="list-disc pl-4 text-xs text-muted-foreground space-y-1">
<li>访 WxPusher </li>
<li> Token UID</li>
<li></li>
<li></li>
</ul>
</div>
</div>
</CardContent>
</Card>
</div>
);
}