Skip to content

Commit 45fe0d4

Browse files
authored
Merge pull request #14 from jsoncode/master
update front_end config and proxy
2 parents 63d3702 + c372d01 commit 45fe0d4

File tree

15 files changed

+52
-72
lines changed

15 files changed

+52
-72
lines changed

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@ vim front_end/.env # set the excetly host.
199199
<summary>Beginner's recommendation!</summary>
200200

201201
```shell
202+
# Change the script file format from DOS to UNIX.
203+
sed -i "s/\r//" scripts/run_for_local.sh
204+
sed -i "s/^M//" scripts/run_for_local.sh
205+
# delete BOM
206+
sed -i '1s/^.*#//;s/\r$//' scripts/run_for_local.sh
207+
# check bom
208+
head -1 scripts/run_for_local.sh | od -c
209+
# 0000000 ! / b i n / b a s h \n
210+
202211
# Front desk startup, log prints to the screen in real time, press ctrl+c to stop.
203212
docker-compose -f docker-compose-windows.yaml up qanything_local
204213
```
@@ -208,6 +217,9 @@ docker-compose -f docker-compose-windows.yaml up qanything_local
208217
<summary>Recommended for experienced players!</summary>
209218

210219
```shell
220+
# The script file is changed from DOS format to Unix format.
221+
sed -i "s/\r//" scripts/run_for_local.sh
222+
sed -i "s/^M//" scripts/run_for_local.sh
211223
# Background startup, ctrl+c will not stop.
212224
docker-compose -f docker-compose-windows.yaml up -d
213225
# Execute the following command to view the log.
@@ -217,12 +229,6 @@ docker-compose -f docker-compose-windows.yaml down
217229
```
218230
</details>
219231

220-
2. Double click run_in_windows.bat
221-
3. Execute command line:
222-
```shell
223-
Start-Process -FilePath ".\run_in_windows.bat" -Wait -NoNewWindow
224-
```
225-
226232
##### in the Linux system
227233
<details>
228234
<summary>Beginner's recommendation!</summary>

README_zh.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ vim front_end/.env # 设置准确的host,本地环境默认一般是localhost
196196
<summary>新手推荐!</summary>
197197

198198
```shell
199+
# 脚本文件从dos格式改为unix格式
200+
sed -i "s/\r//" scripts/run_for_local.sh
201+
sed -i "s/^M//" scripts/run_for_local.sh
202+
# 删除dos系统中的BOM字符
203+
sed -i '1s/^ *//' scripts/run_for_local.sh
204+
# 查看BOM是否删除成功
205+
head -1 scripts/run_for_local.sh | od -c
206+
# 如果显示:0000000 ! / b i n / b a s h \n 表示成功
199207
# 前台启动,日志实时打印到屏幕上,ctrl+c即可停止
200208
docker-compose -f docker-compose-windows.yaml up qanything_local
201209
```
@@ -205,6 +213,9 @@ docker-compose -f docker-compose-windows.yaml up qanything_local
205213
<summary>老手推荐!</summary>
206214

207215
```shell
216+
# 脚本文件从dos格式改为unix格式
217+
sed -i "s/\r//" scripts/run_for_local.sh
218+
sed -i "s/^M//" scripts/run_for_local.sh
208219
# 后台启动,ctrl+c不会停止
209220
docker-compose -f docker-compose-windows.yaml up -d
210221
# 执行如下命令查看日志
@@ -214,12 +225,6 @@ docker-compose -f docker-compose-windows.yaml down
214225
```
215226
</details>
216227

217-
2. 双击 run_in_windows.bat
218-
3. 命令行执行run_in_windows.bat:
219-
```shell
220-
Start-Process -FilePath ".\run_in_windows.bat" -Wait -NoNewWindow
221-
```
222-
223228
##### 在Linux系统下
224229
<details>
225230
<summary>新手推荐!</summary>

front_end/.env

Lines changed: 0 additions & 2 deletions
This file was deleted.

front_end/.env.development

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
VITE_APP_API_HOST=
2-
VITE_APP_API_PREFIX=/api/local_doc_qa
1+
VITE_APP_API_HOST=http://localhost:8777
2+
VITE_APP_API_PREFIX=/api
33
VITE_APP_WEB_PREFIX=/qanything
4+
VITE_APP_MODE=dev
45

front_end/.env.production

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
VITE_APP_API_HOST=http://localhost
2-
VITE_APP_API_PREFIX=/api/local_doc_qa
1+
VITE_APP_API_HOST=http://localhost:8777
2+
VITE_APP_API_PREFIX=/api
33
VITE_APP_WEB_PREFIX=/qanything
4+
VITE_APP_MODE=prod

