soiz1 commited on
Commit
de8b5e7
·
verified ·
1 Parent(s): 15f5a20

Update src/lib/tw-filesystem-api.js

Browse files
Files changed (1) hide show
  1. src/lib/tw-filesystem-api.js +17 -12
src/lib/tw-filesystem-api.js CHANGED
@@ -1,17 +1,22 @@
1
  const available = () => !!window.showSaveFilePicker;
2
 
3
- const showSaveFilePicker = fileName => window.showSaveFilePicker({
4
- suggestedName: fileName,
5
- types: [
6
- {
7
- description: 'PenguinMod Project',
8
- accept: {
9
- 'text/plain': '.txt'
10
- }
11
- }
12
- ],
13
- excludeAcceptAllOption: true
14
- });
 
 
 
 
 
15
 
16
  const showOpenFilePicker = async () => {
17
  const [handle] = await window.showOpenFilePicker({
 
1
  const available = () => !!window.showSaveFilePicker;
2
 
3
+ const showSaveFilePicker = fileName => {
4
+ const blob = new Blob(['このファイルの内容'], { type: 'text/plain' });
5
+ const url = URL.createObjectURL(blob);
6
+
7
+ // ダウンロード用のリンクを作成
8
+ const a = document.createElement('a');
9
+ a.href = url;
10
+ a.download = fileName;
11
+
12
+ // リンクをクリックしてファイルをダウンロード
13
+ document.body.appendChild(a);
14
+ a.click();
15
+
16
+ // 一時的に作成したリンクを削除
17
+ document.body.removeChild(a);
18
+ URL.revokeObjectURL(url);
19
+ };
20
 
21
  const showOpenFilePicker = async () => {
22
  const [handle] = await window.showOpenFilePicker({