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
07fbeb6c
Unverified
Commit
07fbeb6c
authored
Feb 27, 2024
by
Rozstone
Committed by
GitHub
Feb 27, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enhancement: improve client-side code (#2568)
parent
fc64cdee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
24 deletions
+20
-24
index.tsx
web/app/components/base/button/index.tsx
+9
-5
index.tsx
web/app/components/billing/billing-page/index.tsx
+7
-11
index.tsx
web/app/components/header/account-setting/index.tsx
+4
-8
No files found.
web/app/components/base/button/index.tsx
View file @
07fbeb6c
...
@@ -3,13 +3,16 @@ import React from 'react'
...
@@ -3,13 +3,16 @@ import React from 'react'
import
Spinner
from
'../spinner'
import
Spinner
from
'../spinner'
export
type
IButtonProps
=
{
export
type
IButtonProps
=
{
type
?:
string
/**
* The style of the button
*/
type
?:
'primary'
|
'warning'
|
(
string
&
{})
className
?:
string
className
?:
string
disabled
?:
boolean
disabled
?:
boolean
loading
?:
boolean
loading
?:
boolean
tabIndex
?:
number
tabIndex
?:
number
children
:
React
.
ReactNode
children
:
React
.
ReactNode
onClick
?:
MouseEventHandler
<
HTML
Div
Element
>
onClick
?:
MouseEventHandler
<
HTML
Button
Element
>
}
}
const
Button
:
FC
<
IButtonProps
>
=
({
const
Button
:
FC
<
IButtonProps
>
=
({
...
@@ -35,15 +38,16 @@ const Button: FC<IButtonProps> = ({
...
@@ -35,15 +38,16 @@ const Button: FC<IButtonProps> = ({
}
}
return
(
return
(
<
div
<
button
className=
{
`btn ${style} ${className && className}`
}
className=
{
`btn ${style} ${className && className}`
}
tabIndex=
{
tabIndex
}
tabIndex=
{
tabIndex
}
onClick=
{
disabled
?
undefined
:
onClick
}
disabled=
{
disabled
}
onClick=
{
onClick
}
>
>
{
children
}
{
children
}
{
/* Spinner is hidden when loading is false */
}
{
/* Spinner is hidden when loading is false */
}
<
Spinner
loading=
{
loading
}
className=
'!text-white !h-3 !w-3 !border-2 !ml-1'
/>
<
Spinner
loading=
{
loading
}
className=
'!text-white !h-3 !w-3 !border-2 !ml-1'
/>
</
div
>
</
button
>
)
)
}
}
...
...
web/app/components/billing/billing-page/index.tsx
View file @
07fbeb6c
'use client'
'use client'
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
React
,
{
useEffect
}
from
'react'
import
React
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
useSWR
from
'swr'
import
PlanComp
from
'../plan'
import
PlanComp
from
'../plan'
import
{
ReceiptList
}
from
'../../base/icons/src/vender/line/financeAndECommerce'
import
{
ReceiptList
}
from
'../../base/icons/src/vender/line/financeAndECommerce'
import
{
LinkExternal01
}
from
'../../base/icons/src/vender/line/general'
import
{
LinkExternal01
}
from
'../../base/icons/src/vender/line/general'
...
@@ -12,17 +13,11 @@ import { useProviderContext } from '@/context/provider-context'
...
@@ -12,17 +13,11 @@ import { useProviderContext } from '@/context/provider-context'
const
Billing
:
FC
=
()
=>
{
const
Billing
:
FC
=
()
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
isCurrentWorkspaceManager
}
=
useAppContext
()
const
{
isCurrentWorkspaceManager
}
=
useAppContext
()
const
[
billingUrl
,
setBillingUrl
]
=
React
.
useState
(
''
)
const
{
enableBilling
}
=
useProviderContext
()
const
{
enableBilling
}
=
useProviderContext
()
const
{
data
:
billingUrl
}
=
useSWR
(
useEffect
(()
=>
{
(
!
enableBilling
||
!
isCurrentWorkspaceManager
)
?
null
:
[
'/billing/invoices'
],
if
(
!
enableBilling
||
!
isCurrentWorkspaceManager
)
()
=>
fetchBillingUrl
().
then
(
data
=>
data
.
url
),
return
)
(
async
()
=>
{
const
{
url
}
=
await
fetchBillingUrl
()
setBillingUrl
(
url
)
})()
},
[
isCurrentWorkspaceManager
])
return
(
return
(
<
div
>
<
div
>
...
@@ -39,4 +34,5 @@ const Billing: FC = () => {
...
@@ -39,4 +34,5 @@ const Billing: FC = () => {
</
div
>
</
div
>
)
)
}
}
export
default
React
.
memo
(
Billing
)
export
default
React
.
memo
(
Billing
)
web/app/components/header/account-setting/index.tsx
View file @
07fbeb6c
...
@@ -138,16 +138,12 @@ export default function AccountSetting({
...
@@ -138,16 +138,12 @@ export default function AccountSetting({
]
]
const
scrollRef
=
useRef
<
HTMLDivElement
>
(
null
)
const
scrollRef
=
useRef
<
HTMLDivElement
>
(
null
)
const
[
scrolled
,
setScrolled
]
=
useState
(
false
)
const
[
scrolled
,
setScrolled
]
=
useState
(
false
)
const
scrollHandle
=
(
e
:
Event
)
=>
{
if
((
e
.
target
as
HTMLDivElement
).
scrollTop
>
0
)
setScrolled
(
true
)
else
setScrolled
(
false
)
}
useEffect
(()
=>
{
useEffect
(()
=>
{
const
targetElement
=
scrollRef
.
current
const
targetElement
=
scrollRef
.
current
const
scrollHandle
=
(
e
:
Event
)
=>
{
const
userScrolled
=
(
e
.
target
as
HTMLDivElement
).
scrollTop
>
0
setScrolled
(
userScrolled
)
}
targetElement
?.
addEventListener
(
'scroll'
,
scrollHandle
)
targetElement
?.
addEventListener
(
'scroll'
,
scrollHandle
)
return
()
=>
{
return
()
=>
{
targetElement
?.
removeEventListener
(
'scroll'
,
scrollHandle
)
targetElement
?.
removeEventListener
(
'scroll'
,
scrollHandle
)
...
...
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