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 Header from '../signin/_header'
import ActivateForm from './activateForm'
import cn from '@/utils/classnames'
...
...
@@ -7,7 +6,6 @@ const Activate = () => {
return (
<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')}>
<Header />
<ActivateForm />
<div className='px-8 py-6 text-sm font-normal text-text-tertiary'>
© {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) => {
);
const messageList = useMemo(() => {
console.log(chatList, "chatList", currentConversationId);
if (currentConversationId) return chatList;
return chatList.filter((item) => item.isOpeningStatement);
return chatList;
}, [chatList, 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) => {
let hasEmptyInput = "";
let fileIsUploading = false;
const requiredVars = inputsForms.filter(({ required }) => required);
console.log(requiredVars, "requiredVars");
if (requiredVars.length) {
requiredVars.forEach(({ variable, label, type }) => {
if (hasEmptyInput) return;
...
...
@@ -412,18 +413,21 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
},
[handleConversationIdInfoChange, setClearChatList]
);
const handleNewConversation = useCallback(() => {
currentChatInstanceRef.current.handleStop();
setShowNewConversationItemInList(true);
handleChangeConversation("");
handleNewConversationInputsChange({});
setClearChatList(true);
}, [
handleChangeConversation,
setShowNewConversationItemInList,
handleNewConversationInputsChange,
setClearChatList,
]);
const handleNewConversation = useCallback(
(inputs?: Record<string, any>) => {
currentChatInstanceRef.current.handleStop();
setShowNewConversationItemInList(true);
handleChangeConversation("");
handleNewConversationInputsChange(inputs || {});
setClearChatList(true);
},
[
handleChangeConversation,
setShowNewConversationItemInList,
handleNewConversationInputsChange,
setClearChatList,
]
);
const handleUpdateConversationList = useCallback(() => {
mutateAppConversationData();
mutateAppPinnedConversationData();
...
...
app/components/base/chat/chat-with-history/index.tsx
View file @
d5667bc
...
...
@@ -41,9 +41,8 @@ const getQueryParams = function (): urlProps {
};
};
const newInputs = getQueryParams();
newInputs.queryType =
'0'
newInputs.queryType =
"0";
const avatar: string = newInputs.avatar!;
console.log(newInputs, 22);
delete newInputs.avatar;
const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
...
...
@@ -54,20 +53,7 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
appChatListDataLoading,
chatShouldReloadKey,
isMobile,
themeBuilder,
} = 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) {
return <Loading type="app" />;
...
...
@@ -160,10 +146,8 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
} = useChatWithHistory(installedAppInfo);
useEffect(() => {
//新建对话
handleNewConversation();
setTimeout(() => {
console.log(newInputs,88);
handleNewConversationInputsChange(newInputs);
handleNewConversation(newInputs);
}, 1000);
}, []);
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";
import FeatureBar from "@/app/components/base/features/new-feature-panel/feature-bar";
import type { FileUpload } from "@/app/components/base/features/types";
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 = {
showFeatureBar?: boolean;
showFileUpload?: boolean;
...
...
@@ -105,11 +105,11 @@ const ChatInputArea = ({
});
return;
}
if (checkInputsForm(inputs, inputsForm)) {
onSend({message:query,type:SELF_INPUT
}, files);
setQuery("");
setFiles([]);
}
//
if (checkInputsForm(inputs, inputsForm)) {
onSend({ message: query, type: SELF_INPUT
}, files);
setQuery("");
setFiles([]);
//
}
}
};
const handleCompositionStart = () => {
...
...
app/components/base/chat/chat/index.tsx
View file @
d5667bc
...
...
@@ -142,8 +142,8 @@ const Chat: FC<ChatProps> = ({
const handleScrollToBottom = useCallback(() => {
if (
chatList.length > 1 &&
chatContainerRef.current
&&
!userScrolledRef.current
chatContainerRef.current
//
!userScrolledRef.current
)
chatContainerRef.current.scrollTop =
chatContainerRef.current.scrollHeight;
...
...
@@ -257,7 +257,7 @@ const Chat: FC<ChatProps> = ({
chatContainerClassName
)}
>
{chatNode}
<div
ref={chatContainerInnerRef}
className={cn(
...
...
app/layout.tsx
View file @
d5667bc
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'
/*
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-22 09:29:21
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
* @LastEditTime: 2025-04-27 10:09:19
* @FilePath: \glsk-ai-assistant\app\layout.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
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 = {
title:
'Dify'
,
}
title:
"广联AI集市"
,
}
;
export const viewport: Viewport = {
width:
'device-width'
,
width:
"device-width"
,
initialScale: 1,
maximumScale: 1,
viewportFit:
'cover'
,
viewportFit:
"cover"
,
userScalable: false,
}
}
;
const LocaleLayout = async ({
children,
}: {
children: React.ReactNode
}) => {
const locale = await getLocaleOnServer()
const LocaleLayout = async ({ children }: { children: React.ReactNode }) => {
const locale = await getLocaleOnServer();
return (
<html
lang=
{locale
??
'
en
'
}
className=
"h-full"
suppressHydrationWarning
>
<html
lang=
{locale
??
"
en
"
}
className=
"h-full"
suppressHydrationWarning
>
<head>
<meta
name=
"theme-color"
content=
"#FFFFFF"
/>
<meta
name=
"mobile-web-app-capable"
content=
"yes"
/>
...
...
@@ -39,41 +43,57 @@ const LocaleLayout = async ({
className=
"color-scheme h-full select-auto"
data-api-prefix=
{process.env.NEXT_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-url-prefix=
{process.env.NEXT_PUBLIC_MARKETPLACE_URL_PREFIX}
data-marketplace-api-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-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-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-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-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-indexing-max-segmentation-tokens-length=
{process.env.NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH}
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}
data-public-indexing-max-segmentation-tokens-length=
{
process
.
env
.
NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH
}
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>
<SentryInitor>
<TanstackQueryIniter>
<ThemeProvider
attribute=
'data-theme'
forcedTheme=
'light'
defaultTheme=
'light'
//
TODO:
change
to
'
system
'
when
dark
mode
ready
attribute=
"data-theme"
forcedTheme=
"light"
defaultTheme=
"light"
//
TODO:
change
to
'
system
'
when
dark
mode
ready
enableSystem
disableTransitionOnChange
>
<I18nServer>
{children}
</I18nServer>
<I18nServer>
{children}
</I18nServer>
</ThemeProvider>
</TanstackQueryIniter>
</SentryInitor>
</BrowserInitor>
</body>
</html>
)
}
)
;
}
;
export default LocaleLayout
export default LocaleLayout
;
hooks/use-app-favicon.ts
View file @
d5667bc
import
{
useAsyncEffect
}
from
'ahooks'
import
{
appDefaultIconBackground
}
from
'@/config'
import
{
searchEmoji
}
from
'@/utils/emoji'
import
type
{
AppIconType
}
from
'@/types/app'
/*
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-22 09:29:21
* @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
=
{
enable
?:
boolean
icon_type
?:
AppIconType
|
null
icon
?:
string
icon_background
?:
string
|
null
icon_url
?:
string
|
null
}
enable
?:
boolean
;
icon_type
?:
AppIconType
|
null
;
icon
?:
string
;
icon_background
?:
string
|
null
;
icon_url
?:
string
|
null
;
}
;
export
function
useAppFavicon
(
options
:
UseAppFaviconOptions
)
{
const
{
enable
=
true
,
icon_type
=
'emoji'
,
icon_type
=
"emoji"
,
icon
,
icon_background
,
icon_url
,
}
=
options
}
=
options
;
useAsyncEffect
(
async
()
=>
{
if
(
!
enable
||
(
icon_type
===
'image'
&&
!
icon_url
)
||
(
icon_type
===
'emoji'
&&
!
icon
))
return
const
isValidImageIcon
=
icon_type
===
'image'
&&
icon_url
if
(
!
enable
||
(
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
?
icon_url
:
'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
.
href
=
"https://img02.glsx.com.cn/weapp/resource/saas/ai/ai-avatar.png"
;
link
.
rel
=
'shortcut icon'
link
.
type
=
'image/svg'
document
.
getElementsByTagName
(
'head'
)[
0
].
appendChild
(
link
)
},
[
enable
,
icon
,
icon_background
])
link
.
rel
=
"shortcut icon"
;
link
.
type
=
"image/svg"
;
document
.
getElementsByTagName
(
"head"
)[
0
].
appendChild
(
link
);
},
[
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