lots of change

This commit is contained in:
2026-08-11 09:36:38 +08:00
parent 17b5459ce1
commit 5199e3040f
13 changed files with 26 additions and 83 deletions
+10 -2
View File
@@ -1,7 +1,6 @@
import { useState, useEffect } from 'preact/hooks'
import Pagination from './Pagination'
import Modal from './Modal'
import ImagePreview from './ImagePreview'
import { message } from '../utils/toast'
import type { HistoryItem } from '../preact'
@@ -22,6 +21,7 @@ const History = () => {
const pageSize = 5
const [total, setTotal] = useState<number>(50)
const [historyList, setHistoryList] = useState<HistoryItem[]>([])
const [currentItem, setCurrentItem] = useState<HistoryItem>()
const [showDelete, setShowDelete] = useState<boolean>(false)
const [currentId, setCurrentId] = useState<number | null>(null)
const [showClear, setShowClear] = useState<boolean>(false)
@@ -49,6 +49,10 @@ const History = () => {
fetchData(page)
}
const handleShowItem = (item: HistoryItem) => setCurrentItem(item)
const handleItemClose = () => setCurrentItem(undefined)
const handleShowDelete = (id: number) => {
setCurrentId(id)
setShowDelete(true)
@@ -60,6 +64,7 @@ const History = () => {
message.error('currentId为空')
return
}
// dfdfdf
const result = await (window as any).go.backend.App.DeleteOneHistory(currentId)
if (result.code === 0) {
message.success('删除成功')
@@ -104,7 +109,7 @@ const History = () => {
{historyList.map((item: HistoryItem) =>
<div key={item.id} class="history-card">
<div class="card-left">
<ImagePreview filename={item.img} />
<img src={`/images/${item.img}`} onClick={() => handleShowItem(item)} />
</div>
<div class="card-right">
<div class="right-top">
@@ -142,6 +147,9 @@ const History = () => {
<Modal open={showClear} title="信息" onClick={handleClearOk} onClose={handleClearClose}>
<p></p>
</Modal>
<Modal open={!!currentItem} title={currentItem?.name || ''} onClose={handleItemClose}>
<p>{currentItem?.brief || ''}</p>
</Modal>
</>
)
}
-27
View File
@@ -1,27 +0,0 @@
import { useState, useEffect } from 'preact/hooks'
interface Props {
filename: string
class?: string
id?: string
}
const ImagePreview = ({ filename, ...props }: Props) => {
const [src, setSrc] = useState<string>('')
useEffect(() => {
const loadImage = async () => {
const result = await (window as any).go.backend.App.GetImage(filename)
if (result.code === 0) {
setSrc(result.data)
}
}
loadImage()
}, [filename])
if (!src) return <div {...props} />
return <img src={src} {...props} />
}
export default ImagePreview
+5 -4
View File
@@ -1,6 +1,5 @@
import { useState, useRef } from 'preact/hooks'
import type { DetectResult } from '../preact'
import ImagePreview from './ImagePreview'
import { message } from '../utils/toast'
const Main = () => {
@@ -65,6 +64,7 @@ const Main = () => {
file.name
)
if (result.code === 0) {
console.log("rrr", result)
setFileSrc(result.data)
setStep(1)
} else if (result.code === 1) {
@@ -97,7 +97,6 @@ const Main = () => {
setDetectResult(result.data)
setStep(3)
} else if (result.code === 1) {
console.log("result.message", result.message)
message.error(result.message)
}
}, 1000)
@@ -109,6 +108,8 @@ const Main = () => {
resetUpload()
}
console.log("fff", fileSrc)
return (
<main class="app-main">
<div class="main-container">
@@ -134,7 +135,7 @@ const Main = () => {
>
{fileSrc.length > 0 && step == 1 ?
<div id="previewContent">
<ImagePreview filename={fileSrc} id="previewImage" />
<img src={`/images/${fileSrc}`} />
<button onClick={handleRemovePhoto}>
</button>
@@ -193,7 +194,7 @@ const Main = () => {
<h2></h2>
</div>
<div class="result-main">
<ImagePreview filename={fileSrc} />
<img src={`/images/${fileSrc}`} />
<div class="result-word">
<div>
<h3>{detectResult?.name}</h3>
+2 -2
View File
@@ -27,8 +27,8 @@ const Modal = ({ open, title, onClick, onClose, children }: ModalProps) => {
</div>
{children}
<div class="bottom">
<button onClick={handleClose}></button>
<button onClick={handleConfirm}></button>
<button class="close" onClick={handleClose}></button>
{onClick ? <button class="confirm" onClick={handleConfirm}></button> : null}
</div>
</div>
<div class="app-mask" onClick={handleMaskClick}></div>
-1
View File
@@ -1,7 +1,6 @@
import { useState, useEffect } from 'preact/hooks'
import type { PaginationProps } from '../preact'
const Pagination = ({
total,
onChange,
+3 -4
View File
@@ -199,7 +199,7 @@ a
border-radius: 1.5rem
border-width: 2px
border-style: dashed
border-color: #e2e8f0
border-color: #bdc3cb
text-align: center
cursor: pointer
@@ -305,7 +305,6 @@ a
display: flex
align-items: center
justify-content: center
// height: 2.25rem
gap: 0.75rem
margin: 0.5rem 0 1.5rem 0
@@ -474,12 +473,12 @@ a
font-size: 0.875rem
border-radius: 0.25rem
&:first-child
> button.close
color: var(--text)
border: 1px solid #c9c9c9
background-color: none
&:last-child
> button.confirm
color: white
background-color: var(--primary)
-2
View File
@@ -11,8 +11,6 @@ export function Detect(arg1:string):Promise<backend.Response>;
export function GetHistory(arg1:number,arg2:number):Promise<backend.Response>;
export function GetImage(arg1:string):Promise<backend.Response>;
export function GormDB():Promise<gorm.DB>;
export function UploadImage(arg1:Array<number>,arg2:string):Promise<backend.Response>;
-4
View File
@@ -18,10 +18,6 @@ export function GetHistory(arg1, arg2) {
return window['go']['backend']['App']['GetHistory'](arg1, arg2);
}
export function GetImage(arg1) {
return window['go']['backend']['App']['GetImage'](arg1);
}
export function GormDB() {
return window['go']['backend']['App']['GormDB']();
}