js weekly articles

Posted on:March 1, 2024 at 02:31 PM
预计阅读时长:3 min read 字数:565

按周更新

也可能按月,反正会持续更新

目录

daily

2024-2-23=> 2024-2-29

2024-05-26=>2024-05-31

2024-06-01=>2024-06-07

简单使用
npm install --save signature_pad
import { useEffect, useRef } from "react";
import SignaturePad from "signature_pad";
import { Button } from "@shadcn/ui/button";

const signaturePadDemo = () => {
  const canvasRef = useRef<HTMLCanvasElement>(null);
  let signaturePad: SignaturePad | null;
  useEffect(() => {
    const canvas = canvasRef.current;
    if (canvas) {
      signaturePad = new SignaturePad(canvasRef.current!, {
        backgroundColor: "rgb(255, 255, 255)",
      });
      console.log("signaturePad:", signaturePad);
      function resizeCanvas() {
        const ratio = Math.max(window.devicePixelRatio || 1, 1);
        canvas.width = canvas.offsetWidth * ratio;
        canvas.height = canvas.offsetHeight * ratio;
        canvas.getContext("2d").scale(ratio, ratio);
        signaturePad.clear();
      }
      resizeCanvas();
      addEventListener("resize", resizeCanvas);
    }
  });
  const downloadPng = () => {
    const data = signaturePad?.toDataURL();
    if (data) {
      const link = document.createElement("a");
      link.download = "signature.png";
      link.href = data;
      link.click();
    }
  };
  const downloadSvg = () => {
    const data = signaturePad?.toDataURL("image/svg+xml");
    if (data) {
      const link = document.createElement("a");
      link.download = "signature.svg";
      link.href = data;
      link.click();
    }
  };
  return (
    <>
      <canvas ref={canvasRef} className="w-full h-40"></canvas>
      <div className="ope flex gap-5 justify-center pt-2">
        <Button variant="outline" onClick={downloadPng}>
          下载png
        </Button>
        <Button variant="outline" onClick={downloadSvg}>
          下载svg
        </Button>
        <Button
          variant="outline"
          onClick={() => {
            signaturePad?.clear();
          }}
        >
          清空
        </Button>
      </div>
    </>
  );
};

export default signaturePadDemo;

源代码地址

2024-07-17=>2024-07-26

2024-08-02=>2024-08-18

Click to expand

2024-08-18=>2024-09-08

how to use
import 'react-tooltip/dist/react-tooltip.css'

import { Tooltip } from 'react-tooltip'

<a
  data-tooltip-id="my-tooltip"
  data-tooltip-content="Hello world!"
  data-tooltip-place="top"
>
  ◕‿‿◕
</a>

<Tooltip client:load id="my-tooltip" />

<a className="my-anchor-element">◕‿‿◕</a>
<a className="my-anchor-element">◕‿‿◕</a>
<a className="my-anchor-element">◕‿‿◕</a>

<Tooltip anchorSelect=".my-anchor-element" place="top">
  Hello world!
</Tooltip>

2024-09-08 13:41:26=>2024-10-11 10:58:29

v0 ai 初次使用

hello darkness my old friend, I’m coming to you now 👋 again

2024-10-11 10:58:29=>2024-12-11 17:55:24

2024-12-11 17:55:24=>********

emoji domain

others

基本信息
详细信息
ID
访问次数
状态
进度
1 页,
0

LLM

-MaxKB-基于大模型和 RAG 的知识库问答系统