Skip to content

Commit 43abb24

Browse files
0.15.0 更新客户端enter直接触发搜索
1 parent 70d0e64 commit 43abb24

File tree

5 files changed

+39
-14
lines changed

5 files changed

+39
-14
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
![example](doc/example.png)
66

7-
8-
9-
107
# 操作说明
118

129
- 搜索模式选项说明
@@ -79,7 +76,7 @@ log_level = "trace" # 日志级别
7976
# log_level = "info" # 日志级别
8077
```
8178

82-
# 功能列表
79+
# 功能 && TODO
8380

8481
> 最新的功能可能还没有发布到[Release](https://github.com/ToniXWD/file_elf/releases), 需要本地编译
8582
@@ -100,6 +97,8 @@ log_level = "trace" # 日志级别
10097
- [ ] 支持配置文件热重载
10198
- [ ] 支持剥离关系型数据库 `sqlite3`存储, 创建自定义的文件格式存储
10299
- [ ] 配置文件支持自定义数据库(目前使用 `sqlite3`)
100+
- [ ] 搜索项支持系统级别的更多操作(仅 `windows`)
101+
- [ ] 客户端界面优化: 设定默认聚焦组件 && `table` 切换 && `Enter `默认行为
103102

104103
# 安装和开发
105104

app/search-files-app/src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"productName": "search-files-app",
4646
"mainBinaryName": "search-files-app",
47-
"version": "0.14.3",
47+
"version": "0.15.0",
4848
"identifier": "com.file.efl.toni",
4949
"plugins": {
5050
"cli": {

app/search-files-app/src/elements/ResultItem.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const ResultItem = ({ result, addMessage }) => {
5959
<ListGroup.Item>
6060
{/* 解构 result 以提取字符串和布尔值 */}
6161
{result[0]}{' '} {/* 这是字符串部分 */}
62+
<br></br>
6263
<Button variant="outline-secondary" size="sm" onClick={() => openDir(result[0])}>
6364
📁
6465
</Button>

app/search-files-app/src/elements/SearchForm.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, { useState, useEffect, useRef } from 'react';
22
import { Form, Button, Container, Row, Col } from 'react-bootstrap';
33
import ResultsList from './ResultsList.js';
44
import NotificationToast from './NotificationToast.js';
@@ -14,8 +14,20 @@ const SearchForm = () => {
1414
const [message, setMessage] = useState('');
1515
const [showToast, setShowToast] = useState(false);
1616

17+
// 创建输入框的引用
18+
const inputRef = useRef(null);
19+
20+
// 聚焦输入框的函数
21+
const focusInput = () => {
22+
if (inputRef.current) {
23+
inputRef.current.focus();
24+
}
25+
};
26+
1727
useEffect(() => {
1828
setResults([]);
29+
30+
focusInput();
1931
}, []);
2032

2133
const handleSearch = async () => {
@@ -59,13 +71,21 @@ const SearchForm = () => {
5971
<Row className="justify-content-center">
6072
<Col md={6}>
6173
<h1 className="text-start mb-4">Search Files</h1>
62-
<Form>
74+
<Form onSubmit={(e) => e.preventDefault()}>
6375
<Form.Group controlId="entry">
6476
<Form.Control
6577
type="text"
6678
value={entry}
6779
onChange={(e) => setEntry(e.target.value)}
80+
ref={inputRef} // 绑定引用
6881
placeholder="Enter your search query"
82+
onKeyDown={(e) => {
83+
if (e.key === 'Enter') {
84+
e.preventDefault(); // 阻止默认行为,避免清空输入框
85+
console.log('Enter pressed');
86+
handleSearch();
87+
}
88+
}}
6989
/>
7090
</Form.Group>
7191
<br />
@@ -91,7 +111,10 @@ const SearchForm = () => {
91111
<HelpBar></HelpBar>
92112
<ConfigBar></ConfigBar
93113
>
94-
<Button variant="primary" className="ms-auto" onClick={handleSearch}>Search</Button>
114+
<Button variant="primary" type="button" className="ms-auto"
115+
onClick={handleSearch}>
116+
Search
117+
</Button>
95118
</div>
96119
</Form>
97120
<ResultsList results={results} addMessage={addMessage} />

build.ps1

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ param (
99
$PUBLISH_DIR = "./publish"
1010
$CARGO_TARGET_DIR = "./target/release"
1111
$TAURI_APP_DIR = "./app/search-files-app"
12-
$TAURI_TARGET_DIR = "$TAURI_APP_DIR/src-tauri/target/release"
12+
$TAURI_TARGET_RELEASE_DIR = "$TAURI_APP_DIR/src-tauri/target/release"
13+
$TAURI_TARGET_DEBUG_DIR = "$TAURI_APP_DIR/src-tauri/target/debug"
1314
$RUST_BINARY = "file_elf.exe"
1415
$TAURI_BINARY = "search-files-app.exe"
1516
$TAURI_INSTALL_MSI = "bundle/msi/search-files-app_*_x64_en-US.msi"
@@ -44,9 +45,9 @@ function Publish-Files {
4445
Write-Host "Copying files to the publish directory..."
4546
Copy-Item "base.toml" "$PUBLISH_DIR/"
4647
Copy-Item "$CARGO_TARGET_DIR/$RUST_BINARY" "$PUBLISH_DIR/"
47-
Copy-Item "$TAURI_TARGET_DIR/$TAURI_BINARY" "$PUBLISH_DIR/"
48-
Copy-Item "$TAURI_TARGET_DIR/$TAURI_INSTALL_MSI" "$PUBLISH_DIR/"
49-
Copy-Item "$TAURI_TARGET_DIR/$TAURI_INSTALL_EXE" "$PUBLISH_DIR/"
48+
Copy-Item "$TAURI_TARGET_RELEASE_DIR/$TAURI_BINARY" "$PUBLISH_DIR/"
49+
Copy-Item "$TAURI_TARGET_RELEASE_DIR/$TAURI_INSTALL_MSI" "$PUBLISH_DIR/"
50+
Copy-Item "$TAURI_TARGET_RELEASE_DIR/$TAURI_INSTALL_EXE" "$PUBLISH_DIR/"
5051
}
5152

5253
# Package the build artifacts into a zip file
@@ -61,7 +62,8 @@ function Clean-Build {
6162
cargo clean
6263
Remove-Item -Recurse -Force $PUBLISH_DIR
6364
Remove-Item -Recurse -Force "$TAURI_APP_DIR/build/"
64-
Remove-Item -Recurse -Force "$TAURI_TARGET_DIR/"
65+
Remove-Item -Recurse -Force "$TAURI_TARGET_RELEASE_DIR/"
66+
Remove-Item -Recurse -Force "$TAURI_TARGET_DEBUG_DIR/"
6567
}
6668

6769
# Clean only the publish directory
@@ -74,7 +76,7 @@ function Clean-Publish {
7476
function Clean-Tauri {
7577
Write-Host "Cleaning Tauri build artifacts..."
7678
Remove-Item -Recurse -Force "$TAURI_APP_DIR/build/"
77-
Remove-Item -Recurse -Force "$TAURI_TARGET_DIR/"
79+
Remove-Item -Recurse -Force "$TAURI_TARGET_RELEASE_DIR/"
7880
}
7981

8082
# Clean only the Rust project artifacts

0 commit comments

Comments
 (0)