ci: 构建单镜像版本
1. 优化路由改为createWebHashHistory 2. 优化Dockerfile
This commit is contained in:
@@ -205,7 +205,6 @@ import {
|
||||
NFormItem,
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NSwitch,
|
||||
NAlert,
|
||||
NDivider,
|
||||
NDropdown,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import { createRouter, createWebHashHistory } from 'vue-router';
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
import { apiService } from '@/services/api';
|
||||
import StockAnalysisApp from '@/components/StockAnalysisApp.vue';
|
||||
@@ -24,7 +24,7 @@ const routes: Array<RouteRecordRaw> = [
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
history: createWebHashHistory(),
|
||||
routes
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import axios from 'axios';
|
||||
import type { AnalyzeRequest, TestApiRequest, TestApiResponse, SearchResult, LoginRequest, LoginResponse } from '@/types';
|
||||
|
||||
// 在开发环境中使用完整URL
|
||||
const API_PREFIX = '';
|
||||
// API前缀
|
||||
const API_PREFIX = '/api';
|
||||
|
||||
// 创建axios实例
|
||||
const axiosInstance = axios.create({
|
||||
@@ -42,7 +42,7 @@ export const apiService = {
|
||||
// 用户登录
|
||||
login: async (request: LoginRequest): Promise<LoginResponse> => {
|
||||
try {
|
||||
const response = await axios.post(`${API_PREFIX}/login`, request);
|
||||
const response = await axiosInstance.post('/login', request);
|
||||
if (response.data.access_token) {
|
||||
localStorage.setItem('token', response.data.access_token);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ export const apiService = {
|
||||
// 检查认证状态
|
||||
checkAuth: async (): Promise<boolean> => {
|
||||
try {
|
||||
const response = await axiosInstance.get(`${API_PREFIX}/check_auth`);
|
||||
const response = await axiosInstance.get('/check_auth');
|
||||
return response.data.authenticated === true;
|
||||
} catch (error) {
|
||||
// 认证失败,清除token
|
||||
@@ -82,7 +82,7 @@ export const apiService = {
|
||||
|
||||
// 分析股票
|
||||
analyzeStocks: async (request: AnalyzeRequest) => {
|
||||
return axiosInstance.post(`${API_PREFIX}/analyze`, request, {
|
||||
return axiosInstance.post('/analyze', request, {
|
||||
responseType: 'stream'
|
||||
});
|
||||
},
|
||||
@@ -90,7 +90,7 @@ export const apiService = {
|
||||
// 测试API连接
|
||||
testApiConnection: async (request: TestApiRequest): Promise<TestApiResponse> => {
|
||||
try {
|
||||
const response = await axiosInstance.post(`${API_PREFIX}/test_api_connection`, request);
|
||||
const response = await axiosInstance.post('/test_api_connection', request);
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
if (error.response) {
|
||||
@@ -106,7 +106,7 @@ export const apiService = {
|
||||
// 搜索美股
|
||||
searchUsStocks: async (keyword: string): Promise<SearchResult[]> => {
|
||||
try {
|
||||
const response = await axiosInstance.get(`${API_PREFIX}/search_us_stocks`, {
|
||||
const response = await axiosInstance.get('/search_us_stocks', {
|
||||
params: { keyword }
|
||||
});
|
||||
return response.data.results || [];
|
||||
@@ -119,14 +119,14 @@ export const apiService = {
|
||||
// 获取配置
|
||||
getConfig: async () => {
|
||||
try {
|
||||
const response = await axios.get(`${API_PREFIX}/config`);
|
||||
const response = await axiosInstance.get('/config');
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('获取配置时出错:', error);
|
||||
return {
|
||||
announcement: '',
|
||||
default_api_url: '',
|
||||
default_api_model: 'gpt-3.5-turbo',
|
||||
default_api_model: '',
|
||||
default_api_timeout: '60'
|
||||
};
|
||||
}
|
||||
@@ -135,7 +135,7 @@ export const apiService = {
|
||||
// 检查是否需要登录
|
||||
checkNeedLogin: async (): Promise<boolean> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_PREFIX}/need_login`);
|
||||
const response = await axiosInstance.get('/need_login');
|
||||
return response.data.require_login;
|
||||
} catch (error) {
|
||||
console.error('检查是否需要登录时出错:', error);
|
||||
|
||||
Reference in New Issue
Block a user