移到新目錄(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
+13 -4
View File
@@ -3,11 +3,20 @@ import 'dart:convert';
import '../auth_manager.dart'; // 確保引入 AuthManager
// 共用 API 常數
const String BASE_IP = "https://api.gex.com.tw:8033";
const String COMMON_API_ENDPOINT = "xapi/v2/eis_demo/orm_api_v2/2/";
const String COMMON_API_URL = "$BASE_IP/$COMMON_API_ENDPOINT";
//const String BASE_IP = "https://api.gex.com.tw:8033";
//const String COMMON_API_ENDPOINT = "xapi/v2/eis_demo/orm_api_v2/2/";
//const String COMMON_API_URL = "$BASE_IP/$COMMON_API_ENDPOINT";
class GenericApiService {
// [修改] 移除 const COMMON_API_URL,改為方法獲取
static const String BASE_IP = "https://api.gex.com.tw:8033";
String _getDynamicUrl() {
// 從 AuthManager 獲取目前登入的公司別,若無則預設 eis_demo
final String db = AuthManager().currentCompany ?? "demo";
final String db_all = "eis_" + db;
return "$BASE_IP/xapi/v2/$db_all/orm_api_v2/2/";
}
/// 通用的獲取列表方法
/// [T] : 目標資料模型 (例如 Announcement 或 Todo)
@@ -49,7 +58,7 @@ class GenericApiService {
try {
final response = await http.post(
Uri.parse(COMMON_API_URL),
Uri.parse(_getDynamicUrl()),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},