移到新目錄(gogs) 並優化 login 及上傳圖片機制

This commit is contained in:
2026-01-03 00:48:49 +08:00
parent b26a339d5c
commit 0a9f0b8583
6 changed files with 99 additions and 24 deletions
+29 -1
View File
@@ -1,5 +1,8 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
// 在 expense_model.dart 中修改
import '../auth_manager.dart';
import '../services/generic_api_service.dart';
// --- 新增類別模型 ---
class ExpenseClass {
@@ -30,6 +33,31 @@ class ExpenseApply {
final String? creatorId;
final DateTime? createDateTime;
// [修改] 動態取得完整網址的 Getter
String get fullPicUrl {
if (picPath == null || picPath!.trim().isEmpty) return "";
// 1. 先去除前後空白,避免不可見字元的干擾
String path = picPath!.trim();
// 2. 判斷是否已經是完整網址 (http/https)
if (path.startsWith('http://') || path.startsWith('https://')) {
return path;
}
// 3. 【關鍵修正】檢查 path 開頭是否有斜線,如果有,把它去掉
// 避免與前面的 "/images/" 組成 "//" 導致解析異常
if (path.startsWith('/')) {
path = path.substring(1);
}
// 4. 取得目前登入的公司別
final String db = AuthManager().currentCompany ?? "demo";
// 5. 組合最終網址
return "${GenericApiService.BASE_IP}/upload/eis_$db/images/$path";
}
ExpenseApply({
this.applyId,
required this.applyDate,
@@ -59,5 +87,5 @@ class ExpenseApply {
}
// 輔助屬性:取得完整圖片路徑 (假設後端基礎 URL)
String get fullPicUrl => "https://api.gex.com.tw:8033/uploads/$picPath";
// String get fullPicUrl => "https://api.gex.com.tw:8033/uploads/$picPath";
}