import { ExternalLinkIcon, ScissorsIcon } from "lucide-react";
import { Badge } from "@/components/ui/badge";
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
import { useInstance } from "@/contexts/InstanceContext";
import { WEB_CLIPPER_URL } from "@/lib/constants";
import { useTranslate } from "@/utils/i18n";
const GITHUB_COMMIT_URL_PREFIX = "https://github.com/usememos/memos/commit/";
const GITHUB_RELEASE_URL_PREFIX = "https://github.com/usememos/memos/releases/tag/v";
const DEFAULT_TITLE = "Memos";
const DEFAULT_TAGLINE = "Capture first. Keep it yours.";
const DEFAULT_LOGO = "/logo.webp";
const isCommitSha = (commit: string) => /^[0-9a-f]{7,40}$/i.test(commit);
const isSemver = (version: string) => /^\d+\.\d+\.\d+/.test(version);
const Chip = ({ href, children }: { href?: string; children: React.ReactNode }) => {
const className = "inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 font-mono text-xs text-muted-foreground";
if (href) {
return (
{children}
);
}
return {children};
};
const SectionLabel = ({ children }: { children: React.ReactNode }) => (
{children}
);
interface Props {
open: boolean;
onOpenChange: (open: boolean) => void;
}
const AboutDialog = ({ open, onOpenChange }: Props) => {
const t = useTranslate();
const { profile, generalSetting } = useInstance();
const customProfile = generalSetting.customProfile;
const instanceTitle = customProfile?.title || DEFAULT_TITLE;
const instanceTagline = customProfile?.description || DEFAULT_TAGLINE;
const instanceLogo = customProfile?.logoUrl || DEFAULT_LOGO;
const isCustomBranded = instanceTitle !== DEFAULT_TITLE;
const hasSemver = isSemver(profile.version);
const releaseUrl = hasSemver ? `${GITHUB_RELEASE_URL_PREFIX}${profile.version}` : "";
const versionLabel = hasSemver ? `v${profile.version}` : profile.version;
const hasCommitSha = isCommitSha(profile.commit);
const commitUrl = hasCommitSha ? `${GITHUB_COMMIT_URL_PREFIX}${profile.commit}` : "";
const shortCommit = hasCommitSha ? profile.commit.slice(0, 7) : "";
const buildRows: { label: string; value: React.ReactNode }[] = [];
if (profile.version) {
buildRows.push({ label: t("common.version"), value: {versionLabel} });
}
if (shortCommit) {
buildRows.push({ label: t("about.commit"), value: {shortCommit} });
}
buildRows.push({ label: t("about.license"), value: MIT });
if (isCustomBranded) {
buildRows.push({
label: t("about.distribution"),
value: {t("about.powered-by")},
});
}
const projectLinks = [
{ label: t("about.official-website"), note: t("about.official-website-note"), href: "https://usememos.com/" },
{ label: t("about.documents"), note: t("about.documents-note"), href: "https://usememos.com/docs" },
{ label: t("about.api-docs"), note: t("about.api-docs-note"), href: "https://usememos.com/docs/api" },
{
label: t("about.github-repository"),
note: t("about.github-repository-note"),
href: "https://github.com/usememos/memos",
},
{ label: t("about.web-clipper"), note: t("about.web-clipper-platforms"), href: WEB_CLIPPER_URL, icon: ScissorsIcon },
];
return (
);
};
export default AboutDialog;