Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nexmoe committed Apr 30, 2024
1 parent 7063737 commit 1acd987
Show file tree
Hide file tree
Showing 17 changed files with 158 additions and 60 deletions.
5 changes: 4 additions & 1 deletion app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ watch(

<template>
<NuxtLayout>
<NuxtLoadingIndicator :duration="1000" color="repeating-linear-gradient(90deg, #f7d038, #ffe993)" />
<NuxtLoadingIndicator
:duration="1000"
color="repeating-linear-gradient(90deg, #f7d038, #ffe993)"
/>
<NuxtPage />
</NuxtLayout>
</template>
Expand Down
4 changes: 3 additions & 1 deletion components/LinkIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ function getOrigin(url: string) {
<NuxtImg
class="rounded-md outline-2 hover:outline cursor-pointer"
:src="`https://lib.xiaoshuapp.com/icon/x?url=${getOrigin(props.url)}`"
:alt="props.url" referrerpolicy="no-referrer" loading="lazy"
:alt="props.url"
referrerpolicy="no-referrer"
loading="lazy"
/>
</template>
5 changes: 4 additions & 1 deletion components/flow/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const props = defineProps<Props>()
</script>

<template>
<div :id="props.title" class="flow-header pl-2.5 flex items-center justify-between">
<div
:id="props.title"
class="flow-header pl-2.5 flex items-center justify-between"
>
<div class="flex items-center space-x-3">
<h2 class="text-xl -mt-1 font-bold sm:truncate sm:text-3xl sm:tracking-tight">
{{ props.title }}
Expand Down
35 changes: 28 additions & 7 deletions components/flow/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,42 @@ provide('flow', props.flow)

<template>
<div class="flow">
<FlowHeader v-if="props.header" :id="props.flow!.id" :title="props.flow!.title" :url="props.flow!.homepage" />
<FlowHeader
v-if="props.header"
:id="props.flow!.id"
:title="props.flow!.title"
:url="props.flow!.homepage"
/>

<div
class="flow-body" :class="[
class="flow-body"
:class="[
props.flow!.configCard === 'gallery' ? 'n-gallery' : 'n-grid',
]"
>
<NuxtLink
v-for="(module) in props.flow!.module" :key="module.url" :title="module.title" :to="module.url"
v-for="(module) in props.flow!.module"
:key="module.url"
:title="module.title"
:to="module.url"
target="_blank"
>
<LazyModuleList v-if="props.flow!.configCard === 'list'" v-bind="{ module }" />
<LazyModuleProject v-else-if="props.flow!.configCard === 'project'" v-bind="{ module }" />
<LazyModuleGallery v-else-if="props.flow!.configCard === 'gallery'" v-bind="{ module }" />
<LazyModuleImage v-else v-bind="{ module }" />
<LazyModuleList
v-if="props.flow!.configCard === 'list'"
v-bind="{ module }"
/>
<LazyModuleProject
v-else-if="props.flow!.configCard === 'project'"
v-bind="{ module }"
/>
<LazyModuleGallery
v-else-if="props.flow!.configCard === 'gallery'"
v-bind="{ module }"
/>
<LazyModuleImage
v-else
v-bind="{ module }"
/>
</NuxtLink>
</div>
</div>
Expand Down
14 changes: 11 additions & 3 deletions components/module/Gallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ const props = defineProps<Props>()
{{ formatDateTime(module.date) }}
</div>
</div>
<div v-if="props.module.image" class="min-h-[68px] shadow-sm border rounded-2xl relative overflow-hidden">
<div
v-if="props.module.image"
class="min-h-[68px] shadow-sm border rounded-2xl relative overflow-hidden"
>
<NuxtImg
class="w-full" format="webp" :src="props.module!.image" :alt="module.title"
referrerpolicy="no-referrer" loading="lazy" width="420px"
class="w-full"
format="webp"
:src="props.module!.image"
:alt="module.title"
referrerpolicy="no-referrer"
loading="lazy"
width="420px"
/>
<div class="absolute bottom-0 left-0 px-5 pt-5 pb-4 bg-gradient-to-t from-black/35 to-transparent w-full">
<h3 class="drop-shadow-md text-white font-bold text-2xl tracking-tight">
Expand Down
29 changes: 23 additions & 6 deletions components/module/Image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,42 @@ const text = computed(() => extractTextFromHTML(props.module.content))
{{ formatDateTime(module.date) }}
</div>
</div>
<div v-if="props.module.image" class="shadow-sm max-h-96 rounded-xl relative overflow-hidden">
<div
v-if="props.module.image"
class="shadow-sm max-h-96 rounded-xl relative overflow-hidden"
>
<NuxtImg
class="w-full" format="webp" :src="props.module!.image" :alt="module.title"
referrerpolicy="no-referrer" loading="lazy" width="420px"
class="w-full"
format="webp"
:src="props.module!.image"
:alt="module.title"
referrerpolicy="no-referrer"
loading="lazy"
width="420px"
/>
</div>
</div>
<div class="space-y-4 px-3 pb-3 pt-0">
<h3 v-if="!flow?.configNoTitle" class="card-title font-bold text-2xl tracking-tight text-black">
<h3
v-if="!flow?.configNoTitle"
class="card-title font-bold text-2xl tracking-tight text-black"
>
{{ props.module.title }}
</h3>
<div v-if="!flow?.configNoContent && text !== ' '" class="line-clamp-3" v-html="text" />
<div
v-if="!flow?.configNoContent && text !== ' '"
class="line-clamp-3"
v-html="text"

Check warning on line 55 in components/module/Image.vue

View workflow job for this annotation

GitHub Actions / testCodebase

'v-html' directive can lead to XSS attack
/>
<div
v-if="!props.module.image || (props.module.platform?.length || 0) > 1"
class="flex flex-row items-center gap-1"
>
<template v-if="(props.module.platform?.length || 0) > 1">
<div
v-for="platform in props.module.platform" :key="platform" class="w-7 h-7 block"
v-for="platform in props.module.platform"
:key="platform"
class="w-7 h-7 block"
@click="navigateTo(platform, { open: { target: '_blank' }, external: true })"
>
<LinkIcon :url="platform" />
Expand Down
5 changes: 4 additions & 1 deletion components/module/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ const text = extractTextFromHTML(props.module.content)
</h3>
</div>

<div v-if="!flow.configNoContent" class="truncate">
<div
v-if="!flow.configNoContent"
class="truncate"
>
<div v-html="text" />

Check warning on line 45 in components/module/List.vue

View workflow job for this annotation

GitHub Actions / testCodebase

'v-html' directive can lead to XSS attack
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/public/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const config = await useGetConfig()
</NuxtLink>
</div>
<div class="flex flex-1 items-center flex-row gap-3 justify-end">
<Social v-for="item in config.socials" v-bind="item" :key="item.url" />
<PublicSocial v-for="item in config.socials" v-bind="item" :key="item.url" />
</div>
</div>
<Sheet>
Expand All @@ -51,7 +51,7 @@ const config = await useGetConfig()
</NuxtLink>
<div class="flex items-center flex-row gap-3">
<div v-for="item in config.socials" :key="item.url" class="item !p-3">
<Social v-bind="item" />
<PublicSocial v-bind="item" />
</div>
</div>
</div>
Expand Down
7 changes: 6 additions & 1 deletion components/Social.vue → components/public/Social.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export interface Props {
</script>

<template>
<a class="text-2xl text-gray-600 flex" :href="url" target="_blank" :title="props.name">
<a
class="text-2xl text-gray-600 flex"
:href="url"
target="_blank"
:title="props.name"
>
<Icon :name="iconMap[props.icon]" />
</a>
</template>
28 changes: 14 additions & 14 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import withNuxt from './.nuxt/eslint.config.mjs'

export default withNuxt(
// your custom flat configs go here, for example:
// {
// files: ['**/*.ts', '**/*.tsx'],
// rules: {
// 'no-console': 'off' // allow console.log in TypeScript files
// }
// },
// {
// ...
// }
{

ignores: ['dist', '**/dist/**', 'public', '**/public/**', 'auto-imports.d.ts', '**/auto-imports.d.ts/**', 'components.d.ts', '**/components.d.ts/**', '.output', '**/.output/**', 'node_modules', '**/node_modules/**', 'components/ui', '**/components/ui/**'],
// your custom flat configs go here, for example:
// {
// files: ['**/*.ts', '**/*.tsx'],
// rules: {
// 'no-console': 'off' // allow console.log in TypeScript files
// }
// },
// {
// ...
// }
{

}
ignores: ['dist', '**/dist/**', 'public', '**/public/**', 'auto-imports.d.ts', '**/auto-imports.d.ts/**', 'components.d.ts', '**/components.d.ts/**', '.output', '**/.output/**', 'node_modules', '**/node_modules/**', 'components/ui', '**/components/ui/**'],

},
)
8 changes: 4 additions & 4 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ useHead({

<template>
<div>
<PublicHeader />
<slot />
<LazyPublicTool />
<LazyPublicFooter v-once />
<PublicHeader />
<slot />
<LazyPublicTool />
<LazyPublicFooter v-once />
</div>
</template>

Expand Down
10 changes: 5 additions & 5 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ export default defineNuxtConfig({
'@nuxtjs/html-validator',
'@nuxtjs/web-vitals',
'nuxt-gtag',
"@nuxt/eslint"
'@nuxt/eslint',
],

eslint: {
config: {
stylistic: {
indent: 'tab',
}
}
},
},
},

shadcn: {
Expand Down Expand Up @@ -112,7 +112,7 @@ export default defineNuxtConfig({
'cdn.dribbble.com',
'picx.zhimg.com',
'img.zcool.cn',
'image.coolapk.com'
'image.coolapk.com',
],
},

Expand Down Expand Up @@ -142,4 +142,4 @@ export default defineNuxtConfig({
enabled: true,
},
},
})
})
15 changes: 12 additions & 3 deletions pages/flow/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,19 @@ defineOgImageComponent('NuxtSeo', {
<Head>
<Title>{{ flow.title }}</Title>
</Head>
<PublicProse v-if="flow.description" :title="flow.title">
<PublicProse
v-if="flow.description"
:title="flow.title"
>
{{ flow.description }}
</PublicProse>
<PublicProse v-else :title="flow.title" />
<Flow v-if="!loading" v-bind="{ flow, header: false }" />
<PublicProse
v-else
:title="flow.title"
/>
<Flow
v-if="!loading"
v-bind="{ flow, header: false }"
/>
</div>
</template>
18 changes: 14 additions & 4 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,28 @@ defineOgImageComponent('NuxtSeo', {
<div class="page">
<div class="container">
<PublicProse :title="`Hi, I'm ${config.siteName}`">
<div class="whitespace-pre-wrap" v-html="config.description" />
<div
class="whitespace-pre-wrap"
v-html="config.description"

Check warning on line 33 in pages/index.vue

View workflow job for this annotation

GitHub Actions / testCodebase

'v-html' directive can lead to XSS attack
/>
<div class="tags flex flex-row flex-wrap gap-2">
<div
v-for="item in config.tags" :key="item"
v-for="item in config.tags"
:key="item"
class="text-black inline-block shu-card border-none text-sm px-3 py-0.5"
>
{{ item }}
</div>
</div>
</PublicProse>
<template v-for=" flow in flows " :key="flow.id">
<LazyFlow v-if="flow.module.length > 0" v-bind="{ flow }" />
<template
v-for=" flow in flows "
:key="flow.id"
>
<LazyFlow
v-if="flow.module.length > 0"
v-bind="{ flow }"
/>
</template>
</div>

Expand Down
19 changes: 15 additions & 4 deletions pages/module/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ function replaceImg(html: string) {
<template>
<div class="page-module">
<UContainer
v-if="module" class="relative max-w-4xl bg-white px-4 sm:px-8 lg:px-12 pb-48"
v-if="module"
class="relative max-w-4xl bg-white px-4 sm:px-8 lg:px-12 pb-48"
>
<UButton
class="sticky rounded-full top-32 left-0 -ml-12 -translate-x-1/2" icon="i-heroicons-chevron-left"
class="sticky rounded-full top-32 left-0 -ml-12 -translate-x-1/2"
icon="i-heroicons-chevron-left"
square
size="xl"
variant="solid"
Expand All @@ -43,10 +45,19 @@ function replaceImg(html: string) {
<div class="mr-4 text-lg">
{{ formatDateTime(module.date) }}
</div>
<LinkIcon v-for="platform in module.platform" :key="platform" class="w-6 h-6 block" :url="platform" @click="navigateTo(platform, { open: { target: '_blank' }, external: true })" />
<LinkIcon
v-for="platform in module.platform"
:key="platform"
class="w-6 h-6 block"
:url="platform"
@click="navigateTo(platform, { open: { target: '_blank' }, external: true })"
/>
</div>
<div class="my-6 border-b border-gray-200 w-1/3" />
<div class="apple-markdown" v-html="replaceImg(module.content)" />
<div
class="apple-markdown"
v-html="replaceImg(module.content)"

Check warning on line 59 in pages/module/[id].vue

View workflow job for this annotation

GitHub Actions / testCodebase

'v-html' directive can lead to XSS attack
/>
</UContainer>
</div>
</template>
Expand Down
10 changes: 8 additions & 2 deletions pages/space/_[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ provide('flows', flows)
</div>
<div class="content">
<UContainer class="px-6 lg:px-12 pb-24 pt-16">
<template v-for="flow in flows" :key="flow.id">
<Flow v-if="flow.module.length > 0" v-bind="{ flow }" />
<template
v-for="flow in flows"
:key="flow.id"
>
<Flow
v-if="flow.module.length > 0"
v-bind="{ flow }"
/>
</template>
</UContainer>
<IndexTool />
Expand Down
Loading

0 comments on commit 1acd987

Please sign in to comment.