Merge remote-tracking branch 'origin/main' into dev

This commit is contained in:
sijinhui 2024-09-27 13:05:38 +08:00
commit f8cac63d1e
11 changed files with 99 additions and 33 deletions

View File

@ -28,6 +28,13 @@ jobs:
uses: docker/build-push-action@v4 uses: docker/build-push-action@v4
with: with:
context: . context: .
file: cache.Dockerfile file: cache.install.Dockerfile
push: true
tags: sijinhui/chatgpt-next-web:installcache
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: cache.build.Dockerfile
push: true push: true
tags: sijinhui/chatgpt-next-web:buildcache tags: sijinhui/chatgpt-next-web:buildcache

View File

@ -1,27 +1,36 @@
FROM sijinhui/chatgpt-next-web:buildcache AS deps #FROM sijinhui/chatgpt-next-web:installcache AS deps
#
#WORKDIR /app
#
#COPY package.json yarn.lock ./
#
#RUN yarn install
#
#FROM sijinhui/node:base AS builder
#
#RUN apk add --no-cache git libc6-compat
#
#ENV OPENAI_API_KEY=""
#ENV GOOGLE_API_KEY=""
#ENV CODE=""
#
#WORKDIR /app
#COPY . .
#COPY --from=deps /app/node_modules ./node_modules
## 避免下面那个报错
## RUN mkdir -p "/app/node_modules/tiktoken" && mkdir -p "/app/node_modules/sharp"
## RUN yarn add sharp
## ENV NEXT_SHARP_PATH /app/node_modules/sharp
#RUN yarn build
WORKDIR /app FROM sijinhui/chatgpt-next-web:buildcache as base
COPY package.json yarn.lock ./
RUN yarn install
FROM sijinhui/node:base AS builder FROM sijinhui/node:base AS builder
RUN apk add --no-cache git libc6-compat
ENV OPENAI_API_KEY=""
ENV GOOGLE_API_KEY=""
ENV CODE=""
WORKDIR /app WORKDIR /app
COPY . . COPY . .
COPY --from=deps /app/node_modules ./node_modules COPY --from=base /app/.next ./next
# 避免下面那个报错 COPY --from=base /app/node_modules ./node_modules
# RUN mkdir -p "/app/node_modules/tiktoken" && mkdir -p "/app/node_modules/sharp" RUN yarn install && yarn build
# RUN yarn add sharp
# ENV NEXT_SHARP_PATH /app/node_modules/sharp
RUN yarn build
FROM sijinhui/node:base AS runner FROM sijinhui/node:base AS runner
WORKDIR /app WORKDIR /app

View File

