1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2026-07-25 05:24:08 +08:00

feat: 添加runapi本地代理

This commit is contained in:
zclzone
2026-06-17 17:43:08 +08:00
parent 3a09be229b
commit e4fcbc0b07
2 changed files with 16 additions and 1 deletions

View File

@@ -21,6 +21,8 @@ export const DEFAULT_SETTINGS = {
export const EXPERIENCE_KEY_MAX_TEXT_LENGTH = 100 export const EXPERIENCE_KEY_MAX_TEXT_LENGTH = 100
const RUNAPI_PROXY_BASE_URL = '/runapi'
const TRANSLATION_RULES = 'Translate directly. Return only the translation. Preserve formatting, markdown, code, URLs, numbers, placeholders, and line breaks.' const TRANSLATION_RULES = 'Translate directly. Return only the translation. Preserve formatting, markdown, code, URLs, numbers, placeholders, and line breaks.'
export function isSettingsReady(target) { export function isSettingsReady(target) {
@@ -80,10 +82,17 @@ function createFastModelOptions(model) {
} }
} }
function createRequestBaseUrl(apiBaseUrl) {
const baseUrl = apiBaseUrl.trim().replace(/\/+$/, '')
if (baseUrl === API_BASE_URL_OPTIONS[0])
return RUNAPI_PROXY_BASE_URL
return baseUrl
}
export async function translateText(text, settings) { export async function translateText(text, settings) {
validateTranslateText(text, settings) validateTranslateText(text, settings)
const baseUrl = settings.apiBaseUrl.trim().replace(/\/+$/, '') const baseUrl = createRequestBaseUrl(settings.apiBaseUrl)
const model = settings.model.trim() || DEFAULT_SETTINGS.model const model = settings.model.trim() || DEFAULT_SETTINGS.model
const sourceLanguage = detectSourceLanguage(text) const sourceLanguage = detectSourceLanguage(text)

View File

@@ -67,6 +67,12 @@ export default defineConfig(({ mode }) => {
}) })
}, },
}, },
'/runapi': {
target: 'https://runapi.co',
changeOrigin: true,
rewrite: path => path.replace(/^\/runapi/, '/v1'),
secure: false,
},
}, },
}, },
optimizeDeps: { optimizeDeps: {