dify移动端UI定制与美化

#修改web的挂载方式,build方式才会读取修改的web文件
    打开:\dify\docker,修改 docker-compose.yml,查找web:,如果发现只有image: ,没有build: ,则删除image:xxx,替换为build: ../web

#打开powershell,切换到对应目录,如D:\dify\web\app\

#通过浏览器控制台找到要修改页面的html信息,并通过该信息查找要修改的文件
    查找目录下含chat-answer-container group ml-4的文件
    Get-ChildItem -Recurse -Include *.* | Select-String -Pattern "chat-answer-container group ml-4"
    得到:\dify\web\app\components\base\chat\chat\answer\index.tsx

#删除ai头像
查找文件内relative h-10 w-10 shrink-0,删除以下代码
      {!hideAvatar && (
        <div className="relative h-10 w-10 shrink-0">
          {answerIcon || <AnswerIcon />}
          {responding && (
            <div className="absolute left-[-3px] top-[-3px] flex h-4 w-4 items-center rounded-full border-[0.5px] border-divider-subtle bg-background-section-burn pl-[6px] shadow-xs">
              <LoadingAnim type="avatar" />
            </div>
          )}
        </div>
      )}    
      
#重新构建web服务
打开docker文件夹,地址栏输入cmd,执行
    docker-compose build web --no-cache   # 强制重新构建,不使用缓存
    docker-compose up -d web               # 重启 web 服务

#并将AI气泡宽度保持与屏幕宽度一致
------------------
\dify\web\app\components\base\chat\chat\answer\index.tsx
// 原代码
<div className="chat-answer-container group ml-4 w-0 grow pb-4" ref={containerRef}>
// 修改后(删除 ml-4)
<div className="chat-answer-container group w-0 grow pb-4" ref={containerRef}>
------------------
\dify\web\app\components\base\chat\chat\answer\index.tsx
// 原代码
<div class="group relative pr-10">,有2个改,都改
// 修改后
<div class="group relative pr-0">
------------------
\dify\web\app\components\base\chat\chat-with-history\chat-wrapper.tsx
// 原代码(外层容器)
<div className="mx-auto pt-6 w-full max-w-[768px] px-4">,有2个,都改
// 修改后(把 px-4 改成 px-0,去掉左右内边距)
<div className="mx-auto pt-6 w-full max-w-[768px] px-0">

#去除页面title内的dify文字
------------------
titleStr = `${prefix}dify`
改成
titleStr = `${prefix}`
------------------
\dify\web\hooks\use-document-title.ts
const prefix = title ? `${title} - ` : ''
改成const prefix = title ? `${title}` : ''

#隐藏对话顶部对话名称信息层
\dify\web\app\components\base\chat\chat-with-history\header-in-mobile.tsx
查找flex shrink-0 items-center,所在的div的class增加hidden,如下
className="hidden flex......

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