af-mobile-client-vue3 1.4.53 → 1.4.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/vite/optimize.ts +36 -36
- package/package.json +1 -1
- package/public/favicon.svg +4 -4
- package/scripts/verifyCommit.js +19 -19
- package/src/App.vue +14 -2
- package/src/components/common/MateChat/apiService.ts +285 -0
- package/src/components/common/MateChat/assets/035-avatar-13.svg +1 -0
- package/src/components/common/MateChat/components/MateChatContent.vue +281 -0
- package/src/components/common/MateChat/components/MateChatHeader.vue +298 -0
- package/src/components/common/MateChat/components/PasswordDialog.vue +97 -0
- package/src/components/common/MateChat/components/PromptList/PromptList.vue +189 -0
- package/src/components/common/MateChat/components/PromptList/index.ts +1 -0
- package/src/components/common/MateChat/composables/useChatHistoryCache.ts +117 -0
- package/src/components/common/MateChat/composables/useChatMessagesCache.ts +72 -0
- package/src/components/common/MateChat/composables/useMateChat.ts +372 -0
- package/src/components/common/MateChat/composables/usePasswordManager.ts +38 -0
- package/src/components/common/MateChat/index.vue +429 -0
- package/src/components/common/MateChat/types.ts +236 -0
- package/src/components/common/otherCharge/ChargePrintSelectorAndRemarks.vue +137 -137
- package/src/components/common/otherCharge/CodePayment.vue +357 -357
- package/src/components/common/otherCharge/FileUploader.vue +602 -602
- package/src/components/common/otherCharge/GridFileUploader.vue +846 -846
- package/src/components/common/otherCharge/PaymentMethodSelector.vue +202 -202
- package/src/components/common/otherCharge/PaymentMethodSelectorCard.vue +45 -45
- package/src/components/common/otherCharge/ReceiptModal.vue +273 -273
- package/src/components/common/otherCharge/index.ts +43 -43
- package/src/components/data/OtherCharge/OtherChargeItemModal.vue +547 -547
- package/src/components/data/UserDetail/types.ts +1 -1
- package/src/components/data/XReportGrid/XAddReport/index.ts +1 -1
- package/src/components/data/XReportGrid/XReportDrawer/index.ts +1 -1
- package/src/components/data/XTag/index.vue +10 -10
- package/src/components/layout/TabBarLayout/index.vue +40 -40
- package/src/hooks/useCommon.ts +9 -9
- package/src/plugins/AppData.ts +38 -38
- package/src/router/invoiceRoutes.ts +33 -33
- package/src/services/api/common.ts +109 -109
- package/src/services/api/manage.ts +8 -8
- package/src/services/api/search.ts +16 -16
- package/src/services/restTools.ts +56 -56
- package/src/utils/authority-utils.ts +84 -84
- package/src/utils/crypto.ts +39 -39
- package/src/utils/queryFormDefaultRangePicker.ts +57 -57
- package/src/utils/runEvalFunction.ts +13 -13
- package/src/views/component/EvaluateRecordView/index.vue +40 -40
- package/src/views/component/MateChat/MateChatView.vue +10 -254
- package/src/views/component/XCellDetailView/index.vue +217 -217
- package/src/views/component/XCellListView/index.vue +107 -138
- package/src/views/component/XFormGroupView/index.vue +78 -82
- package/src/views/component/XFormView/index.vue +41 -46
- package/src/views/component/XReportFormIframeView/index.vue +47 -47
- package/src/views/component/XReportFormView/index.vue +13 -13
- package/src/views/component/XSignatureView/index.vue +50 -50
- package/src/views/component/notice.vue +46 -46
- package/src/views/component/topNav.vue +36 -36
- package/src/views/invoiceShow/index.vue +61 -61
- package/src/views/user/login/index.vue +22 -22
- package/vite.config.ts +2 -1
- package/src/views/component/MateChat/apiService.ts +0 -104
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import XSignature from '@af-mobile-client-vue3/components/data/XSignature/index.vue'
|
|
3
|
-
import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
|
|
4
|
-
import { showToast, Image as VanImage } from 'vant'
|
|
5
|
-
import { ref } from 'vue'
|
|
6
|
-
|
|
7
|
-
const signatureImage = ref('')
|
|
8
|
-
|
|
9
|
-
function handleSave() {
|
|
10
|
-
showToast('签名已保存')
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function handleClear() {
|
|
14
|
-
showToast('签名已清除')
|
|
15
|
-
}
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<template>
|
|
19
|
-
<NormalDataLayout title="签名组件">
|
|
20
|
-
<template #layout_content>
|
|
21
|
-
基础使用
|
|
22
|
-
<div class="signature-demo">
|
|
23
|
-
<XSignature v-model="signatureImage" @save="handleSave" @clear="handleClear" />
|
|
24
|
-
<div v-if="signatureImage" class="preview">
|
|
25
|
-
<h3>预览签名</h3>
|
|
26
|
-
<VanImage v-if="signatureImage" :src="signatureImage" />
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
</template>
|
|
30
|
-
</NormalDataLayout>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
<style scoped lang="less">
|
|
34
|
-
.signature-demo {
|
|
35
|
-
padding: 16px;
|
|
36
|
-
.preview {
|
|
37
|
-
margin-top: 20px;
|
|
38
|
-
h3 {
|
|
39
|
-
margin: 0 0 10px;
|
|
40
|
-
font-size: 16px;
|
|
41
|
-
color: #323233;
|
|
42
|
-
}
|
|
43
|
-
img {
|
|
44
|
-
max-width: 100%;
|
|
45
|
-
border: 1px solid #ebedf0;
|
|
46
|
-
border-radius: 8px;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import XSignature from '@af-mobile-client-vue3/components/data/XSignature/index.vue'
|
|
3
|
+
import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
|
|
4
|
+
import { showToast, Image as VanImage } from 'vant'
|
|
5
|
+
import { ref } from 'vue'
|
|
6
|
+
|
|
7
|
+
const signatureImage = ref('')
|
|
8
|
+
|
|
9
|
+
function handleSave() {
|
|
10
|
+
showToast('签名已保存')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function handleClear() {
|
|
14
|
+
showToast('签名已清除')
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<NormalDataLayout title="签名组件">
|
|
20
|
+
<template #layout_content>
|
|
21
|
+
基础使用
|
|
22
|
+
<div class="signature-demo">
|
|
23
|
+
<XSignature v-model="signatureImage" @save="handleSave" @clear="handleClear" />
|
|
24
|
+
<div v-if="signatureImage" class="preview">
|
|
25
|
+
<h3>预览签名</h3>
|
|
26
|
+
<VanImage v-if="signatureImage" :src="signatureImage" />
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
</NormalDataLayout>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<style scoped lang="less">
|
|
34
|
+
.signature-demo {
|
|
35
|
+
padding: 16px;
|
|
36
|
+
.preview {
|
|
37
|
+
margin-top: 20px;
|
|
38
|
+
h3 {
|
|
39
|
+
margin: 0 0 10px;
|
|
40
|
+
font-size: 16px;
|
|
41
|
+
color: #323233;
|
|
42
|
+
}
|
|
43
|
+
img {
|
|
44
|
+
max-width: 100%;
|
|
45
|
+
border: 1px solid #ebedf0;
|
|
46
|
+
border-radius: 8px;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</style>
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { getImageUrl } from '@af-mobile-client-vue3/utils/common'
|
|
3
|
-
import {
|
|
4
|
-
Divider as VanDivider,
|
|
5
|
-
NoticeBar as VanNoticeBar,
|
|
6
|
-
} from 'vant/es'
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<template>
|
|
10
|
-
<div>
|
|
11
|
-
<VanNoticeBar class="notice" color="#1989fa" background="#ebf2fb" mode="link">
|
|
12
|
-
<img class="notice_icon" :src="getImageUrl('../assets/img/home/notice/icon.png')">
|
|
13
|
-
<span class="notice_title">
|
|
14
|
-
消息中心<VanDivider vertical :style="{ borderColor: '#1989fa' }" />
|
|
15
|
-
</span>
|
|
16
|
-
<span class="notice_content">
|
|
17
|
-
您有0条未读消息
|
|
18
|
-
</span>
|
|
19
|
-
</VanNoticeBar>
|
|
20
|
-
</div>
|
|
21
|
-
</template>
|
|
22
|
-
|
|
23
|
-
<style scoped lang="less">
|
|
24
|
-
.notice {
|
|
25
|
-
font-size: 14px;
|
|
26
|
-
margin-bottom: var(--base-interval-1);
|
|
27
|
-
.notice_icon {
|
|
28
|
-
width: 30px;
|
|
29
|
-
height: 30px;
|
|
30
|
-
vertical-align: middle;
|
|
31
|
-
position: relative;
|
|
32
|
-
bottom: 2px;
|
|
33
|
-
}
|
|
34
|
-
.notice_title {
|
|
35
|
-
padding-left: 4px;
|
|
36
|
-
line-height: 50px;
|
|
37
|
-
}
|
|
38
|
-
.notice_content {
|
|
39
|
-
color: #000;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
:deep(.van-notice-bar) {
|
|
43
|
-
height: 50px;
|
|
44
|
-
padding: 0 8px;
|
|
45
|
-
}
|
|
46
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { getImageUrl } from '@af-mobile-client-vue3/utils/common'
|
|
3
|
+
import {
|
|
4
|
+
Divider as VanDivider,
|
|
5
|
+
NoticeBar as VanNoticeBar,
|
|
6
|
+
} from 'vant/es'
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div>
|
|
11
|
+
<VanNoticeBar class="notice" color="#1989fa" background="#ebf2fb" mode="link">
|
|
12
|
+
<img class="notice_icon" :src="getImageUrl('../assets/img/home/notice/icon.png')">
|
|
13
|
+
<span class="notice_title">
|
|
14
|
+
消息中心<VanDivider vertical :style="{ borderColor: '#1989fa' }" />
|
|
15
|
+
</span>
|
|
16
|
+
<span class="notice_content">
|
|
17
|
+
您有0条未读消息
|
|
18
|
+
</span>
|
|
19
|
+
</VanNoticeBar>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<style scoped lang="less">
|
|
24
|
+
.notice {
|
|
25
|
+
font-size: 14px;
|
|
26
|
+
margin-bottom: var(--base-interval-1);
|
|
27
|
+
.notice_icon {
|
|
28
|
+
width: 30px;
|
|
29
|
+
height: 30px;
|
|
30
|
+
vertical-align: middle;
|
|
31
|
+
position: relative;
|
|
32
|
+
bottom: 2px;
|
|
33
|
+
}
|
|
34
|
+
.notice_title {
|
|
35
|
+
padding-left: 4px;
|
|
36
|
+
line-height: 50px;
|
|
37
|
+
}
|
|
38
|
+
.notice_content {
|
|
39
|
+
color: #000;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
:deep(.van-notice-bar) {
|
|
43
|
+
height: 50px;
|
|
44
|
+
padding: 0 8px;
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
Col as VanCol,
|
|
4
|
-
Row as VanRow,
|
|
5
|
-
Search as VanSearch,
|
|
6
|
-
} from 'vant/es'
|
|
7
|
-
import { ref } from 'vue'
|
|
8
|
-
|
|
9
|
-
const value = ref('')
|
|
10
|
-
</script>
|
|
11
|
-
|
|
12
|
-
<template>
|
|
13
|
-
<div class="top_nav_main">
|
|
14
|
-
<VanRow gutter="54" align="center">
|
|
15
|
-
<VanCol span="2">
|
|
16
|
-
<img alt="default-user-profile" class="default_user_profile" src="../../assets/common/default-user-profile.png">
|
|
17
|
-
</VanCol>
|
|
18
|
-
<VanCol span="22">
|
|
19
|
-
<VanSearch v-model="value" placeholder="请输入搜索关键词" />
|
|
20
|
-
</VanCol>
|
|
21
|
-
</VanRow>
|
|
22
|
-
</div>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<style scoped lang="less">
|
|
26
|
-
.top_nav_main {
|
|
27
|
-
padding-bottom: var(--base-interval-1);
|
|
28
|
-
}
|
|
29
|
-
.default_user_profile {
|
|
30
|
-
border-radius: 50%;
|
|
31
|
-
width: 33px;
|
|
32
|
-
height: 33px;
|
|
33
|
-
position: relative;
|
|
34
|
-
top: 2px;
|
|
35
|
-
}
|
|
36
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Col as VanCol,
|
|
4
|
+
Row as VanRow,
|
|
5
|
+
Search as VanSearch,
|
|
6
|
+
} from 'vant/es'
|
|
7
|
+
import { ref } from 'vue'
|
|
8
|
+
|
|
9
|
+
const value = ref('')
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<div class="top_nav_main">
|
|
14
|
+
<VanRow gutter="54" align="center">
|
|
15
|
+
<VanCol span="2">
|
|
16
|
+
<img alt="default-user-profile" class="default_user_profile" src="../../assets/common/default-user-profile.png">
|
|
17
|
+
</VanCol>
|
|
18
|
+
<VanCol span="22">
|
|
19
|
+
<VanSearch v-model="value" placeholder="请输入搜索关键词" />
|
|
20
|
+
</VanCol>
|
|
21
|
+
</VanRow>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<style scoped lang="less">
|
|
26
|
+
.top_nav_main {
|
|
27
|
+
padding-bottom: var(--base-interval-1);
|
|
28
|
+
}
|
|
29
|
+
.default_user_profile {
|
|
30
|
+
border-radius: 50%;
|
|
31
|
+
width: 33px;
|
|
32
|
+
height: 33px;
|
|
33
|
+
position: relative;
|
|
34
|
+
top: 2px;
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { http } from '@af-mobile-client-vue3/utils/http'
|
|
3
|
-
import { showDialog, Loading as VanLoading } from 'vant'
|
|
4
|
-
import { onMounted, ref } from 'vue'
|
|
5
|
-
import { useRoute } from 'vue-router'
|
|
6
|
-
|
|
7
|
-
// 获取url中的sellid参数
|
|
8
|
-
const route = useRoute()
|
|
9
|
-
const sellid = route.query.sellid
|
|
10
|
-
const showLoading = ref(true)
|
|
11
|
-
|
|
12
|
-
onMounted(async () => {
|
|
13
|
-
if (sellid) {
|
|
14
|
-
http.request({
|
|
15
|
-
url: '/invoice/rs/logic/getInvoiceBySellId',
|
|
16
|
-
method: 'post',
|
|
17
|
-
data: {
|
|
18
|
-
sellid,
|
|
19
|
-
},
|
|
20
|
-
}).then((_res: any) => {
|
|
21
|
-
showLoading.value = false
|
|
22
|
-
if (_res.type === 'success') {
|
|
23
|
-
if (_res.url)
|
|
24
|
-
window.open(_res.url)
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
showDialog({
|
|
28
|
-
message: _res.msg,
|
|
29
|
-
theme: 'round-button',
|
|
30
|
-
showConfirmButton: false,
|
|
31
|
-
}).then(() => {
|
|
32
|
-
// on close
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
</script>
|
|
39
|
-
|
|
40
|
-
<template>
|
|
41
|
-
<div class="invoiceShow">
|
|
42
|
-
<VanLoading v-if="showLoading" type="spinner" color="#1989fa" vertical>
|
|
43
|
-
正在努力获取发票信息,请稍后。。。
|
|
44
|
-
</VanLoading>
|
|
45
|
-
</div>
|
|
46
|
-
</template>
|
|
47
|
-
|
|
48
|
-
<style scoped lang="less">
|
|
49
|
-
.invoiceShow {
|
|
50
|
-
width: 100vw !important;
|
|
51
|
-
height: 100vh !important;
|
|
52
|
-
overflow-y: hidden;
|
|
53
|
-
display: flex;
|
|
54
|
-
justify-content: center;
|
|
55
|
-
align-items: center;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.invoiceShow > * {
|
|
59
|
-
transform: scale(1.5);
|
|
60
|
-
}
|
|
61
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { http } from '@af-mobile-client-vue3/utils/http'
|
|
3
|
+
import { showDialog, Loading as VanLoading } from 'vant'
|
|
4
|
+
import { onMounted, ref } from 'vue'
|
|
5
|
+
import { useRoute } from 'vue-router'
|
|
6
|
+
|
|
7
|
+
// 获取url中的sellid参数
|
|
8
|
+
const route = useRoute()
|
|
9
|
+
const sellid = route.query.sellid
|
|
10
|
+
const showLoading = ref(true)
|
|
11
|
+
|
|
12
|
+
onMounted(async () => {
|
|
13
|
+
if (sellid) {
|
|
14
|
+
http.request({
|
|
15
|
+
url: '/invoice/rs/logic/getInvoiceBySellId',
|
|
16
|
+
method: 'post',
|
|
17
|
+
data: {
|
|
18
|
+
sellid,
|
|
19
|
+
},
|
|
20
|
+
}).then((_res: any) => {
|
|
21
|
+
showLoading.value = false
|
|
22
|
+
if (_res.type === 'success') {
|
|
23
|
+
if (_res.url)
|
|
24
|
+
window.open(_res.url)
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
showDialog({
|
|
28
|
+
message: _res.msg,
|
|
29
|
+
theme: 'round-button',
|
|
30
|
+
showConfirmButton: false,
|
|
31
|
+
}).then(() => {
|
|
32
|
+
// on close
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<div class="invoiceShow">
|
|
42
|
+
<VanLoading v-if="showLoading" type="spinner" color="#1989fa" vertical>
|
|
43
|
+
正在努力获取发票信息,请稍后。。。
|
|
44
|
+
</VanLoading>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<style scoped lang="less">
|
|
49
|
+
.invoiceShow {
|
|
50
|
+
width: 100vw !important;
|
|
51
|
+
height: 100vh !important;
|
|
52
|
+
overflow-y: hidden;
|
|
53
|
+
display: flex;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
align-items: center;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.invoiceShow > * {
|
|
59
|
+
transform: scale(1.5);
|
|
60
|
+
}
|
|
61
|
+
</style>
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import ForgetPasswordForm from './ForgetPasswordForm.vue'
|
|
3
|
-
import LoginForm from './LoginForm.vue'
|
|
4
|
-
import LoginTitle from './LoginTitle.vue'
|
|
5
|
-
</script>
|
|
6
|
-
|
|
7
|
-
<template>
|
|
8
|
-
<div class="login_container">
|
|
9
|
-
<LoginTitle />
|
|
10
|
-
<LoginForm />
|
|
11
|
-
<ForgetPasswordForm />
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<style scoped lang="less">
|
|
16
|
-
.login_container {
|
|
17
|
-
height: 100vh;
|
|
18
|
-
padding-top: 10px;
|
|
19
|
-
background: var(--van-background-2);
|
|
20
|
-
position: relative;
|
|
21
|
-
}
|
|
22
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import ForgetPasswordForm from './ForgetPasswordForm.vue'
|
|
3
|
+
import LoginForm from './LoginForm.vue'
|
|
4
|
+
import LoginTitle from './LoginTitle.vue'
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<div class="login_container">
|
|
9
|
+
<LoginTitle />
|
|
10
|
+
<LoginForm />
|
|
11
|
+
<ForgetPasswordForm />
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<style scoped lang="less">
|
|
16
|
+
.login_container {
|
|
17
|
+
height: 100vh;
|
|
18
|
+
padding-top: 10px;
|
|
19
|
+
background: var(--van-background-2);
|
|
20
|
+
position: relative;
|
|
21
|
+
}
|
|
22
|
+
</style>
|
package/vite.config.ts
CHANGED
|
@@ -65,7 +65,8 @@ export default ({ mode }: ConfigEnv): UserConfig => {
|
|
|
65
65
|
rewrite: path => path.replace(/^\/linepatrol\/geoserver/, '/geoserver'),
|
|
66
66
|
},
|
|
67
67
|
// MateChat 聊天 API 代理
|
|
68
|
-
'/api/
|
|
68
|
+
'/api/fastApi': {
|
|
69
|
+
rewrite: (path: string) => path.replace(/^\/api\/fastApi/, '/api'),
|
|
69
70
|
target: 'http://k8s.aofengcloud.com:32202',
|
|
70
71
|
ws: false,
|
|
71
72
|
changeOrigin: true,
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance } from 'axios'
|
|
2
|
-
import axios from 'axios'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 聊天消息接口
|
|
6
|
-
*/
|
|
7
|
-
export interface ChatMessage {
|
|
8
|
-
role: 'user' | 'assistant' | 'system'
|
|
9
|
-
content: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 聊天请求参数接口
|
|
14
|
-
*/
|
|
15
|
-
export interface ChatCompletionsRequest {
|
|
16
|
-
chatId: string
|
|
17
|
-
stream: boolean
|
|
18
|
-
detail: boolean
|
|
19
|
-
variables: {
|
|
20
|
-
uid: string
|
|
21
|
-
name: string
|
|
22
|
-
}
|
|
23
|
-
messages: ChatMessage[]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 聊天响应使用情况接口
|
|
28
|
-
*/
|
|
29
|
-
export interface ChatUsage {
|
|
30
|
-
prompt_tokens: number
|
|
31
|
-
completion_tokens: number
|
|
32
|
-
total_tokens: number
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 聊天响应选择项接口
|
|
37
|
-
*/
|
|
38
|
-
export interface ChatChoice {
|
|
39
|
-
message: {
|
|
40
|
-
role: 'assistant'
|
|
41
|
-
content: string
|
|
42
|
-
}
|
|
43
|
-
finish_reason: string
|
|
44
|
-
index: number
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 聊天响应接口
|
|
49
|
-
*/
|
|
50
|
-
export interface ChatCompletionsResponse {
|
|
51
|
-
id: string
|
|
52
|
-
model: string
|
|
53
|
-
usage: ChatUsage
|
|
54
|
-
choices: ChatChoice[]
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 创建独立的 axios 实例,不经过拦截器
|
|
59
|
-
*/
|
|
60
|
-
const chatAxiosInstance: AxiosInstance = axios.create({
|
|
61
|
-
baseURL: import.meta.env.VITE_APP_API_BASE_URL || '',
|
|
62
|
-
timeout: 20000,
|
|
63
|
-
headers: {
|
|
64
|
-
'Content-Type': 'application/json',
|
|
65
|
-
},
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 发送聊天请求
|
|
70
|
-
* @param content 用户输入的内容
|
|
71
|
-
* @returns Promise<ChatCompletionsResponse>
|
|
72
|
-
*/
|
|
73
|
-
/**
|
|
74
|
-
* 发送聊天请求
|
|
75
|
-
* @param content 用户输入的内容
|
|
76
|
-
* @returns Promise<ChatCompletionsResponse>
|
|
77
|
-
*/
|
|
78
|
-
export function chatCompletions(content: string): Promise<ChatCompletionsResponse> {
|
|
79
|
-
const requestData: ChatCompletionsRequest = {
|
|
80
|
-
chatId: 'chatId13333113',
|
|
81
|
-
stream: false,
|
|
82
|
-
detail: false,
|
|
83
|
-
variables: {
|
|
84
|
-
uid: 'asdfadsfasfd2323',
|
|
85
|
-
name: '张三',
|
|
86
|
-
},
|
|
87
|
-
messages: [
|
|
88
|
-
{
|
|
89
|
-
role: 'user',
|
|
90
|
-
content,
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return chatAxiosInstance.post<ChatCompletionsResponse>(
|
|
96
|
-
'/v1/chat/completions',
|
|
97
|
-
requestData,
|
|
98
|
-
{
|
|
99
|
-
headers: {
|
|
100
|
-
Authorization: 'Bearer fastgpt-jqZX5C3vo7pUgzqIGdYsdSy5Nb72qxqgSVnAbUWTtYmoP5Yzvh8wgBdIwhXqaf',
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
).then(response => response.data)
|
|
104
|
-
}
|