From 16fbb7d54b1badcc79b97d30f64ee96392362892 Mon Sep 17 00:00:00 2001 From: Developer <91611@user.local> Date: Thu, 4 Jun 2026 15:35:52 +0800 Subject: [PATCH] =?UTF-8?q?refactor(programs):=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E7=9B=AE=E5=BD=95=E6=94=B9=E4=B8=BA=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - getDownloadsDirectory() 优先,失败时回退到应用文档目录 - 更新 dartdoc 说明 --- lib/features/programs/services/excel_template_service.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/features/programs/services/excel_template_service.dart b/lib/features/programs/services/excel_template_service.dart index a75bfd6..322790d 100644 --- a/lib/features/programs/services/excel_template_service.dart +++ b/lib/features/programs/services/excel_template_service.dart @@ -18,11 +18,13 @@ class ExcelTemplateService { static const String sheetPrograms = 'Programs'; static const String sheetSteps = 'Steps'; - /// 生成模板并保存到应用文档目录,返回文件对象 + /// 生成模板并保存到下载目录,返回文件对象 + /// + /// 优先使用系统下载目录;不支持时回退到应用文档目录。 Future generateTemplate() async { final excel = Excel.createExcel(); final bytes = _buildTemplateBytes(excel); - final dir = await getApplicationDocumentsDirectory(); + final dir = await getDownloadsDirectory() ?? await getApplicationDocumentsDirectory(); final file = File('${dir.path}/program_template.xlsx'); await file.writeAsBytes(bytes, flush: true); return file;