From 0af55366f1443e66ad1e74852af9ee0ebaf47165 Mon Sep 17 00:00:00 2001 From: yiqiuzheng Date: Wed, 5 Apr 2023 02:49:44 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix(utils):=20=E4=BF=AE=E5=A4=8D=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/utils.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/app/utils.ts b/app/utils.ts index 5fe277c63..81f3d24b3 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -6,17 +6,23 @@ export function trimTopic(topic: string) { } export async function copyToClipboard(text: string) { - try { - await navigator.clipboard.writeText(text); - } catch (error) { - const textarea = document.createElement("textarea"); - textarea.value = text; - document.body.appendChild(textarea); - textarea.select(); - document.execCommand("copy"); - document.body.removeChild(textarea); - } finally { - showToast(Locale.Copy.Success); + if (navigator.clipboard) { + navigator.clipboard.writeText(text).catch(err => { + console.error('Failed to copy: ', err); + }); + } else { + const textArea = document.createElement('textarea'); + textArea.value = text; + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + try { + document.execCommand('copy'); + console.log('Text copied to clipboard'); + } catch (err) { + console.error('Failed to copy: ', err); + } + document.body.removeChild(textArea); } } From 91322f33eb502a46c2d1dc40e5c4e7e1ffae7f54 Mon Sep 17 00:00:00 2001 From: waltcow Date: Wed, 5 Apr 2023 15:29:25 +0800 Subject: [PATCH 2/6] emoji resouce CDN format override --- app/components/settings.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 1b51356eb..ecf0eb82c 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -1,6 +1,6 @@ import { useState, useEffect, useMemo, HTMLProps } from "react"; -import EmojiPicker, { Theme as EmojiTheme } from "emoji-picker-react"; +import EmojiPicker, { Theme as EmojiTheme, EmojiStyle, } from "emoji-picker-react"; import styles from "./settings.module.scss"; @@ -181,6 +181,9 @@ export function Settings(props: { closeSettings: () => void }) { { + return `https://cdn.staticfile.org/emoji-datasource-apple/14.0.0/img/${style}/64/${unified}.png`; + }} onEmojiClick={(e) => { updateConfig((config) => (config.avatar = e.unified)); setShowEmojiPicker(false); From 80904ac2bb9ba873183b436970cabe7c03b6c5ed Mon Sep 17 00:00:00 2001 From: waltcow Date: Wed, 5 Apr 2023 15:31:46 +0800 Subject: [PATCH 3/6] fix import --- app/components/settings.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/settings.tsx b/app/components/settings.tsx index ecf0eb82c..649da1b76 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -1,6 +1,6 @@ import { useState, useEffect, useMemo, HTMLProps } from "react"; -import EmojiPicker, { Theme as EmojiTheme, EmojiStyle, } from "emoji-picker-react"; +import EmojiPicker, { Theme as EmojiTheme, EmojiStyle } from "emoji-picker-react"; import styles from "./settings.module.scss"; From f4fc682fa3e05bbb0dd56c6eca834a09b8b59f19 Mon Sep 17 00:00:00 2001 From: waltcow Date: Wed, 5 Apr 2023 15:48:44 +0800 Subject: [PATCH 4/6] add `getEmojiUrl` as util function --- app/components/chat.tsx | 3 ++- app/components/settings.tsx | 8 +++----- app/utils.ts | 5 +++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 6cd229cc3..7ac9ca085 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -17,6 +17,7 @@ import { Message, SubmitKey, useChatStore, BOT_HELLO, ROLES } from "../store"; import { copyToClipboard, downloadAs, + getEmojiUrl, isMobileScreen, selectOrCopy, } from "../utils"; @@ -50,7 +51,7 @@ export function Avatar(props: { role: Message["role"] }) { return (
- +
); } diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 649da1b76..b563d7bab 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -1,6 +1,6 @@ import { useState, useEffect, useMemo, HTMLProps } from "react"; -import EmojiPicker, { Theme as EmojiTheme, EmojiStyle } from "emoji-picker-react"; +import EmojiPicker, { Theme as EmojiTheme } from "emoji-picker-react"; import styles from "./settings.module.scss"; @@ -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"; @@ -181,9 +181,7 @@ export function Settings(props: { closeSettings: () => void }) { { - return `https://cdn.staticfile.org/emoji-datasource-apple/14.0.0/img/${style}/64/${unified}.png`; - }} + getEmojiUrl={getEmojiUrl} onEmojiClick={(e) => { updateConfig((config) => (config.avatar = e.unified)); setShowEmojiPicker(false); diff --git a/app/utils.ts b/app/utils.ts index 5fe277c63..93f7561af 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -1,3 +1,4 @@ +import { EmojiStyle } from "emoji-picker-react"; import { showToast } from "./components/ui-lib"; import Locale from "./locales"; @@ -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`; +} From dbdb9baf5f139cebda0e921dc23603298b6f3716 Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Thu, 6 Apr 2023 01:35:53 +0800 Subject: [PATCH 5/6] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 43 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 +++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..eb83f7741 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,43 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +** Deployment +- [ ] Docker +- [ ] Vercel +- [ ] Server + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional Logs** +Add any logs about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..bbcbbe7d6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. From eb1573de4f8e11a33daf9cbbc6bc5fef6ee716c7 Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Thu, 6 Apr 2023 01:44:02 +0800 Subject: [PATCH 6/6] Update issue templates --- .github/ISSUE_TEMPLATE/功能建议.md | 20 ++++++++++++++++++++ .github/ISSUE_TEMPLATE/反馈问题.md | 23 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/功能建议.md create mode 100644 .github/ISSUE_TEMPLATE/反馈问题.md diff --git a/.github/ISSUE_TEMPLATE/功能建议.md b/.github/ISSUE_TEMPLATE/功能建议.md new file mode 100644 index 000000000..9ed1c845d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/功能建议.md @@ -0,0 +1,20 @@ +--- +name: 功能建议 +about: 请告诉我们你的灵光一闪 +title: "[Feature] " +labels: '' +assignees: '' + +--- + +**这个功能与现有的问题有关吗?** +如果有关,请在此列出链接或者描述问题。 + +**你想要什么功能或者有什么建议?** +尽管告诉我们。 + +**有没有可以参考的同类竞品?** +可以给出参考产品的链接或者截图。 + +**其他信息** +可以说说你的其他考虑。 diff --git a/.github/ISSUE_TEMPLATE/反馈问题.md b/.github/ISSUE_TEMPLATE/反馈问题.md new file mode 100644 index 000000000..4545721e6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/反馈问题.md @@ -0,0 +1,23 @@ +--- +name: 反馈问题 +about: 请告诉我们你遇到的问题 +title: "[Bug] " +labels: '' +assignees: '' + +--- + +**描述问题** +请在此描述你遇到了什么问题。 + +**如何复现** +请告诉我们你是通过什么操作触发的该问题。 + +**截图** +请在此提供控制台截图、屏幕截图或者服务端的 log 截图。 + +**一些必要的信息** + - 系统:[比如 windows 10/ macos 12/ linux / android 11 / ios 16] + - 浏览器: [比如 chrome, safari] + - 版本: [填写设置页面的版本号] + - 部署方式:[比如 vercel、docker 或者服务器部署]