提交 d5f82065 编写于 作者: D DebugIsFalse

fix: eslint

上级 ddccb0a3
......@@ -23,3 +23,5 @@ logs
.env.*
!.env.example
yarn.lock
.eslintcache
.vscode/
\ No newline at end of file
......@@ -34,9 +34,9 @@
<USkeleton class="h-4" />
<USkeleton class="h-4 w-2/3" />
</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>
<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" />
整理答案
</div>
......
......@@ -45,8 +45,8 @@
<UModal v-model="isOpenHistory" :ui="{ width: 'w-full sm:max-w-screen-md' }">
<div class="flex items-center p-2">
<UInput
class="w-full"
v-model="query"
class="w-full"
:padded="false"
variant="none"
leading-icon="i-heroicons-magnifying-glass-20-solid"
......
......@@ -12,7 +12,7 @@
>
<div class="flex flex-grow justify-between items-center">
<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>K</UKbd>
</div>
......
......@@ -9,7 +9,7 @@
</Transition>
</template>
<script setup>
const props = defineProps({
defineProps({
open: {
type: Boolean,
default: true
......
......@@ -5,8 +5,8 @@
:ui="cardUI"
>
<UTextarea
name="createInput"
v-model="query"
name="createInput"
autoresize
placeholder="输入搜索内容..."
:rows="5"
......@@ -17,7 +17,7 @@
<div class="flex justify-between items-center">
<div class="flex items-center gap-2">
<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
:ui="{ rounded: 'rounded-full' }"
:icon="isPro ? 'i-heroicons-sparkles-20-solid' : 'i-heroicons-sparkles-20-solid'"
......@@ -27,14 +27,14 @@
/>
</UTooltip>
<USelectMenu
:ui-menu="menuUI"
v-model="selectedRepo"
:ui-menu="menuUI"
:options="$repos"
placeholder="选择 GitHub 项目"
value-attribute="label"
option-attribute="label"
>
<UTooltip :text="isPro ? '选择 GitHub 项目' : '选择 GitHub 项目(需开启专家搜索)'" v-if="!selectedRepo">
<UTooltip v-if="!selectedRepo" :text="isPro ? '选择 GitHub 项目' : '选择 GitHub 项目(需开启专家搜索)'">
<UButton
:ui="{ rounded: 'rounded-full' }"
icon="i-simple-icons-github"
......@@ -51,11 +51,11 @@
<UButton
v-if="selectedRepo"
class="hidden group-hover:flex"
@click.stop.prevent="handleClearRepo"
icon="i-heroicons-x-mark-20-solid"
:padded="false"
color="gray"
variant="link"
@click.stop.prevent="handleClearRepo"
/>
</UButton>
</USelectMenu>
......@@ -64,10 +64,10 @@
<UButton
:ui="{ rounded: 'rounded-full' }"
icon="i-heroicons-chevron-right-20-solid"
@click="handleSearch"
:loading="loading"
:disabled="query === ''"
size="md"
@click="handleSearch"
/>
</UTooltip>
</div>
......
......@@ -8,8 +8,8 @@
@click="handleToggleAside"
/>
<USlideover
class="w-64"
v-model="isOpenAside"
class="w-64"
side="left"
:overlay="false"
>
......
......@@ -36,11 +36,8 @@
</div>
</template>
<script setup>
const emits = defineEmits(['sign', 'clear'])
const modal = useModal()
const { $searchHistory } = storeToRefs(useSearchStore())
const { $clearSearchHistory } = useSearchStore()
const query = ref('')
function handleClear () {
$clearSearchHistory()
}
......
......@@ -16,7 +16,7 @@
size="md"
@click="handleGetSignUrl('gitcode')"
>
<img src="~/assets/svg/logo-gitcode.svg" />
<img src="~/assets/svg/logo-gitcode.svg" >
使用 GitCode 登录
</UButton>
<UButton
......@@ -35,31 +35,31 @@
size="md"
disabled
/>
<!-- <UDivider label="或" />-->
<!-- <UInput-->
<!-- class="w-full"-->
<!-- v-model="email"-->
<!-- placeholder="输入邮箱地址..."-->
<!-- size="md"-->
<!-- />-->
<!-- <UButton-->
<!-- block-->
<!-- leading-icon="i-heroicons-envelope-20-solid"-->
<!-- label="邮箱登录"-->
<!-- size="md"-->
<!-- @click="handleSign"-->
<!-- />-->
<!-- <UDivider label="或" />-->
<!-- <UInput-->
<!-- class="w-full"-->
<!-- v-model="email"-->
<!-- placeholder="输入邮箱地址..."-->
<!-- size="md"-->
<!-- />-->
<!-- <UButton-->
<!-- block-->
<!-- leading-icon="i-heroicons-envelope-20-solid"-->
<!-- label="邮箱登录"-->
<!-- size="md"-->
<!-- @click="handleSign"-->
<!-- />-->
</div>
</template>
<script setup>
const emits = defineEmits(['close', 'signIn'])
const email = ref('')
// const email = ref('')
function handleClose () {
emits('close')
}
function handleSign () {
emits('signIn')
}
// function handleSign () {
// emits('signIn')
// }
async function handleGetSignUrl (source) {
let url
if (source === 'github') {
......
......@@ -16,11 +16,11 @@ const { deleteCollectionRecord, deleteThread } = useCollectionRequest()
const Layout = inject('Layout')
const modal = useModal()
const props = defineProps({
collection_id: {
collectionId: {
type: [String, Number],
default: ''
},
c_id: {
cId: {
type: [String, Number],
default: ''
},
......
<template>
<UModal
:model-value="!id ? $isLibraryCreateOpen : updateVisible"
@update:modelValue="handleCloseModal"
: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' }">
<template #header>
<div class="flex items-center justify-between">
<div class="text-xl" v-if="!id">创建合集</div>
<div class="text-xl" v-else>更新合集</div>
<div v-if="!id" class="text-xl">创建合集</div>
<div v-else class="text-xl">更新合集</div>
<UButton
leading-icon="i-heroicons-x-mark-20-solid"
color="gray"
......
......@@ -4,7 +4,7 @@
<div class="flex justify-between items-center gap-4">
<div class="flex gap-4">
<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" />
<div>主题</div>
</div>
......@@ -24,13 +24,13 @@
</div>
<div class="flex flex-grow justify-end items-center gap-4">
<div class="flex">
<IActionCollect :id="collectId" v-if="collect" />
<IActionCollect v-if="collect" :id="collectId" />
</div>
<div class="flex" v-if="!collect">
<div v-if="!collect" class="flex">
<UInput
v-model="searchQuery"
name="queryInput"
:ui="{ icon: { trailing: { pointer: '' } } }"
v-model="searchQuery"
:loading="searchLoading"
icon="i-heroicons-magnifying-glass-20-solid"
placeholder="搜索你的主题..."
......@@ -54,7 +54,7 @@
</div>
<UDivider />
<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>
</template>
......
......@@ -22,10 +22,10 @@
<div class="flex flex-col gap-2">
<UButton
v-for="item in $collection"
:key="item.id"
color="white"
size="md"
class="flex"
:key="item.id"
@click="handleSelected(item.id)"
>
<div class="flex flex-grow justify-between items-center">
......
<template>
<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="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 }}
</div>
</ULink>
......@@ -11,10 +11,10 @@
<UIcon :name="thread.is_public ? 'i-heroicons-lock-open' : 'i-heroicons-lock-closed'" />
<span>{{ thread.is_public ? '公开' : '私有' }}</span>
</UTooltip>
<!-- <div class="flex items-center text-sm gap-0.5" :class="textColor">-->
<!-- <UIcon name="i-heroicons-eye" />-->
<!-- <span>1</span>-->
<!-- </div>-->
<!-- <div class="flex items-center text-sm gap-0.5" :class="textColor">-->
<!-- <UIcon name="i-heroicons-eye" />-->
<!-- <span>1</span>-->
<!-- </div>-->
<div class="flex" :class="textColor">
<UTooltip class="flex items-center text-sm gap-0.5">
<UIcon name="i-heroicons-clock" />
......@@ -35,7 +35,7 @@
:label="collect.collection_name"
/>
</template>
<UTooltip text="添加到收藏" v-if="!thread.collections.length">
<UTooltip v-if="!thread.collections.length" text="添加到收藏">
<UButton
color="gray"
variant="ghost"
......
<template>
<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>
</template>
<script setup>
......
......@@ -6,7 +6,7 @@
</div>
<slot />
</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" />
</div>
</div>
......
......@@ -6,12 +6,12 @@
>
<UTextarea
ref="queryInput"
v-model="continueQuestion"
class="flex-grow"
name="queryInput"
:rows="1"
:maxrows="10"
autoresize
v-model="continueQuestion"
:placeholder="placeholder"
size="xl"
:padded="false"
......
......@@ -9,15 +9,15 @@
<ISearchSource :source="item.source" />
</div>
</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" />
<span>{{ item.ansLoading ? '回答中' : '回答' }}</span>
</div>
<IMdMdc :content="item.article" />
<div class="space-x-2" v-if="item.showActions">
<UButton size="xs" color="gray" @click="handleCopyMD" leading-icon="i-heroicons-document-duplicate-20-solid" label="复制" />
<UButton size="xs" color="gray" @click="handleShare" leading-icon="i-heroicons-share-20-solid" label="分享" />
<UButton v-if="isLastIndex" size="xs" color="gray" @click="handleReGenerate" leading-icon="i-heroicons-arrow-path-rounded-square-20-solid" label="重写" />
<div v-if="item.showActions" class="space-x-2">
<UButton size="xs" color="gray" leading-icon="i-heroicons-document-duplicate-20-solid" label="复制" @click="handleCopyMD" />
<UButton size="xs" color="gray" leading-icon="i-heroicons-share-20-solid" label="分享" @click="handleShare" />
<UButton v-if="isLastIndex" size="xs" color="gray" leading-icon="i-heroicons-arrow-path-rounded-square-20-solid" label="重写" @click="handleReGenerate" />
</div>
</template>
<script setup>
......@@ -65,7 +65,7 @@ function handleCopyMD () {
title: '复制成功'
})
}
function handleShare () {
function handleShare() {
const hash = props.index + 1;
const url = window.location.href + (hash ? '#' + hash : '')
Search.handleUpdateOpenState(url)
......
......@@ -3,12 +3,12 @@
<div class="w-full p-2 justify-between flex">
<IMenuSider />
<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 }}
</div>
</div>
<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>
</UTooltip>
<UInput
......@@ -74,7 +74,7 @@
</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" />
<span>链接已复制</span>
</div>
......@@ -94,7 +94,10 @@ const { $selectCollectionId } = storeToRefs(useLibraryStore())
const { $openLibrarySelect, $setSelectCollectionId } = useLibraryStore()
const { findRecordCollection } = useCollectionRequest()
const props = defineProps({
query: String,
query: {
type: String,
default: ''
},
isPublic: {
type: Boolean,
default: false
......
......@@ -5,7 +5,8 @@
</div>
<div class="flex flex-col gap-2">
<UButton
v-for="item in recommendQuestions"
v-for="(item, index) in recommendQuestions"
:key="index"
color="gray"
size="md"
variant="soft"
......
<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">
<div class="flex flex-col h-full gap-1">
<template v-if="getIconPath(item.url) === 'github'">
......@@ -27,7 +27,7 @@
</div>
</UCard>
</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">
<UIcon v-if="!showAllSource" name="i-heroicons-chevron-down-20-solid" />
<UIcon v-else name="i-heroicons-chevron-up-20-solid" />
......@@ -65,7 +65,7 @@ function getIconPath (url) {
}
function getDomain(url) {
// 使用正则表达式匹配协议和域名部分
const regex = /^(https?:\/\/)?([^\/]+)/
const regex = /^(https?:\/\/)?([^/]+)/
const match = url.match(regex)
// 如果匹配不到,返回空字符串
......
<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>
<script setup>
const props = defineProps({
......
<template>
<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>
</template>
<script setup>
......@@ -8,7 +8,10 @@ import MarkdownIt from 'markdown-it'
import hljs from 'highlight.js'
import 'highlight.js/styles/atom-one-dark.css'
const props = defineProps({
content: String
content: {
type: String,
default: ''
}
})
const mdHtml = ref('')
const initMarkdownIt = new MarkdownIt({
......
<template>
<div class="w-full relative" style="aspect-ratio: 2/1">
<canvas ref="refChart" :aria-label="title"></canvas>
<canvas ref="refChart" :aria-label="title"/>
</div>
</template>
<script setup>
......
......@@ -10,7 +10,7 @@
/>
</pre>
<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>
</template>
......
......@@ -8,16 +8,16 @@ const request = async (url, options = {}) => {
'Content-Type': 'application/json',
'Authorization': token
},
onRequest({ request, options }) {
onRequest() {
// 设置请求头
},
onRequestError({ request, options, error }) {
onRequestError({ error }) {
// 处理请求错误
error && console.error(error)
},
onResponse({ request, response, options }) {
onResponse() {
},
onResponseError({ request, response, options }) {
onResponseError({ request, response }) {
const status = response.status
useRequestError(status, response._data.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
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({
'@nuxtjs/device',
'@vueuse/nuxt',
'@pinia/nuxt',
'@formkit/auto-animate/nuxt'
'@formkit/auto-animate/nuxt',
"@nuxt/eslint"
],
eslint: {
checker: {
configType: 'eslintrc'
}
},
ui: {
icons: ['simple-icons']
},
......
此差异已折叠。
......@@ -9,7 +9,8 @@
"dev-sw": "SW=true nuxi dev --host",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
"postinstall": "nuxt prepare",
"lint": "eslint . --fix"
},
"dependencies": {
"@formkit/auto-animate": "^0.8.2",
......@@ -31,6 +32,8 @@
"vue-router": "^4.3.2"
},
"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 @@
<div v-auto-animate class="flex flex-col gap-4">
<ILibraryThread
v-for="item in themesTagList"
:item="item"
:key="item.id"
:item="item"
is-item
@delete="handleDeletedThread"
/>
......
......@@ -2,19 +2,19 @@
<div class="w-full items-center flex flex-col">
<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="flex gap-10" v-show="ready">
<div class="flex flex-col flex-grow" v-show="tab === 0 || tab === -1">
<div v-show="ready" class="flex gap-10">
<div v-show="tab === 0 || tab === -1" class="flex flex-col flex-grow">
<div v-auto-animate class="flex flex-col gap-4">
<ILibraryThread
v-for="item in threads"
:item="item"
:key="item.c_id"
:item="item"
@delete="handleDeletedThread"
/>
<IEmpty v-if="!threads.length" />
</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 items-center text-lg gap-2">
<UIcon name="i-heroicons-squares-2x2" />
......@@ -29,8 +29,8 @@
<div v-auto-animate class="flex flex-col gap-4 mt-4">
<ILibraryCollect
v-for="item in $collection"
:item="item"
:key="item.id"
:item="item"
/>
</div>
</div>
......
......@@ -12,23 +12,23 @@ const lineChart = `
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":""}]'}
`
const table = `
| 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 | |
`
const table2 = `
| 列1 | 列2 | 列3 | 列4 | 列5 | 列6 | 列7 | 列8 | 列9 | 列10 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 行1数据A | 数据B | 数据C | 数据D | 数据E | 数据F | 数据G | 数据H | 数据I | 数据J |
| 行2数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行3数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行4数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行5数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行6数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行7数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行8数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行9数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行10数据A | 数据B | 数据C | 数据D | 数据E | 数据F | 数据G | 数据H | 数据I | 数据J |
`
// const table = `
// | 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 | |
// `
// const table2 = `
// | 列1 | 列2 | 列3 | 列4 | 列5 | 列6 | 列7 | 列8 | 列9 | 列10 |
// | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
// | 行1数据A | 数据B | 数据C | 数据D | 数据E | 数据F | 数据G | 数据H | 数据I | 数据J |
// | 行2数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
// | 行3数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
// | 行4数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
// | 行5数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
// | 行6数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
// | 行7数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
// | 行8数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
// | 行9数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
// | 行10数据A | 数据B | 数据C | 数据D | 数据E | 数据F | 数据G | 数据H | 数据I | 数据J |
// `
</script>
\ No newline at end of file
......@@ -9,11 +9,11 @@
:repo="state.repo"
@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">
<ISearchArticle>
<template #title>
<ISearchTitle as="h2" :title="item.question" :id="index + 1" />
<ISearchTitle :id="index + 1" as="h2" :title="item.question" />
</template>
<ISearchContent
:item="item"
......@@ -22,7 +22,7 @@
:index="index"
:actions="item.actions"
:collapse="false"
processStatus="finish"
process-status="finish"
/>
<template v-if="item.extra && item.extra.length > 0" #extra>
<ISearchExtraInfo :data="item.extra" />
......@@ -33,7 +33,7 @@
<template v-if="askingData.question">
<ISearchArticle>
<template #title>
<ISearchTitle #title as="h2" :title="askingData.question" :id="data.length + 1" />
<ISearchTitle :id="data.length + 1" as="h2" :title="askingData.question" />
</template>
<ISearchContent
:item="askingData"
......@@ -41,8 +41,8 @@
:collapse="askingData.collapse"
:is-last-index="true"
:actions="askingData.actions"
:process-status="askingData.processStatus"
@regenerate="handleReGenerate"
:processStatus="askingData.processStatus"
/>
<template v-if="askingSidebarCards.length > 0" #extra>
<ISearchExtraInfo :data="askingSidebarCards" />
......@@ -98,9 +98,9 @@ function initSearchItemInfo (info, records) {
}
}
async function initSearchRecordsChart (repos) {
if (!process.client) return
if (!import.meta.client) return
repos.forEach((repo) => {
let {output, index} = repo
const {output, index} = repo
const {gits, urls} = handleFormatInfoData(output)
fetchRepoStarsData(urls).then((result) => {
const card = handleFormatRepoStars(result, gits)
......@@ -113,7 +113,8 @@ async function initSearchRecordsChart (repos) {
function initSearchRecords (records) {
const repos = []
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
const historyItem = { article: answer, question, showActions: true}
actions = typeof actions === 'string' ? JSON.parse(actions) : actions
......@@ -165,7 +166,7 @@ const isAutoToBottom = ref(true)
watch(() => directions.top, () => {
if (directions.top) isAutoToBottom.value = false
})
watch(() => askingData.value.collapse, (newVal, oldVal) => {
watch(() => askingData.value.collapse, (newVal) => {
if (!newVal && asking.value) resetAutoBottom()
})
watch(() => directions.bottom, () => {
......
<template>
</template>
<script setup>
definePageMeta({
layout: 'empty'
......@@ -14,7 +11,7 @@ const state = reactive({
let url
if (state.source === 'github') url = '/v1/user/github/login'
else if (state.source === 'gitcode') url = '/v1/user/gitcode/login'
const { data } = await useRequest(url, {
await useRequest(url, {
query: { code: state.code },
server: false,
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'
const router = createRouter()
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 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 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\` 属性来定义。`
return code1 + code2
}))
......
import type { Config } from 'tailwindcss'
import defaultTheme from 'tailwindcss/defaultTheme'
export default <Partial<Config>>{
theme: {
......
......@@ -22,7 +22,7 @@ export function handleFormatReports (content) {
let chartStart = '::ProseChart'
let tableStart = '::ProseGridTable'
let result = ''
const reg = /\'/g
const reg = /'/g
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]}]' }
content.forEach(item => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册