Skip to content

Commit

Permalink
fix: add apikey save to localstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzonggui committed Mar 29, 2023
1 parent e6d1870 commit feea637
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
"version": "0.0.0",
"private": false,
"description": "ChatGPT Tauri",
"author": "pljhonglu@gmail.com",
"homepage": "https://github.com/pljhonglu/ChatGPT-T",
"author": "hzg1226620085@gmail.com",
"homepage": "https://github.com/huangzonggui/ChatGPT-Desktop",
"keywords": [
"chatgpt-tauri",
"chatgpt",
"chatbot",
"vue",
"tauri"
"tauri",
"desktop",
"access token",
"app"
],
"scripts": {
"dev:fe": "vite",
Expand Down
22 changes: 13 additions & 9 deletions src/components/common/Setting/General.vue
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,21 @@ async function checkAppUpdate() {

<div class="flex items-center space-x-4">
<span class="flex-shrink-0 w-[100px]">Api Key 列表</span>
<div class="flex flex-wrap items-center gap-4">
<div class="flex-wrap items-center gap-4">
<NInputGroup>
<NInput v-model:value="model.apiKey" />
<NButton @click="userStore.addApiKey(model.apiKey)">
添加
</NButton>
<NInput v-model:value="model.apiKey" />
</NInputGroup>
<NList>
<NListItem v-for="item in userStore.userConfig.apiKeyList" :key="item">
<NTag> {{ item }} </NTag>
<NButton @click="userStore.deleteApiKey(item)">
删除
</NButton>
<NTag type="info" class="m-2">
{{ item }}
</NTag>
</NListItem>
</NList>
</div>
Expand All @@ -248,19 +250,19 @@ async function checkAppUpdate() {
<span class="flex-shrink-0 w-[100px]">Access Token 列表</span>
<div class="flex flex-wrap items-center gap-4">
<NInputGroup>
<NInput v-model:value="model.accessToken" />
<NButton @click="userStore.addAccessToken(model.accessToken)">
添加
</NButton>
<NInput v-model:value="model.accessToken" class="w-[300px]" />
</NInputGroup>
<NList>
<NListItem v-for="item in userStore.userConfig.accessTokenList" :key="item">
<NTag type="info" class="mr-2">
{{ item }}
</NTag>
<NButton @click="userStore.deleteAccessToken(item)">
删除
</NButton>
<NTag type="info" class="m-2">
{{ item }}
</NTag>
</NListItem>
</NList>
</div>
Expand All @@ -270,17 +272,19 @@ async function checkAppUpdate() {
<span class="flex-shrink-0 w-[100px]">Host 列表</span>
<div class="flex flex-wrap items-center gap-4">
<NInputGroup>
<NInput v-model:value="model.host" />
<NButton @click="userStore.addHost(model.host)">
添加
</NButton>
<NInput v-model:value="model.host" />
</NInputGroup>
<NList>
<NListItem v-for="item in userStore.userConfig.hostList" :key="item">
<NTag> {{ item }} </NTag>
<NButton @click="userStore.deleteHost(item)">
删除
</NButton>
<NTag type="info" class="m-2">
{{ item }}
</NTag>
</NListItem>
</NList>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Setting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const show = computed({
</script>

<template>
<NModal v-model:show="show" :auto-focus="false" preset="card" :title="$t('setting.setting')" style="width: 95%; max-width: 640px;">
<NModal v-model:show="show" :auto-focus="false" preset="card" :title="$t('setting.setting')" style="width: 95%; max-width: 1080px; margin: 20px auto;">
<div>
<NTabs v-model:value="active" type="line" animated>
<NTabPane name="User" tab="User">
Expand Down
2 changes: 2 additions & 0 deletions src/store/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const useUserStore = defineStore('user-store', {

addApiKey(apiKey: string) {
this.userConfig.apiKeyList.push(apiKey)
this.recordState()
},

deleteApiKey(apiKey: string) {
Expand All @@ -21,6 +22,7 @@ export const useUserStore = defineStore('user-store', {

addAccessToken(accessToken: string) {
this.userConfig.accessTokenList.push(accessToken)
this.recordState()
},

deleteAccessToken(accessToken: string) {
Expand Down

0 comments on commit feea637

Please sign in to comment.