移到新目錄(gogs) 並優化 login 及上傳圖片機制
This commit is contained in:
@@ -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',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user