Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
glsk-ai-assistant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d5667bcb
authored
Apr 27, 2025
by
杨明
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
标题
1 parent
a795daf2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
122 additions
and
112 deletions
app/activate/page.tsx
app/components/base/chat/chat-with-history/chat-wrapper.tsx
app/components/base/chat/chat-with-history/hooks.tsx
app/components/base/chat/chat-with-history/index.tsx
app/components/base/chat/chat/chat-input-area/index.tsx
app/components/base/chat/chat/index.tsx
app/layout.tsx
hooks/use-app-favicon.ts
app/activate/page.tsx
View file @
d5667bc
import React from 'react'
import React from 'react'
import Header from '../signin/_header'
import ActivateForm from './activateForm'
import ActivateForm from './activateForm'
import cn from '@/utils/classnames'
import cn from '@/utils/classnames'
...
@@ -7,7 +6,6 @@ const Activate = () => {
...
@@ -7,7 +6,6 @@ const Activate = () => {
return (
return (
<div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
<div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
<div className={cn('flex w-full shrink-0 flex-col rounded-2xl border border-effects-highlight bg-background-default-subtle')}>
<div className={cn('flex w-full shrink-0 flex-col rounded-2xl border border-effects-highlight bg-background-default-subtle')}>
<Header />
<ActivateForm />
<ActivateForm />
<div className='px-8 py-6 text-sm font-normal text-text-tertiary'>
<div className='px-8 py-6 text-sm font-normal text-text-tertiary'>
© {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
© {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
...
...
app/components/base/chat/chat-with-history/chat-wrapper.tsx
View file @
d5667bc
...
@@ -197,9 +197,7 @@ const ChatWrapper = ({ avatar, aiAvatar }: Props) => {
...
@@ -197,9 +197,7 @@ const ChatWrapper = ({ avatar, aiAvatar }: Props) => {
);
);
const messageList = useMemo(() => {
const messageList = useMemo(() => {
console.log(chatList, "chatList", currentConversationId);
return chatList;
if (currentConversationId) return chatList;
return chatList.filter((item) => item.isOpeningStatement);
}, [chatList, currentConversationId]);
}, [chatList, currentConversationId]);
const [collapsed, setCollapsed] = useState(!!currentConversationId);
const [collapsed, setCollapsed] = useState(!!currentConversationId);
...
...
app/components/base/chat/chat-with-history/hooks.tsx
View file @
d5667bc
...
@@ -341,6 +341,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
...
@@ -341,6 +341,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
let hasEmptyInput = "";
let hasEmptyInput = "";
let fileIsUploading = false;
let fileIsUploading = false;
const requiredVars = inputsForms.filter(({ required }) => required);
const requiredVars = inputsForms.filter(({ required }) => required);
console.log(requiredVars, "requiredVars");
if (requiredVars.length) {
if (requiredVars.length) {
requiredVars.forEach(({ variable, label, type }) => {
requiredVars.forEach(({ variable, label, type }) => {
if (hasEmptyInput) return;
if (hasEmptyInput) return;
...
@@ -412,18 +413,21 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
...
@@ -412,18 +413,21 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
},
},
[handleConversationIdInfoChange, setClearChatList]
[handleConversationIdInfoChange, setClearChatList]
);
);
const handleNewConversation = useCallback(() => {
const handleNewConversation = useCallback(
currentChatInstanceRef.current.handleStop();
(inputs?: Record<string, any>) => {
setShowNewConversationItemInList(true);
currentChatInstanceRef.current.handleStop();
handleChangeConversation("");
setShowNewConversationItemInList(true);
handleNewConversationInputsChange({});
handleChangeConversation("");
setClearChatList(true);
handleNewConversationInputsChange(inputs || {});
}, [
setClearChatList(true);
handleChangeConversation,
},
setShowNewConversationItemInList,
[
handleNewConversationInputsChange,
handleChangeConversation,
setClearChatList,
setShowNewConversationItemInList,
]);
handleNewConversationInputsChange,
setClearChatList,
]
);
const handleUpdateConversationList = useCallback(() => {
const handleUpdateConversationList = useCallback(() => {
mutateAppConversationData();
mutateAppConversationData();
mutateAppPinnedConversationData();
mutateAppPinnedConversationData();
...
...
app/components/base/chat/chat-with-history/index.tsx
View file @
d5667bc
...
@@ -41,9 +41,8 @@ const getQueryParams = function (): urlProps {
...
@@ -41,9 +41,8 @@ const getQueryParams = function (): urlProps {
};
};
};
};
const newInputs = getQueryParams();
const newInputs = getQueryParams();
newInputs.queryType =
'0'
newInputs.queryType =
"0";
const avatar: string = newInputs.avatar!;
const avatar: string = newInputs.avatar!;
console.log(newInputs, 22);
delete newInputs.avatar;
delete newInputs.avatar;
const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
...
@@ -54,20 +53,7 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
...
@@ -54,20 +53,7 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
appChatListDataLoading,
appChatListDataLoading,
chatShouldReloadKey,
chatShouldReloadKey,
isMobile,
isMobile,
themeBuilder,
} = useChatWithHistoryContext();
} = useChatWithHistoryContext();
const customConfig = appData?.custom_config;
const site = appData?.site; // 替换 'paramName' 为实际的参数名
useEffect(() => {
themeBuilder?.buildTheme(
site?.chat_color_theme,
site?.chat_color_theme_inverted
);
if (site) {
if (customConfig) document.title = `${site.title}`;
else document.title = `${site.title} - Powered by Dify`;
}
}, [site, customConfig, themeBuilder]);
if (appInfoLoading) {
if (appInfoLoading) {
return <Loading type="app" />;
return <Loading type="app" />;
...
@@ -160,10 +146,8 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
...
@@ -160,10 +146,8 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
} = useChatWithHistory(installedAppInfo);
} = useChatWithHistory(installedAppInfo);
useEffect(() => {
useEffect(() => {
//新建对话
//新建对话
handleNewConversation();
setTimeout(() => {
setTimeout(() => {
console.log(newInputs,88);
handleNewConversation(newInputs);
handleNewConversationInputsChange(newInputs);
}, 1000);
}, 1000);
}, []);
}, []);
return (
return (
...
...
app/components/base/chat/chat/chat-input-area/index.tsx
View file @
d5667bc
...
@@ -20,7 +20,7 @@ import { useToastContext } from "@/app/components/base/toast";
...
@@ -20,7 +20,7 @@ import { useToastContext } from "@/app/components/base/toast";
import FeatureBar from "@/app/components/base/features/new-feature-panel/feature-bar";
import FeatureBar from "@/app/components/base/features/new-feature-panel/feature-bar";
import type { FileUpload } from "@/app/components/base/features/types";
import type { FileUpload } from "@/app/components/base/features/types";
import { TransferMethod } from "@/types/app";
import { TransferMethod } from "@/types/app";
import {
SELF_INPUT
} from "@/app/components/base/chat/constants";
import {
SELF_INPUT
} from "@/app/components/base/chat/constants";
type ChatInputAreaProps = {
type ChatInputAreaProps = {
showFeatureBar?: boolean;
showFeatureBar?: boolean;
showFileUpload?: boolean;
showFileUpload?: boolean;
...
@@ -105,11 +105,11 @@ const ChatInputArea = ({
...
@@ -105,11 +105,11 @@ const ChatInputArea = ({
});
});
return;
return;
}
}
if (checkInputsForm(inputs, inputsForm)) {
//
if (checkInputsForm(inputs, inputsForm)) {
onSend({message:query,type:SELF_INPUT
}, files);
onSend({ message: query, type: SELF_INPUT
}, files);
setQuery("");
setQuery("");
setFiles([]);
setFiles([]);
}
//
}
}
}
};
};
const handleCompositionStart = () => {
const handleCompositionStart = () => {
...
...
app/components/base/chat/chat/index.tsx
View file @
d5667bc
...
@@ -142,8 +142,8 @@ const Chat: FC<ChatProps> = ({
...
@@ -142,8 +142,8 @@ const Chat: FC<ChatProps> = ({
const handleScrollToBottom = useCallback(() => {
const handleScrollToBottom = useCallback(() => {
if (
if (
chatList.length > 1 &&
chatList.length > 1 &&
chatContainerRef.current
&&
chatContainerRef.current
!userScrolledRef.current
//
!userScrolledRef.current
)
)
chatContainerRef.current.scrollTop =
chatContainerRef.current.scrollTop =
chatContainerRef.current.scrollHeight;
chatContainerRef.current.scrollHeight;
...
@@ -257,7 +257,7 @@ const Chat: FC<ChatProps> = ({
...
@@ -257,7 +257,7 @@ const Chat: FC<ChatProps> = ({
chatContainerClassName
chatContainerClassName
)}
)}
>
>
{chatNode}
<div
<div
ref={chatContainerInnerRef}
ref={chatContainerInnerRef}
className={cn(
className={cn(
...
...
app/layout.tsx
View file @
d5667bc
import type { Viewport } from 'next'
/*
import I18nServer from './components/i18n-server'
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
import BrowserInitor from './components/browser-initor'
* @Date: 2025-04-22 09:29:21
import SentryInitor from './components/sentry-initor'
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
import { getLocaleOnServer } from '@/i18n/server'
* @LastEditTime: 2025-04-27 10:09:19
import { TanstackQueryIniter } from '@/context/query-client'
* @FilePath: \glsk-ai-assistant\app\layout.tsx
import { ThemeProvider } from 'next-themes'
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
import './styles/globals.css'
*/
import './styles/markdown.scss'
import type { Viewport } from "next";
import I18nServer from "./components/i18n-server";
import BrowserInitor from "./components/browser-initor";
import SentryInitor from "./components/sentry-initor";
import { getLocaleOnServer } from "@/i18n/server";
import { TanstackQueryIniter } from "@/context/query-client";
import { ThemeProvider } from "next-themes";
import "./styles/globals.css";
import "./styles/markdown.scss";
export const metadata = {
export const metadata = {
title:
'Dify'
,
title:
"广联AI集市"
,
}
}
;
export const viewport: Viewport = {
export const viewport: Viewport = {
width:
'device-width'
,
width:
"device-width"
,
initialScale: 1,
initialScale: 1,
maximumScale: 1,
maximumScale: 1,
viewportFit:
'cover'
,
viewportFit:
"cover"
,
userScalable: false,
userScalable: false,
}
}
;
const LocaleLayout = async ({
const LocaleLayout = async ({ children }: { children: React.ReactNode }) => {
children,
const locale = await getLocaleOnServer();
}: {
children: React.ReactNode
}) => {
const locale = await getLocaleOnServer()
return (
return (
<html
lang=
{locale
??
'
en
'
}
className=
"h-full"
suppressHydrationWarning
>
<html
lang=
{locale
??
"
en
"
}
className=
"h-full"
suppressHydrationWarning
>
<head>
<head>
<meta
name=
"theme-color"
content=
"#FFFFFF"
/>
<meta
name=
"theme-color"
content=
"#FFFFFF"
/>
<meta
name=
"mobile-web-app-capable"
content=
"yes"
/>
<meta
name=
"mobile-web-app-capable"
content=
"yes"
/>
...
@@ -39,41 +43,57 @@ const LocaleLayout = async ({
...
@@ -39,41 +43,57 @@ const LocaleLayout = async ({
className=
"color-scheme h-full select-auto"
className=
"color-scheme h-full select-auto"
data-api-prefix=
{process.env.NEXT_PUBLIC_API_PREFIX}
data-api-prefix=
{process.env.NEXT_PUBLIC_API_PREFIX}
data-pubic-api-prefix=
{process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX}
data-pubic-api-prefix=
{process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX}
data-marketplace-api-prefix=
{process.env.NEXT_PUBLIC_MARKETPLACE_API_PREFIX}
data-marketplace-api-prefix=
{
data-marketplace-url-prefix=
{process.env.NEXT_PUBLIC_MARKETPLACE_URL_PREFIX}
process
.
env
.
NEXT_PUBLIC_MARKETPLACE_API_PREFIX
}
data-marketplace-url-prefix=
{
process
.
env
.
NEXT_PUBLIC_MARKETPLACE_URL_PREFIX
}
data-public-edition=
{process.env.NEXT_PUBLIC_EDITION}
data-public-edition=
{process.env.NEXT_PUBLIC_EDITION}
data-public-support-mail-login=
{process.env.NEXT_PUBLIC_SUPPORT_MAIL_LOGIN}
data-public-support-mail-login=
{
process
.
env
.
NEXT_PUBLIC_SUPPORT_MAIL_LOGIN
}
data-public-sentry-dsn=
{process.env.NEXT_PUBLIC_SENTRY_DSN}
data-public-sentry-dsn=
{process.env.NEXT_PUBLIC_SENTRY_DSN}
data-public-maintenance-notice=
{process.env.NEXT_PUBLIC_MAINTENANCE_NOTICE}
data-public-maintenance-notice=
{
process
.
env
.
NEXT_PUBLIC_MAINTENANCE_NOTICE
}
data-public-site-about=
{process.env.NEXT_PUBLIC_SITE_ABOUT}
data-public-site-about=
{process.env.NEXT_PUBLIC_SITE_ABOUT}
data-public-text-generation-timeout-ms=
{process.env.NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS}
data-public-text-generation-timeout-ms=
{
process
.
env
.
NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS
}
data-public-max-tools-num=
{process.env.NEXT_PUBLIC_MAX_TOOLS_NUM}
data-public-max-tools-num=
{process.env.NEXT_PUBLIC_MAX_TOOLS_NUM}
data-public-max-parallel-limit=
{process.env.NEXT_PUBLIC_MAX_PARALLEL_LIMIT}
data-public-max-parallel-limit=
{
process
.
env
.
NEXT_PUBLIC_MAX_PARALLEL_LIMIT
}
data-public-top-k-max-value=
{process.env.NEXT_PUBLIC_TOP_K_MAX_VALUE}
data-public-top-k-max-value=
{process.env.NEXT_PUBLIC_TOP_K_MAX_VALUE}
data-public-indexing-max-segmentation-tokens-length=
{process.env.NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH}
data-public-indexing-max-segmentation-tokens-length=
{
data-public-loop-node-max-count=
{process.env.NEXT_PUBLIC_LOOP_NODE_MAX_COUNT}
process
.
env
.
NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH
data-public-max-iterations-num=
{process.env.NEXT_PUBLIC_MAX_ITERATIONS_NUM}
}
data-public-loop-node-max-count=
{
process
.
env
.
NEXT_PUBLIC_LOOP_NODE_MAX_COUNT
}
data-public-max-iterations-num=
{
process
.
env
.
NEXT_PUBLIC_MAX_ITERATIONS_NUM
}
>
>
<BrowserInitor>
<BrowserInitor>
<SentryInitor>
<SentryInitor>
<TanstackQueryIniter>
<TanstackQueryIniter>
<ThemeProvider
<ThemeProvider
attribute=
'data-theme'
attribute=
"data-theme"
forcedTheme=
'light'
forcedTheme=
"light"
defaultTheme=
'light'
//
TODO:
change
to
'
system
'
when
dark
mode
ready
defaultTheme=
"light"
//
TODO:
change
to
'
system
'
when
dark
mode
ready
enableSystem
enableSystem
disableTransitionOnChange
disableTransitionOnChange
>
>
<I18nServer>
<I18nServer>
{children}
</I18nServer>
{children}
</I18nServer>
</ThemeProvider>
</ThemeProvider>
</TanstackQueryIniter>
</TanstackQueryIniter>
</SentryInitor>
</SentryInitor>
</BrowserInitor>
</BrowserInitor>
</body>
</body>
</html>
</html>
)
)
;
}
}
;
export default LocaleLayout
export default LocaleLayout
;
hooks/use-app-favicon.ts
View file @
d5667bc
import
{
useAsyncEffect
}
from
'ahooks'
/*
import
{
appDefaultIconBackground
}
from
'@/config'
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
import
{
searchEmoji
}
from
'@/utils/emoji'
* @Date: 2025-04-22 09:29:21
import
type
{
AppIconType
}
from
'@/types/app'
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
* @LastEditTime: 2025-04-27 10:23:22
* @FilePath: \glsk-ai-assistant\hooks\use-app-favicon.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import
{
useAsyncEffect
}
from
"ahooks"
;
import
{
appDefaultIconBackground
}
from
"@/config"
;
import
{
searchEmoji
}
from
"@/utils/emoji"
;
import
type
{
AppIconType
}
from
"@/types/app"
;
type
UseAppFaviconOptions
=
{
type
UseAppFaviconOptions
=
{
enable
?:
boolean
enable
?:
boolean
;
icon_type
?:
AppIconType
|
null
icon_type
?:
AppIconType
|
null
;
icon
?:
string
icon
?:
string
;
icon_background
?:
string
|
null
icon_background
?:
string
|
null
;
icon_url
?:
string
|
null
icon_url
?:
string
|
null
;
}
}
;
export
function
useAppFavicon
(
options
:
UseAppFaviconOptions
)
{
export
function
useAppFavicon
(
options
:
UseAppFaviconOptions
)
{
const
{
const
{
enable
=
true
,
enable
=
true
,
icon_type
=
'emoji'
,
icon_type
=
"emoji"
,
icon
,
icon
,
icon_background
,
icon_background
,
icon_url
,
icon_url
,
}
=
options
}
=
options
;
useAsyncEffect
(
async
()
=>
{
useAsyncEffect
(
async
()
=>
{
if
(
!
enable
||
(
icon_type
===
'image'
&&
!
icon_url
)
||
(
icon_type
===
'emoji'
&&
!
icon
))
if
(
return
!
enable
||
(
icon_type
===
"image"
&&
!
icon_url
)
||
const
isValidImageIcon
=
icon_type
===
'image'
&&
icon_url
(
icon_type
===
"emoji"
&&
!
icon
)
)
return
;
const
link
:
HTMLLinkElement
=
document
.
querySelector
(
'link[rel*="icon"]'
)
||
document
.
createElement
(
'link'
)
const
link
:
HTMLLinkElement
=
document
.
querySelector
(
'link[rel*="icon"]'
)
||
document
.
createElement
(
"link"
);
link
.
href
=
isValidImageIcon
link
.
href
=
?
icon_url
"https://img02.glsx.com.cn/weapp/resource/saas/ai/ai-avatar.png"
;
:
'data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22>'
+
`<rect width=%22100%25%22 height=%22100%25%22 fill=%22
${
encodeURIComponent
(
icon_background
||
appDefaultIconBackground
)}
%22 rx=%2230%22 ry=%2230%22 />`
+
`<text x=%2212.5%22 y=%221em%22 font-size=%2275%22>
${
icon
?
await
searchEmoji
(
icon
)
:
'🤖'
}
<
/text>
`
+
'</svg>'
link
.
rel
=
'shortcut icon'
link
.
rel
=
"shortcut icon"
;
link
.
type
=
'image/svg'
link
.
type
=
"image/svg"
;
document
.
getElementsByTagName
(
'head'
)[
0
].
appendChild
(
link
)
document
.
getElementsByTagName
(
"head"
)[
0
].
appendChild
(
link
);
},
[
enable
,
icon
,
icon_background
])
},
[
enable
,
icon
,
icon_background
])
;
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment