提交 d5f82065 编写于 作者: D DebugIsFalse

fix: eslint

上级 ddccb0a3
...@@ -23,3 +23,5 @@ logs ...@@ -23,3 +23,5 @@ logs
.env.* .env.*
!.env.example !.env.example
yarn.lock yarn.lock
.eslintcache
.vscode/
\ No newline at end of file
...@@ -34,9 +34,9 @@ ...@@ -34,9 +34,9 @@
<USkeleton class="h-4" /> <USkeleton class="h-4" />
<USkeleton class="h-4 w-2/3" /> <USkeleton class="h-4 w-2/3" />
</template> </template>
<div class="text-xs pl-5" v-else>找到 {{ item.source && item.source.length || 0 }} 条来源</div> <div v-else class="text-xs pl-5">找到 {{ item.source && item.source.length || 0 }} 条来源</div>
</template> </template>
<div class="text-base flex items-center gap-1" v-if="item.ansLoading !== undefined"> <div v-if="item.ansLoading !== undefined" class="text-base flex items-center gap-1">
<UIcon name="i-heroicons-pencil-square" /> <UIcon name="i-heroicons-pencil-square" />
整理答案 整理答案
</div> </div>
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
<UModal v-model="isOpenHistory" :ui="{ width: 'w-full sm:max-w-screen-md' }"> <UModal v-model="isOpenHistory" :ui="{ width: 'w-full sm:max-w-screen-md' }">
<div class="flex items-center p-2"> <div class="flex items-center p-2">
<UInput <UInput
class="w-full"
v-model="query" v-model="query"
class="w-full"
:padded="false" :padded="false"
variant="none" variant="none"
leading-icon="i-heroicons-magnifying-glass-20-solid" leading-icon="i-heroicons-magnifying-glass-20-solid"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
> >
<div class="flex flex-grow justify-between items-center"> <div class="flex flex-grow justify-between items-center">
<span>新主题</span> <span>新主题</span>
<div class="flex items-center gap-0.5" v-if="$device.isDesktop"> <div v-if="$device.isDesktop" class="flex items-center gap-0.5">
<UKbd>{{ metaSymbol }}</UKbd> <UKbd>{{ metaSymbol }}</UKbd>
<UKbd>K</UKbd> <UKbd>K</UKbd>
</div> </div>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</Transition> </Transition>
</template> </template>
<script setup> <script setup>
const props = defineProps({ defineProps({
open: { open: {
type: Boolean, type: Boolean,
default: true default: true
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
:ui="cardUI" :ui="cardUI"
> >
<UTextarea <UTextarea
name="createInput"
v-model="query" v-model="query"
name="createInput"
autoresize autoresize
placeholder="输入搜索内容..." placeholder="输入搜索内容..."
:rows="5" :rows="5"
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<div class="flex justify-between items-center"> <div class="flex justify-between items-center">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<UTooltip class="relative" :text="isPro ? '已开启专家搜索' : '已关闭专家搜索'" :shortcuts="[metaSymbol, 'O']"> <UTooltip class="relative" :text="isPro ? '已开启专家搜索' : '已关闭专家搜索'" :shortcuts="[metaSymbol, 'O']">
<div class="absolute w-7 h-0.5 rotate-45 top-3.5 left-1 bg-gray-700 dark:bg-gray-200 hover:bg-gray-900 dark:hover:bg-white rounded" v-show="!isPro"></div> <div v-show="!isPro" class="absolute w-7 h-0.5 rotate-45 top-3.5 left-1 bg-gray-700 dark:bg-gray-200 hover:bg-gray-900 dark:hover:bg-white rounded"/>
<UButton <UButton
:ui="{ rounded: 'rounded-full' }" :ui="{ rounded: 'rounded-full' }"
:icon="isPro ? 'i-heroicons-sparkles-20-solid' : 'i-heroicons-sparkles-20-solid'" :icon="isPro ? 'i-heroicons-sparkles-20-solid' : 'i-heroicons-sparkles-20-solid'"
...@@ -27,14 +27,14 @@ ...@@ -27,14 +27,14 @@
/> />
</UTooltip> </UTooltip>
<USelectMenu <USelectMenu
:ui-menu="menuUI"
v-model="selectedRepo" v-model="selectedRepo"
:ui-menu="menuUI"
:options="$repos" :options="$repos"
placeholder="选择 GitHub 项目" placeholder="选择 GitHub 项目"
value-attribute="label" value-attribute="label"
option-attribute="label" option-attribute="label"
> >
<UTooltip :text="isPro ? '选择 GitHub 项目' : '选择 GitHub 项目(需开启专家搜索)'" v-if="!selectedRepo"> <UTooltip v-if="!selectedRepo" :text="isPro ? '选择 GitHub 项目' : '选择 GitHub 项目(需开启专家搜索)'">
<UButton <UButton
:ui="{ rounded: 'rounded-full' }" :ui="{ rounded: 'rounded-full' }"
icon="i-simple-icons-github" icon="i-simple-icons-github"
...@@ -51,11 +51,11 @@ ...@@ -51,11 +51,11 @@
<UButton <UButton
v-if="selectedRepo" v-if="selectedRepo"
class="hidden group-hover:flex" class="hidden group-hover:flex"
@click.stop.prevent="handleClearRepo"
icon="i-heroicons-x-mark-20-solid" icon="i-heroicons-x-mark-20-solid"
:padded="false" :padded="false"
color="gray" color="gray"
variant="link" variant="link"
@click.stop.prevent="handleClearRepo"
/> />
</UButton> </UButton>
</USelectMenu> </USelectMenu>
...@@ -64,10 +64,10 @@ ...@@ -64,10 +64,10 @@
<UButton <UButton
:ui="{ rounded: 'rounded-full' }" :ui="{ rounded: 'rounded-full' }"
icon="i-heroicons-chevron-right-20-solid" icon="i-heroicons-chevron-right-20-solid"
@click="handleSearch"
:loading="loading" :loading="loading"
:disabled="query === ''" :disabled="query === ''"
size="md" size="md"
@click="handleSearch"
/> />
</UTooltip> </UTooltip>
</div> </div>
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
@click="handleToggleAside" @click="handleToggleAside"
/> />
<USlideover <USlideover
class="w-64"
v-model="isOpenAside" v-model="isOpenAside"
class="w-64"
side="left" side="left"
:overlay="false" :overlay="false"
> >
......
...@@ -36,11 +36,8 @@ ...@@ -36,11 +36,8 @@
</div> </div>
</template> </template>
<script setup> <script setup>
const emits = defineEmits(['sign', 'clear'])
const modal = useModal()
const { $searchHistory } = storeToRefs(useSearchStore()) const { $searchHistory } = storeToRefs(useSearchStore())
const { $clearSearchHistory } = useSearchStore() const { $clearSearchHistory } = useSearchStore()
const query = ref('')
function handleClear () { function handleClear () {
$clearSearchHistory() $clearSearchHistory()
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
size="md" size="md"
@click="handleGetSignUrl('gitcode')" @click="handleGetSignUrl('gitcode')"
> >
<img src="~/assets/svg/logo-gitcode.svg" /> <img src="~/assets/svg/logo-gitcode.svg" >
使用 GitCode 登录 使用 GitCode 登录
</UButton> </UButton>
<UButton <UButton
...@@ -35,31 +35,31 @@ ...@@ -35,31 +35,31 @@
size="md" size="md"
disabled disabled
/> />
<!-- <UDivider label="或" />--> <!-- <UDivider label="或" />-->
<!-- <UInput--> <!-- <UInput-->
<!-- class="w-full"--> <!-- class="w-full"-->
<!-- v-model="email"--> <!-- v-model="email"-->
<!-- placeholder="输入邮箱地址..."--> <!-- placeholder="输入邮箱地址..."-->
<!-- size="md"--> <!-- size="md"-->
<!-- />--> <!-- />-->
<!-- <UButton--> <!-- <UButton-->
<!-- block--> <!-- block-->
<!-- leading-icon="i-heroicons-envelope-20-solid"--> <!-- leading-icon="i-heroicons-envelope-20-solid"-->
<!-- label="邮箱登录"--> <!-- label="邮箱登录"-->
<!-- size="md"--> <!-- size="md"-->
<!-- @click="handleSign"--> <!-- @click="handleSign"-->
<!-- />--> <!-- />-->
</div> </div>
</template> </template>
<script setup> <script setup>
const emits = defineEmits(['close', 'signIn']) const emits = defineEmits(['close', 'signIn'])
const email = ref('') // const email = ref('')
function handleClose () { function handleClose () {
emits('close') emits('close')
} }
function handleSign () { // function handleSign () {
emits('signIn') // emits('signIn')
} // }
async function handleGetSignUrl (source) { async function handleGetSignUrl (source) {
let url let url
if (source === 'github') { if (source === 'github') {
......
...@@ -16,11 +16,11 @@ const { deleteCollectionRecord, deleteThread } = useCollectionRequest() ...@@ -16,11 +16,11 @@ const { deleteCollectionRecord, deleteThread } = useCollectionRequest()
const Layout = inject('Layout') const Layout = inject('Layout')
const modal = useModal() const modal = useModal()
const props = defineProps({ const props = defineProps({
collection_id: { collectionId: {
type: [String, Number], type: [String, Number],
default: '' default: ''
}, },
c_id: { cId: {
type: [String, Number], type: [String, Number],
default: '' default: ''
}, },
......
<template> <template>
<UModal <UModal
:model-value="!id ? $isLibraryCreateOpen : updateVisible" :model-value="!id ? $isLibraryCreateOpen : updateVisible"
@update:modelValue="handleCloseModal"
:ui="{ width: 'w-96 sm:max-w-screen-md' }" :ui="{ width: 'w-96 sm:max-w-screen-md' }"
@update:model-value="handleCloseModal"
> >
<UCard :ui="{ ring: '', divide: 'divide-y divide-gray-100 dark:divide-gray-800' }"> <UCard :ui="{ ring: '', divide: 'divide-y divide-gray-100 dark:divide-gray-800' }">
<template #header> <template #header>
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div class="text-xl" v-if="!id">创建合集</div> <div v-if="!id" class="text-xl">创建合集</div>
<div class="text-xl" v-else>更新合集</div> <div v-else class="text-xl">更新合集</div>
<UButton <UButton
leading-icon="i-heroicons-x-mark-20-solid" leading-icon="i-heroicons-x-mark-20-solid"
color="gray" color="gray"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="flex justify-between items-center gap-4"> <div class="flex justify-between items-center gap-4">
<div class="flex gap-4"> <div class="flex gap-4">
<IMenuSider /> <IMenuSider />
<div class="flex flex-shrink-0 items-center text-xl gap-2" v-if="!collect"> <div v-if="!collect" class="flex flex-shrink-0 items-center text-xl gap-2">
<UIcon name="i-heroicons-rectangle-stack-20-solid" /> <UIcon name="i-heroicons-rectangle-stack-20-solid" />
<div>主题</div> <div>主题</div>
</div> </div>
...@@ -24,13 +24,13 @@ ...@@ -24,13 +24,13 @@
</div> </div>
<div class="flex flex-grow justify-end items-center gap-4"> <div class="flex flex-grow justify-end items-center gap-4">
<div class="flex"> <div class="flex">
<IActionCollect :id="collectId" v-if="collect" /> <IActionCollect v-if="collect" :id="collectId" />
</div> </div>
<div class="flex" v-if="!collect"> <div v-if="!collect" class="flex">
<UInput <UInput
v-model="searchQuery"
name="queryInput" name="queryInput"
:ui="{ icon: { trailing: { pointer: '' } } }" :ui="{ icon: { trailing: { pointer: '' } } }"
v-model="searchQuery"
:loading="searchLoading" :loading="searchLoading"
icon="i-heroicons-magnifying-glass-20-solid" icon="i-heroicons-magnifying-glass-20-solid"
placeholder="搜索你的主题..." placeholder="搜索你的主题..."
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</div> </div>
<UDivider /> <UDivider />
<div v-if="showTabs" class="w-full p-6 block lg:hidden"> <div v-if="showTabs" class="w-full p-6 block lg:hidden">
<UTabs :model-value="tab" @update:modelValue="handleChangeTab" :items="tabs" /> <UTabs :model-value="tab" :items="tabs" @update:model-value="handleChangeTab" />
</div> </div>
</div> </div>
</template> </template>
......
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<UButton <UButton
v-for="item in $collection" v-for="item in $collection"
:key="item.id"
color="white" color="white"
size="md" size="md"
class="flex" class="flex"
:key="item.id"
@click="handleSelected(item.id)" @click="handleSelected(item.id)"
> >
<div class="flex flex-grow justify-between items-center"> <div class="flex flex-grow justify-between items-center">
......
<template> <template>
<ULink :to="`/search/${thread.c_id}`" class="flex flex-col group"> <ULink :to="`/search/${thread.c_id}`" class="flex flex-col group">
<div class="flex items-center gap-2 transition group-hover:text-primary">{{ thread.title }}</div> <div class="flex items-center gap-2 transition group-hover:text-primary">{{ thread.title }}</div>
<div class="break-word text-balance line-clamp-2 font-sans text-sm" :class="textColor" v-if="false"> <div v-if="false" class="break-word text-balance line-clamp-2 font-sans text-sm" :class="textColor">
{{ thread.description }} {{ thread.description }}
</div> </div>
</ULink> </ULink>
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
<UIcon :name="thread.is_public ? 'i-heroicons-lock-open' : 'i-heroicons-lock-closed'" /> <UIcon :name="thread.is_public ? 'i-heroicons-lock-open' : 'i-heroicons-lock-closed'" />
<span>{{ thread.is_public ? '公开' : '私有' }}</span> <span>{{ thread.is_public ? '公开' : '私有' }}</span>
</UTooltip> </UTooltip>
<!-- <div class="flex items-center text-sm gap-0.5" :class="textColor">--> <!-- <div class="flex items-center text-sm gap-0.5" :class="textColor">-->
<!-- <UIcon name="i-heroicons-eye" />--> <!-- <UIcon name="i-heroicons-eye" />-->
<!-- <span>1</span>--> <!-- <span>1</span>-->
<!-- </div>--> <!-- </div>-->
<div class="flex" :class="textColor"> <div class="flex" :class="textColor">
<UTooltip class="flex items-center text-sm gap-0.5"> <UTooltip class="flex items-center text-sm gap-0.5">
<UIcon name="i-heroicons-clock" /> <UIcon name="i-heroicons-clock" />
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
:label="collect.collection_name" :label="collect.collection_name"
/> />
</template> </template>
<UTooltip text="添加到收藏" v-if="!thread.collections.length"> <UTooltip v-if="!thread.collections.length" text="添加到收藏">
<UButton <UButton
color="gray" color="gray"
variant="ghost" variant="ghost"
......
<template> <template>
<div class="grid grid-cols-1"> <div class="grid grid-cols-1">
<MDC class="prose dark:prose-invert max-w-none" :class="'prose-' + size" v-if="content" :value="content" tag="article" /> <MDC v-if="content" class="prose dark:prose-invert max-w-none" :class="'prose-' + size" :value="content" tag="article" />
</div> </div>
</template> </template>
<script setup> <script setup>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</div> </div>
<slot /> <slot />
</div> </div>
<div class="flex flex-col w-full lg:w-64 flex-shrink-0 gap-6" v-if="$slots.extra"> <div v-if="$slots.extra" class="flex flex-col w-full lg:w-64 flex-shrink-0 gap-6">
<slot name="extra" /> <slot name="extra" />
</div> </div>
</div> </div>
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
> >
<UTextarea <UTextarea
ref="queryInput" ref="queryInput"
v-model="continueQuestion"
class="flex-grow" class="flex-grow"
name="queryInput" name="queryInput"
:rows="1" :rows="1"
:maxrows="10" :maxrows="10"
autoresize autoresize
v-model="continueQuestion"
:placeholder="placeholder" :placeholder="placeholder"
size="xl" size="xl"
:padded="false" :padded="false"
......
...@@ -9,15 +9,15 @@ ...@@ -9,15 +9,15 @@
<ISearchSource :source="item.source" /> <ISearchSource :source="item.source" />
</div> </div>
</template> </template>
<div class="text-xl flex items-center space-x-1" v-if="processStatus ==='finish'"> <div v-if="processStatus ==='finish'" class="text-xl flex items-center space-x-1">
<UIcon name="i-heroicons-chat-bubble-left-right-20-solid" /> <UIcon name="i-heroicons-chat-bubble-left-right-20-solid" />
<span>{{ item.ansLoading ? '回答中' : '回答' }}</span> <span>{{ item.ansLoading ? '回答中' : '回答' }}</span>
</div> </div>
<IMdMdc :content="item.article" /> <IMdMdc :content="item.article" />
<div class="space-x-2" v-if="item.showActions"> <div v-if="item.showActions" class="space-x-2">
<UButton size="xs" color="gray" @click="handleCopyMD" leading-icon="i-heroicons-document-duplicate-20-solid" label="复制" /> <UButton size="xs" color="gray" leading-icon="i-heroicons-document-duplicate-20-solid" label="复制" @click="handleCopyMD" />
<UButton size="xs" color="gray" @click="handleShare" leading-icon="i-heroicons-share-20-solid" label="分享" /> <UButton size="xs" color="gray" leading-icon="i-heroicons-share-20-solid" label="分享" @click="handleShare" />
<UButton v-if="isLastIndex" size="xs" color="gray" @click="handleReGenerate" leading-icon="i-heroicons-arrow-path-rounded-square-20-solid" label="重写" /> <UButton v-if="isLastIndex" size="xs" color="gray" leading-icon="i-heroicons-arrow-path-rounded-square-20-solid" label="重写" @click="handleReGenerate" />
</div> </div>
</template> </template>
<script setup> <script setup>
...@@ -65,7 +65,7 @@ function handleCopyMD () { ...@@ -65,7 +65,7 @@ function handleCopyMD () {
title: '复制成功' title: '复制成功'
}) })
} }
function handleShare () { function handleShare() {
const hash = props.index + 1; const hash = props.index + 1;
const url = window.location.href + (hash ? '#' + hash : '') const url = window.location.href + (hash ? '#' + hash : '')
Search.handleUpdateOpenState(url) Search.handleUpdateOpenState(url)
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
<div class="w-full p-2 justify-between flex"> <div class="w-full p-2 justify-between flex">
<IMenuSider /> <IMenuSider />
<div class="hidden md:flex"> <div class="hidden md:flex">
<div class="flex items-center gap-2" v-if="repo"> <div v-if="repo" class="flex items-center gap-2">
<UIcon name="i-simple-icons-github" />{{ repo }} <UIcon name="i-simple-icons-github" />{{ repo }}
</div> </div>
</div> </div>
<div class="flex-grow justify-center items-center space-x-2 hidden sm:flex"> <div class="flex-grow justify-center items-center space-x-2 hidden sm:flex">
<UTooltip text="点击修改标题" v-if="!isEditTitle"> <UTooltip v-if="!isEditTitle" text="点击修改标题">
<div @click="handleFocusTitle">{{ editTitle }}</div> <div @click="handleFocusTitle">{{ editTitle }}</div>
</UTooltip> </UTooltip>
<UInput <UInput
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="flex gap-1 items-center text-xs text-primary-500" v-if="isOpen"> <div v-if="isOpen" class="flex gap-1 items-center text-xs text-primary-500">
<UIcon name="i-heroicons-clipboard-document-check" /> <UIcon name="i-heroicons-clipboard-document-check" />
<span>链接已复制</span> <span>链接已复制</span>
</div> </div>
...@@ -94,7 +94,10 @@ const { $selectCollectionId } = storeToRefs(useLibraryStore()) ...@@ -94,7 +94,10 @@ const { $selectCollectionId } = storeToRefs(useLibraryStore())
const { $openLibrarySelect, $setSelectCollectionId } = useLibraryStore() const { $openLibrarySelect, $setSelectCollectionId } = useLibraryStore()
const { findRecordCollection } = useCollectionRequest() const { findRecordCollection } = useCollectionRequest()
const props = defineProps({ const props = defineProps({
query: String, query: {
type: String,
default: ''
},
isPublic: { isPublic: {
type: Boolean, type: Boolean,
default: false default: false
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
</div> </div>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<UButton <UButton
v-for="item in recommendQuestions" v-for="(item, index) in recommendQuestions"
:key="index"
color="gray" color="gray"
size="md" size="md"
variant="soft" variant="soft"
......
<template> <template>
<ULink v-for="(item, index) in limitSource" :to="item.url" :title="item.url" target="_blank"> <ULink v-for="(item, index) in limitSource" :key="index" :to="item.url" :title="item.url" target="_blank">
<UCard :ui="cardUI"> <UCard :ui="cardUI">
<div class="flex flex-col h-full gap-1"> <div class="flex flex-col h-full gap-1">
<template v-if="getIconPath(item.url) === 'github'"> <template v-if="getIconPath(item.url) === 'github'">
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</div> </div>
</UCard> </UCard>
</ULink> </ULink>
<UCard class="cursor-pointer" :ui="cardUI" v-if="source.length > 6" @click="handleToggleShowAll"> <UCard v-if="source.length > 6" class="cursor-pointer" :ui="cardUI" @click="handleToggleShowAll">
<div class="flex items-center justify-center h-full gap-1"> <div class="flex items-center justify-center h-full gap-1">
<UIcon v-if="!showAllSource" name="i-heroicons-chevron-down-20-solid" /> <UIcon v-if="!showAllSource" name="i-heroicons-chevron-down-20-solid" />
<UIcon v-else name="i-heroicons-chevron-up-20-solid" /> <UIcon v-else name="i-heroicons-chevron-up-20-solid" />
...@@ -65,7 +65,7 @@ function getIconPath (url) { ...@@ -65,7 +65,7 @@ function getIconPath (url) {
} }
function getDomain(url) { function getDomain(url) {
// 使用正则表达式匹配协议和域名部分 // 使用正则表达式匹配协议和域名部分
const regex = /^(https?:\/\/)?([^\/]+)/ const regex = /^(https?:\/\/)?([^/]+)/
const match = url.match(regex) const match = url.match(regex)
// 如果匹配不到,返回空字符串 // 如果匹配不到,返回空字符串
......
<template> <template>
<component :is="titleTag" :class="{ 'text-3xl': titleTag !== 'div' }" :id="id">{{ title }}</component> <component :is="titleTag" :id="id" :class="{ 'text-3xl': titleTag !== 'div' }">{{ title }}</component>
</template> </template>
<script setup> <script setup>
const props = defineProps({ const props = defineProps({
......
<template> <template>
<div class="grid grid-cols-1"> <div class="grid grid-cols-1">
<article class="prose dark:prose-invert max-w-none" v-html="mdHtml"></article> <article class="prose dark:prose-invert max-w-none" v-html="mdHtml"/>
</div> </div>
</template> </template>
<script setup> <script setup>
...@@ -8,7 +8,10 @@ import MarkdownIt from 'markdown-it' ...@@ -8,7 +8,10 @@ import MarkdownIt from 'markdown-it'
import hljs from 'highlight.js' import hljs from 'highlight.js'
import 'highlight.js/styles/atom-one-dark.css' import 'highlight.js/styles/atom-one-dark.css'
const props = defineProps({ const props = defineProps({
content: String content: {
type: String,
default: ''
}
}) })
const mdHtml = ref('') const mdHtml = ref('')
const initMarkdownIt = new MarkdownIt({ const initMarkdownIt = new MarkdownIt({
......
<template> <template>
<div class="w-full relative" style="aspect-ratio: 2/1"> <div class="w-full relative" style="aspect-ratio: 2/1">
<canvas ref="refChart" :aria-label="title"></canvas> <canvas ref="refChart" :aria-label="title"/>
</div> </div>
</template> </template>
<script setup> <script setup>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
/> />
</pre> </pre>
<UDivider :ui="{ border: { base: 'border-gray-700' } }" /> <UDivider :ui="{ border: { base: 'border-gray-700' } }" />
<pre :class="$props.class" class="m-0 rounded-none"><code v-html="codeBlock"></code></pre> <pre :class="$props.class" class="m-0 rounded-none"><code v-html="codeBlock"/></pre>
</UCard> </UCard>
</template> </template>
......
...@@ -8,16 +8,16 @@ const request = async (url, options = {}) => { ...@@ -8,16 +8,16 @@ const request = async (url, options = {}) => {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': token 'Authorization': token
}, },
onRequest({ request, options }) { onRequest() {
// 设置请求头 // 设置请求头
}, },
onRequestError({ request, options, error }) { onRequestError({ error }) {
// 处理请求错误 // 处理请求错误
error && console.error(error) error && console.error(error)
}, },
onResponse({ request, response, options }) { onResponse() {
}, },
onResponseError({ request, response, options }) { onResponseError({ request, response }) {
const status = response.status const status = response.status
useRequestError(status, response._data.message) useRequestError(status, response._data.message)
// 处理响应错误 // 处理响应错误
......
export default function (status, message) { export default function (status, message) {
if (process.client && [400, 401, 403].includes(status)) { if (import.meta.client && [400, 401, 403].includes(status)) {
// 全局弹提示 // 全局弹提示
let title let title
if (status === 400) title = message if (status === 400) title = message
......
// @ts-check
import withNuxt from './.nuxt/eslint.config.mjs'
export default withNuxt({
files: ['**/*.vue', '**/*.js'],
rules: {
'indent': [2, 2],
'vue/html-indent': ['off', 'tab', { }],
'no-empty': ['error', { 'allowEmptyCatch': true }],
'vue/no-v-html': 'off',
'no-useless-escape': 'error',
'vue/no-multiple-template-root': 'off',
'vue/multi-word-component-names': 0
}
})
...@@ -12,8 +12,14 @@ export default defineNuxtConfig({ ...@@ -12,8 +12,14 @@ export default defineNuxtConfig({
'@nuxtjs/device', '@nuxtjs/device',
'@vueuse/nuxt', '@vueuse/nuxt',
'@pinia/nuxt', '@pinia/nuxt',
'@formkit/auto-animate/nuxt' '@formkit/auto-animate/nuxt',
"@nuxt/eslint"
], ],
eslint: {
checker: {
configType: 'eslintrc'
}
},
ui: { ui: {
icons: ['simple-icons'] icons: ['simple-icons']
}, },
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
"dev-sw": "SW=true nuxi dev --host", "dev-sw": "SW=true nuxi dev --host",
"generate": "nuxt generate", "generate": "nuxt generate",
"preview": "nuxt preview", "preview": "nuxt preview",
"postinstall": "nuxt prepare" "postinstall": "nuxt prepare",
"lint": "eslint . --fix"
}, },
"dependencies": { "dependencies": {
"@formkit/auto-animate": "^0.8.2", "@formkit/auto-animate": "^0.8.2",
...@@ -31,6 +32,8 @@ ...@@ -31,6 +32,8 @@
"vue-router": "^4.3.2" "vue-router": "^4.3.2"
}, },
"devDependencies": { "devDependencies": {
"@nuxtjs/device": "^3.1.1" "@nuxtjs/device": "^3.1.1",
"vite-plugin-eslint2": "^4.4.0",
"@nuxt/eslint": "^0.3.13"
} }
} }
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
<div v-auto-animate class="flex flex-col gap-4"> <div v-auto-animate class="flex flex-col gap-4">
<ILibraryThread <ILibraryThread
v-for="item in themesTagList" v-for="item in themesTagList"
:item="item"
:key="item.id" :key="item.id"
:item="item"
is-item is-item
@delete="handleDeletedThread" @delete="handleDeletedThread"
/> />
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
<div class="w-full items-center flex flex-col"> <div class="w-full items-center flex flex-col">
<ILibraryHeader show-tabs :tab="tab" @change-tab="handleChangeTab" @search="handleSearch" @clear="getThreadData" /> <ILibraryHeader show-tabs :tab="tab" @change-tab="handleChangeTab" @search="handleSearch" @clear="getThreadData" />
<div class="container max-w-screen-lg 2xl:max-w-screen-xl flex flex-col p-6 pt-0 lg:pt-6"> <div class="container max-w-screen-lg 2xl:max-w-screen-xl flex flex-col p-6 pt-0 lg:pt-6">
<div class="flex gap-10" v-show="ready"> <div v-show="ready" class="flex gap-10">
<div class="flex flex-col flex-grow" v-show="tab === 0 || tab === -1"> <div v-show="tab === 0 || tab === -1" class="flex flex-col flex-grow">
<div v-auto-animate class="flex flex-col gap-4"> <div v-auto-animate class="flex flex-col gap-4">
<ILibraryThread <ILibraryThread
v-for="item in threads" v-for="item in threads"
:item="item"
:key="item.c_id" :key="item.c_id"
:item="item"
@delete="handleDeletedThread" @delete="handleDeletedThread"
/> />
<IEmpty v-if="!threads.length" /> <IEmpty v-if="!threads.length" />
</div> </div>
</div> </div>
<div class="flex flex-col flex-shrink-0 w-full lg:w-56" v-show="tab === 1 || tab === -1"> <div v-show="tab === 1 || tab === -1" class="flex flex-col flex-shrink-0 w-full lg:w-56">
<div class="flex justify-between items-center"> <div class="flex justify-between items-center">
<div class="flex items-center text-lg gap-2"> <div class="flex items-center text-lg gap-2">
<UIcon name="i-heroicons-squares-2x2" /> <UIcon name="i-heroicons-squares-2x2" />
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
<div v-auto-animate class="flex flex-col gap-4 mt-4"> <div v-auto-animate class="flex flex-col gap-4 mt-4">
<ILibraryCollect <ILibraryCollect
v-for="item in $collection" v-for="item in $collection"
:item="item"
:key="item.id" :key="item.id"
:item="item"
/> />
</div> </div>
</div> </div>
......
...@@ -12,23 +12,23 @@ const lineChart = ` ...@@ -12,23 +12,23 @@ const lineChart = `
const tableChart = ` const tableChart = `
::ProseGridTable{:data='[{"repo_id":"806709826","repo_name":"2noise/ChatTTS","primary_language":"Jupyter Notebook","description":"ChatTTS is a generative speech model for daily dialogue.","stars":"1451","forks":"167","pull_requests":"3","pushes":"","total_score":"6000.5405","contributor_logins":"zhouhao27,Huixxi,Thinking80s,bank010,lphkxd","collection_names":""}]'} ::ProseGridTable{:data='[{"repo_id":"806709826","repo_name":"2noise/ChatTTS","primary_language":"Jupyter Notebook","description":"ChatTTS is a generative speech model for daily dialogue.","stars":"1451","forks":"167","pull_requests":"3","pushes":"","total_score":"6000.5405","contributor_logins":"zhouhao27,Huixxi,Thinking80s,bank010,lphkxd","collection_names":""}]'}
` `
const table = ` // const table = `
| repo_id | repo_name | primary_language | description | stars | forks | pull_requests | pushes | total_score | contributor_logins | collection_names | // | repo_id | repo_name | primary_language | description | stars | forks | pull_requests | pushes | total_score | contributor_logins | collection_names |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | // | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 806709826 | 2noise/ChatTTS | Jupyter Notebook | ChatTTS is a generative speech model for daily dialogue | 1451 | 167 | 3 | | 6000.5405 | zhouhao27,Huixxi,Thinking80s,bank010,lphkxd | | // | 806709826 | 2noise/ChatTTS | Jupyter Notebook | ChatTTS is a generative speech model for daily dialogue | 1451 | 167 | 3 | | 6000.5405 | zhouhao27,Huixxi,Thinking80s,bank010,lphkxd | |
` // `
const table2 = ` // const table2 = `
| 列1 | 列2 | 列3 | 列4 | 列5 | 列6 | 列7 | 列8 | 列9 | 列10 | // | 列1 | 列2 | 列3 | 列4 | 列5 | 列6 | 列7 | 列8 | 列9 | 列10 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | // | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 行1数据A | 数据B | 数据C | 数据D | 数据E | 数据F | 数据G | 数据H | 数据I | 数据J | // | 行1数据A | 数据B | 数据C | 数据D | 数据E | 数据F | 数据G | 数据H | 数据I | 数据J |
| 行2数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... | // | 行2数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行3数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... | // | 行3数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行4数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... | // | 行4数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行5数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... | // | 行5数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行6数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... | // | 行6数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行7数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... | // | 行7数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行8数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... | // | 行8数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行9数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... | // | 行9数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行10数据A | 数据B | 数据C | 数据D | 数据E | 数据F | 数据G | 数据H | 数据I | 数据J | // | 行10数据A | 数据B | 数据C | 数据D | 数据E | 数据F | 数据G | 数据H | 数据I | 数据J |
` // `
</script> </script>
\ No newline at end of file
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
:repo="state.repo" :repo="state.repo"
@update-query="handleUpdateQuery" @update-query="handleUpdateQuery"
/> />
<div class="container min-h-svh max-w-screen-lg 2xl:max-w-screen-xl flex flex-col space-y-6 p-6 mb-6 pb-0" ref="scrollElement"> <div ref="scrollElement" class="container min-h-svh max-w-screen-lg 2xl:max-w-screen-xl flex flex-col space-y-6 p-6 mb-6 pb-0">
<template v-for="(item, index) in data" :key="index"> <template v-for="(item, index) in data" :key="index">
<ISearchArticle> <ISearchArticle>
<template #title> <template #title>
<ISearchTitle as="h2" :title="item.question" :id="index + 1" /> <ISearchTitle :id="index + 1" as="h2" :title="item.question" />
</template> </template>
<ISearchContent <ISearchContent
:item="item" :item="item"
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
:index="index" :index="index"
:actions="item.actions" :actions="item.actions"
:collapse="false" :collapse="false"
processStatus="finish" process-status="finish"
/> />
<template v-if="item.extra && item.extra.length > 0" #extra> <template v-if="item.extra && item.extra.length > 0" #extra>
<ISearchExtraInfo :data="item.extra" /> <ISearchExtraInfo :data="item.extra" />
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<template v-if="askingData.question"> <template v-if="askingData.question">
<ISearchArticle> <ISearchArticle>
<template #title> <template #title>
<ISearchTitle #title as="h2" :title="askingData.question" :id="data.length + 1" /> <ISearchTitle :id="data.length + 1" as="h2" :title="askingData.question" />
</template> </template>
<ISearchContent <ISearchContent
:item="askingData" :item="askingData"
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
:collapse="askingData.collapse" :collapse="askingData.collapse"
:is-last-index="true" :is-last-index="true"
:actions="askingData.actions" :actions="askingData.actions"
:process-status="askingData.processStatus"
@regenerate="handleReGenerate" @regenerate="handleReGenerate"
:processStatus="askingData.processStatus"
/> />
<template v-if="askingSidebarCards.length > 0" #extra> <template v-if="askingSidebarCards.length > 0" #extra>
<ISearchExtraInfo :data="askingSidebarCards" /> <ISearchExtraInfo :data="askingSidebarCards" />
...@@ -98,9 +98,9 @@ function initSearchItemInfo (info, records) { ...@@ -98,9 +98,9 @@ function initSearchItemInfo (info, records) {
} }
} }
async function initSearchRecordsChart (repos) { async function initSearchRecordsChart (repos) {
if (!process.client) return if (!import.meta.client) return
repos.forEach((repo) => { repos.forEach((repo) => {
let {output, index} = repo const {output, index} = repo
const {gits, urls} = handleFormatInfoData(output) const {gits, urls} = handleFormatInfoData(output)
fetchRepoStarsData(urls).then((result) => { fetchRepoStarsData(urls).then((result) => {
const card = handleFormatRepoStars(result, gits) const card = handleFormatRepoStars(result, gits)
...@@ -113,7 +113,8 @@ async function initSearchRecordsChart (repos) { ...@@ -113,7 +113,8 @@ async function initSearchRecordsChart (repos) {
function initSearchRecords (records) { function initSearchRecords (records) {
const repos = [] const repos = []
records = records.map((item, index) => { records = records.map((item, index) => {
let { answer, actions, question, answer_type } = item let { answer, actions } = item
const { question, answer_type } = item
answer = answer_type === 'json' ? handleFormatReports(answer) : answer answer = answer_type === 'json' ? handleFormatReports(answer) : answer
const historyItem = { article: answer, question, showActions: true} const historyItem = { article: answer, question, showActions: true}
actions = typeof actions === 'string' ? JSON.parse(actions) : actions actions = typeof actions === 'string' ? JSON.parse(actions) : actions
...@@ -165,7 +166,7 @@ const isAutoToBottom = ref(true) ...@@ -165,7 +166,7 @@ const isAutoToBottom = ref(true)
watch(() => directions.top, () => { watch(() => directions.top, () => {
if (directions.top) isAutoToBottom.value = false if (directions.top) isAutoToBottom.value = false
}) })
watch(() => askingData.value.collapse, (newVal, oldVal) => { watch(() => askingData.value.collapse, (newVal) => {
if (!newVal && asking.value) resetAutoBottom() if (!newVal && asking.value) resetAutoBottom()
}) })
watch(() => directions.bottom, () => { watch(() => directions.bottom, () => {
......
<template>
</template>
<script setup> <script setup>
definePageMeta({ definePageMeta({
layout: 'empty' layout: 'empty'
...@@ -14,7 +11,7 @@ const state = reactive({ ...@@ -14,7 +11,7 @@ const state = reactive({
let url let url
if (state.source === 'github') url = '/v1/user/github/login' if (state.source === 'github') url = '/v1/user/github/login'
else if (state.source === 'gitcode') url = '/v1/user/gitcode/login' else if (state.source === 'gitcode') url = '/v1/user/gitcode/login'
const { data } = await useRequest(url, { await useRequest(url, {
query: { code: state.code }, query: { code: state.code },
server: false, server: false,
onResponse({ response }) { onResponse({ response }) {
......
export default defineEventHandler(async (event) => {
// const config = useRuntimeConfig(event)
const cookie = event.headers.get('cookie')
// console.log(`config:`, event.headers.get('cookie'))
const repo = await $fetch('https://ieditor-ai.inscode.cc/ai/md', {
method: 'POST',
headers: {
cookie
}
})
return repo
})
\ No newline at end of file
...@@ -3,8 +3,8 @@ import { createRouter, defineEventHandler, useBase } from 'h3' ...@@ -3,8 +3,8 @@ import { createRouter, defineEventHandler, useBase } from 'h3'
const router = createRouter() const router = createRouter()
router.get('/test', defineEventHandler(() => { router.get('/test', defineEventHandler(() => {
const code1 = `在Vue 3中,通过\`setup()\`函数与Composition API的结合,你可以实现更加高效和模块化的组件开发。下面提供一个综合示例,该示例展示了如何使用\`ref\`创建响应式数据、定义方法以及如何在模板中使用这些功能,同时还包括条件渲染和事件处理。\n\n**组件代码示例:**\n\n\`\`\`vue\n<template>\n <div>\n <!-- 显示响应式消息 -->\n <p v-if=\"showMessage\">{{ displayedMessage }}</p>\n \n <!-- 按钮控制消息的显示与切换 -->\n <button @click=\"toggleMessage\">切换消息</button>\n <button @click=\"hideShowMessage\">隐藏/显示消息</button>\n </div>\n</template>\n\n<script>\nimport { ref, computed } from 'vue';\n\nexport default {\n setup() {\n // 使用ref创建响应式数据\n const originalMessage = ref('这是原始消息');\n \n // 计算属性用于展示的消息,基于原始消息动态变化\n const displayedMessage = computed(() => {\n if (showMessage.value) {\n return originalMessage.value;\n }\n return '';\n });\n \n // 控制消息显示与否的响应式数据\n const showMessage = ref(true);\n \n // 切换消息的内容(假设为一种简单切换)\n function toggleMessage() {\n originalMessage.value = originalMessage.value === '这是原始消息' ?\n '现在消息已改变!' :\n '这是原始消息';\n }\n\n // 控制消息的显示与隐藏\n function hideShowMessage() {\n showMessage.value = !showMessage.value;\n }\n\n // 返回给模板的数据和方法\n return {\n displayedMessage,\n toggleMessage,\n hideShowMessage,\n showMessage, // 如果需要在模板中直接控制显隐,可以返回\n };\n },\n};\n</script>\n\`\`\`\n\n在这个示例中:\n- 使用\`ref\`创建了两个响应式变量\`originalMessage\`\`showMessage\`,分别用于存储消息内容和控制是否显示消息。\n- 利用\`computed\`创建\`displayedMessage\`来根据\`originalMessage\`和显示标志动态展现消息。\n- 定义了两个方法\`toggleMessage\`\`hideShowMessage\`,分别用来切换消息内容和控制消息的显示与隐藏。\n- 模板中通过\`v-if\`指令和事件监听来呈现动态效果,实现了用户交互和数据反应性的完美融合,体现了Composition API的优势。` const code1 = ''// `在Vue 3中,通过\`setup()\`函数与Composition API的结合,你可以实现更加高效和模块化的组件开发。下面提供一个综合示例,该示例展示了如何使用\`ref\`创建响应式数据、定义方法以及如何在模板中使用这些功能,同时还包括条件渲染和事件处理。\n\n**组件代码示例:**\n\n\`\`\`vue\n<template>\n <div>\n <!-- 显示响应式消息 -->\n <p v-if=\"showMessage\">{{ displayedMessage }}</p>\n \n <!-- 按钮控制消息的显示与切换 -->\n <button @click=\"toggleMessage\">切换消息</button>\n <button @click=\"hideShowMessage\">隐藏/显示消息</button>\n </div>\n</template>\n\n<script>\nimport { ref, computed } from 'vue';\n\nexport default {\n setup() {\n // 使用ref创建响应式数据\n const originalMessage = ref('这是原始消息');\n \n // 计算属性用于展示的消息,基于原始消息动态变化\n const displayedMessage = computed(() => {\n if (showMessage.value) {\n return originalMessage.value;\n }\n return '';\n });\n \n // 控制消息显示与否的响应式数据\n const showMessage = ref(true);\n \n // 切换消息的内容(假设为一种简单切换)\n function toggleMessage() {\n originalMessage.value = originalMessage.value === '这是原始消息' ?\n '现在消息已改变!' :\n '这是原始消息';\n }\n\n // 控制消息的显示与隐藏\n function hideShowMessage() {\n showMessage.value = !showMessage.value;\n }\n\n // 返回给模板的数据和方法\n return {\n displayedMessage,\n toggleMessage,\n hideShowMessage,\n showMessage, // 如果需要在模板中直接控制显隐,可以返回\n };\n },\n};\n</script>\n\`\`\`\n\n在这个示例中:\n- 使用\`ref\`创建了两个响应式变量\`originalMessage\`和\`showMessage\`,分别用于存储消息内容和控制是否显示消息。\n- 利用\`computed\`创建\`displayedMessage\`来根据\`originalMessage\`和显示标志动态展现消息。\n- 定义了两个方法\`toggleMessage\`和\`hideShowMessage\`,分别用来切换消息内容和控制消息的显示与隐藏。\n- 模板中通过\`v-if\`指令和事件监听来呈现动态效果,实现了用户交互和数据反应性的完美融合,体现了Composition API的优势。`
const code2 = `在Vue 3中,两种编写组件的方式是通过\`setup()\`函数和使用\`defineComponent\`。下面分别展示这两种方法的基本用法。\n\n### 使用 \`setup()\` 函数\n\n\`setup()\` 是Vue 3 Composition API的一部分,它提供了一个独立的作用域来设置组件的逻辑,不直接混入到模板或数据属性中。此函数不接受任何选项对象,而是直接访问setupContext的属性(如props和attrs)。\n\n\`\`\`vue\n<script>\nimport { defineComponent, ref } from 'vue';\n\nexport default defineComponent({\n setup(props) {\n // 定义响应式数据\n const count = ref(0);\n\n // 方法\n const increment = () => {\n count.value++;\n };\n\n return { count, increment };\n },\n template: \`\n <button @click=\"increment\">{{ count }}</button>\n \`,\n});\n</script>\n\`\`\`\n\n### 使用 \`defineComponent\` 结合选项API\n\n虽然\`setup()\`更偏向于Composition API,但如果你想混合使用Options API与一些Composition API特性,可以直接在其选项结构中使用\`setup()\`,或者完全使用\`defineComponent\`包裹传统的Options风格代码。\n\n\`\`\`vue\n<script>\nimport { defineComponent } from 'vue';\n\nexport default defineComponent({\n data() {\n return {\n count: 0,\n };\n },\n methods: {\n increment() {\n this.count++;\n },\n },\n template: \`\n <button @click=\"increment\">{{ count }}</button>\n \`,\n});\n</script>\n\`\`\`\n\n在这个例子中,我们展示了如何在Vue 3中定义一个简单的组件,其中一个是使用了Composition API的\`setup()\`函数,另一个则是传统风格,通过\`data\`, \`methods\`, 和 \`template\` 属性来定义。` const code2 = ''// `在Vue 3中,两种编写组件的方式是通过\`setup()\`函数和使用\`defineComponent\`。下面分别展示这两种方法的基本用法。\n\n### 使用 \`setup()\` 函数\n\n\`setup()\` 是Vue 3 Composition API的一部分,它提供了一个独立的作用域来设置组件的逻辑,不直接混入到模板或数据属性中。此函数不接受任何选项对象,而是直接访问setupContext的属性(如props和attrs)。\n\n\`\`\`vue\n<script>\nimport { defineComponent, ref } from 'vue';\n\nexport default defineComponent({\n setup(props) {\n // 定义响应式数据\n const count = ref(0);\n\n // 方法\n const increment = () => {\n count.value++;\n };\n\n return { count, increment };\n },\n template: \`\n <button @click=\"increment\">{{ count }}</button>\n \`,\n});\n</script>\n\`\`\`\n\n### 使用 \`defineComponent\` 结合选项API\n\n虽然\`setup()\`更偏向于Composition API,但如果你想混合使用Options API与一些Composition API特性,可以直接在其选项结构中使用\`setup()\`,或者完全使用\`defineComponent\`包裹传统的Options风格代码。\n\n\`\`\`vue\n<script>\nimport { defineComponent } from 'vue';\n\nexport default defineComponent({\n data() {\n return {\n count: 0,\n };\n },\n methods: {\n increment() {\n this.count++;\n },\n },\n template: \`\n <button @click=\"increment\">{{ count }}</button>\n \`,\n});\n</script>\n\`\`\`\n\n在这个例子中,我们展示了如何在Vue 3中定义一个简单的组件,其中一个是使用了Composition API的\`setup()\`函数,另一个则是传统风格,通过\`data\`, \`methods\`, 和 \`template\` 属性来定义。`
return code1 + code2 return code1 + code2
})) }))
......
import type { Config } from 'tailwindcss' import type { Config } from 'tailwindcss'
import defaultTheme from 'tailwindcss/defaultTheme'
export default <Partial<Config>>{ export default <Partial<Config>>{
theme: { theme: {
......
...@@ -22,7 +22,7 @@ export function handleFormatReports (content) { ...@@ -22,7 +22,7 @@ export function handleFormatReports (content) {
let chartStart = '::ProseChart' let chartStart = '::ProseChart'
let tableStart = '::ProseGridTable' let tableStart = '::ProseGridTable'
let result = '' let result = ''
const reg = /\'/g const reg = /'/g
const replaceStr = '&#39;' const replaceStr = '&#39;'
// ::ProseChart{type='line' title='langchain-ai/langchain [2023-06-05,2024-06-04] Star Data' :labels='["2023-06-05","2023-06-12"]' :data='[{"label": "star数量", "data": [43071,44946]}]' } // ::ProseChart{type='line' title='langchain-ai/langchain [2023-06-05,2024-06-04] Star Data' :labels='["2023-06-05","2023-06-12"]' :data='[{"label": "star数量", "data": [43071,44946]}]' }
content.forEach(item => { content.forEach(item => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册