Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
73b8d1dd
Unverified
Commit
73b8d1dd
authored
Apr 16, 2023
by
boojack
Committed by
GitHub
Apr 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: revert hide ask ai button (#1539)
parent
58fa0007
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
36 additions
and
63 deletions
+36
-63
system.go
api/system.go
+0
-2
system.go
server/system.go
+0
-11
AskAIDialog.tsx
web/src/components/AskAIDialog.tsx
+1
-1
Header.tsx
web/src/components/Header.tsx
+8
-12
SystemSection.tsx
web/src/components/Settings/SystemSection.tsx
+26
-23
zh-Hans.json
web/src/locales/zh-Hans.json
+1
-1
global.ts
web/src/store/module/global.ts
+0
-8
global.ts
web/src/store/reducer/global.ts
+0
-4
system.d.ts
web/src/types/modules/system.d.ts
+0
-1
No files found.
api/system.go
View file @
73b8d1dd
...
...
@@ -24,6 +24,4 @@ type SystemStatus struct {
StorageServiceID
int
`json:"storageServiceId"`
// Local storage path
LocalStoragePath
string
`json:"localStoragePath"`
// Local storage path
OpenAIConfig
OpenAIConfig
`json:"openAIConfig"`
}
server/system.go
View file @
73b8d1dd
...
...
@@ -56,10 +56,6 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
},
StorageServiceID
:
api
.
DatabaseStorage
,
LocalStoragePath
:
""
,
OpenAIConfig
:
api
.
OpenAIConfig
{
Key
:
""
,
Host
:
""
,
},
}
systemSettingList
,
err
:=
s
.
Store
.
FindSystemSettingList
(
ctx
,
&
api
.
SystemSettingFind
{})
...
...
@@ -99,13 +95,6 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
systemStatus
.
StorageServiceID
=
int
(
baseValue
.
(
float64
))
}
else
if
systemSetting
.
Name
==
api
.
SystemSettingLocalStoragePathName
{
systemStatus
.
LocalStoragePath
=
baseValue
.
(
string
)
}
else
if
systemSetting
.
Name
==
api
.
SystemSettingOpenAIConfigName
{
openAIConfig
:=
api
.
OpenAIConfig
{}
err
:=
json
.
Unmarshal
([]
byte
(
systemSetting
.
Value
),
&
openAIConfig
)
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to unmarshal system setting open ai config value"
)
.
SetInternal
(
err
)
}
systemStatus
.
OpenAIConfig
=
openAIConfig
}
}
...
...
web/src/components/AskAIDialog.tsx
View file @
73b8d1dd
...
...
@@ -89,7 +89,7 @@ const AskAIDialog: React.FC<Props> = (props: Props) => {
</
div
>
<
div
className=
"dialog-content-container !w-112 max-w-full"
>
{
messageList
.
map
((
message
,
index
)
=>
(
<
div
key=
{
index
}
className=
"w-full flex flex-col justify-start items-start
mt-4
space-y-2"
>
<
div
key=
{
index
}
className=
"w-full flex flex-col justify-start items-start space-y-2"
>
{
message
.
role
===
"user"
?
(
<
div
className=
"w-full flex flex-row justify-end items-start pl-6"
>
<
span
className=
"word-break shadow rounded-lg rounded-tr-none px-3 py-2 opacity-80 bg-gray-100 dark:bg-zinc-700"
>
...
...
web/src/components/Header.tsx
View file @
73b8d1dd
import
{
useEffect
}
from
"react"
;
import
{
NavLink
,
useLocation
}
from
"react-router-dom"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
use
GlobalStore
,
use
LayoutStore
,
useUserStore
}
from
"@/store/module"
;
import
{
useLayoutStore
,
useUserStore
}
from
"@/store/module"
;
import
{
resolution
}
from
"@/utils/layout"
;
import
Icon
from
"./Icon"
;
import
showSettingDialog
from
"./SettingDialog"
;
...
...
@@ -14,10 +14,8 @@ const Header = () => {
const
{
t
}
=
useTranslation
();
const
location
=
useLocation
();
const
userStore
=
useUserStore
();
const
globalStore
=
useGlobalStore
();
const
layoutStore
=
useLayoutStore
();
const
showHeader
=
layoutStore
.
state
.
showHeader
;
const
showAskAI
=
globalStore
.
showAskAI
();
const
isVisitorMode
=
userStore
.
isVisitorMode
()
&&
!
userStore
.
state
.
user
;
useEffect
(()
=>
{
...
...
@@ -109,7 +107,6 @@ const Header = () => {
</
NavLink
>
{
!
isVisitorMode
&&
(
<>
{
showAskAI
&&
(
<
button
id=
"header-ask-ai"
className=
"px-4 pr-5 py-2 rounded-lg flex flex-row items-center text-lg text-gray-800 dark:text-gray-300 hover:bg-white hover:shadow dark:hover:bg-zinc-700"
...
...
@@ -117,7 +114,6 @@ const Header = () => {
>
<
Icon
.
Bot
className=
"mr-3 w-6 h-auto opacity-70"
/>
{
t
(
"ask-ai.title"
)
}
</
button
>
)
}
<
button
id=
"header-archived-memo"
className=
"px-4 pr-5 py-2 rounded-lg flex flex-row items-center text-lg text-gray-800 dark:text-gray-300 hover:bg-white hover:shadow dark:hover:bg-zinc-700"
...
...
web/src/components/Settings/SystemSection.tsx
View file @
73b8d1dd
...
...
@@ -16,7 +16,6 @@ interface State {
disablePublicMemos
:
boolean
;
additionalStyle
:
string
;
additionalScript
:
string
;
openAIConfig
:
OpenAIConfig
;
}
const
SystemSection
=
()
=>
{
...
...
@@ -30,13 +29,25 @@ const SystemSection = () => {
additionalStyle
:
systemStatus
.
additionalStyle
,
additionalScript
:
systemStatus
.
additionalScript
,
disablePublicMemos
:
systemStatus
.
disablePublicMemos
,
openAIConfig
:
systemStatus
.
openAIConfig
,
});
const
[
openAIConfig
,
setOpenAIConfig
]
=
useState
<
OpenAIConfig
>
({
key
:
""
,
host
:
""
,
});
useEffect
(()
=>
{
globalStore
.
fetchSystemStatus
();
},
[]);
useEffect
(()
=>
{
api
.
getSystemSetting
().
then
(({
data
:
{
data
:
systemSettings
}
})
=>
{
const
openAIConfigSetting
=
systemSettings
.
find
((
setting
)
=>
setting
.
name
===
"openai-config"
);
if
(
openAIConfigSetting
)
{
setOpenAIConfig
(
JSON
.
parse
(
openAIConfigSetting
.
value
));
}
});
},
[]);
useEffect
(()
=>
{
setState
({
...
state
,
...
...
@@ -45,7 +56,6 @@ const SystemSection = () => {
additionalStyle
:
systemStatus
.
additionalStyle
,
additionalScript
:
systemStatus
.
additionalScript
,
disablePublicMemos
:
systemStatus
.
disablePublicMemos
,
openAIConfig
:
systemStatus
.
openAIConfig
,
});
},
[
systemStatus
]);
...
...
@@ -87,12 +97,16 @@ const SystemSection = () => {
};
const
handleOpenAIConfigKeyChanged
=
(
value
:
string
)
=>
{
setState
({
...
state
,
openAIConfig
:
{
...
state
.
openAIConfig
,
setOpenAIConfig
({
...
openAIConfig
,
key
:
value
,
},
});
};
const
handleOpenAIConfigHostChanged
=
(
value
:
string
)
=>
{
setOpenAIConfig
({
...
openAIConfig
,
host
:
value
,
});
};
...
...
@@ -100,9 +114,8 @@ const SystemSection = () => {
try
{
await
api
.
upsertSystemSetting
({
name
:
"openai-config"
,
value
:
JSON
.
stringify
(
state
.
openAIConfig
),
value
:
JSON
.
stringify
(
openAIConfig
),
});
globalStore
.
setSystemStatus
({
openAIConfig
:
state
.
openAIConfig
});
}
catch
(
error
)
{
console
.
error
(
error
);
return
;
...
...
@@ -110,16 +123,6 @@ const SystemSection = () => {
toast
.
success
(
"OpenAI Config updated"
);
};
const
handleOpenAIConfigHostChanged
=
(
value
:
string
)
=>
{
setState
({
...
state
,
openAIConfig
:
{
...
state
.
openAIConfig
,
host
:
value
,
},
});
};
const
handleAdditionalStyleChanged
=
(
value
:
string
)
=>
{
setState
({
...
state
,
...
...
@@ -222,7 +225,7 @@ const SystemSection = () => {
fontSize
:
"14px"
,
}
}
placeholder=
{
t
(
"setting.system-section.openai-api-key-placeholder"
)
}
value=
{
state
.
openAIConfig
.
key
}
value=
{
openAIConfig
.
key
}
onChange=
{
(
event
)
=>
handleOpenAIConfigKeyChanged
(
event
.
target
.
value
)
}
/>
<
div
className=
"form-label mt-2"
>
...
...
@@ -235,7 +238,7 @@ const SystemSection = () => {
fontSize
:
"14px"
,
}
}
placeholder=
{
t
(
"setting.system-section.openai-api-host-placeholder"
)
}
value=
{
state
.
openAIConfig
.
host
}
value=
{
openAIConfig
.
host
}
onChange=
{
(
event
)
=>
handleOpenAIConfigHostChanged
(
event
.
target
.
value
)
}
/>
<
Divider
className=
"!mt-3 !my-4"
/>
...
...
web/src/locales/zh-Hans.json
View file @
73b8d1dd
...
...
@@ -315,7 +315,7 @@
},
"ask-ai"
:
{
"placeholder"
:
"随便问"
,
"title"
:
"
问
AI"
,
"title"
:
"
Ask
AI"
,
"not-enabled"
:
"您尚未设置 OpenAI API 密钥。"
,
"go-to-settings"
:
"前往设置"
},
...
...
web/src/store/module/global.ts
View file @
73b8d1dd
...
...
@@ -23,10 +23,6 @@ export const initialGlobalState = async () => {
appearance
:
"system"
,
externalUrl
:
""
,
},
openAIConfig
:
{
key
:
""
,
host
:
""
,
},
}
as
SystemStatus
,
};
...
...
@@ -69,10 +65,6 @@ export const useGlobalStore = () => {
isDev
:
()
=>
{
return
state
.
systemStatus
.
profile
.
mode
!==
"prod"
;
},
showAskAI
:
()
=>
{
const
openAIConfig
=
state
.
systemStatus
.
openAIConfig
;
return
Boolean
(
openAIConfig
.
key
&&
openAIConfig
.
host
);
},
fetchSystemStatus
:
async
()
=>
{
const
{
data
:
systemStatus
}
=
(
await
api
.
getSystemStatus
()).
data
;
store
.
dispatch
(
setGlobalState
({
systemStatus
:
systemStatus
}));
...
...
web/src/store/reducer/global.ts
View file @
73b8d1dd
...
...
@@ -31,10 +31,6 @@ const globalSlice = createSlice({
appearance
:
"system"
,
externalUrl
:
""
,
},
openAIConfig
:
{
key
:
""
,
host
:
""
,
},
},
}
as
State
,
reducers
:
{
...
...
web/src/types/modules/system.d.ts
View file @
73b8d1dd
...
...
@@ -30,7 +30,6 @@ interface SystemStatus {
customizedProfile
:
CustomizedProfile
;
storageServiceId
:
number
;
localStoragePath
:
string
;
openAIConfig
:
OpenAIConfig
;
}
interface
SystemSetting
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment