mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-05-06 20:42:52 +08:00
refactor(backend): 更新默认提供商路径获取方法并配置前端请求基础 URL
- 新增 get_builtin_providers_path 函数以动态获取内置提供商 JSON 文件路径 - 修改 seed_default_providers 函数,使用新的路径获取方法 - 更新前端请求工具,配置 API 基础 URL 以适应不同环境
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const request = axios.create({
|
||||
baseURL: '/api', // 默认请求路径前缀
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000',
|
||||
timeout: 10000,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
from app.db.sqlite_client import get_connection
|
||||
from app.utils.logger import get_logger
|
||||
@@ -8,6 +9,13 @@ logger = get_logger(__name__)
|
||||
|
||||
|
||||
|
||||
def get_builtin_providers_path():
|
||||
if getattr(sys, 'frozen', False):
|
||||
base_path = sys._MEIPASS
|
||||
else:
|
||||
base_path = os.path.dirname(__file__)
|
||||
return os.path.join(base_path, 'builtin_providers.json')
|
||||
|
||||
def seed_default_providers():
|
||||
conn = get_connection()
|
||||
if conn is None:
|
||||
@@ -24,7 +32,7 @@ def seed_default_providers():
|
||||
conn.close()
|
||||
return
|
||||
|
||||
json_path = os.path.join(os.path.dirname(__file__), 'builtin_providers.json')
|
||||
json_path = get_builtin_providers_path()
|
||||
try:
|
||||
with open(json_path, 'r', encoding='utf-8') as f:
|
||||
providers = json.load(f)
|
||||
@@ -47,7 +55,6 @@ def seed_default_providers():
|
||||
p['type'],
|
||||
p.get('enabled', 1)
|
||||
))
|
||||
|
||||
conn.commit()
|
||||
logger.info("Default providers seeded successfully.")
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user