Skip to content

Commit

Permalink
v1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gcslaoli committed Mar 31, 2023
1 parent 61db812 commit 08c9798
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 29 deletions.
19 changes: 19 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,22 @@ func (a *App) ChatProcess(req *ChatProcessReq) {
func (a *App) StopChat() {
g.Log().Info(a.ctx, "StopChat~~~~~~~~~~~~~~~~~~~~")
}

// RefreshBind
func (a *App) RefreshBind(baseURI string, accessToken string) (result string) {
g.Log().Info(a.ctx, "RefreshToken~~~~~~~~~~~~~~~~~~~~", baseURI, accessToken)
res, err := g.Client().ContentJson().Post(a.ctx, baseURI+"/backend-api/xy/refresh-bind", g.Map{
"token": accessToken,
})
if err != nil {
g.Log().Error(a.ctx, "RefreshToken", err)
return "fail"
}
defer res.Close()
if res.StatusCode != 200 {
g.Log().Error(a.ctx, "RefreshToken", res.ReadAllString())
return "fail"
}

return "success"
}
Binary file added frontend/public/defaultavatar.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 30 additions & 25 deletions frontend/src/components/common/Setting/General.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { NButton, NInput, NPopconfirm, NSelect, useMessage } from 'naive-ui'
import { RefreshBind } from '../../../../wailsjs/go/main/App'
import type { Language, Theme } from '@/store/modules/app/helper'
import { SvgIcon } from '@/components/common'
import { useAppStore, useUserStore } from '@/store'
Expand Down Expand Up @@ -122,6 +123,16 @@ function handleImportButtonClick(): void {
if (fileInput)
fileInput.click()
}
function handleRefreshBind(baseURI: string, accessToken: string) {
RefreshBind(baseURI, accessToken).then((res) => {
if (res === 'success')
ms.success(t('common.success'))
else
ms.error(t('common.failed'))
})
}
</script>

<template>
Expand All @@ -135,6 +146,9 @@ function handleImportButtonClick(): void {
<NButton size="tiny" text type="primary" @click="updateUserInfo({ baseURI })">
{{ $t('common.save') }}
</NButton>
<NButton size="tiny" text type="warning" @click="handleRefreshBind(baseURI, accessToken)">
{{ $t('common.refreshBinding') }}
</NButton>
</div>
<div class="flex items-center space-x-4">
<span class="flex-shrink-0 w-[100px]">AccessToken</span>
Expand All @@ -146,20 +160,20 @@ function handleImportButtonClick(): void {
</NButton>
</div>
<!-- <div
class="flex items-center space-x-4"
:class="isMobile && 'items-start'"
>
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.serverConfig') }}</span>
class="flex items-center space-x-4"
:class="isMobile && 'items-start'"
>
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.serverConfig') }}</span>
<div class="flex flex-wrap items-center gap-4">
<NButton size="small" @click="exportData">
<template #icon>
<SvgIcon icon="ri:refresh-line" />
</template>
{{ $t('common.refreshBinding') }}
</NButton>
</div>
</div> -->
<div class="flex flex-wrap items-center gap-4">
<NButton size="small" @click="exportData">
<template #icon>
<SvgIcon icon="ri:refresh-line" />
</template>
{{ $t('common.refreshBinding') }}
</NButton>
</div>
</div> -->
<div class="flex items-center space-x-4">
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.avatarLink') }}</span>
<div class="flex-1">
Expand Down Expand Up @@ -188,10 +202,7 @@ function handleImportButtonClick(): void {
</NButton>
</div>

<div
class="flex items-center space-x-4"
:class="isMobile && 'items-start'"
>
<div class="flex items-center space-x-4" :class="isMobile && 'items-start'">
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.chatHistory') }}</span>

<div class="flex flex-wrap items-center gap-4">
Expand Down Expand Up @@ -227,11 +238,7 @@ function handleImportButtonClick(): void {
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.theme') }}</span>
<div class="flex flex-wrap items-center gap-4">
<template v-for="item of themeOptions" :key="item.key">
<NButton
size="small"
:type="item.key === theme ? 'primary' : undefined"
@click="appStore.setTheme(item.key)"
>
<NButton size="small" :type="item.key === theme ? 'primary' : undefined" @click="appStore.setTheme(item.key)">
<template #icon>
<SvgIcon :icon="item.icon" />
</template>
Expand All @@ -243,9 +250,7 @@ function handleImportButtonClick(): void {
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.language') }}</span>
<div class="flex flex-wrap items-center gap-4">
<NSelect
style="width: 140px"
:value="language"
:options="languageOptions"
style="width: 140px" :value="language" :options="languageOptions"
@update-value="value => appStore.setLanguage(value)"
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default {
httpsProxy: 'HTTPS Proxy',
balance: 'API Balance',
serverConfig: 'Server Config',
confirmRefreshBind: 'Are you sure to refresh the binding?',
},
store: {
local: 'Local',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default {
httpsProxy: 'HTTPS Proxy',
balance: 'API余额',
serverConfig: '服务器配置',
confirmRefreshBind: '是否刷新绑定?',
},
store: {
local: '本地',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/zh-TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default {
httpsProxy: 'HTTPS Proxy',
balance: 'API余額',
serverConfig: '伺服器設定',
confirmRefreshBind: '是否重新綁定?',
},
store: {
local: '本機',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/store/modules/user/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function defaultSetting(): UserState {

return {
userInfo: {
avatar: 'https://xyhelper.cn/defaultavatar.jpeg',
avatar: '/defaultavatar.jpeg',
name: '攻城狮老李',
description: '官网: https://xyhelper.cn',
baseURI: 'https://freechat.lidong.xin',
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/chat/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async function onConversation() {
accessToken: userInfo.value.accessToken,
isGPT4: State.isGPT4,
}).then((data: any) => {
}).then(() => {
EventsOff(chatChannel)
loading.value = false
})
Expand Down Expand Up @@ -376,7 +376,7 @@ function ChangeModel() {
ms.success('已关闭gpt4模型')
else
ms.success('已开启gpt4模型')
ms.success('已开启gpt4模型,仅PLUS用户开启有效')
}
// 可优化部分
Expand Down Expand Up @@ -488,7 +488,7 @@ onUnmounted(() => {
<SvgIcon icon="ri:chat-history-line" />
</span>
</HoverButton>
<NSwitch v-model:value="State.isGPT4" class="w-[160px]" @update:value="$enent => ChangeModel(`gpt4`)">
<NSwitch v-model:value="State.isGPT4" class="w-[160px]" @update:value="$enent => ChangeModel()">
<template #checked>
gpt4
</template>
Expand Down
2 changes: 2 additions & 0 deletions frontend/wailsjs/go/main/App.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export function ChatProcess(arg1:any):Promise<void>;

export function Greet(arg1:string):Promise<string>;

export function RefreshBind(arg1:string,arg2:string):Promise<string>;

export function Session():Promise<any>;

export function StopChat():Promise<void>;
4 changes: 4 additions & 0 deletions frontend/wailsjs/go/main/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export function Greet(arg1) {
return window['go']['main']['App']['Greet'](arg1);
}

export function RefreshBind(arg1, arg2) {
return window['go']['main']['App']['RefreshBind'](arg1, arg2);
}

export function Session() {
return window['go']['main']['App']['Session']();
}
Expand Down

0 comments on commit 08c9798

Please sign in to comment.