-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 支持 markdown 格式和图片 * perf: 重载的时候滚动条保持 * chore: version 2.5.2 * feat: 添加文字换行 * chore: 添加新封面 * chore: 更新 cover
- Loading branch information
1 parent
938c91f
commit ac9536a
Showing
11 changed files
with
85 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "chatgpt-web", | ||
"version": "2.5.1", | ||
"version": "2.5.2", | ||
"private": false, | ||
"description": "ChatGPT Web", | ||
"author": "ChenZhaoYu <[email protected]>", | ||
|
@@ -25,6 +25,7 @@ | |
"dependencies": { | ||
"@vueuse/core": "^9.13.0", | ||
"highlight.js": "^11.7.0", | ||
"marked": "^4.2.12", | ||
"naive-ui": "^2.34.3", | ||
"pinia": "^2.0.30", | ||
"vue": "^3.2.47", | ||
|
@@ -36,6 +37,7 @@ | |
"@commitlint/config-conventional": "^17.4.4", | ||
"@iconify/vue": "^4.1.0", | ||
"@types/crypto-js": "^4.1.1", | ||
"@types/marked": "^4.0.8", | ||
"@types/node": "^18.14.0", | ||
"@types/web-bluetooth": "^0.0.16", | ||
"@vitejs/plugin-vue": "^4.0.0", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function includeCode(text: string | null | undefined) { | ||
const regexp = /^(?:\s{4}|\t).+/gm | ||
if (text?.includes(' = ') || text?.match(regexp)) | ||
return true | ||
return false | ||
} | ||
|
||
export default includeCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,60 @@ | ||
<script lang="ts" setup> | ||
import { computed } from 'vue' | ||
import { marked } from 'marked' | ||
import includeCode from '@/utils/functions/includeCode' | ||
interface Props { | ||
inversion?: boolean | ||
error?: boolean | ||
text?: string | ||
loading?: boolean | ||
} | ||
defineProps<Props>() | ||
const props = defineProps<Props>() | ||
const wrapClass = computed(() => { | ||
return [ | ||
'text-wrap', | ||
'p-2', | ||
'min-w-[20px]', | ||
'rounded-md', | ||
props.inversion ? 'bg-[#d2f9d1]' : 'bg-[#f4f6f8]', | ||
{ 'text-red-500': props.error }, | ||
] | ||
}) | ||
const text = computed(() => { | ||
if (props.text) { | ||
if (!includeCode(props.text)) | ||
return marked.parse(props.text) | ||
return props.text | ||
} | ||
return '' | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div | ||
class="min-w-[20px] p-2 rounded-md" | ||
:class="[inversion ? 'bg-[#d2f9d1]' : 'bg-[#f4f6f8]', { 'text-red-500': error }]" | ||
> | ||
<span | ||
v-highlight | ||
class="leading-relaxed whitespace-pre-wrap" | ||
> | ||
<slot /> | ||
</span> | ||
<div :class="wrapClass"> | ||
<template v-if="loading"> | ||
<span class="w-[3px] h-[20px] block animate-blink" /> | ||
</template> | ||
<template v-else> | ||
<code v-if="includeCode(text)" v-highlight class="leading-relaxed" v-text="text" /> | ||
<div v-else class="leading-relaxed break-all" v-html="text" /> | ||
</template> | ||
</div> | ||
</template> | ||
|
||
<style> | ||
<style lang="less"> | ||
.text-wrap{ | ||
img{ | ||
max-width: 100%; | ||
vertical-align: middle; | ||
} | ||
} | ||
.hljs { | ||
background-color: #fff0 !important; | ||
white-space: break-spaces; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters