Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#497 from waltcow/main
Browse files Browse the repository at this point in the history
fix 头像无法正常显示
  • Loading branch information
Yidadaa authored Apr 5, 2023
2 parents ee4564d + f4fc682 commit 2ae62d9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Message, SubmitKey, useChatStore, BOT_HELLO, ROLES } from "../store";
import {
copyToClipboard,
downloadAs,
getEmojiUrl,
isMobileScreen,
selectOrCopy,
} from "../utils";
Expand Down Expand Up @@ -50,7 +51,7 @@ export function Avatar(props: { role: Message["role"] }) {

return (
<div className={styles["user-avtar"]}>
<Emoji unified={config.avatar} size={18} />
<Emoji unified={config.avatar} size={18} getEmojiUrl={getEmojiUrl} />
</div>
);
}
Expand Down
3 changes: 2 additions & 1 deletion app/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import { Avatar } from "./chat";

import Locale, { AllLangs, changeLang, getLang } from "../locales";
import { getCurrentVersion } from "../utils";
import { getCurrentVersion, getEmojiUrl } from "../utils";
import Link from "next/link";
import { UPDATE_URL } from "../constant";
import { SearchService, usePromptStore } from "../store/prompt";
Expand Down Expand Up @@ -181,6 +181,7 @@ export function Settings(props: { closeSettings: () => void }) {
<EmojiPicker
lazyLoadEmojis
theme={EmojiTheme.AUTO}
getEmojiUrl={getEmojiUrl}
onEmojiClick={(e) => {
updateConfig((config) => (config.avatar = e.unified));
setShowEmojiPicker(false);
Expand Down
5 changes: 5 additions & 0 deletions app/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EmojiStyle } from "emoji-picker-react";
import { showToast } from "./components/ui-lib";
import Locale from "./locales";

Expand Down Expand Up @@ -81,3 +82,7 @@ export function getCurrentVersion() {

return currentId;
}

export function getEmojiUrl(unified: string, style: EmojiStyle) {
return `https://cdn.staticfile.org/emoji-datasource-apple/14.0.0/img/${style}/64/${unified}.png`;
}

0 comments on commit 2ae62d9

Please sign in to comment.