Просмотр исходного кода

fix: export button labels + download URL fix + server restart reliability

nonvioce 3 месяцев назад
Родитель
Сommit
990b61c0f7

+ 8 - 18
tiku-client/lib/pages/export/export_page.dart

@@ -104,27 +104,17 @@ class _ExportPageState extends ConsumerState<ExportPage> {
                 Text('导出成功!共 ${_result!['count']} 题'),
                 const SizedBox(height: 16),
                 FilledButton.tonal(
-                  onPressed: () => _downloadFile(_result!['student'] as String, '学生版'),
-                  child: Row(
-                    mainAxisSize: MainAxisSize.min,
-                    children: [
-                      const Icon(Icons.download, size: 18),
-                      const SizedBox(width: 8),
-                      Text('学生版: ${_result!['student']}'),
-                    ],
-                  ),
+                  onPressed: () => _downloadFile(_result!['student'] as String, '学生版.docx'),
+                  child: const Row(mainAxisSize: MainAxisSize.min, children: [
+                    Icon(Icons.download, size: 18), SizedBox(width: 8), Text('学生版'),
+                  ]),
                 ),
                 const SizedBox(height: 8),
                 FilledButton.tonal(
-                  onPressed: () => _downloadFile(_result!['teacher'] as String, '教师版'),
-                  child: Row(
-                    mainAxisSize: MainAxisSize.min,
-                    children: [
-                      const Icon(Icons.download, size: 18),
-                      const SizedBox(width: 8),
-                      Text('教师版: ${_result!['teacher']}'),
-                    ],
-                  ),
+                  onPressed: () => _downloadFile(_result!['teacher'] as String, '教师版.docx'),
+                  child: const Row(mainAxisSize: MainAxisSize.min, children: [
+                    Icon(Icons.download, size: 18), SizedBox(width: 8), Text('教师版'),
+                  ]),
                 ),
                 const SizedBox(height: 16),
                 TextButton(

+ 1 - 2
tiku-client/lib/services/api_service.dart

@@ -225,8 +225,7 @@ class ApiService {
   String get downloadUrl => '$_baseUrl/api/exports/';
 
   Future<String> downloadExport(String filename, String savePath) async {
-    final url = '$_baseUrl/api/exports/$filename';
-    await _dio.download(url, savePath, options: _authOptions);
+    await _dio.download('/api/exports/$filename', savePath, options: _authOptions);
     return savePath;
   }
 

+ 3 - 3
tiku-server/app/routers/admin.py

@@ -116,12 +116,12 @@ def git_update(request: Request, _=Depends(verify_token)):
         if result.returncode != 0:
             raise RuntimeError(result.stderr)
 
-        # 有更新,触发重启
-        import threading
+        # 有更新,1秒后重启
+        import threading, sys
         def restart():
             import time
             time.sleep(1)
-            os.kill(os.getpid(), signal.SIGTERM)
+            sys.exit(0)
 
         threading.Thread(target=restart, daemon=True).start()