soiz1 commited on
Commit
662f4d1
·
verified ·
1 Parent(s): c2b7b33

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

Browse files
Files changed (1) hide show
  1. src/lib/tw-filesystem-api.js +13 -18
src/lib/tw-filesystem-api.js CHANGED
@@ -1,22 +1,17 @@
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({
@@ -43,4 +38,4 @@ export default {
43
  available,
44
  showOpenFilePicker,
45
  showSaveFilePicker
46
- };
 
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({
 
38
  available,
39
  showOpenFilePicker,
40
  showSaveFilePicker
41
+ };