@ -22,7 +22,7 @@ import { useMobileScreen } from "../utils";
// motion // motion
import QueueAnim from "rc-queue-anim"; import QueueAnim from "rc-queue-anim";
export function ChatItem(props: { function ChatItem(props: {
onClick?: () => void; onClick?: () => void;
onDelete?: () => void; onDelete?: () => void;
title: string; title: string;
@ -34,6 +34,7 @@ export function ChatItem(props: {
narrow?: boolean; narrow?: boolean;
mask: Mask; mask: Mask;
provided: DraggableProvided; provided: DraggableProvided;
isMobileScreen: boolean;
}) { }) {
const draggableRef = useRef<HTMLDivElement | null>(null); const draggableRef = useRef<HTMLDivElement | null>(null);
useEffect(() => { useEffect(() => {
@ -57,8 +58,8 @@ export function ChatItem(props: {
draggableRef.current = ele; draggableRef.current = ele;
props.provided.innerRef(ele); props.provided.innerRef(ele);
}} }}
{...props.provided.draggableProps} {...(props.isMobileScreen ? {} : props.provided.draggableProps)}
{...props.provided.dragHandleProps} {...(props.isMobileScreen ? {} : props.provided.dragHandleProps)}
title={`${props.title}\n${Locale.ChatItem.ChatItemCount(props.count)}`} title={`${props.title}\n${Locale.ChatItem.ChatItemCount(props.count)}`}
> >
{props.narrow ? ( {props.narrow ? (
@ -84,7 +85,10 @@ export function ChatItem(props: {
)} )}
<div <div
className={styles["chat-item-delete"]} className={
styles["chat-item-delete"] +
` ${props.isMobileScreen ? styles["chat-item-delete-visible"] : ""}`
}
onClickCapture={(e) => { onClickCapture={(e) => {
props.onDelete?.(); props.onDelete?.();
e.preventDefault(); e.preventDefault();
@ -155,6 +159,7 @@ export function ChatList(props: { narrow?: boolean }) {
narrow={props.narrow} narrow={props.narrow}
mask={sessions[rubic.source.index].mask} mask={sessions[rubic.source.index].mask}
provided={provided} provided={provided}
isMobileScreen={isMobileScreen}
/> />
)} )}
> >
@ -167,13 +172,16 @@ export function ChatList(props: { narrow?: boolean }) {
<QueueAnim <QueueAnim
delay={[100, 0]} delay={[100, 0]}
ease={"easeOutQuart"} // "easeInOutQuart" ease={"easeOutQuart"} // "easeInOutQuart"
duration={[550, 450]} duration={[350, 450]}
animConfig={[ animConfig={[
{ opacity: [1, 0], translateY: [0, -30] }, { opacity: [1, 0], translateY: [0, -30], height: [71, 0] },
{ height: 0 }, { height: 0 },
]} ]}
// TODO目前仅剩添加元素其他元素平移动画问题 // TODO手机端好像还有点问题,先把拖拽关了
// interval={150} onEnd={({ key, type, target }) => {
if (type === "enter") target.style.height = "auto";
}}
interval={50}
> >
{sessions.map((item, i) => ( {sessions.map((item, i) => (
<div key={item.id}> <div key={item.id}>
@ -202,6 +210,7 @@ export function ChatList(props: { narrow?: boolean }) {
narrow={props.narrow} narrow={props.narrow}
mask={item.mask} mask={item.mask}
provided={provided} provided={provided}
isMobileScreen={isMobileScreen}
/> />
)} )}
</Draggable> </Draggable>

View File

@ -229,6 +229,13 @@
opacity: 1; opacity: 1;
} }
/* 新增类,按钮持续显示 */
.chat-item > .chat-item-delete-visible {
opacity: 0.5;
transform: translateX(-4px);
}
.chat-item-info { .chat-item-info {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

View File

@ -434,7 +434,7 @@ export const DEFAULT_MODELS = [
// }, // },
// }, // },
{ {
name: "o1-preview-all", name: "o1-preview",
describe: "GPT,o1,最新模型,目前较贵", describe: "GPT,o1,最新模型,目前较贵",
available: true, available: true,
sorted: seq++, sorted: seq++,

View File

@ -182,7 +182,7 @@ export const useAppConfig = createPersistStore(
}), }),
{ {
name: StoreKey.Config, name: StoreKey.Config,
version: 4.1, version: 4.2,
merge(persistedState, currentState) { merge(persistedState, currentState) {
const state = persistedState as ChatConfig | undefined; const state = persistedState as ChatConfig | undefined;
@ -229,7 +229,7 @@ export const useAppConfig = createPersistStore(
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
} }
if (version < 4.1) { if (version < 4.2) {
state.modelConfig.compressModel = state.modelConfig.compressModel =
DEFAULT_CONFIG.modelConfig.compressModel; DEFAULT_CONFIG.modelConfig.compressModel;
state.modelConfig.compressProviderName = state.modelConfig.compressProviderName =

18
cache.build.Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM sijinhui/chatgpt-next-web:installcache AS deps
FROM sijinhui/node:base AS builder
RUN apk add --no-cache git libc6-compat
ENV OPENAI_API_KEY=""
ENV GOOGLE_API_KEY=""
ENV CODE=""
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
# 避免下面那个报错
# RUN mkdir -p "/app/node_modules/tiktoken" && mkdir -p "/app/node_modules/sharp"
# RUN yarn add sharp
# ENV NEXT_SHARP_PATH /app/node_modules/sharp
RUN yarn build

12
ecosystem.config.js Normal file
View File

@ -0,0 +1,12 @@
module.exports = {
apps : [{
name : "chat",
script : "yarn",
args : "start",
env : {
PORT : 23000
},
autorestart: true,
interpreter: '/bin/bash',
}]
}

View File

@ -86,7 +86,11 @@ const nextConfig = {
}, },
experimental: { experimental: {
forceSwcTransforms: true, forceSwcTransforms: true,
serverComponentsExternalPackages: ["tiktoken"] serverComponentsExternalPackages: ["tiktoken"],
// 加速跟踪依赖项
// turbotrace: {
// logDetail: true,
// },
}, },
// externals: { // externals: {
// 'sharp': 'commonjs sharp' // 'sharp': 'commonjs sharp'

View File

@ -1,4 +1,4 @@
FROM hub.si.icu/library/node:22.1-alpine AS base FROM node:22.1-alpine AS base
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache tzdata RUN apk add --no-cache tzdata
# 设置时区环境变量 # 设置时区环境变量