mirror of
https://gitee.com/dify_ai/dify.git
synced 2024-12-02 03:07:59 +08:00
feat: web app support some feature (#1753)
This commit is contained in:
parent
b5b20234e9
commit
eede84eb9e
@ -70,17 +70,18 @@ const Main: FC<IMainProps> = ({
|
|||||||
const [promptConfig, setPromptConfig] = useState<PromptConfig | null>(null)
|
const [promptConfig, setPromptConfig] = useState<PromptConfig | null>(null)
|
||||||
const [inited, setInited] = useState<boolean>(false)
|
const [inited, setInited] = useState<boolean>(false)
|
||||||
const [plan, setPlan] = useState<string>('basic') // basic/plus/pro
|
const [plan, setPlan] = useState<string>('basic') // basic/plus/pro
|
||||||
|
const [canReplaceLogo, setCanReplaceLogo] = useState<boolean>(false)
|
||||||
// in mobile, show sidebar by click button
|
// in mobile, show sidebar by click button
|
||||||
const [isShowSidebar, { setTrue: showSidebar, setFalse: hideSidebar }] = useBoolean(false)
|
const [isShowSidebar, { setTrue: showSidebar, setFalse: hideSidebar }] = useBoolean(false)
|
||||||
// Can Use metadata(https://beta.nextjs.org/docs/api-reference/metadata) to set title. But it only works in server side client.
|
// Can Use metadata(https://beta.nextjs.org/docs/api-reference/metadata) to set title. But it only works in server side client.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (siteInfo?.title) {
|
if (siteInfo?.title) {
|
||||||
if (plan !== 'basic')
|
if (canReplaceLogo)
|
||||||
document.title = `${siteInfo.title}`
|
document.title = `${siteInfo.title}`
|
||||||
else
|
else
|
||||||
document.title = `${siteInfo.title} - Powered by Dify`
|
document.title = `${siteInfo.title} - Powered by Dify`
|
||||||
}
|
}
|
||||||
}, [siteInfo?.title, plan])
|
}, [siteInfo?.title, canReplaceLogo])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* conversation info
|
* conversation info
|
||||||
@ -363,9 +364,10 @@ const Main: FC<IMainProps> = ({
|
|||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const [appData, conversationData, appParams]: any = await fetchInitData()
|
const [appData, conversationData, appParams]: any = await fetchInitData()
|
||||||
const { app_id: appId, site: siteInfo, plan }: any = appData
|
const { app_id: appId, site: siteInfo, plan, can_replace_logo }: any = appData
|
||||||
setAppId(appId)
|
setAppId(appId)
|
||||||
setPlan(plan)
|
setPlan(plan)
|
||||||
|
setCanReplaceLogo(can_replace_logo)
|
||||||
const tempIsPublicVersion = siteInfo.prompt_public
|
const tempIsPublicVersion = siteInfo.prompt_public
|
||||||
setIsPublicVersion(tempIsPublicVersion)
|
setIsPublicVersion(tempIsPublicVersion)
|
||||||
const prompt_template = ''
|
const prompt_template = ''
|
||||||
@ -733,6 +735,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
savedInputs={currInputs as Record<string, any>}
|
savedInputs={currInputs as Record<string, any>}
|
||||||
onInputsChange={setCurrInputs}
|
onInputsChange={setCurrInputs}
|
||||||
plan={plan}
|
plan={plan}
|
||||||
|
canReplaceLogo={canReplaceLogo}
|
||||||
></ConfigSence>
|
></ConfigSence>
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,7 @@ export type IWelcomeProps = {
|
|||||||
savedInputs: Record<string, any>
|
savedInputs: Record<string, any>
|
||||||
onInputsChange: (inputs: Record<string, any>) => void
|
onInputsChange: (inputs: Record<string, any>) => void
|
||||||
plan?: string
|
plan?: string
|
||||||
|
canReplaceLogo?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const Welcome: FC<IWelcomeProps> = ({
|
const Welcome: FC<IWelcomeProps> = ({
|
||||||
@ -39,6 +40,7 @@ const Welcome: FC<IWelcomeProps> = ({
|
|||||||
canEidtInpus,
|
canEidtInpus,
|
||||||
savedInputs,
|
savedInputs,
|
||||||
onInputsChange,
|
onInputsChange,
|
||||||
|
canReplaceLogo,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const hasVar = promptConfig.prompt_variables.length > 0
|
const hasVar = promptConfig.prompt_variables.length > 0
|
||||||
@ -350,7 +352,7 @@ const Welcome: FC<IWelcomeProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
: <div>
|
: <div>
|
||||||
</div>}
|
</div>}
|
||||||
{plan === 'basic' && <a className='flex items-center pr-3 space-x-3' href="https://dify.ai/" target="_blank">
|
{!canReplaceLogo && <a className='flex items-center pr-3 space-x-3' href="https://dify.ai/" target="_blank">
|
||||||
<span className='uppercase'>{t('share.chat.powerBy')}</span>
|
<span className='uppercase'>{t('share.chat.powerBy')}</span>
|
||||||
<FootLogo />
|
<FootLogo />
|
||||||
</a>}
|
</a>}
|
||||||
|
@ -54,15 +54,16 @@ const Main: FC<IMainProps> = ({
|
|||||||
const [promptConfig, setPromptConfig] = useState<PromptConfig | null>(null)
|
const [promptConfig, setPromptConfig] = useState<PromptConfig | null>(null)
|
||||||
const [inited, setInited] = useState<boolean>(false)
|
const [inited, setInited] = useState<boolean>(false)
|
||||||
const [plan, setPlan] = useState<string>('basic') // basic/plus/pro
|
const [plan, setPlan] = useState<string>('basic') // basic/plus/pro
|
||||||
|
const [canReplaceLogo, setCanReplaceLogo] = useState<boolean>(false)
|
||||||
// Can Use metadata(https://beta.nextjs.org/docs/api-reference/metadata) to set title. But it only works in server side client.
|
// Can Use metadata(https://beta.nextjs.org/docs/api-reference/metadata) to set title. But it only works in server side client.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (siteInfo?.title) {
|
if (siteInfo?.title) {
|
||||||
if (plan !== 'basic')
|
if (canReplaceLogo)
|
||||||
document.title = `${siteInfo.title}`
|
document.title = `${siteInfo.title}`
|
||||||
else
|
else
|
||||||
document.title = `${siteInfo.title} - Powered by Dify`
|
document.title = `${siteInfo.title} - Powered by Dify`
|
||||||
}
|
}
|
||||||
}, [siteInfo?.title, plan])
|
}, [siteInfo?.title, canReplaceLogo])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* conversation info
|
* conversation info
|
||||||
@ -282,9 +283,10 @@ const Main: FC<IMainProps> = ({
|
|||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const [appData, conversationData, appParams]: any = await fetchInitData()
|
const [appData, conversationData, appParams]: any = await fetchInitData()
|
||||||
const { app_id: appId, site: siteInfo, plan }: any = appData
|
const { app_id: appId, site: siteInfo, plan, can_replace_logo }: any = appData
|
||||||
setAppId(appId)
|
setAppId(appId)
|
||||||
setPlan(plan)
|
setPlan(plan)
|
||||||
|
setCanReplaceLogo(can_replace_logo)
|
||||||
const tempIsPublicVersion = siteInfo.prompt_public
|
const tempIsPublicVersion = siteInfo.prompt_public
|
||||||
setIsPublicVersion(tempIsPublicVersion)
|
setIsPublicVersion(tempIsPublicVersion)
|
||||||
const prompt_template = ''
|
const prompt_template = ''
|
||||||
@ -589,6 +591,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
savedInputs={currInputs as Record<string, any>}
|
savedInputs={currInputs as Record<string, any>}
|
||||||
onInputsChange={setCurrInputs}
|
onInputsChange={setCurrInputs}
|
||||||
plan={plan}
|
plan={plan}
|
||||||
|
canReplaceLogo={canReplaceLogo}
|
||||||
></ConfigScene>
|
></ConfigScene>
|
||||||
{
|
{
|
||||||
shouldReload && (
|
shouldReload && (
|
||||||
|
@ -26,6 +26,7 @@ export type IWelcomeProps = {
|
|||||||
savedInputs: Record<string, any>
|
savedInputs: Record<string, any>
|
||||||
onInputsChange: (inputs: Record<string, any>) => void
|
onInputsChange: (inputs: Record<string, any>) => void
|
||||||
plan: string
|
plan: string
|
||||||
|
canReplaceLogo?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const Welcome: FC<IWelcomeProps> = ({
|
const Welcome: FC<IWelcomeProps> = ({
|
||||||
@ -39,6 +40,7 @@ const Welcome: FC<IWelcomeProps> = ({
|
|||||||
canEditInputs,
|
canEditInputs,
|
||||||
savedInputs,
|
savedInputs,
|
||||||
onInputsChange,
|
onInputsChange,
|
||||||
|
canReplaceLogo,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const hasVar = promptConfig.prompt_variables.length > 0
|
const hasVar = promptConfig.prompt_variables.length > 0
|
||||||
@ -351,7 +353,7 @@ const Welcome: FC<IWelcomeProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
: <div>
|
: <div>
|
||||||
</div>}
|
</div>}
|
||||||
{plan === 'basic' && <a className='flex items-center pr-3 space-x-3' href="https://dify.ai/" target="_blank">
|
{!canReplaceLogo && <a className='flex items-center pr-3 space-x-3' href="https://dify.ai/" target="_blank">
|
||||||
<span className='uppercase'>{t('share.chat.powerBy')}</span>
|
<span className='uppercase'>{t('share.chat.powerBy')}</span>
|
||||||
<FootLogo />
|
<FootLogo />
|
||||||
</a>}
|
</a>}
|
||||||
|
@ -71,6 +71,7 @@ const TextGeneration: FC<IMainProps> = ({
|
|||||||
const [inputs, setInputs] = useState<Record<string, any>>({})
|
const [inputs, setInputs] = useState<Record<string, any>>({})
|
||||||
const [appId, setAppId] = useState<string>('')
|
const [appId, setAppId] = useState<string>('')
|
||||||
const [siteInfo, setSiteInfo] = useState<SiteInfo | null>(null)
|
const [siteInfo, setSiteInfo] = useState<SiteInfo | null>(null)
|
||||||
|
const [canReplaceLogo, setCanReplaceLogo] = useState<boolean>(false)
|
||||||
const [promptConfig, setPromptConfig] = useState<PromptConfig | null>(null)
|
const [promptConfig, setPromptConfig] = useState<PromptConfig | null>(null)
|
||||||
const [moreLikeThisConfig, setMoreLikeThisConfig] = useState<MoreLikeThisConfig | null>(null)
|
const [moreLikeThisConfig, setMoreLikeThisConfig] = useState<MoreLikeThisConfig | null>(null)
|
||||||
|
|
||||||
@ -343,9 +344,10 @@ const TextGeneration: FC<IMainProps> = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const [appData, appParams]: any = await fetchInitData()
|
const [appData, appParams]: any = await fetchInitData()
|
||||||
const { app_id: appId, site: siteInfo } = appData
|
const { app_id: appId, site: siteInfo, can_replace_logo } = appData
|
||||||
setAppId(appId)
|
setAppId(appId)
|
||||||
setSiteInfo(siteInfo as SiteInfo)
|
setSiteInfo(siteInfo as SiteInfo)
|
||||||
|
setCanReplaceLogo(can_replace_logo)
|
||||||
changeLanguage(siteInfo.default_language)
|
changeLanguage(siteInfo.default_language)
|
||||||
|
|
||||||
const { user_input_form, more_like_this, file_upload, sensitive_word_avoidance }: any = appParams
|
const { user_input_form, more_like_this, file_upload, sensitive_word_avoidance }: any = appParams
|
||||||
@ -364,9 +366,13 @@ const TextGeneration: FC<IMainProps> = ({
|
|||||||
|
|
||||||
// Can Use metadata(https://beta.nextjs.org/docs/api-reference/metadata) to set title. But it only works in server side client.
|
// Can Use metadata(https://beta.nextjs.org/docs/api-reference/metadata) to set title. But it only works in server side client.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (siteInfo?.title)
|
if (siteInfo?.title) {
|
||||||
|
if (canReplaceLogo)
|
||||||
|
document.title = `${siteInfo.title}`
|
||||||
|
else
|
||||||
document.title = `${siteInfo.title} - Powered by Dify`
|
document.title = `${siteInfo.title} - Powered by Dify`
|
||||||
}, [siteInfo?.title])
|
}
|
||||||
|
}, [siteInfo?.title, canReplaceLogo])
|
||||||
|
|
||||||
const [isShowResSidebar, { setTrue: showResSidebar, setFalse: hideResSidebar }] = useBoolean(false)
|
const [isShowResSidebar, { setTrue: showResSidebar, setFalse: hideResSidebar }] = useBoolean(false)
|
||||||
const resRef = useRef<HTMLDivElement>(null)
|
const resRef = useRef<HTMLDivElement>(null)
|
||||||
|
@ -101,7 +101,7 @@ const translation = {
|
|||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
accountGroup: 'ACCOUNT',
|
accountGroup: 'ACCOUNT',
|
||||||
workplaceGroup: 'WORKPLACE',
|
workplaceGroup: 'WORKSPACE',
|
||||||
account: 'My account',
|
account: 'My account',
|
||||||
members: 'Members',
|
members: 'Members',
|
||||||
billing: 'Billing',
|
billing: 'Billing',
|
||||||
|
Loading…
Reference in New Issue
Block a user