mirror of
https://github.com/handsomezhuzhu/2fa-tool.git
synced 2026-04-18 22:32:53 +00:00
Compare commits
3 Commits
5ad17bcb63
...
b1be9aa5a4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1be9aa5a4 | ||
|
|
3055b781cc | ||
|
|
73fe5da3c1 |
@@ -49,16 +49,16 @@ A pure frontend TOTP two-factor authentication tool with multiple token import m
|
|||||||
|
|
||||||
**构建配置:**
|
**构建配置:**
|
||||||
|
|
||||||
```
|
\`\`\`
|
||||||
安装命令:npm install
|
安装命令:npm install
|
||||||
构建命令:npm run build
|
构建命令:npm run build
|
||||||
静态资源目录:out
|
静态资源目录:out
|
||||||
Node.js 版本:20.x 或 22.x
|
Node.js 版本:20.x 或 22.x
|
||||||
```
|
\`\`\`
|
||||||
|
|
||||||
### 本地开发
|
### 本地开发
|
||||||
|
|
||||||
```bash
|
\`\`\`bash
|
||||||
# 安装依赖
|
# 安装依赖
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ npm run dev
|
|||||||
|
|
||||||
# 构建
|
# 构建
|
||||||
npm run build
|
npm run build
|
||||||
```
|
\`\`\`
|
||||||
|
|
||||||
## Security / 安全说明
|
## Security / 安全说明
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type React from "react"
|
import type React from "react"
|
||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import { Geist, Geist_Mono } from "next/font/google"
|
import { Geist, Geist_Mono } from "next/font/google"
|
||||||
import { Analytics } from "@vercel/analytics/next"
|
|
||||||
import { ThemeProvider } from "@/components/theme-provider"
|
import { ThemeProvider } from "@/components/theme-provider"
|
||||||
import { LanguageProvider } from "@/lib/i18n"
|
import { LanguageProvider } from "@/lib/i18n"
|
||||||
import "./globals.css"
|
import "./globals.css"
|
||||||
@@ -36,7 +35,6 @@ export default function RootLayout({
|
|||||||
>
|
>
|
||||||
<LanguageProvider>{children}</LanguageProvider>
|
<LanguageProvider>{children}</LanguageProvider>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
<Analytics />
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
import type React from "react"
|
import type React from "react"
|
||||||
|
|
||||||
import { useState, useEffect, useRef, useCallback } from "react"
|
import { useState, useEffect, useRef, useCallback } from "react"
|
||||||
import jsQR from "jsqr"
|
|
||||||
import {
|
import {
|
||||||
Plus,
|
Plus,
|
||||||
Camera,
|
Camera,
|
||||||
@@ -450,7 +449,7 @@ export default function TwoFactorAuth() {
|
|||||||
|
|
||||||
if (!ctx) return
|
if (!ctx) return
|
||||||
|
|
||||||
const scan = () => {
|
const scan = async () => {
|
||||||
if (!streamRef.current) return
|
if (!streamRef.current) return
|
||||||
|
|
||||||
if (video.readyState === video.HAVE_ENOUGH_DATA) {
|
if (video.readyState === video.HAVE_ENOUGH_DATA) {
|
||||||
@@ -459,6 +458,7 @@ export default function TwoFactorAuth() {
|
|||||||
ctx.drawImage(video, 0, 0, canvas.width, canvas.height)
|
ctx.drawImage(video, 0, 0, canvas.width, canvas.height)
|
||||||
|
|
||||||
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height)
|
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height)
|
||||||
|
const jsQR = (await import("jsqr")).default
|
||||||
const code = jsQR(imageData.data, imageData.width, imageData.height, {
|
const code = jsQR(imageData.data, imageData.width, imageData.height, {
|
||||||
inversionAttempts: "dontInvert",
|
inversionAttempts: "dontInvert",
|
||||||
})
|
})
|
||||||
@@ -494,7 +494,7 @@ export default function TwoFactorAuth() {
|
|||||||
|
|
||||||
const img = new Image()
|
const img = new Image()
|
||||||
img.crossOrigin = "anonymous"
|
img.crossOrigin = "anonymous"
|
||||||
img.onload = () => {
|
img.onload = async () => {
|
||||||
const canvas = document.createElement("canvas")
|
const canvas = document.createElement("canvas")
|
||||||
canvas.width = img.width
|
canvas.width = img.width
|
||||||
canvas.height = img.height
|
canvas.height = img.height
|
||||||
@@ -503,6 +503,7 @@ export default function TwoFactorAuth() {
|
|||||||
|
|
||||||
ctx.drawImage(img, 0, 0)
|
ctx.drawImage(img, 0, 0)
|
||||||
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height)
|
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height)
|
||||||
|
const jsQR = (await import("jsqr")).default
|
||||||
const code = jsQR(imageData.data, imageData.width, imageData.height, {
|
const code = jsQR(imageData.data, imageData.width, imageData.height, {
|
||||||
inversionAttempts: "attemptBoth",
|
inversionAttempts: "attemptBoth",
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user