front_end/src/components/AddKnowledgeDialog.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @LastEditors: 祝占朋 [email protected]
55
* @LastEditTime: 2023-12-04 14:43:43
66
* @FilePath: /ai-demo/src/components/AddKnowledgeDialog.vue
7-
* @Description:
7+
* @Description:
88
-->
99
<template>
1010
<Teleport to="body">
@@ -191,9 +191,7 @@ const acceptList = [
191191
//上传前校验
192192
const beforeFileUpload = async (file, index) => {
193193
return new Promise((resolve, reject) => {
194-
console.log(file.name.split('.').pop());
195-
console.log(acceptList.includes);
196-
if (acceptList.includes('.' + file.name.split('.').pop().toLowerCase())) {
194+
if (file.name && acceptList.includes('.' + file.name.split('.').pop().toLowerCase())) {
197195
fileList.value.push({
198196
file_name: file.name,
199197
file: file,

front_end/src/components/Chat.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
<DefaultModal :content="content" :confirm-loading="confirmLoading" @ok="confirm" />
121121
</template>
122122
<script lang="ts" setup>
123+
import { apiBase } from '@/services';
123124
import { IChatItem } from '@/utils/types';
124125
import { useThrottleFn, useClipboard } from '@vueuse/core';
125126
import { message } from 'ant-design-vue';
@@ -244,10 +245,9 @@ const send = () => {
244245
history.value = [];
245246
}
246247
showLoading.value = true;
247-
const severUrl = import.meta.env.VITE_APP_SERVER_URL;
248248
ctrl = new AbortController();
249249
250-
fetchEventSource(severUrl + '/local_doc_qa/local_doc_chat', {
250+
fetchEventSource(apiBase + '/local_doc_qa/local_doc_chat', {
251251
method: 'POST',
252252
headers: {
253253
'Content-Type': 'application/json',

front_end/src/components/FileUploadDialog.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @LastEditors: 祝占朋 [email protected]
55
* @LastEditTime: 2024-01-08 15:09:48
66
* @FilePath: /qanything-open-source/src/components/FileUploadDialog.vue
7-
* @Description:
7+
* @Description:
88
-->
99
<template>
1010
<Teleport to="body">
@@ -84,6 +84,7 @@
8484
</Teleport>
8585
</template>
8686
<script lang="ts" setup>
87+
import { apiBase } from '@/services';
8788
import { useKnowledgeModal } from '@/store/useKnowledgeModal';
8889
import { useKnowledgeBase } from '@/store/useKnowledgeBase';
8990
import { useOptiionList } from '@/store/useOptiionList';
@@ -149,7 +150,7 @@ const acceptList = [
149150
//上传前校验
150151
const beforeFileUpload = async (file, index) => {
151152
return new Promise((resolve, reject) => {
152-
if (acceptList.includes('.' + file.name.split('.').pop().toLowerCase())) {
153+
if (file.name && acceptList.includes('.' + file.name.split('.').pop().toLowerCase())) {
153154
uploadFileList.value.push({
154155
file_name: file.name,
155156
file: file,
@@ -233,8 +234,7 @@ const uplolad = async () => {
233234
// 上传模式,soft:文件名重复的文件不再上传,strong:文件名重复的文件强制上传
234235
formData.append('mode', 'strong');
235236
236-
const base = import.meta.env.VITE_APP_SERVER_URL;
237-
fetch(base + '/local_doc_qa/upload_files', {
237+
fetch(apiBase + '/local_doc_qa/upload_files', {
238238
method: 'POST',
239239
body: formData,
240240
})

front_end/src/components/NewAddKnowledgeDialog.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @LastEditors: 祝占朋 [email protected]
55
* @LastEditTime: 2023-12-11 16:06:52
66
* @FilePath: /ai-demo/src/components/NewAddKnowledgeDialog.vue
7-
* @Description:
7+
* @Description:
88
-->
99
<template>
1010
<Teleport to="body">
@@ -191,9 +191,7 @@ const acceptList = [
191191
//上传前校验
192192
const beforeFileUpload = async (file, index) => {
193193
return new Promise((resolve, reject) => {
194-
console.log(file.name.split('.').pop());
195-
console.log(acceptList.includes);
196-
if (acceptList.includes('.' + file.name.split('.').pop().toLowerCase())) {
194+
if (file.name && acceptList.includes('.' + file.name.split('.').pop().toLowerCase())) {
197195
fileList.value.push({
198196
file_name: file.name,
199197
file: file,

front_end/src/services/axiosInterceptor/interceptors/forceRetry.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const forceHandle = {
22
// 注意:切换页面是否要清空保留的requests根据业务来处理
33
requests: {} as any,
44
getKey(config: any) {
5-
const url = config.url.split('?')[0];
5+
console.log(config.url);
6+
const url = config.url?.split('?')[0];
67
return `${url}/&request_type=${config.method}`;
78
},
89
clear() {

0 commit comments

Comments
 (0)