Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Synaptrix/ChatGPT-Desktop
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.3
Choose a base ref
...
head repository: Synaptrix/ChatGPT-Desktop
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.0.4
Choose a head ref
  • 6 commits
  • 14 files changed
  • 3 contributors

Commits on Mar 20, 2023

  1. Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    7d9e298 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    72107aa View commit details
  3. Copy the full SHA
    e2a2565 View commit details
  4. Copy the full SHA
    55ab28f View commit details
  5. chore: update version (#40)

    ayangweb authored Mar 20, 2023
    Copy the full SHA
    0689305 View commit details
  6. v0.0.4

    ayangweb committed Mar 20, 2023
    Copy the full SHA
    872eee9 View commit details
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@


## [0.0.4](https://github.com/bilibili-ayang/ChatGPT-desktop/compare/v0.0.3...v0.0.4) (2023-03-20)


### Bug Fixes

* filter role list problem ([#34](https://github.com/bilibili-ayang/ChatGPT-desktop/issues/34)) ([7d9e298](https://github.com/bilibili-ayang/ChatGPT-desktop/commit/7d9e298dcce28f07e6d17abdfe7916d4c522b451))


### Features

* add sessionList style close [#35](https://github.com/bilibili-ayang/ChatGPT-desktop/issues/35) ([#36](https://github.com/bilibili-ayang/ChatGPT-desktop/issues/36)) ([72107aa](https://github.com/bilibili-ayang/ChatGPT-desktop/commit/72107aa8569fdc605161f22125d19e3d2b81900a))


### Performance Improvements

* optimized the display of session content ([#39](https://github.com/bilibili-ayang/ChatGPT-desktop/issues/39)) ([55ab28f](https://github.com/bilibili-ayang/ChatGPT-desktop/commit/55ab28f6876a23d1f7426fd4bf5dbfadc021854e))

## [0.0.3](https://github.com/bilibili-ayang/ChatGPT-desktop/compare/v0.0.2...v0.0.3) (2023-03-20)


3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ChatGPT-Desktop",
"private": true,
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"scripts": {
"dev": "npm run build:icon && vite",
@@ -23,6 +23,7 @@
"@multiavatar/multiavatar": "^1.0.7",
"@tauri-apps/api": "^1.2.0",
"@types/marked": "^4.0.8",
"dayjs": "^1.11.7",
"highlight.js": "^11.7.0",
"html-to-image": "^1.11.11",
"markdown-it": "^13.0.1",
3 changes: 2 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chat_gpt"
version = "0.0.2"
version = "0.0.4"
description = "ChatGPT-Desktop"
authors = ["orangelckc", "bilibili-ayang"]
license = "MIT"
3 changes: 1 addition & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -87,8 +87,7 @@
}
],
"systemTray": {
"iconPath": "assets/tray.png",
"iconAsTemplate": true
"iconPath": "assets/tray.png"
}
}
}
7 changes: 4 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ onMounted(async () => {
// 监听窗口有无获取焦点
appWindow.onFocusChanged(({ payload }) => {
windowFocused.value = payload
setTimeout(() => {
if (!windowFocused.value && !isFix.value) appWindow.hide()
}, 100)
@@ -37,11 +38,11 @@ onMounted(async () => {
</div>

<template v-else>
<div class="text-7 z-999 fixed top-2 right-2 flex gap-2">
<!-- 主题切换 -->
<Theme />
<div class="text-7 z-999 fixed top-2 left-2 flex flex-col gap-2">
<!-- 固定窗口 -->
<Fixed />
<!-- 主题切换 -->
<Theme />
</div>

<!-- 会话信息 -->
25 changes: 17 additions & 8 deletions src/api/openAi.ts
Original file line number Diff line number Diff line change
@@ -56,6 +56,17 @@ export const getOpenAIResultStreamApi = async (messages: MessageData[]) => {
'Content-Type': 'application/json',
Accept: 'application/json'
},
async onopen(response) {
if (response.ok) return

if (response.status === 429) {
throw new Error('请求的 key 超出限制')
} else if (response.status === 401) {
throw new Error('请求的 API KEY 无效')
} else {
throw new Error('请求出错')
}
},
onmessage(msg: EventSourceMessage) {
if (msg.data !== '[DONE]') {
const { choices } = JSON.parse(msg.data)
@@ -70,7 +81,7 @@ export const getOpenAIResultStreamApi = async (messages: MessageData[]) => {
updateSessionData(sessionDataList.value.at(-1)!)
},
onerror({ message }: any) {
throw new Error(`流输出出错:${message}`)
throw new Error(message)
}
})
}
@@ -87,7 +98,8 @@ export const getAiMessage = async (value?: string) => {
return
}

const { isThinking } = storeToRefs(useSessionStore())
const { isThinking, sessionDataList } = storeToRefs(useSessionStore())
const { updateSessionData } = useSessionStore()

try {
const { currentRole } = useRoleStore()
@@ -167,12 +179,9 @@ export const getAiMessage = async (value?: string) => {

isThinking.value = false
} catch ({ message }: any) {
// TODO: 删除失败的询问和回答项
if (message.includes('timed out')) {
dialogErrorMessage('请求超时!')
} else {
dialogErrorMessage('填写的 API KEY 无效')
}
sessionDataList.value.at(-1)!.message.content = message

updateSessionData(sessionDataList.value.at(-1)!)

isThinking.value = false
}
6 changes: 5 additions & 1 deletion src/assets/css/theme.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
body {
--background-color: #f2f3f5;

--scroll-thumb-color: #c0c0c0;
--scroll-thumb-color-hover: #a7a7a7;
--scroll-track-color: #f1f1f1;
}

body[theme-mode="dark"] {
body[arco-theme='dark'] {
--background-color: #17171a;

--scroll-thumb-color: #686868;
--scroll-thumb-color-hover: #7a7a7a;
--scroll-track-color: #444;
16 changes: 8 additions & 8 deletions src/components/Function/index.vue
Original file line number Diff line number Diff line change
@@ -21,14 +21,14 @@ const disabled = computed(
// 控制设置弹框
const modalVisible = ref(false)
const setModalVisible = () => {
modalVisible.value = !modalVisible.value
const closeModal = () => {
modalVisible.value = false
}
// 控制历史列表抽屉
const drawerVisible = ref(false)
const setDrawerVisible = () => {
drawerVisible.value = !drawerVisible.value
const closeDrawer = () => {
drawerVisible.value = false
}
// TODO: 在获取数据时删除的处理,在获取数据时切换历史记录的处理
@@ -54,12 +54,12 @@ const functions = computed(() => [
{
content: '历史记录',
icon: IconHistory,
handleClick: setDrawerVisible
handleClick: () => (drawerVisible.value = true)
},
{
content: '设置',
icon: IconSettings,
handleClick: setModalVisible
handleClick: () => (modalVisible.value = true)
}
])
</script>
@@ -96,10 +96,10 @@ const functions = computed(() => [
</div>

<!-- 设置弹框 -->
<SettingsModal :visible="modalVisible" :set-visible="setModalVisible" />
<SettingsModal :visible="modalVisible" :set-visible="closeModal" />

<!-- 历史会话抽屉 -->
<HistoryDrawer :visible="drawerVisible" :set-visible="setDrawerVisible" />
<HistoryDrawer :visible="drawerVisible" :set-visible="closeDrawer" />
</template>

<style scoped lang="scss">
9 changes: 4 additions & 5 deletions src/components/Input/components/RoleList.vue
Original file line number Diff line number Diff line change
@@ -11,20 +11,21 @@ import type { RolePayload } from '@/types'
const roleStore = useRoleStore()
const { getRoleList, updateRole, deleteRole, addRole } = roleStore
const { currentRole, roleList, filterRoleList, popoverVisible } =
const { currentRole, roleList, filterRoleList, popoverVisible, isEdit } =
storeToRefs(roleStore)
const { sessionDataList } = storeToRefs(useSessionStore())
const isAdd = ref(false)
const isEdit = computed(() => roleList.value.some((item) => item.isEdit))
const renderList = computed(() =>
filterRoleList.value.length && !isAdd.value
? filterRoleList.value
: roleList.value
)
watch(renderList, () => handleVisible(!!renderList.value.length))
const handleVisible = (value: boolean) => {
if (sessionDataList.value.length || isAdd.value || isEdit.value) return
@@ -33,12 +34,11 @@ const handleVisible = (value: boolean) => {
const handleAdd = () => {
isAdd.value = true
filterRoleList.value = []
roleList.value = [{ name: '', description: '', isEdit: true }]
}
const handleClick = () => {
getRoleList()
if (sessionDataList.value.length) {
Message.info({ content: '每个会话只能选择一个对话角色' })
@@ -108,7 +108,6 @@ const handleClose = () => {
</script>

<!-- TODO: 优化代码 -->
<!-- 修改和添加后期可优化为modal,会省去很多代码和 bug -->
<template>
<a-popover
title="请选择对话的角色"
8 changes: 2 additions & 6 deletions src/components/Input/index.vue
Original file line number Diff line number Diff line change
@@ -8,13 +8,10 @@ const recordStore = useSessionStore()
const { isThinking } = storeToRefs(recordStore)
const roleStore = useRoleStore()
const { getFilterRoleList } = roleStore
const { currentRole, isEdit } = storeToRefs(roleStore)
const { currentRole, isEdit, textAreaValue } = storeToRefs(roleStore)
const textAreaElement = ref<HTMLTextAreaElement | null>(null)
const textAreaValue = ref('')
const onKeydown = (event: KeyboardEvent) => {
if (event.key === 'Enter') {
if (isEdit.value) {
@@ -67,10 +64,9 @@ onMounted(() => {
class="bordered bg-transparent!"
:placeholder="isThinking ? 'AI 正在思考...' : '有什么问题尽管问我'"
v-model="textAreaValue"
:disabled="isThinking"
:disabled="isThinking || isEdit"
auto-size
clearable
@input="getFilterRoleList"
@keydown="onKeydown"
></a-textarea>
</div>
Loading