Skip to content

Commit f0ecb86

Browse files
Copilotnpv2k1
andcommitted
Fix TypeScript API changes for Tauri v2 - Build successful
Co-authored-by: npv2k1 <73846954+npv2k1@users.noreply.github.com>
1 parent fa9dcb4 commit f0ecb86

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/modules/dictionary/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DbStorage } from '@/utils/db';
22
import { CloseOutlined, DownloadOutlined } from '@ant-design/icons';
3-
import { ResponseType, fetch } from '@tauri-apps/plugin-http';
3+
import { fetch } from '@tauri-apps/plugin-http';
44
import { Button } from 'antd';
55
import Search from 'antd/es/input/Search';
66
import * as cheerio from 'cheerio';
@@ -27,10 +27,10 @@ const DictionaryPage = () => {
2727
}
2828

2929
const steamUrl = `https://dictionary.cambridge.org/dictionary/english-vietnamese/${_key}`;
30-
const html = await fetch<string>(steamUrl, {
30+
const response = await fetch(steamUrl, {
3131
method: 'GET',
32-
responseType: ResponseType.Text,
33-
}).then((res) => res.data);
32+
});
33+
const html = await response.text();
3434
const $ = cheerio.load(html);
3535
const dic = $('.entry-body').html() || '';
3636
if (dic) {

src/modules/tauri/components/shell/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Child, Command } from '@tauri-apps/plugin-shell';
33
import { Button } from 'antd';
44
import TextArea from 'antd/es/input/TextArea';
55
import path from 'path';
6-
import { BaseDirectory, Dir, writeTextFile } from '@tauri-apps/plugin-fs';
6+
import { BaseDirectory, writeTextFile } from '@tauri-apps/plugin-fs';
77
import { join, appDataDir, homeDir } from '@tauri-apps/api/path';
88
import Editor from '@monaco-editor/react';
99

@@ -26,7 +26,7 @@ const TauriShell = () => {
2626
const runCommand = async () => {
2727
setStdOut('');
2828
setStatus(ProcessStatus.RUNNING);
29-
const command = new Command('python', [pythonDir.current]);
29+
const command = Command.create('python', [pythonDir.current]);
3030
command.on('close', (data) => {
3131
console.log(`command finished with code ${data.code} and signal ${data.signal}`);
3232
setStatus(data.code === 0 ? ProcessStatus.SUCCESS : ProcessStatus.ERROR);
@@ -42,7 +42,7 @@ const TauriShell = () => {
4242
});
4343

4444
child.current = await command.spawn();
45-
console.log('pid:', child.current.pid);
45+
console.log('pid:', child.current?.pid);
4646
};
4747

4848
const kill = async () => {
@@ -65,8 +65,9 @@ const TauriShell = () => {
6565
const _homeDir = await homeDir();
6666
pythonDir.current = await join(_homeDir, '.pntools', 'python', 'python.py');
6767
await writeTextFile(
68-
{ contents: code, path: await join(_homeDir, '.pntools', 'python', 'python.py') },
69-
{ dir: BaseDirectory.Home },
68+
await join(_homeDir, '.pntools', 'python', 'python.py'),
69+
code,
70+
{ baseDir: BaseDirectory.Home },
7071
);
7172
})();
7273
}, [code]);

0 commit comments

Comments
 (0)