Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
share121 committed Nov 30, 2024
1 parent 6437a47 commit 673868c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "s-photo",
"private": true,
"version": "1.0.9",
"version": "1.1.0",
"type": "module",
"license": "MIT",
"description": "使用几个快捷键即可快速筛选照片",
Expand Down
1 change: 1 addition & 0 deletions src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"fs:allow-exists",
"fs:allow-read-dir",
"fs:allow-read-file",
"fs:allow-write-text-file",
"fs:allow-mkdir"
]
}
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "s-photo",
"version": "1.0.9",
"version": "1.1.0",
"identifier": "com.s-photo.share121",
"build": {
"beforeDevCommand": "pnpm dev",
Expand Down
35 changes: 16 additions & 19 deletions src/components/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,25 @@ onMounted(async () => {
const store = useFilesStore();
async function openDialog() {
const dirs = await open({
const dir = await open({
directory: true,
multiple: true,
recursive: true,
});
if (!dirs) return;
for (const dir of dirs) {
readDir(dir).then((entries) => {
for (const entry of entries) {
if (!entry.isFile) continue;
const ext = extname(entry.name).toLowerCase();
if (![".jpg", ".jpeg", ".png"].includes(ext)) continue;
store.files.push({
dir,
name: entry.name,
state: FileState.wait,
path: join(dir, entry.name),
url: convertFileSrc(join(dir, entry.name)),
});
}
});
}
if (!dir) return;
readDir(dir).then((entries) => {
for (const entry of entries) {
if (!entry.isFile) continue;
const ext = extname(entry.name).toLowerCase();
if (![".jpg", ".jpeg", ".png"].includes(ext)) continue;
store.files.push({
dir,
name: entry.name,
state: FileState.wait,
path: join(dir, entry.name),
url: convertFileSrc(join(dir, entry.name)),
});
}
});
}
onMounted(() => {
Expand Down
12 changes: 11 additions & 1 deletion src/stores/files.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { convertFileSrc } from "@tauri-apps/api/core";
import { join } from "path-browserify";
import GetTagsWorker from "../workers/get-tags.ts?worker";
import { exists, mkdir, readFile, rename } from "@tauri-apps/plugin-fs";
import {
exists,
mkdir,
readFile,
rename,
writeTextFile,
} from "@tauri-apps/plugin-fs";
import { Mutex } from "async-mutex";
import "requestidlecallback-polyfill";

Expand Down Expand Up @@ -79,6 +85,10 @@ export const useFilesStore = defineStore("files", () => {
file.url = convertFileSrc(file.path);
}, { timeout: 3000 });
}
writeTextFile(
join(files[0].dir, "通过率.txt"),
passRate.value * 100 + "%",
);
});
}, { debounce: 1000 });
return {
Expand Down

0 comments on commit 673868c

Please sign in to comment.