fix(config): 更新环境配置和API代理地址

master
钟良源 4 weeks ago
parent 72df46b096
commit 1ff50c6089

@ -2,5 +2,5 @@
VITE_USER_NODE_ENV=development
# 子应用地址(开发环境)
VITE_LABEL_APP_URL=http://localhost:3004/labelapp/
VITE_FLOW_APP_URL=http://localhost:9222/flowapp/
VITE_LABEL_APP_URL=https://aistudio.ngsk.tech:7001/labelapp/
VITE_FLOW_APP_URL=https://aistudio.ngsk.tech:7001/flowapp/

@ -2,5 +2,5 @@
VITE_USER_NODE_ENV=production
# 子应用地址(生产环境,相对路径,部署在同一域名下)
VITE_LABEL_APP_URL=/labelapp/
VITE_FLOW_APP_URL=/flowapp/
VITE_LABEL_APP_URL=https://aistudio.ngsk.tech:7001/labelapp/
VITE_FLOW_APP_URL=https://aistudio.ngsk.tech:7001/flowapp/

@ -1,67 +1,67 @@
import path from 'path';
import TerserPlugin from 'terser-webpack-plugin';
import { defineConfig } from 'umi';
import { appName } from './src/conf.json';
import {defineConfig} from 'umi';
import {appName} from './src/conf.json';
import routes from './src/routes';
export default defineConfig({
title: appName,
outputPath: 'dist',
alias: { '@parent': path.resolve(__dirname, '../') },
npmClient: 'npm',
base: '/flowapp/',
publicPath: '/flowapp/',
runtimePublicPath: false,
mfsu: false,
routes,
esbuildMinifyIIFE: true,
icons: {},
hash: true, // 生产环境开启 hash
favicons: ['/flowapp/flow-app.png'],
headScripts: [{ src: '/flowapp/iconfont.js', defer: true }],
clickToComponent: {},
history: {
type: 'browser',
},
plugins: [
'@react-dev-inspector/umi4-plugin',
'@umijs/plugins/dist/tailwindcss',
],
jsMinifier: 'terser',
jsMinifierOptions: {
compress: {
drop_console: true,
drop_debugger: true,
title: appName,
outputPath: 'dist',
alias: {'@parent': path.resolve(__dirname, '../')},
npmClient: 'npm',
base: '/flowapp/',
publicPath: '/flowapp/',
runtimePublicPath: false,
mfsu: false,
routes,
esbuildMinifyIIFE: true,
icons: {},
hash: true, // 生产环境开启 hash
favicons: ['/flowapp/flow-app.png'],
headScripts: [{src: '/flowapp/iconfont.js', defer: true}],
clickToComponent: {},
history: {
type: 'browser',
},
},
lessLoader: {
modifyVars: {
hack: `true; @import "~@/less/index.less";`,
plugins: [
'@react-dev-inspector/umi4-plugin',
'@umijs/plugins/dist/tailwindcss',
],
jsMinifier: 'terser',
jsMinifierOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
},
devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
copy: [
{ from: 'src/conf.json', to: 'dist/conf.json' },
{ from: 'node_modules/monaco-editor/min/vs/', to: 'dist/vs/' },
],
proxy: {
'/api': {
target: 'http://ngsk.tech:29380',
changeOrigin: true,
lessLoader: {
modifyVars: {
hack: `true; @import "~@/less/index.less";`,
},
},
'/databuilder/v1': {
target: 'http://192.168.8.131:29380',
changeOrigin: true,
pathRewrite: { '^/databuilder': '/' },
devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
copy: [
{from: 'src/conf.json', to: 'dist/conf.json'},
{from: 'node_modules/monaco-editor/min/vs/', to: 'dist/vs/'},
],
proxy: {
'/api': {
target: 'http://ngsk.tech:29380',
changeOrigin: true,
},
'/databuilder/v1': {
// target: 'http://192.168.8.131:29380',
target: 'https://aistudio.ngsk.tech:7001/',
changeOrigin: true,
},
},
},
writeToDisk: true,
chainWebpack(memo, args) {
memo.module.rule('markdown').test(/\.md$/).type('asset/source');
writeToDisk: true,
chainWebpack(memo, args) {
memo.module.rule('markdown').test(/\.md$/).type('asset/source');
memo.optimization.minimizer('terser').use(TerserPlugin);
memo.optimization.minimizer('terser').use(TerserPlugin);
return memo;
},
tailwindcss: {},
return memo;
},
tailwindcss: {},
});

@ -1,4 +1,4 @@
let api_host = `/databuilder/v1`;
let api_host = `/api/databuilder/v1`;
export { api_host };

@ -72,7 +72,7 @@ const authorizationBearerFailed = (error: any) => {
const requestConfig = {
timeout: 99999,
baseURL: '/databuilder',
baseURL: '/api/databuilder',
};
const request = axios.create(requestConfig);

@ -1,9 +1,9 @@
import { resolve } from "path";
import {resolve} from "path";
import { defineConfig } from "vite";
import {defineConfig} from "vite";
import react from "@vitejs/plugin-react";
import svgr from "vite-plugin-svgr";
import { ViteEjsPlugin } from "vite-plugin-ejs";
import {ViteEjsPlugin} from "vite-plugin-ejs";
import tsMonoAlias from "vite-plugin-ts-mono-alias";
const isOnline = !!process.env.VITE_IS_ONLINE;
@ -11,66 +11,67 @@ console.log("isOnline", isOnline);
// https://vitejs.dev/config/
export default defineConfig({
base: "/labelapp/",
publicDir: resolve(__dirname, "public"),
envDir: resolve(__dirname, "env"),
server: {
host: "0.0.0.0",
port: 3004,
// micro-app 跨域配置
cors: true,
headers: {
"Access-Control-Allow-Origin": "*",
base: "/labelapp/",
publicDir: resolve(__dirname, "public"),
envDir: resolve(__dirname, "env"),
server: {
host: "0.0.0.0",
port: 3004,
// micro-app 跨域配置
cors: true,
headers: {
"Access-Control-Allow-Origin": "*",
},
proxy: {
"/databuilder": {
// target: "http://192.168.8.131:28080",
target: 'https://aistudio.ngsk.tech:7001/',
changeOrigin: true,
},
"/ws": {
target: "wss://labu.tech:8888/",
ws: true,
changeOrigin: true,
},
},
},
proxy: {
"/databuilder": {
target: "http://192.168.8.131:28080",
changeOrigin: true,
},
"/ws": {
target: "wss://labu.tech:8888/",
ws: true,
changeOrigin: true,
},
},
},
optimizeDeps: {
include: ["react/jsx-runtime"],
},
optimizeDeps: {
include: ["react/jsx-runtime"],
},
plugins: [
react(),
svgr(),
ViteEjsPlugin(),
!process.env.DIST && process.env.NODE_ENV !== "production" && tsMonoAlias(),
].filter(Boolean),
plugins: [
react(),
svgr(),
ViteEjsPlugin(),
!process.env.DIST && process.env.NODE_ENV !== "production" && tsMonoAlias(),
].filter(Boolean),
resolve: {
alias: {
"@": resolve(__dirname, "src/"),
resolve: {
alias: {
"@": resolve(__dirname, "src/"),
},
},
},
build: {
outDir: "dist",
target: "es2015",
// micro-app 需要的配置
cssCodeSplit: false,
minify: "terser",
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
rollupOptions: {
output: {
// 确保资源路径正确
assetFileNames: "assets/[name]-[hash][extname]",
chunkFileNames: "assets/[name]-[hash].js",
entryFileNames: "assets/[name]-[hash].js",
},
build: {
outDir: "dist",
target: "es2015",
// micro-app 需要的配置
cssCodeSplit: false,
minify: "terser",
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
rollupOptions: {
output: {
// 确保资源路径正确
assetFileNames: "assets/[name]-[hash][extname]",
chunkFileNames: "assets/[name]-[hash].js",
entryFileNames: "assets/[name]-[hash].js",
},
},
},
},
});

@ -12,6 +12,8 @@ export interface RegisterParams {
}
export interface LoginResponse {
code: number
message: string
access_token: string
token_type: string
}
@ -36,10 +38,28 @@ userAuthService.interceptors.request.use(
// 响应拦截器
userAuthService.interceptors.response.use(
response => response,
response => {
const { code, message } = response.data
// code 为 0 表示成功
if (code === 0) {
return response
}
// code 为 401 表示未授权,跳转登录
if (code === 401) {
localStorage.removeItem('Access-Token')
localStorage.removeItem('Refresh-Token')
window.location.href = '/#/login'
return Promise.reject(new Error(message || '登录已过期,请重新登录'))
}
// 其他非 0 的 code 视为业务错误
return Promise.reject(new Error(message || '请求失败'))
},
error => {
if (error.response?.status === 401) {
// 清除 token 并跳转登录
// HTTP 401 状态码,清除 token 并跳转登录
localStorage.removeItem('Access-Token')
localStorage.removeItem('Refresh-Token')
window.location.href = '/#/login'

@ -70,7 +70,7 @@ const rootUrl = ref('');
onMounted(() => {
const appUrl = getAppDetail('label-app')?.appUrl || ''; // 线
const devUrl = 'http://localhost:3004/labelapp/';
const devUrl = 'https://aistudio.ngsk.tech:7001/labelapp/';
const isProd = (import.meta as any).env.VITE_USER_NODE_ENV === 'production';
const commonUrl = config ? `tasks/${taskId}/edit` : `tasks/${taskId}/samples/${sampleId}?media_type=${media_type}`;

@ -231,7 +231,7 @@ onMounted(() => {
if (appUrl) {
baseUrl.value = appUrl;
} else {
baseUrl.value = 'http://localhost:3004/';
baseUrl.value = 'https://aistudio.ngsk.tech:7001/';
}
});

@ -459,7 +459,7 @@ const previewFlowHandle = (row: any) => {
previewUrl.value = appUrl + commonUrl;
microAppX.setData('flow-app-log', {...postData, server_ip: location.origin, isPreview: true});
} else {
previewUrl.value = 'http://localhost:9222/flowapp/' + commonUrl;
previewUrl.value = 'https://aistudio.ngsk.tech:7001/flowapp/' + commonUrl;
microAppX.setData('flow-app-log', {...postData, server_ip: undefined, isPreview: true});
}
};

@ -36,7 +36,7 @@ onMounted(() => {
microAppX.setData('flow-app', {...postData, server_ip: location.origin, isTemplate: route.query.isTemplate}); //
} else {
//
baseUrl.value = 'http://localhost:9222/flowapp/' + commonUrl;
baseUrl.value = 'https://aistudio.ngsk.tech:7001/flowapp/' + commonUrl;
microAppX.setData('flow-app', {...postData, server_ip: undefined, isTemplate: route.query.isTemplate}); // 使
}
});

@ -378,7 +378,7 @@ onMounted(async () => {
}); //
} else {
//
baseUrl.value = 'http://localhost:9222/flowapp/' + commonUrl;
baseUrl.value = 'https://aistudio.ngsk.tech:7001/flowapp/' + commonUrl;
microAppX.setData('flow-app-log', { ...postData, server_ip: undefined, logBaseUrl: config.value.storage_space_base_url }); // 使
}
});

@ -24,7 +24,7 @@ const router = useRouter()
const baseUrl = ref('')
//
const devUrl = 'http://localhost:3004/labelapp/'
const devUrl = 'https://aistudio.ngsk.tech:7001/labelapp/'
onMounted(() => {
// URL

@ -12,21 +12,29 @@
<div class="brand-section">
<div class="brand-content">
<div class="brand-icon">
<el-icon :size="48"><DataAnalysis /></el-icon>
<el-icon :size="48">
<DataAnalysis/>
</el-icon>
</div>
<h1 class="brand-title">数据工厂</h1>
<p class="brand-desc">智能数据处理与分析平台</p>
<div class="brand-features">
<div class="feature-item">
<el-icon><Check /></el-icon>
<el-icon>
<Check/>
</el-icon>
<span>数据连接与集成</span>
</div>
<div class="feature-item">
<el-icon><Check /></el-icon>
<el-icon>
<Check/>
</el-icon>
<span>流程自动化处理</span>
</div>
<div class="feature-item">
<el-icon><Check /></el-icon>
<el-icon>
<Check/>
</el-icon>
<span>智能数据标注</span>
</div>
</div>
@ -83,7 +91,8 @@
</el-form-item>
<el-form-item>
<div class="register-link">
还没有账号<router-link to="/register">立即注册</router-link>
还没有账号
<router-link to="/register">立即注册</router-link>
</div>
</el-form-item>
</el-form>
@ -94,10 +103,10 @@
</template>
<script setup lang="ts">
import { User, Lock, DataAnalysis, Check } from '@element-plus/icons-vue'
import { ElMessage, FormInstance, FormRules } from 'element-plus'
import { useUserStore } from '@/stores/modules/user'
import { useRouter, useRoute } from 'vue-router'
import {User, Lock, DataAnalysis, Check} from '@element-plus/icons-vue'
import {ElMessage, FormInstance, FormRules} from 'element-plus'
import {useUserStore} from '@/stores/modules/user'
import {useRouter, useRoute} from 'vue-router'
const router = useRouter()
const route = useRoute()
@ -114,11 +123,11 @@ const loginForm = reactive({
const loginRules: FormRules = {
username: [
{ required: true, message: '请输入用户名', trigger: 'blur' },
{ min: 1, max: 50, message: '用户名长度不超过50字符', trigger: 'blur' }
{required: true, message: '请输入用户名', trigger: 'blur'},
{min: 1, max: 50, message: '用户名长度不超过50字符', trigger: 'blur'}
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' }
{required: true, message: '请输入密码', trigger: 'blur'}
]
}
@ -127,7 +136,7 @@ onMounted(() => {
const savedCredentials = localStorage.getItem('login-credentials')
if (savedCredentials) {
try {
const { username, password } = JSON.parse(atob(savedCredentials))
const {username, password} = JSON.parse(atob(savedCredentials))
loginForm.username = username || ''
loginForm.password = password || ''
} catch (e) {
@ -153,7 +162,7 @@ const handleLogin = async () => {
if (rememberPassword.value) {
localStorage.setItem(
'login-credentials',
btoa(JSON.stringify({ username: loginForm.username, password: loginForm.password }))
btoa(JSON.stringify({username: loginForm.username, password: loginForm.password}))
)
} else {
localStorage.removeItem('login-credentials')
@ -247,9 +256,8 @@ const handleLogin = async () => {
content: '';
position: absolute;
inset: 0;
background:
radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
background: radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
}
}

@ -54,39 +54,15 @@ export default defineConfig({
},
// databuilder 数据工厂服务
'/api/databuilder': {
target: 'http://192.168.8.131:29380',
// target: 'http://192.168.8.131:29380',
target: 'https://aistudio.ngsk.tech:7001/',
changeOrigin: true,
rewrite: path => path.replace(/^\/api\/databuilder/, '')
},
// 数据工厂专用鉴权接口
'/api/databuilder/v1/': {
target: 'http://192.168.8.131:8084',
// target: 'http://192.168.8.131:8084',
target: 'https://aistudio.ngsk.tech:7001/',
changeOrigin: true,
rewrite: path => path.replace(/^\/api\/databuilder\/v1/, '')
},
// console API (dify agents 服务)
'/api/console': {
target: 'http://192.168.8.122:12800/console',
changeOrigin: true,
rewrite: path => path.replace(/^\/api\/console/, '')
},
// 通用 API
'/api': {
target: 'http://192.168.8.207:8084/api',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
},
// 文件存储服务
'/storage': {
target: 'http://192.168.8.207:8084/storage',
changeOrigin: true,
rewrite: path => path.replace(/^\/storage/, '')
},
// 文件预览服务
'/kkpreview': {
target: 'http://192.168.8.207:8084/kkpreview',
changeOrigin: true,
rewrite: path => path.replace(/^\/kkpreview/, '')
},
},
},

Loading…
Cancel
Save