diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 320c8ad..d1f74d0 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,2 @@ github: [ztjhz] -ko_fi: freechatgpt +ko_fi: betterchatgpt diff --git a/README-zh_CN.md b/README-zh_CN.md index 21d2696..6898ecb 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -98,11 +98,11 @@ Better ChatGPT 已经包含了大量的功能。您可以使用以下功能: 如果您想支持我们的团队,请考虑通过以下方法之一赞助我们。每一份贡献,无论多小,都有助于我们维护和改善我们的服务。 -| 付款方式 | 链接 | -| -------------- | -------------------------------------------------------------------------------------- | -| 支付宝 (Ayaka) | | -| 微信 (Ayaka) | | -| KoFi | [![support](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/freechatgpt) | +| 付款方式 | 链接 | +| -------------- | ---------------------------------------------------------------------------------------- | +| 支付宝 (Ayaka) | | +| 微信 (Ayaka) | | +| KoFi | [![support](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/betterchatgpt) | 感谢您成为我们社区的一员,我们期待着在未来为您提供更好的服务。 diff --git a/README.md b/README.md index d4826d4..a85c4ac 100644 --- a/README.md +++ b/README.md @@ -105,11 +105,11 @@ If you have enjoyed using our app, we kindly ask you to give this project a ⭐ If you would like to support the team, consider sponsoring us through one of the methods below. Every contribution, no matter how small, helps us to maintain and improve our service. -| Payment Method | Link | -| -------------- | -------------------------------------------------------------------------------------- | -| KoFi | [![support](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/freechatgpt) | -| Alipay (Ayaka) | | -| Wechat (Ayaka) | | +| Payment Method | Link | +| -------------- | ---------------------------------------------------------------------------------------- | +| KoFi | [![support](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/betterchatgpt) | +| Alipay (Ayaka) | | +| Wechat (Ayaka) | | Thank you for being a part of our community, and we look forward to serving you better in the future. diff --git a/index.html b/index.html index 9d45652..b7cf0ec 100644 --- a/index.html +++ b/index.html @@ -10,11 +10,11 @@ diff --git a/package.json b/package.json index b8e8ef2..5c15b89 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "chatgpt-free-app", + "name": "better-chatgpt", "private": true, "version": "0.0.0", "type": "module", diff --git a/src/components/AboutMenu/AboutMenu.tsx b/src/components/AboutMenu/AboutMenu.tsx index 8d21fa9..4b66ed2 100644 --- a/src/components/AboutMenu/AboutMenu.tsx +++ b/src/components/AboutMenu/AboutMenu.tsx @@ -78,7 +78,7 @@ const AboutMenu = () => {

{t('support.paragraph3', { ns: 'about' })}

- + Support us through the Ko-fi platform. { + navigator.clipboard.writeText(content); + }; + return ( <>
@@ -157,14 +163,17 @@ const ContentView = React.memo(
{isDelete || ( <> - {role === 'assistant' && messageIndex === lastMessageIndex && ( - - )} + {!useStore.getState().generating && + role === 'assistant' && + messageIndex === lastMessageIndex && ( + + )} {messageIndex !== 0 && } {messageIndex !== lastMessageIndex && ( )} + @@ -277,6 +286,7 @@ const UpButton = ({ /> ); }; + const RefreshButton = ({ onClick, }: { @@ -284,6 +294,28 @@ const RefreshButton = ({ }) => { return } onClick={onClick} />; }; + +const CopyButton = ({ + onClick, +}: { + onClick: React.MouseEventHandler; +}) => { + const [isCopied, setIsCopied] = useState(false); + + return ( + : } + onClick={(e) => { + onClick(e); + setIsCopied(true); + window.setTimeout(() => { + setIsCopied(false); + }, 3000); + }} + /> + ); +}; + const EditView = ({ content, setIsEdit, @@ -481,6 +513,7 @@ const EditViewButtons = React.memo( )}
+ {sticky && }
); diff --git a/src/components/TokenCount/TokenCount.tsx b/src/components/TokenCount/TokenCount.tsx new file mode 100644 index 0000000..8b78c3c --- /dev/null +++ b/src/components/TokenCount/TokenCount.tsx @@ -0,0 +1,29 @@ +import React, { useEffect, useState } from 'react'; +import useStore from '@store/store'; +import { shallow } from 'zustand/shallow'; + +import { countMessagesToken } from '@utils/messageUtils'; + +const TokenCount = React.memo(() => { + const [tokenCount, setTokenCount] = useState(0); + const generating = useStore((state) => state.generating); + const messages = useStore( + (state) => + state.chats ? state.chats[state.currentChatIndex].messages : [], + shallow + ); + + useEffect(() => { + if (!generating) setTokenCount(countMessagesToken(messages)); + }, [messages, generating]); + + return ( +
+
+ Tokens: {tokenCount} +
+
+ ); +}); + +export default TokenCount; diff --git a/src/components/TokenCount/index.ts b/src/components/TokenCount/index.ts new file mode 100644 index 0000000..c895917 --- /dev/null +++ b/src/components/TokenCount/index.ts @@ -0,0 +1 @@ +export { default } from './TokenCount'; diff --git a/src/main.css b/src/main.css index f2f9d72..b8301c9 100644 --- a/src/main.css +++ b/src/main.css @@ -27,6 +27,42 @@ height: 100%; } + .markdown table { + --tw-border-spacing-x: 0px; + --tw-border-spacing-y: 0px; + border-collapse: separate; + border-spacing: var(--tw-border-spacing-x) var(--tw-border-spacing-y); + width: 100%; + } + .markdown th { + background-color: rgba(236, 236, 241, 0.2); + border-bottom-width: 1px; + border-left-width: 1px; + border-top-width: 1px; + padding: 0.25rem 0.75rem; + } + .markdown th:first-child { + border-top-left-radius: 0.375rem; + } + .markdown th:last-child { + border-right-width: 1px; + border-top-right-radius: 0.375rem; + } + .markdown td { + border-bottom-width: 1px; + border-left-width: 1px; + padding: 0.25rem 0.75rem; + } + .markdown td:last-child { + border-right-width: 1px; + } + .markdown tbody tr:last-child td:first-child { + border-bottom-left-radius: 0.375rem; + } + .markdown tbody tr:last-child td:last-child { + border-bottom-right-radius: 0.375rem; + } + img { @apply inline-block; } diff --git a/src/utils/messageUtils.ts b/src/utils/messageUtils.ts index cef477a..faff1bb 100644 --- a/src/utils/messageUtils.ts +++ b/src/utils/messageUtils.ts @@ -17,3 +17,10 @@ export const limitMessageTokens = ( return limitedMessages; }; + +export const countMessagesToken = (messages: MessageInterface[]) => { + return messages.reduce( + (tokenCount, message) => (tokenCount += countTokens(message.content)), + 0 + ); +};