Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
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
ai-tech
dify
Commits
53db5bab
Unverified
Commit
53db5bab
authored
Jun 06, 2023
by
zxhlyh
Committed by
GitHub
Jun 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feat/add GitHub star icon (#302)
parent
6483beb0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
21 deletions
+41
-21
github-icon.svg
web/app/components/header/assets/github-icon.svg
+3
-0
index.module.css
web/app/components/header/index.module.css
+4
-3
index.tsx
web/app/components/header/index.tsx
+24
-11
common.ts
web/models/common.ts
+4
-0
common.ts
web/service/common.ts
+6
-7
No files found.
web/app/components/header/assets/github-icon.svg
0 → 100644
View file @
53db5bab
<svg
width=
"18"
height=
"18"
viewBox=
"0 0 18 18"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
d=
"M9 1.125C4.64906 1.125 1.125 4.64906 1.125 9C1.125 12.4847 3.37922 15.428 6.50953 16.4714C6.90328 16.5403 7.05094 16.3041 7.05094 16.0973C7.05094 15.9103 7.04109 15.2902 7.04109 14.6306C5.0625 14.9948 4.55062 14.1483 4.39312 13.7053C4.30453 13.4789 3.92062 12.78 3.58594 12.593C3.31031 12.4453 2.91656 12.0811 3.57609 12.0712C4.19625 12.0614 4.63922 12.6422 4.78688 12.8784C5.49563 14.0695 6.62766 13.7348 7.08047 13.5281C7.14937 13.0163 7.35609 12.6717 7.5825 12.4748C5.83031 12.278 3.99938 11.5988 3.99938 8.58656C3.99938 7.73016 4.30453 7.02141 4.80656 6.47016C4.72781 6.27328 4.45219 5.46609 4.88531 4.38328C4.88531 4.38328 5.54484 4.17656 7.05094 5.19047C7.68094 5.01328 8.35031 4.92469 9.01969 4.92469C9.68906 4.92469 10.3584 5.01328 10.9884 5.19047C12.4945 4.16672 13.1541 4.38328 13.1541 4.38328C13.5872 5.46609 13.3116 6.27328 13.2328 6.47016C13.7348 7.02141 14.04 7.72031 14.04 8.58656C14.04 11.6086 12.1992 12.278 10.447 12.4748C10.7325 12.7209 10.9786 13.1934 10.9786 13.9317C10.9786 14.985 10.9688 15.8316 10.9688 16.0973C10.9688 16.3041 11.1164 16.5502 11.5102 16.4714C13.0735 15.9436 14.432 14.9389 15.3943 13.5986C16.3567 12.2583 16.8746 10.65 16.875 9C16.875 4.64906 13.3509 1.125 9 1.125Z"
fill=
"#24292F"
/>
</svg>
web/app/components/header/index.module.css
View file @
53db5bab
...
@@ -16,9 +16,10 @@
...
@@ -16,9 +16,10 @@
}
}
.github-icon
{
.github-icon
{
width
:
16px
;
width
:
18px
;
height
:
16px
;
height
:
18px
;
background
:
url(./assets/github.svg)
center
center
no-repeat
;
background
:
url(./assets/github-icon.svg)
center
center
no-repeat
;
background-size
:
contain
;
}
}
.alpha
{
.alpha
{
...
...
web/app/components/header/index.tsx
View file @
53db5bab
'use client'
'use client'
import
{
useCallback
,
useState
}
from
'react'
import
{
useCallback
,
use
Effect
,
use
State
}
from
'react'
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
useSWRInfinite
from
'swr/infinite'
import
useSWRInfinite
from
'swr/infinite'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
...
@@ -12,8 +12,8 @@ import Link from 'next/link'
...
@@ -12,8 +12,8 @@ import Link from 'next/link'
import
AccountDropdown
from
'./account-dropdown'
import
AccountDropdown
from
'./account-dropdown'
import
Nav
from
'./nav'
import
Nav
from
'./nav'
import
s
from
'./index.module.css'
import
s
from
'./index.module.css'
import
type
{
GithubRepo
,
LangGeniusVersionResponse
,
UserProfileResponse
}
from
'@/models/common'
import
type
{
AppListResponse
}
from
'@/models/app'
import
type
{
AppListResponse
}
from
'@/models/app'
import
type
{
LangGeniusVersionResponse
,
UserProfileResponse
}
from
'@/models/common'
import
NewAppDialog
from
'@/app/(commonLayout)/apps/NewAppDialog'
import
NewAppDialog
from
'@/app/(commonLayout)/apps/NewAppDialog'
import
{
WorkspaceProvider
}
from
'@/context/workspace-context'
import
{
WorkspaceProvider
}
from
'@/context/workspace-context'
import
{
useDatasetsContext
}
from
'@/context/datasets-context'
import
{
useDatasetsContext
}
from
'@/context/datasets-context'
...
@@ -62,6 +62,13 @@ const Header: FC<IHeaderProps> = ({
...
@@ -62,6 +62,13 @@ const Header: FC<IHeaderProps> = ({
const
selectedSegment
=
useSelectedLayoutSegment
()
const
selectedSegment
=
useSelectedLayoutSegment
()
const
isPluginsComingSoon
=
selectedSegment
===
'plugins-coming-soon'
const
isPluginsComingSoon
=
selectedSegment
===
'plugins-coming-soon'
const
isExplore
=
selectedSegment
===
'explore'
const
isExplore
=
selectedSegment
===
'explore'
const
[
starCount
,
setStarCount
]
=
useState
(
0
)
useEffect
(()
=>
{
globalThis
.
fetch
(
'https://api.github.com/repos/langgenius/dify'
).
then
(
res
=>
res
.
json
()).
then
((
data
:
GithubRepo
)
=>
{
setStarCount
(
data
.
stargazers_count
)
})
},
[])
const
appItems
=
flatten
(
appsData
?.
map
(
appData
=>
appData
.
data
))
const
appItems
=
flatten
(
appsData
?.
map
(
appData
=>
appData
.
data
))
const
handleLoadmore
=
useCallback
(()
=>
{
const
handleLoadmore
=
useCallback
(()
=>
{
...
@@ -82,17 +89,23 @@ const Header: FC<IHeaderProps> = ({
...
@@ -82,17 +89,23 @@ const Header: FC<IHeaderProps> = ({
'flex flex-1 items-center justify-between px-4'
,
'flex flex-1 items-center justify-between px-4'
,
)
}
>
)
}
>
<
div
className=
'flex items-center'
>
<
div
className=
'flex items-center'
>
<
Link
href=
"/apps"
className=
'flex items-center mr-
3
'
>
<
Link
href=
"/apps"
className=
'flex items-center mr-
4
'
>
<
div
className=
{
s
.
logo
}
/>
<
div
className=
{
s
.
logo
}
/>
</
Link
>
</
Link
>
{
/* Add it when has many stars */
}
{
<
div
className=
'
starCount
>
0
&&
(
flex items-center h-[26px] px-2 bg-white
<
Link
border border-solid border-[#E5E7EB] rounded-l-[6px] rounded-r-[6px]
href=
'https://github.com/langgenius/dify'
'
>
target=
'_blank'
<
div
className=
{
s
.
alpha
}
/>
className=
'flex items-center leading-[18px] border border-gray-200 rounded-md text-xs text-gray-700 font-semibold overflow-hidden'
>
<
div
className=
'ml-1 text-xs font-semibold text-gray-700'
>
{
t
(
'common.menus.status'
)
}
</
div
>
<
div
className=
'flex items-center px-2 py-1 bg-gray-100'
>
<
div
className=
{
`${s['github-icon']} mr-1 rounded-full`
}
/>
Star
</
div
>
</
div
>
<
div
className=
'px-2 py-1 bg-white border-l border-gray-200'
>
{
`${starCount}`
.
replace
(
/
\B(?=(\d
{3}
)
+
(?!\d))
/g
,
','
)
}
</
div
>
</
Link
>
)
}
</
div
>
</
div
>
<
div
className=
'flex items-center'
>
<
div
className=
'flex items-center'
>
<
Link
href=
"/explore/apps"
className=
{
classNames
(
<
Link
href=
"/explore/apps"
className=
{
classNames
(
...
...
web/models/common.ts
View file @
53db5bab
...
@@ -99,3 +99,7 @@ export type IWorkspace = {
...
@@ -99,3 +99,7 @@ export type IWorkspace = {
created_at
:
number
created_at
:
number
current
:
boolean
current
:
boolean
}
}
export
type
GithubRepo
=
{
stargazers_count
:
number
}
web/service/common.ts
View file @
53db5bab
import
type
{
Fetcher
}
from
'swr'
import
type
{
Fetcher
}
from
'swr'
import
{
get
,
post
,
del
,
put
}
from
'./base'
import
{
del
,
get
,
post
,
put
}
from
'./base'
import
type
{
import
type
{
CommonResponse
,
LangGeniusVersionResponse
,
OauthRespons
e
,
AccountIntegrate
,
CommonResponse
,
IWorkspac
e
,
TenantInfoResponse
,
UserProfileOriginResponse
,
Member
,
LangGeniusVersionResponse
,
Member
,
OauthResponse
,
AccountIntegrate
,
Provider
,
ProviderAzureToken
,
IWorkspace
Provider
,
ProviderAzureToken
,
TenantInfoResponse
,
UserProfileOriginResponse
,
}
from
'@/models/common'
}
from
'@/models/common'
import
type
{
import
type
{
UpdateOpenAIKeyResponse
,
ValidateOpenAIKeyResponse
,
ValidateOpenAIKeyResponse
,
UpdateOpenAIKeyResponse
}
from
'@/models/app'
}
from
'@/models/app'
export
const
login
:
Fetcher
<
CommonResponse
,
{
url
:
string
;
body
:
Record
<
string
,
any
>
}
>
=
({
url
,
body
})
=>
{
export
const
login
:
Fetcher
<
CommonResponse
,
{
url
:
string
;
body
:
Record
<
string
,
any
>
}
>
=
({
url
,
body
})
=>
{
...
@@ -73,7 +73,7 @@ export const updateMemberRole: Fetcher<CommonResponse, { url: string; body: Reco
...
@@ -73,7 +73,7 @@ export const updateMemberRole: Fetcher<CommonResponse, { url: string; body: Reco
return
put
(
url
,
{
body
})
as
Promise
<
CommonResponse
>
return
put
(
url
,
{
body
})
as
Promise
<
CommonResponse
>
}
}
export
const
deleteMemberOrCancelInvitation
:
Fetcher
<
CommonResponse
,
{
url
:
string
;
}
>
=
({
url
})
=>
{
export
const
deleteMemberOrCancelInvitation
:
Fetcher
<
CommonResponse
,
{
url
:
string
}
>
=
({
url
})
=>
{
return
del
(
url
)
as
Promise
<
CommonResponse
>
return
del
(
url
)
as
Promise
<
CommonResponse
>
}
}
...
@@ -88,4 +88,3 @@ export const fetchWorkspaces: Fetcher<{ workspaces: IWorkspace[] }, { url: strin
...
@@ -88,4 +88,3 @@ export const fetchWorkspaces: Fetcher<{ workspaces: IWorkspace[] }, { url: strin
export
const
switchWorkspace
:
Fetcher
<
CommonResponse
&
{
new_tenant
:
IWorkspace
},
{
url
:
string
;
body
:
Record
<
string
,
any
>
}
>
=
({
url
,
body
})
=>
{
export
const
switchWorkspace
:
Fetcher
<
CommonResponse
&
{
new_tenant
:
IWorkspace
},
{
url
:
string
;
body
:
Record
<
string
,
any
>
}
>
=
({
url
,
body
})
=>
{
return
post
(
url
,
{
body
})
as
Promise
<
CommonResponse
&
{
new_tenant
:
IWorkspace
}
>
return
post
(
url
,
{
body
})
as
Promise
<
CommonResponse
&
{
new_tenant
:
IWorkspace
}
>
}
}
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