Skip to content

Commit

Permalink
feat: 去掉了双击备份文件导入的功能 (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb authored Nov 1, 2024
1 parent 1e58abd commit 60dd13c
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 221 deletions.
238 changes: 58 additions & 180 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"@tanstack/react-virtual": "^3.10.8",
"@tauri-apps/api": "^2.0.3",
"@tauri-apps/plugin-autostart": "^2.0.0",
"@tauri-apps/plugin-deep-link": "^2.0.0",
"@tauri-apps/plugin-dialog": "^2.0.1",
"@tauri-apps/plugin-fs": "^2.0.1",
"@tauri-apps/plugin-global-shortcut": "^2.0.0",
Expand Down
10 changes: 0 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ tauri-plugin-dialog = "2"
tauri-plugin-fs = "2"
tauri-plugin-updater = "2"
tauri-plugin-process = "2"
tauri-plugin-deep-link = "2"
tauri-plugin-eco-window.workspace = true
tauri-plugin-eco-macos-permissions.workspace = true
tauri-plugin-eco-mouse.workspace = true
Expand Down
1 change: 0 additions & 1 deletion src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"dialog:default",
"updater:default",
"process:default",
"deep-link:default",
"eco-window:default",
"eco-macos-permissions:default",
"eco-mouse:default",
Expand Down
2 changes: 0 additions & 2 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ pub fn run() {
.plugin(tauri_plugin_updater::Builder::new().build())
// 进程相关插件:https://github.com/tauri-apps/tauri-plugin-process
.plugin(tauri_plugin_process::init())
// 将 EcoPaste 设置为特殊的 URL 或者文件的默认处理程序:https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/deep-link
.plugin(tauri_plugin_deep_link::init())
// 自定义的窗口管理插件
.plugin(tauri_plugin_eco_window::init())
// 自定义的 fs_extra 插件
Expand Down
9 changes: 1 addition & 8 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,7 @@
"icons/icon.icns",
"icons/icon.ico"
],
"resources": ["assets/tray.ico", "assets/tray-mac.ico"],
"fileAssociations": [
{
"ext": ["EcoPaste-backup"],
"mimeType": "text/plain",
"description": "EcoPaste Backup File"
}
]
"resources": ["assets/tray.ico", "assets/tray-mac.ico"]
},
"plugins": {
"updater": {
Expand Down
26 changes: 8 additions & 18 deletions src/pages/Backup/components/Manual/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Icon from "@/components/Icon";
import ProList from "@/components/ProList";
import { emit } from "@tauri-apps/api/event";
import { downloadDir } from "@tauri-apps/api/path";
import { onOpenUrl } from "@tauri-apps/plugin-deep-link";
import { open } from "@tauri-apps/plugin-dialog";
import { Flex, List, message } from "antd";
import type { FC } from "react";
Expand All @@ -12,35 +11,25 @@ const Manual: FC<{ state: State }> = (props) => {
const { state } = props;
const { t } = useTranslation();

useMount(() => {
onOpenUrl((urls) => {
const url = urls.find((item) => item.endsWith(extname()));

if (!url) return;

handleImport(url.replace("file://", ""));
});
});

// 备份文件的扩展名
const extname = () => {
return `${globalStore.env.appName}-backup`;
};

const handleImport = async (path?: string | null) => {
// 导入数据
const handleImport = async () => {
try {
let srcPath = path;

srcPath ??= await open({
const path = await open({
filters: [{ name: "", extensions: [extname()] }],
});

showWindow();

if (!srcPath) return;
if (!path) return;

state.spinning = true;

const result = await importData(srcPath);
const result = await importData(path);

state.spinning = false;

Expand All @@ -60,6 +49,7 @@ const Manual: FC<{ state: State }> = (props) => {
}
};

// 导出数据
const handleExport = async () => {
try {
state.spinning = true;
Expand Down Expand Up @@ -112,7 +102,7 @@ const Manual: FC<{ state: State }> = (props) => {
justify="center"
gap="small"
className="b b-color-2 hover:b-primary h-102 flex-1 cursor-pointer rounded-8 bg-3 px-8 text-center transition hover:text-primary"
onClick={() => event()}
onClick={event}
>
<Icon name={icon} size={26} />
{label}
Expand Down

0 comments on commit 60dd13c

Please sign in to comment.