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

fix: eslint

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