Fix export: use Tauri save_file instead of blob, text button labels
Export was broken on Android — blob download (URL.createObjectURL) doesn't work in WebView. Now uses Tauri save_file command which triggers SAF file picker (same as GPX export). Replaced cryptic arrow icons with readable text: "Импорт" / "Экспорт" on both recipes and supplements screens.
This commit is contained in:
parent
5ecce90744
commit
25849b8537
1 changed files with 16 additions and 6 deletions
|
|
@ -1425,8 +1425,8 @@ async function renderRecipes(container) {
|
|||
<div class="section-header">
|
||||
<h2>Рецепты</h2>
|
||||
<span style="display:flex;gap:6px">
|
||||
<button class="add-btn" id="import-recipes-btn" title="Импорт" style="font-size:14px">⬇</button>
|
||||
<button class="add-btn" id="export-recipes-btn" title="Экспорт всех" style="font-size:14px">⬆</button>
|
||||
<button class="add-btn" id="import-recipes-btn" style="font-size:12px">Импорт</button>
|
||||
<button class="add-btn" id="export-recipes-btn" style="font-size:12px">Экспорт</button>
|
||||
<button class="add-btn" id="add-recipe-btn">+</button>
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -3432,8 +3432,8 @@ async function renderSupplements(container) {
|
|||
<div class="section-header">
|
||||
<h2>Добавки</h2>
|
||||
<span style="display:flex;gap:6px">
|
||||
<button class="add-btn" id="import-supps-btn" title="Импорт" style="font-size:14px">⬇</button>
|
||||
<button class="add-btn" id="export-supps-btn" title="Экспорт всех" style="font-size:14px">⬆</button>
|
||||
<button class="add-btn" id="import-supps-btn" style="font-size:12px">Импорт</button>
|
||||
<button class="add-btn" id="export-supps-btn" style="font-size:12px">Экспорт</button>
|
||||
<button class="add-btn" id="add-new-supp">+</button>
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -4280,8 +4280,18 @@ function addZoomDisplay(map) {
|
|||
// Export/Import: recipes, supplements
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function downloadFile(filename, content, mimeType) {
|
||||
const blob = new Blob([content], { type: mimeType || "application/json" });
|
||||
async function downloadFile(filename, content) {
|
||||
// Use Tauri save_file (works on Android via SAF)
|
||||
try {
|
||||
if (window.__TAURI__) {
|
||||
await window.__TAURI__.core.invoke("save_file", { filename, content });
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[download] Tauri save error:", e);
|
||||
}
|
||||
// Fallback for desktop browsers
|
||||
const blob = new Blob([content], { type: "application/json" });
|
||||
const a = document.createElement("a");
|
||||
a.href = URL.createObjectURL(blob);
|
||||
a.download = filename;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue