提交 6b91b215 编写于 作者: D DebugIsFalse

fix: eslint

上级 59b14e7f
...@@ -74,6 +74,6 @@ watch(() => props.collapse, () => { ...@@ -74,6 +74,6 @@ watch(() => props.collapse, () => {
handleCollapse(false) handleCollapse(false)
}, 500) }, 500)
} }
}, { immediate: true}) }, { immediate: true })
defineExpose({ handleCollapse }) defineExpose({ handleCollapse })
</script> </script>
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
</template> </template>
<script setup> <script setup>
import { IConfirm } from '#components' import { IConfirm } from '#components'
const emits = defineEmits(['sign', 'clear']) const emits = defineEmits([ 'sign', 'clear' ])
const modal = useModal() const modal = useModal()
const { $isSignIn } = storeToRefs(useUserStore()) const { $isSignIn } = storeToRefs(useUserStore())
const { $searchHistory } = storeToRefs(useSearchStore()) const { $searchHistory } = storeToRefs(useSearchStore())
...@@ -109,13 +109,13 @@ function handleClear () { ...@@ -109,13 +109,13 @@ function handleClear () {
}) })
} }
function handleRemoveRecordItem (id) { function handleRemoveRecordItem (id) {
handleRemoveRecords([id]) handleRemoveRecords([ id ])
} }
async function handleRemoveRecords (ids) { async function handleRemoveRecords (ids) {
if (!ids) { if (!ids) {
ids = $searchHistory.value.map(item => item.c_id) ids = $searchHistory.value.map(item => item.c_id)
} }
const { data} = await useRequest('/v1/chat/completion/remove', { const { data } = await useRequest('/v1/chat/completion/remove', {
method: 'post', method: 'post',
body: ids body: ids
}) })
......
...@@ -15,14 +15,20 @@ ...@@ -15,14 +15,20 @@
<template #panel> <template #panel>
<div class="flex flex-col p-2 gap-2"> <div class="flex flex-col p-2 gap-2">
<div class="grid grid-cols-5 gap-px"> <div class="grid grid-cols-5 gap-px">
<ColorPickerPill v-for="color in primaryColors" :key="color.value" :color="color" :selected="primary" <ColorPickerPill
@select="primary = color"/> v-for="color in primaryColors"
:key="color.value"
:color="color"
:selected="primary"
@select="primary = color"
/>
</div> </div>
<UDivider/> <UDivider/>
<div class="grid grid-cols-5 gap-px"> <div class="grid grid-cols-5 gap-px">
<ColorPickerPill v-for="color in grayColors" :key="color.value" :color="color" :selected="gray" <ColorPickerPill
v-for="color in grayColors" :key="color.value" :color="color" :selected="gray"
@select="gray = color"/> @select="gray = color"/>
</div> </div>
</div> </div>
...@@ -50,7 +56,7 @@ const primary = computed({ ...@@ -50,7 +56,7 @@ const primary = computed({
} }
}) })
const grayColors = computed(() => ['slate', 'cool', 'zinc', 'neutral', 'stone'].map(color => ({ value: color, text: color, hex: colors[color][colorMode.value === 'dark' ? 400 : 500] }))) const grayColors = computed(() => [ 'slate', 'cool', 'zinc', 'neutral', 'stone' ].map(color => ({ value: color, text: color, hex: colors[color][colorMode.value === 'dark' ? 400 : 500] })))
const gray = computed({ const gray = computed({
get () { get () {
return grayColors.value.find(option => option.value === appConfig.ui.gray) return grayColors.value.find(option => option.value === appConfig.ui.gray)
......
...@@ -20,6 +20,6 @@ ...@@ -20,6 +20,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
defineProps<{ color: { value: string, hex: string }, selected: { value: string} }>() defineProps<{ color: { value: string, hex: string }, selected: { value: string } }>()
defineEmits(['select']) defineEmits([ 'select' ])
</script> </script>
\ No newline at end of file
...@@ -32,7 +32,7 @@ defineProps({ ...@@ -32,7 +32,7 @@ defineProps({
default: false default: false
} }
}) })
const emits = defineEmits(['success', 'cancel']) const emits = defineEmits([ 'success', 'cancel' ])
function handleCancel () { function handleCancel () {
emits('cancel') emits('cancel')
} }
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
<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 v-show="!isPro" <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"/> 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' }"
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
/> />
</div> </div>
<ClientOnly> <ClientOnly>
<div v-auto-animate <div
v-auto-animate
class="flex overflow-y-auto flex-col gap-1 border-l border-gray-200 dark:border-gray-800 pl-2 ml-5"> class="flex overflow-y-auto flex-col gap-1 border-l border-gray-200 dark:border-gray-800 pl-2 ml-5">
<template v-for="item in $searchHistory.reverse()" :key="item.c_id"> <template v-for="item in $searchHistory.reverse()" :key="item.c_id">
<UButton <UButton
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
</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')
......
...@@ -15,7 +15,7 @@ const { deleteCollection } = useCollectionRequest() ...@@ -15,7 +15,7 @@ const { deleteCollection } = useCollectionRequest()
const modal = useModal() const modal = useModal()
const props = defineProps({ const props = defineProps({
id: { id: {
type: [String, Number], type: [ String, Number ],
default: '' default: ''
} }
}) })
......
...@@ -17,11 +17,11 @@ const Layout = inject('Layout') ...@@ -17,11 +17,11 @@ const Layout = inject('Layout')
const modal = useModal() const modal = useModal()
const props = defineProps({ const props = defineProps({
collectionId: { collectionId: {
type: [String, Number], type: [ String, Number ],
default: '' default: ''
}, },
cId: { cId: {
type: [String, Number], type: [ String, Number ],
default: '' default: ''
}, },
size: { size: {
...@@ -29,7 +29,7 @@ const props = defineProps({ ...@@ -29,7 +29,7 @@ const props = defineProps({
default: 'sm' default: 'sm'
} }
}) })
const emit = defineEmits(['delete']) const emit = defineEmits([ 'delete' ])
const actionItems = computed(() => { const actionItems = computed(() => {
let items let items
if (props.collection_id && props.c_id) { if (props.collection_id && props.c_id) {
...@@ -38,7 +38,7 @@ const actionItems = computed(() => { ...@@ -38,7 +38,7 @@ const actionItems = computed(() => {
label: '更改合集', label: '更改合集',
icon: 'i-heroicons-squares-plus', icon: 'i-heroicons-squares-plus',
click: () => { click: () => {
$openLibrarySelect(props.c_id, [props.collection_id]) $openLibrarySelect(props.c_id, [ props.collection_id ])
} }
}, },
{ {
...@@ -73,7 +73,7 @@ const actionItems = computed(() => { ...@@ -73,7 +73,7 @@ const actionItems = computed(() => {
description: '确定要删除该主题吗?', description: '确定要删除该主题吗?',
async onSuccess() { async onSuccess() {
modal.close() modal.close()
await deleteThread([props.c_id]) await deleteThread([ props.c_id ])
$getCollection() $getCollection()
emit('delete') emit('delete')
}, },
...@@ -83,6 +83,6 @@ const actionItems = computed(() => { ...@@ -83,6 +83,6 @@ const actionItems = computed(() => {
}) })
} }
}) })
return [items] return [ items ]
}) })
</script> </script>
...@@ -70,7 +70,7 @@ const { $closeLibraryCreate, $getCollection } = useLibraryStore() ...@@ -70,7 +70,7 @@ const { $closeLibraryCreate, $getCollection } = useLibraryStore()
const { setOrUpdateCollection } = useCollectionRequest() const { setOrUpdateCollection } = useCollectionRequest()
const props = defineProps({ const props = defineProps({
id: { id: {
type: [String, Number], type: [ String, Number ],
default: '' default: ''
} }
}) })
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<script setup> <script setup>
defineProps({ defineProps({
id: { id: {
type: [String, Number], type: [ String, Number ],
default: '' default: ''
} }
}) })
......
...@@ -73,7 +73,7 @@ defineProps({ ...@@ -73,7 +73,7 @@ defineProps({
default: 0 default: 0
}, },
collectId: { collectId: {
type: [String, Number], type: [ String, Number ],
default: '' default: ''
}, },
showTabs: { showTabs: {
...@@ -85,7 +85,7 @@ defineProps({ ...@@ -85,7 +85,7 @@ defineProps({
default: 0 default: 0
} }
}) })
const emit = defineEmits(['search', 'clear', 'change-tab']) const emit = defineEmits([ 'search', 'clear', 'change-tab' ])
const searchQuery = ref('') const searchQuery = ref('')
const searchLoading = ref(false) const searchLoading = ref(false)
defineShortcuts({ defineShortcuts({
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
> >
<div class="flex flex-grow justify-between items-center"> <div class="flex flex-grow justify-between items-center">
<div>{{ item.name }}</div> <div>{{ item.name }}</div>
<UIcon v-if="selected.includes(item.id)" name="i-heroicons-check-circle-20-solid" <UIcon
v-if="selected.includes(item.id)" name="i-heroicons-check-circle-20-solid"
class="text-primary text-lg"/> class="text-primary text-lg"/>
</div> </div>
</UButton> </UButton>
...@@ -53,7 +54,7 @@ ...@@ -53,7 +54,7 @@
const { $isLibrarySelectOpen, $selectCollectionId, $selectThreadId, $collection } = storeToRefs(useLibraryStore()) const { $isLibrarySelectOpen, $selectCollectionId, $selectThreadId, $collection } = storeToRefs(useLibraryStore())
const { $closeLibrarySelect, $openLibraryCreate, $setSelectCollectionId, $getCollection } = useLibraryStore() const { $closeLibrarySelect, $openLibraryCreate, $setSelectCollectionId, $getCollection } = useLibraryStore()
const { saveCollection, deleteCollectionRecord } = useCollectionRequest() const { saveCollection, deleteCollectionRecord } = useCollectionRequest()
const emits = defineEmits(['success']) const emits = defineEmits([ 'success' ])
// 合集列表 // 合集列表
const selected = ref([]) const selected = ref([])
const loading = ref(false) const loading = ref(false)
...@@ -65,7 +66,7 @@ function handleOpenCreate () { ...@@ -65,7 +66,7 @@ function handleOpenCreate () {
$openLibraryCreate() $openLibraryCreate()
} }
async function handleSelected(id) { async function handleSelected(id) {
selected.value = [id] selected.value = [ id ]
} }
async function handleSave() { async function handleSave() {
if (loading.value) return if (loading.value) return
...@@ -80,7 +81,7 @@ async function handleSave() { ...@@ -80,7 +81,7 @@ async function handleSave() {
if (selected.value.length) { if (selected.value.length) {
const selectedItem = selected.value[0] const selectedItem = selected.value[0]
const { error } = await saveCollection({ collection_id: selectedItem, c_id: $selectThreadId.value }) const { error } = await saveCollection({ collection_id: selectedItem, c_id: $selectThreadId.value })
!error.value && $setSelectCollectionId([selectedItem]) !error.value && $setSelectCollectionId([ selectedItem ])
} }
loading.value = false loading.value = false
handleClose() handleClose()
...@@ -92,7 +93,7 @@ async function handleSave() { ...@@ -92,7 +93,7 @@ async function handleSave() {
}) })
} }
watch(() => $isLibrarySelectOpen.value, () => { watch(() => $isLibrarySelectOpen.value, () => {
selected.value = [...$selectCollectionId.value] selected.value = [ ...$selectCollectionId.value ]
if (!$collection.value.length) { if (!$collection.value.length) {
$getCollection() $getCollection()
} }
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
</ULink> </ULink>
<div class="flex justify-between items-center"> <div class="flex justify-between items-center">
<div class="flex gap-4"> <div class="flex gap-4">
<UTooltip class="flex items-center text-sm gap-0.5" :class="textColor" <UTooltip
class="flex items-center text-sm gap-0.5" :class="textColor"
:text="thread.is_public ? '公开主题,链接可被发现' : '私密主题,仅自己可见'"> :text="thread.is_public ? '公开主题,链接可被发现' : '私密主题,仅自己可见'">
<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>
...@@ -70,7 +71,7 @@ const props = defineProps({ ...@@ -70,7 +71,7 @@ const props = defineProps({
default: false default: false
} }
}) })
const emit = defineEmits(['delete']) const emit = defineEmits([ 'delete' ])
const thread = computed(() => { const thread = computed(() => {
if (!props.isItem) return props.item if (!props.isItem) return props.item
else { else {
...@@ -94,7 +95,7 @@ function handleOpenSelect () { ...@@ -94,7 +95,7 @@ function handleOpenSelect () {
function handleUpdateCollect (data) { function handleUpdateCollect (data) {
const { c_id } = data.value const { c_id } = data.value
if (c_id === thread.value.c_id) { if (c_id === thread.value.c_id) {
thread.value.collections = [data.value] thread.value.collections = [ data.value ]
Layout.handleClearCollectData() Layout.handleClearCollectData()
} }
} }
......
<template> <template>
<div class="grid grid-cols-1"> <div class="grid grid-cols-1">
<MDC v-if="content" class="prose dark:prose-invert max-w-none" :class="'prose-' + size" :value="content" <MDC
v-if="content" class="prose dark:prose-invert max-w-none" :class="'prose-' + size" :value="content"
tag="article"/> tag="article"/>
</div> </div>
</template> </template>
......
...@@ -53,7 +53,7 @@ const props = defineProps({ ...@@ -53,7 +53,7 @@ const props = defineProps({
default: false default: false
} }
}) })
const emits = defineEmits(['ask', 'stop']) const emits = defineEmits([ 'ask', 'stop' ])
const isFocus = ref(false) const isFocus = ref(false)
const cardUI = computed(() => { const cardUI = computed(() => {
const base = { const base = {
......
...@@ -15,10 +15,12 @@ ...@@ -15,10 +15,12 @@
</div> </div>
<IMdMdc :content="item.article"/> <IMdMdc :content="item.article"/>
<div v-if="item.showActions" class="space-x-2"> <div v-if="item.showActions" class="space-x-2">
<UButton size="xs" color="gray" 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"/> @click="handleCopyMD"/>
<UButton size="xs" color="gray" leading-icon="i-heroicons-share-20-solid" label="分享" @click="handleShare"/> <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" <UButton
v-if="isLastIndex" size="xs" color="gray" leading-icon="i-heroicons-arrow-path-rounded-square-20-solid"
label="重写" @click="handleReGenerate"/> label="重写" @click="handleReGenerate"/>
</div> </div>
</template> </template>
...@@ -55,7 +57,7 @@ const props = defineProps({ ...@@ -55,7 +57,7 @@ const props = defineProps({
default: '' // start | finish default: '' // start | finish
} }
}) })
const emits = defineEmits(['regenerate']) const emits = defineEmits([ 'regenerate' ])
function handleReGenerate () { function handleReGenerate () {
emits('regenerate', props.index) emits('regenerate', props.index)
} }
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
<div class="flex mb-2"> <div class="flex mb-2">
<div class="flex items-center gap-1 text-sm overflow-hidden"> <div class="flex items-center gap-1 text-sm overflow-hidden">
<UIcon class="flex-shrink-0" name="i-simple-icons-github"/> <UIcon class="flex-shrink-0" name="i-simple-icons-github"/>
<ULink class="flex-grow truncate underline" :to="chart.info.url" target="_blank" <ULink
class="flex-grow truncate underline" :to="chart.info.url" target="_blank"
:title="chart.info.description">{{ chart.info.name }} :title="chart.info.description">{{ chart.info.name }}
</ULink> </ULink>
<UIcon class="flex-shrink-0" name="i-heroicons-arrow-top-right-on-square"/> <UIcon class="flex-shrink-0" name="i-heroicons-arrow-top-right-on-square"/>
......
...@@ -112,7 +112,7 @@ const state = reactive({ ...@@ -112,7 +112,7 @@ const state = reactive({
id: route.params.id id: route.params.id
}) })
const Layout = inject('Layout') const Layout = inject('Layout')
const emits = defineEmits(['update-query']) const emits = defineEmits([ 'update-query' ])
const isEditTitle = ref(false) const isEditTitle = ref(false)
const titleRef = ref(null) const titleRef = ref(null)
const editTitle = ref('') const editTitle = ref('')
......
...@@ -65,6 +65,6 @@ watch(() => props.collapse, () => { ...@@ -65,6 +65,6 @@ watch(() => props.collapse, () => {
handleCollapse(false) handleCollapse(false)
}, 1000) }, 1000)
} }
}, { immediate: true}) }, { immediate: true })
defineExpose({ handleCollapse }) defineExpose({ handleCollapse })
</script> </script>
...@@ -26,7 +26,7 @@ defineProps({ ...@@ -26,7 +26,7 @@ defineProps({
default: () => [] default: () => []
} }
}) })
const emits = defineEmits(['click']) const emits = defineEmits([ 'click' ])
function handleClick(title) { function handleClick(title) {
emits('click', title) emits('click', title)
} }
......
...@@ -12,7 +12,7 @@ const props = defineProps({ ...@@ -12,7 +12,7 @@ const props = defineProps({
default: '' default: ''
}, },
id: { id: {
type: [String, Number], type: [ String, Number ],
default: '' default: ''
} }
}) })
......
...@@ -45,8 +45,8 @@ function init () { ...@@ -45,8 +45,8 @@ function init () {
datasets: props.data.map(item => { datasets: props.data.map(item => {
// item.backgroundColor = ['rgba(54, 162, 235, 0.2)', 'rgba(255, 99, 132, 0.2)', 'rgba(255, 159, 64, 0.2)', 'rgba(255, 205, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(201, 203, 207, 0.2)'] // item.backgroundColor = ['rgba(54, 162, 235, 0.2)', 'rgba(255, 99, 132, 0.2)', 'rgba(255, 159, 64, 0.2)', 'rgba(255, 205, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(201, 203, 207, 0.2)']
// item.borderColor = ['rgb(54, 162, 235)', 'rgb(255, 99, 132)', 'rgb(255, 159, 64)', 'rgb(255, 205, 86)', 'rgb(75, 192, 192)', 'rgb(153, 102, 255)', 'rgb(201, 203, 207)'] // item.borderColor = ['rgb(54, 162, 235)', 'rgb(255, 99, 132)', 'rgb(255, 159, 64)', 'rgb(255, 205, 86)', 'rgb(75, 192, 192)', 'rgb(153, 102, 255)', 'rgb(201, 203, 207)']
item.backgroundColor = ['rgba(54, 162, 235, 0.2)'] item.backgroundColor = [ 'rgba(54, 162, 235, 0.2)' ]
item.borderColor = ['rgb(54, 162, 235)'] item.borderColor = [ 'rgb(54, 162, 235)' ]
item.borderWidth = 1 item.borderWidth = 1
return item return item
}) })
......
...@@ -9,7 +9,7 @@ export default () => { ...@@ -9,7 +9,7 @@ export default () => {
* description string * description string
* *
*/ */
const {data, error} = await useRequest('/v1/collection/merge', { const { data, error } = await useRequest('/v1/collection/merge', {
method: 'post', method: 'post',
body body
}) })
...@@ -17,7 +17,7 @@ export default () => { ...@@ -17,7 +17,7 @@ export default () => {
} }
// 删除收藏夹 // 删除收藏夹
const deleteCollection = async (collection_id) => { const deleteCollection = async (collection_id) => {
const {data, error} = await useRequest(`/v1/collection/${collection_id}/remove`, { const { data, error } = await useRequest(`/v1/collection/${collection_id}/remove`, {
method: 'post' method: 'post'
}) })
return { data, error } return { data, error }
...@@ -26,7 +26,7 @@ export default () => { ...@@ -26,7 +26,7 @@ export default () => {
const saveCollection = async (body) => { const saveCollection = async (body) => {
// collection_id number 收藏夹ID // collection_id number 收藏夹ID
// c_id string 会话ID // c_id string 会话ID
const {data, error} = await useRequest(`/v1/collection/item/add`, { const { data, error } = await useRequest('/v1/collection/item/add', {
method: 'post', method: 'post',
body body
}) })
...@@ -34,7 +34,7 @@ export default () => { ...@@ -34,7 +34,7 @@ export default () => {
} }
// 查询收藏夹会话列表 // 查询收藏夹会话列表
const findCollection = async (collection_id) => { const findCollection = async (collection_id) => {
const {data, error} = await useRequest(`/v1/collection/${collection_id}/items`) const { data, error } = await useRequest(`/v1/collection/${collection_id}/items`)
if (error.value) { if (error.value) {
return [] return []
} }
...@@ -42,7 +42,7 @@ export default () => { ...@@ -42,7 +42,7 @@ export default () => {
} }
// 删除收藏夹会话 // 删除收藏夹会话
const deleteCollectionRecord = async (collection_id, c_id) => { const deleteCollectionRecord = async (collection_id, c_id) => {
const {data, error} = await useRequest(`/v1/collection/item/delete`, { const { data, error } = await useRequest('/v1/collection/item/delete', {
method: 'post', method: 'post',
body: { collection_id, c_id } body: { collection_id, c_id }
}) })
...@@ -51,12 +51,12 @@ export default () => { ...@@ -51,12 +51,12 @@ export default () => {
} }
// 查询会话是否被收藏 // 查询会话是否被收藏
const findRecordCollection = async (c_id) => { const findRecordCollection = async (c_id) => {
const {data, error} = await useRequest(`/v1/collection/item/check/${c_id}`) const { data, error } = await useRequest(`/v1/collection/item/check/${c_id}`)
return { data, error } return { data, error }
} }
const deleteThread = async (ids) => { const deleteThread = async (ids) => {
const {data, error} = await useRequest('/v1/chat/completion/remove', { const { data, error } = await useRequest('/v1/chat/completion/remove', {
method: 'post', method: 'post',
body: ids body: ids
}) })
......
export default function (status, message) { export default function (status, message) {
if (import.meta.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
......
...@@ -3,7 +3,7 @@ import withNuxt from './.nuxt/eslint.config.mjs' ...@@ -3,7 +3,7 @@ import withNuxt from './.nuxt/eslint.config.mjs'
export default withNuxt({ export default withNuxt({
files: ['**/*.vue', '**/*.js'], files: ['**/*.vue', '**/*.js'],
ignores: ['node_modules/**'],
rules: { rules: {
'semi': [0], 'semi': [0],
'vue/html-indent': ['off'], 'vue/html-indent': ['off'],
...@@ -20,6 +20,6 @@ export default withNuxt({ ...@@ -20,6 +20,6 @@ export default withNuxt({
// 关键字后面是否要空一格 // 关键字后面是否要空一格
'keyword-spacing': [2, { 'before': true, 'after': true }], 'keyword-spacing': [2, { 'before': true, 'after': true }],
// 强制最后一行空行 // 强制最后一行空行
'no-multiple-empty-lines': ['error', { 'max': 2,'maxEOF': 1 }] 'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 1 }],
} }
}) })
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import {LG} from '~/composables/useMQ.js'; import { LG } from '~/composables/useMQ.js';
const { $collection } = storeToRefs(useLibraryStore()) const { $collection } = storeToRefs(useLibraryStore())
const { $openLibraryCreate, $getCollection } = useLibraryStore() const { $openLibraryCreate, $getCollection } = useLibraryStore()
......
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
:repo="state.repo" :repo="state.repo"
@update-query="handleUpdateQuery" @update-query="handleUpdateQuery"
/> />
<div ref="scrollElement" <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"
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>
...@@ -101,8 +103,8 @@ function initSearchItemInfo (info, records) { ...@@ -101,8 +103,8 @@ function initSearchItemInfo (info, records) {
async function initSearchRecordsChart (repos) { async function initSearchRecordsChart (repos) {
if (!import.meta.client) return if (!import.meta.client) return
repos.forEach((repo) => { repos.forEach((repo) => {
const {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)
const cardItem = data.value[index].extra.find(item => item.type === card.type) const cardItem = data.value[index].extra.find(item => item.type === card.type)
...@@ -117,7 +119,7 @@ function initSearchRecords (records) { ...@@ -117,7 +119,7 @@ function initSearchRecords (records) {
let { answer, actions } = item let { answer, actions } = item
const { question, answer_type } = 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
historyItem.extra = historyItem.extra || [] historyItem.extra = historyItem.extra || []
// 处理搜索过程 // 处理搜索过程
...@@ -131,7 +133,7 @@ function initSearchRecords (records) { ...@@ -131,7 +133,7 @@ function initSearchRecords (records) {
} else if (action === 'search_relate_repo') { } else if (action === 'search_relate_repo') {
// 处理请求Loading使用使用 // 处理请求Loading使用使用
historyItem.extra.push({ ready: false, type: action }) historyItem.extra.push({ ready: false, type: action })
repos.push({ output: child.output, index}) repos.push({ output: child.output, index })
} }
return child return child
}) })
...@@ -189,7 +191,7 @@ function scrollToView () { ...@@ -189,7 +191,7 @@ function scrollToView () {
function createGenerateInitItem (question, regenerate) { function createGenerateInitItem (question, regenerate) {
if (askingData.value.question && !regenerate) { if (askingData.value.question && !regenerate) {
const deepCopy = JSON.parse(JSON.stringify(askingData.value)) const deepCopy = JSON.parse(JSON.stringify(askingData.value))
deepCopy.extra = [...askingSidebarCards.value] deepCopy.extra = [ ...askingSidebarCards.value ]
data.value.push(deepCopy) data.value.push(deepCopy)
} }
askingData.value.question = '' askingData.value.question = ''
...@@ -241,7 +243,7 @@ function handleFormFetchData (fetchData) { ...@@ -241,7 +243,7 @@ function handleFormFetchData (fetchData) {
let message = {} let message = {}
try { try {
message = JSON.parse(fetchData) message = JSON.parse(fetchData)
} catch(error) { } } catch (error) { }
if (Object.keys(message).length === 0) return if (Object.keys(message).length === 0) return
const { meta, choices, error, code } = message const { meta, choices, error, code } = message
// 处理403 // 处理403
...@@ -265,7 +267,7 @@ function handleFormFetchData (fetchData) { ...@@ -265,7 +267,7 @@ function handleFormFetchData (fetchData) {
const content = choices[0].message.content const content = choices[0].message.content
switch (meta.action) { switch (meta.action) {
case 'rephrase_question' : case 'rephrase_question' :
askingData.value.actions.push({ action: meta.action, output: content}) askingData.value.actions.push({ action: meta.action, output: content })
break break
case 'search_file' : case 'search_file' :
askingData.value.source = handleFormatSource(content, state) askingData.value.source = handleFormatSource(content, state)
...@@ -312,17 +314,17 @@ function handleStopGenerate () { ...@@ -312,17 +314,17 @@ function handleStopGenerate () {
aiChatController && aiChatController.abort() aiChatController && aiChatController.abort()
} }
function handleError (event) { function handleError (event) {
console.log(`error:`, event) console.log('error:', event)
resetAskingData('') resetAskingData('')
handleStopGenerate() handleStopGenerate()
if (event) throw event if (event) throw event
} }
function handleOpen (status) { function handleOpen (status) {
if ([401, 403].includes(status)) resetAskingData('') if ([ 401, 403 ].includes(status)) resetAskingData('')
} }
async function fetchLinkedQuestion (query) { async function fetchLinkedQuestion (query) {
const { gitPath, id } = state const { gitPath, id } = state
const messages = [{ role: 'user', content: query }] const messages = [ { role: 'user', content: query } ]
const { data } = await useRequest('/v1/chat/recomend_question', { const { data } = await useRequest('/v1/chat/recomend_question', {
method: 'post', method: 'post',
body: { repo_path: gitPath || '', c_id: id, messages } body: { repo_path: gitPath || '', c_id: id, messages }
......
...@@ -56,7 +56,7 @@ export function gitToLabel(url) { ...@@ -56,7 +56,7 @@ export function gitToLabel(url) {
// 如果匹配不到,返回空字符串 // 如果匹配不到,返回空字符串
if (!match) { if (!match) {
return ""; return '';
} }
// 返回匹配到的项目名称 // 返回匹配到的项目名称
...@@ -75,7 +75,7 @@ export function handleFormatRepoStars (repoObj, gits) { ...@@ -75,7 +75,7 @@ export function handleFormatRepoStars (repoObj, gits) {
}) })
Object.keys(repoObj).forEach(child => { Object.keys(repoObj).forEach(child => {
const data = repoObj[child] const data = repoObj[child]
const cardDataItem = { data: [{ data: [], label: 'Star 数量' }], labels: [], info: gitsMap[child] } const cardDataItem = { data: [ { data: [], label: 'Star 数量' } ], labels: [], info: gitsMap[child] }
data.forEach(dataItem => { data.forEach(dataItem => {
const { date, stargazers } = dataItem const { date, stargazers } = dataItem
cardDataItem.labels.push(date) cardDataItem.labels.push(date)
...@@ -92,7 +92,7 @@ export function baseGitUrl(gitPath) { ...@@ -92,7 +92,7 @@ export function baseGitUrl(gitPath) {
return endWidthGit ? gitPath.slice(0, gitPath.length - 4) : gitPath return endWidthGit ? gitPath.slice(0, gitPath.length - 4) : gitPath
} }
export function handleFormatSource (source, params) { export function handleFormatSource (source, params) {
const {gitPath, branch,repo} = params const { gitPath, branch, repo } = params
if (Array.isArray(source)) return source if (Array.isArray(source)) return source
const gitUrl = baseGitUrl(gitPath) const gitUrl = baseGitUrl(gitPath)
return source.split('\n').map((item) => { return source.split('\n').map((item) => {
...@@ -118,7 +118,7 @@ export function handleFormatInfoData (output) { ...@@ -118,7 +118,7 @@ export function handleFormatInfoData (output) {
if (typeof output === 'string') { if (typeof output === 'string') {
try { try {
info.gits = JSON.parse(output) info.gits = JSON.parse(output)
} catch(error) {} } catch (error) { }
} else { } else {
info.gits = output info.gits = output
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册