Compare commits
6 Commits
cdf-releas
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
a222fed6e2 | ||
|
149670c3cf | ||
|
0b1426b72f | ||
|
1250b670e9 | ||
|
a21420754c | ||
c2fcf9c0e2 |
12
README.md
12
README.md
@ -79,3 +79,15 @@
|
|||||||
- web平台: `pnpm build:h5`,打包后的文件在 `dist/build/h5`,可以放到web服务器,如nginx运行。如果最终不是放在根目录,可以在 `manifest.config.ts` 文件的 `h5.router.base` 属性进行修改。
|
- web平台: `pnpm build:h5`,打包后的文件在 `dist/build/h5`,可以放到web服务器,如nginx运行。如果最终不是放在根目录,可以在 `manifest.config.ts` 文件的 `h5.router.base` 属性进行修改。
|
||||||
- weixin平台:`pnpm build:mp-weixin`, 打包后的文件在 `dist/build/mp-weixin`,然后通过微信开发者工具导入,并点击右上角的“上传”按钮进行上传。
|
- weixin平台:`pnpm build:mp-weixin`, 打包后的文件在 `dist/build/mp-weixin`,然后通过微信开发者工具导入,并点击右上角的“上传”按钮进行上传。
|
||||||
- APP平台:`pnpm build:app`, 然后打开 `HBuilderX`,导入刚刚生成的`dist/build/app` 文件夹,选择发行 - APP云打包。
|
- APP平台:`pnpm build:app`, 然后打开 `HBuilderX`,导入刚刚生成的`dist/build/app` 文件夹,选择发行 - APP云打包。
|
||||||
|
|
||||||
|
主要代码路径:AIchat\src\pages\index\index.vue
|
||||||
|
其他文件删除时需要注意是否被AIchat\src\pages\index\index.vue引用
|
||||||
|
|
||||||
|
# 发版 只看这里
|
||||||
|
|
||||||
|
- 现在只用ob
|
||||||
|
- 发正式 pnpm build:h5执行后,打包 AIchat\dist\build\h5,压缩文件名 obAiChat-xiaomo.zip,注意 env/.env.production下请求地址
|
||||||
|
- 上传至 <http://114.218.158.24:8044/files/prod/front/AIchat/>, 然后构建 【线上】前端 front-obaichat-xiaomo
|
||||||
|
- 查看<https://xiaomo.fiee.com> 是否更新
|
||||||
|
- 请求地址为 <https://oa-a.szjixun.cn/api>
|
||||||
|
- 此项目提交commit有规则,通用为 fix: xxx
|
||||||
|
1
env/.env
vendored
1
env/.env
vendored
@ -8,6 +8,7 @@ VITE_DEV_TOKEN= ""
|
|||||||
VITE_APP_PUBLIC_BASE=/
|
VITE_APP_PUBLIC_BASE=/
|
||||||
|
|
||||||
VITE_SERVER_BASEURL = 'http://114.218.158.24:9020'
|
VITE_SERVER_BASEURL = 'http://114.218.158.24:9020'
|
||||||
|
# VITE_SERVER_BASEURL = 'https://oa-b.szjixun.cn/api'
|
||||||
VITE_UPLOAD_BASEURL = 'http://114.218.158.24:9020'
|
VITE_UPLOAD_BASEURL = 'http://114.218.158.24:9020'
|
||||||
|
|
||||||
# 有些同学可能需要在微信小程序里面根据 develop、trial、release 分别设置上传地址,参考代码如下。
|
# 有些同学可能需要在微信小程序里面根据 develop、trial、release 分别设置上传地址,参考代码如下。
|
||||||
|
4
env/.env.development
vendored
4
env/.env.development
vendored
@ -12,10 +12,10 @@ VITE_SHOW_SOURCEMAP = true
|
|||||||
# VITE_SERVER_BASEURL = 'https://warehouse.szjixun.cn/oa_backend'
|
# VITE_SERVER_BASEURL = 'https://warehouse.szjixun.cn/oa_backend'
|
||||||
|
|
||||||
#体制外
|
#体制外
|
||||||
# VITE_SERVER_BASEURL = 'https://oa-a.szjixun.cn/api'
|
VITE_SERVER_BASEURL = 'https://oa-a.szjixun.cn/api'
|
||||||
|
|
||||||
# 体制内
|
# 体制内
|
||||||
VITE_SERVER_BASEURL = 'https://oa-b.szjixun.cn/api'
|
# VITE_SERVER_BASEURL = 'https://oa-b.szjixun.cn/api'
|
||||||
# VITE_SERVER_BASEURL = 'https://oa-b.szjixun.cn/api'
|
# VITE_SERVER_BASEURL = 'https://oa-b.szjixun.cn/api'
|
||||||
# VITE_SERVER_BASEURL = 'https://erpapi.fontree.cn'
|
# VITE_SERVER_BASEURL = 'https://erpapi.fontree.cn'
|
||||||
|
|
||||||
|
4
env/.env.production
vendored
4
env/.env.production
vendored
@ -10,10 +10,10 @@ VITE_SHOW_SOURCEMAP = false
|
|||||||
# VITE_SERVER_BASEURL = 'https://warehouse.szjixun.cn/oa_backend'
|
# VITE_SERVER_BASEURL = 'https://warehouse.szjixun.cn/oa_backend'
|
||||||
# VITE_SERVER_BASEURL = 'https://oa-a.szjixun.cn/api'
|
# VITE_SERVER_BASEURL = 'https://oa-a.szjixun.cn/api'
|
||||||
#体制外
|
#体制外
|
||||||
# VITE_SERVER_BASEURL = 'https://oa-a.szjixun.cn/api'
|
VITE_SERVER_BASEURL = 'https://oa-a.szjixun.cn/api'
|
||||||
|
|
||||||
# 体制内
|
# 体制内
|
||||||
VITE_SERVER_BASEURL = 'https://oa-b.szjixun.cn/api'
|
# VITE_SERVER_BASEURL = 'https://oa-b.szjixun.cn/api'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
<div class="flex flex-col h-screen bg-#ffffff tops">
|
<div class="flex flex-col h-screen bg-#ffffff tops">
|
||||||
<!-- Navigation Bar -->
|
<!-- Navigation Bar -->
|
||||||
<div
|
<div
|
||||||
class="flex-none flex items-center justify-between px-5 pb-6 bg-white shadow-md h-20 pt-15 z-999 fixed top-0 w-full box-border"
|
class="flex-none flex items-center justify-between px-5 pb-2 bg-white shadow-md pt-2 z-999 fixed w-full box-border"
|
||||||
|
:style="{ top: statusBarHeight + 'px' }"
|
||||||
>
|
>
|
||||||
<image src="/static/aichat/black.png" class="w-3 h-4.5" @click="goBack" />
|
<image src="/static/aichat/black.png" class="w-3 h-4.5" @click="goBack" />
|
||||||
<div class="text-lg font-medium ml-12">小墨</div>
|
<div class="text-lg font-medium ml-12">小墨</div>
|
||||||
@ -21,7 +22,6 @@
|
|||||||
<image src="/static/aichat/new.png" class="w-5 h-5" @click="newChat" />
|
<image src="/static/aichat/new.png" class="w-5 h-5" @click="newChat" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 消息区 -->
|
<!-- 消息区 -->
|
||||||
<div
|
<div
|
||||||
:class="[
|
:class="[
|
||||||
@ -514,7 +514,6 @@ import {
|
|||||||
import 'dayjs/locale/zh-cn'
|
import 'dayjs/locale/zh-cn'
|
||||||
import { showToastErr, showToastOk, time_format3 } from '@/utils/tools'
|
import { showToastErr, showToastOk, time_format3 } from '@/utils/tools'
|
||||||
import { uploadFileChunk } from './utils/api.js'
|
import { uploadFileChunk } from './utils/api.js'
|
||||||
// import { TOKEN, AVATAR } from './utils/test'
|
|
||||||
import { deepClone } from 'wot-design-uni/components/common/util'
|
import { deepClone } from 'wot-design-uni/components/common/util'
|
||||||
import VConsole from 'vconsole'
|
import VConsole from 'vconsole'
|
||||||
|
|
||||||
@ -627,11 +626,16 @@ async function createChatSession() {
|
|||||||
gptModel: chatMode.value,
|
gptModel: chatMode.value,
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
Authorization: token.value,
|
Authorization: chatToken.value,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
// 如果后台返回新的会话信息,可以在这里处理,比如拿到 listUuid 等
|
// 如果后台返回新的会话信息,可以在这里处理,比如拿到 listUuid 等
|
||||||
|
if (res.data.status === 401) {
|
||||||
|
const { token: newToken } = await window.NativeBridge.call('auth.refreshToken')
|
||||||
|
chatToken.value = newToken
|
||||||
|
createChatSession()
|
||||||
|
return
|
||||||
|
}
|
||||||
if (res.data.code === 0 && res?.data?.data?.listUuid) {
|
if (res.data.code === 0 && res?.data?.data?.listUuid) {
|
||||||
listUuid.value = res?.data?.data?.listUuid
|
listUuid.value = res?.data?.data?.listUuid
|
||||||
} else {
|
} else {
|
||||||
@ -669,10 +673,14 @@ async function fetchHistoryList() {
|
|||||||
page: state.page,
|
page: state.page,
|
||||||
pageSize: state.pageSize,
|
pageSize: state.pageSize,
|
||||||
},
|
},
|
||||||
header: {
|
header: {},
|
||||||
// Authorization: token.value,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
if (resp.data.status === 401) {
|
||||||
|
const { token: newToken } = await window.NativeBridge.call('auth.refreshToken')
|
||||||
|
chatToken.value = newToken
|
||||||
|
fetchHistoryList()
|
||||||
|
return
|
||||||
|
}
|
||||||
if (resp.data.code == 0 && resp.data.data) {
|
if (resp.data.code == 0 && resp.data.data) {
|
||||||
if (rawList.value.length > 0) {
|
if (rawList.value.length > 0) {
|
||||||
rawList.value = rawList.value.concat(resp.data.data.data)
|
rawList.value = rawList.value.concat(resp.data.data.data)
|
||||||
@ -731,10 +739,14 @@ async function fetchHistoryDiets(value) {
|
|||||||
listUuid: value,
|
listUuid: value,
|
||||||
gptModel: chatMode.value,
|
gptModel: chatMode.value,
|
||||||
},
|
},
|
||||||
header: {
|
header: {},
|
||||||
// Authorization: token.value,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
if (resp.data.status === 401) {
|
||||||
|
const { token: newToken } = await window.NativeBridge.call('auth.refreshToken')
|
||||||
|
chatToken.value = newToken
|
||||||
|
fetchHistoryDiets(value)
|
||||||
|
return
|
||||||
|
}
|
||||||
if (resp.data.status === 0 && resp.data && resp.data.data) {
|
if (resp.data.status === 0 && resp.data && resp.data.data) {
|
||||||
const rawList = resp?.data?.data?.detail // 假设后端直接返回消息数组
|
const rawList = resp?.data?.data?.detail // 假设后端直接返回消息数组
|
||||||
listUuid.value = resp?.data?.data?.listUuid
|
listUuid.value = resp?.data?.data?.listUuid
|
||||||
@ -1004,35 +1016,31 @@ function tryParseMapFormat(str: string): ParsedPart[] | null {
|
|||||||
return result.length > 0 ? result : null
|
return result.length > 0 ? result : null
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = ref<string>()
|
const chatToken = ref<string>()
|
||||||
const userInfo = ref<any>({})
|
const chatUserInfo = ref<any>({})
|
||||||
const refreshToken = ref<string>('')
|
let statusBarHeight = ref<number>(0)
|
||||||
const statusBarHeight = ref<number>(0)
|
|
||||||
const mask = ref('')
|
const mask = ref('')
|
||||||
// ---- 页面初始化 ----
|
// ---- 页面初始化 ----
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
const info = await window?.NativeBridge?.call('device.getInfo')
|
||||||
|
if (info) statusBarHeight.value += info.safeAreaInsets.top
|
||||||
|
|
||||||
|
const { token } = await window.NativeBridge.getAccessToken()
|
||||||
|
const { user } = await window.NativeBridge.call('auth.getUser')
|
||||||
|
chatToken.value = token
|
||||||
|
chatUserInfo.value = user
|
||||||
// 1. 定义一个 init 函数,拿 Extras 并依次调用接口
|
// 1. 定义一个 init 函数,拿 Extras 并依次调用接口
|
||||||
try {
|
try {
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
const wv = plus.webview.currentWebview() // 获取当前页面所属的 Webview 对象。
|
const wv = plus.webview.currentWebview() // 获取当前页面所属的 Webview 对象。
|
||||||
token.value =
|
userAvatar.value = chatUserInfo.value.Avatar
|
||||||
wv.token ||
|
mask.value = chatUserInfo.value.ID
|
||||||
uni.getStorageSync('token') ||
|
|
||||||
store.userInfo.token ||
|
|
||||||
import.meta.env.VITE_DEV_TOKEN
|
|
||||||
userInfo.value = JSON.parse(wv.userInfo) || {}
|
|
||||||
refreshToken.value = wv.refreshToken || uni.getStorageSync('refreshToken')
|
|
||||||
statusBarHeight.value = wv.statusBarHeight || uni.getSystemInfoSync().statusBarHeight
|
|
||||||
userAvatar.value = userInfo.value.Avatar
|
|
||||||
mask.value = userInfo.value.ID
|
|
||||||
store.setUserInfo({
|
store.setUserInfo({
|
||||||
token: token.value,
|
token: chatToken.value,
|
||||||
avatar: userInfo.value.Avatar,
|
avatar: chatUserInfo.value.Avatar,
|
||||||
refreshToken: refreshToken.value,
|
|
||||||
statusBarHeight: statusBarHeight.value,
|
|
||||||
})
|
})
|
||||||
if (userInfo.value.TelNum === '18639432358') {
|
if (chatUserInfo.value.TelNum === '18639432358') {
|
||||||
new VConsole()
|
new VConsole()
|
||||||
}
|
}
|
||||||
await createChatSession()
|
await createChatSession()
|
||||||
@ -1041,12 +1049,7 @@ onMounted(async () => {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('onMounted e: ', e)
|
console.error('onMounted e: ', e)
|
||||||
} finally {
|
} finally {
|
||||||
// store.userInfo.token = ''
|
|
||||||
// token.value = store.userInfo.token
|
|
||||||
}
|
}
|
||||||
// if (JSON.parse(uni.getStorageSync('userInfo'))?.NickName === '常东方') {
|
|
||||||
// new VConsole()
|
|
||||||
// }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function scrollToBottom() {
|
function scrollToBottom() {
|
||||||
@ -1098,9 +1101,10 @@ const shouldShowTimestamp = (i: number) => {
|
|||||||
const formatDayGroup = (d: Date) => dayjs(d).format('YYYY/MM/DD HH:mm')
|
const formatDayGroup = (d: Date) => dayjs(d).format('YYYY/MM/DD HH:mm')
|
||||||
const formatTimeShort = (d: Date) => dayjs(d).format('MM/DD HH:mm')
|
const formatTimeShort = (d: Date) => dayjs(d).format('MM/DD HH:mm')
|
||||||
|
|
||||||
function goBack() {
|
async function goBack() {
|
||||||
const wv = plus.webview.currentWebview()
|
await window.NativeBridge.router.back()
|
||||||
wv.close('slide-out-right', 300) // 或者直接 wv.close()
|
// const wv = plus.webview.currentWebview()
|
||||||
|
// wv.close('slide-out-right', 300) // 或者直接 wv.close()
|
||||||
}
|
}
|
||||||
function viewHistory() {
|
function viewHistory() {
|
||||||
uni.navigateTo({ url: '/pages/history/history' })
|
uni.navigateTo({ url: '/pages/history/history' })
|
||||||
@ -1908,12 +1912,11 @@ const send = async (body) => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Authorization: token.value,
|
Authorization: chatToken.value,
|
||||||
},
|
},
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
signal: signal,
|
signal: signal,
|
||||||
})
|
})
|
||||||
// console.log(resp)
|
|
||||||
|
|
||||||
const reader = resp.body!.getReader()
|
const reader = resp.body!.getReader()
|
||||||
const decoder = new TextDecoder()
|
const decoder = new TextDecoder()
|
||||||
@ -1922,8 +1925,6 @@ const send = async (body) => {
|
|||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
if (stopStreamMsg) {
|
if (stopStreamMsg) {
|
||||||
// 立刻停下
|
|
||||||
// reader.cancel();
|
|
||||||
controller.abort()
|
controller.abort()
|
||||||
stopStreamMsg = false
|
stopStreamMsg = false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user