lots change
This commit is contained in:
@@ -2,7 +2,7 @@ export const Footer = () => (
|
||||
<footer class="app-footer">
|
||||
<span>📩 xiadongliang88@163.com</span>
|
||||
<span>|</span>
|
||||
<span>📦 https://git.leonstack.com/owner</span>
|
||||
<span>📦 https://git.leonstack.com/xiadongliang</span>
|
||||
<span>|</span>
|
||||
<span>🌏 https://www.leonstack.com/</span>
|
||||
</footer>
|
||||
|
||||
@@ -4,6 +4,7 @@ import Modal from './Modal'
|
||||
import { message } from '../utils/toast'
|
||||
import type { HistoryItem } from '../preact'
|
||||
|
||||
|
||||
const formatDate = (timestamp: number) => {
|
||||
const date = new Date(timestamp * 1000)
|
||||
return date.toLocaleString('zh-CN', {
|
||||
@@ -64,7 +65,6 @@ const History = () => {
|
||||
message.error('currentId为空')
|
||||
return
|
||||
}
|
||||
// dfdfdf
|
||||
const result = await (window as any).go.backend.App.DeleteOneHistory(currentId)
|
||||
if (result.code === 0) {
|
||||
message.success('删除成功')
|
||||
@@ -109,7 +109,7 @@ const History = () => {
|
||||
{historyList.map((item: HistoryItem) =>
|
||||
<div key={item.id} class="history-card">
|
||||
<div class="card-left">
|
||||
<img src={`/images/${item.img}`} onClick={() => handleShowItem(item)} />
|
||||
<img src={`data:image/jpeg;base64,${item.img_data}`} onClick={() => handleShowItem(item)} />
|
||||
</div>
|
||||
<div class="card-right">
|
||||
<div class="right-top">
|
||||
|
||||
@@ -2,9 +2,11 @@ import { useState, useRef } from 'preact/hooks'
|
||||
import type { DetectResult } from '../preact'
|
||||
import { message } from '../utils/toast'
|
||||
|
||||
|
||||
const Main = () => {
|
||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||
const [fileSrc, setFileSrc] = useState<string>('')
|
||||
const [filename, setFilename] = useState<string>('')
|
||||
const [step, setStep] = useState<number>(0)
|
||||
const [detectResult, setDetectResult] = useState<DetectResult | null>(null)
|
||||
|
||||
@@ -46,7 +48,6 @@ const Main = () => {
|
||||
}
|
||||
|
||||
const handleFileChange = (e: Event) => {
|
||||
console.log('handleFileChange')
|
||||
const target = e.target as HTMLInputElement
|
||||
const file = target.files?.[0]
|
||||
if (file) {
|
||||
@@ -64,8 +65,8 @@ const Main = () => {
|
||||
file.name
|
||||
)
|
||||
if (result.code === 0) {
|
||||
console.log("rrr", result)
|
||||
setFileSrc(result.data)
|
||||
setFileSrc(result.data.data)
|
||||
setFilename(result.data.filename)
|
||||
setStep(1)
|
||||
} else if (result.code === 1) {
|
||||
message.error(result.message)
|
||||
@@ -92,14 +93,16 @@ const Main = () => {
|
||||
setStep(2)
|
||||
|
||||
setTimeout(async() => {
|
||||
const result = await (window as any).go.backend.App.Detect(fileSrc)
|
||||
if (result.code === 0) {
|
||||
setDetectResult(result.data)
|
||||
setStep(3)
|
||||
} else if (result.code === 1) {
|
||||
message.error(result.message)
|
||||
if (filename) {
|
||||
const result = await (window as any).go.backend.App.Detect(filename)
|
||||
if (result.code === 0) {
|
||||
setDetectResult(result.data)
|
||||
setStep(3)
|
||||
} else if (result.code === 1) {
|
||||
message.error(result.message)
|
||||
}
|
||||
}
|
||||
}, 1000)
|
||||
}, 500)
|
||||
}
|
||||
|
||||
const handleTryOther = () => {
|
||||
@@ -108,8 +111,6 @@ const Main = () => {
|
||||
resetUpload()
|
||||
}
|
||||
|
||||
console.log("fff", fileSrc)
|
||||
|
||||
return (
|
||||
<main class="app-main">
|
||||
<div class="main-container">
|
||||
@@ -135,7 +136,7 @@ const Main = () => {
|
||||
>
|
||||
{fileSrc.length > 0 && step == 1 ?
|
||||
<div id="previewContent">
|
||||
<img src={`/images/${fileSrc}`} />
|
||||
<img src={`data:image/jpeg;base64,${fileSrc}`} />
|
||||
<button onClick={handleRemovePhoto}>
|
||||
❌ 移除照片
|
||||
</button>
|
||||
@@ -194,7 +195,7 @@ const Main = () => {
|
||||
<h2>完成!</h2>
|
||||
</div>
|
||||
<div class="result-main">
|
||||
<img src={`/images/${fileSrc}`} />
|
||||
<img src={`data:image/jpeg;base64,${fileSrc}`} />
|
||||
<div class="result-word">
|
||||
<div>
|
||||
<h3>{detectResult?.name}</h3>
|
||||
@@ -202,7 +203,7 @@ const Main = () => {
|
||||
<div class="probability-bar">
|
||||
<div />
|
||||
</div>
|
||||
<span>置信度 {detectResult ? detectResult.confidence_level * 100 + '%' : ''}</span>
|
||||
<span>置信度 {detectResult ? (detectResult.confidence_level * 100).toFixed(2) + '%' : ''}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p>{detectResult?.brief}</p>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import type { ModalProps } from '../preact'
|
||||
|
||||
|
||||
const Modal = ({ open, title, onClick, onClose, children }: ModalProps) => {
|
||||
const handleClose = () => {
|
||||
onClose?.()
|
||||
}
|
||||
const handleClose = () => onClose?.()
|
||||
|
||||
const handleConfirm = () => {
|
||||
onClick?.()
|
||||
@@ -11,9 +10,7 @@ const Modal = ({ open, title, onClick, onClose, children }: ModalProps) => {
|
||||
}
|
||||
|
||||
const handleMaskClick = (e: MouseEvent) => {
|
||||
if (e.target === e.currentTarget) {
|
||||
handleClose()
|
||||
}
|
||||
if (e.target === e.currentTarget) handleClose()
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Vendored
+1
@@ -1,6 +1,7 @@
|
||||
export interface HistoryItem {
|
||||
id: number
|
||||
img: string
|
||||
img_data: string
|
||||
breed: number
|
||||
date: number
|
||||
name: string
|
||||
|
||||
@@ -23,9 +23,7 @@ export const message: MessageAPI = {
|
||||
div.appendChild(subDiv)
|
||||
document.body.appendChild(div)
|
||||
|
||||
setTimeout(() => {
|
||||
div.remove()
|
||||
}, 3000)
|
||||
setTimeout(() => div.remove(), 3000)
|
||||
},
|
||||
error: (text: string) => {
|
||||
const div = document.createElement('div')
|
||||
@@ -46,8 +44,6 @@ export const message: MessageAPI = {
|
||||
div.appendChild(subDiv)
|
||||
document.body.appendChild(div)
|
||||
|
||||
setTimeout(() => {
|
||||
div.remove()
|
||||
}, 3000)
|
||||
setTimeout(() => div.remove(), 3000)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user