Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nexmoe committed Apr 24, 2024
1 parent 04a69c1 commit 1c16ddc
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 44 deletions.
14 changes: 9 additions & 5 deletions components/flow/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ provide('flow', props.flow)
<div class="flow">
<FlowHeader v-if="props.header" :id="props.flow!.id" :title="props.flow!.title" :url="props.flow!.homepage" />

<div 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"
target="_blank">
<div
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"
target="_blank"
>
<ModuleList v-if="props.flow!.configCard === 'list'" v-bind="{ module }" />
<ModuleProject v-else-if="props.flow!.configCard === 'project'" v-bind="{ module }" />
<ModuleGallery v-else-if="props.flow!.configCard === 'gallery'" v-bind="{ module }" />
Expand Down
20 changes: 13 additions & 7 deletions components/module/Image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { AppRouter } from '@/server/trpc/routers'
type RouterOutput = inferRouterOutputs<AppRouter>
type ModuleOutput = RouterOutput['module']['get']
type FlowOutput = RouterOutput['flow']['get']
type Module = Exclude<ModuleOutput, null>;
type Module = Exclude<ModuleOutput, null>
interface Props {
module: Module
Expand All @@ -28,8 +28,10 @@ const text = computed(() => extractTextFromHTML(props.module.content))
</div>
</div>
<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" />
<NuxtImg
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">
Expand All @@ -39,11 +41,15 @@ const text = computed(() => extractTextFromHTML(props.module.content))
<div v-if="!flow?.configNoContent && text !== ' '" class="line-clamp-3">
<div v-html="text" />
</div>
<div v-if="!props.module.image || (props.module.platform?.length || 0) > 1"
class="flex flex-row items-center gap-1">
<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"
@click="navigateTo(platform, { open: { target: '_blank' }, external: true })">
<div
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" />
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@
]
}
}
}
}
6 changes: 4 additions & 2 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ defineOgImageComponent('NuxtSeo', {
<PublicProse :title="`Hi, I'm ${config.siteName}`">
<div class="whitespace-pre-wrap" v-html="config.description" />
<div class="tags flex flex-row flex-wrap gap-2">
<div v-for="item in config.tags" :key="item"
class="text-black inline-block shu-card border-none text-sm px-3 py-0.5">
<div
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>
Expand Down
10 changes: 5 additions & 5 deletions server/flowing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const prisma = new PrismaClient()
/**
* 计算两个字符串之间的Levenshtein距离。
* Levenshtein距离是一个字符串相似度的度量,表示从一个字符串转换成另一个字符串所需的最少编辑操作次数(插入、删除或替换字符)。
*
*
* @param a 字符串a,作为比较的基准。
* @param b 字符串b,与字符串a进行比较。
* @returns 两个字符串之间的Levenshtein距离,返回一个数字。
Expand Down Expand Up @@ -37,9 +37,9 @@ function levenshteinDistance(a: string, b: string): number {
// 计算当前字符替换、插入或删除的代价
const cost = a[i - 1] === b[j - 1] ? 0 : 1
matrix[i][j] = Math.min(
matrix[i - 1][j] + 1, // 插入操作
matrix[i][j - 1] + 1, // 删除操作
matrix[i - 1][j - 1] + cost, // 替换操作
matrix[i - 1][j] + 1, // 插入操作
matrix[i][j - 1] + 1, // 删除操作
matrix[i - 1][j - 1] + cost, // 替换操作
)
}
}
Expand Down Expand Up @@ -203,4 +203,4 @@ export async function flowingByFlowId(flowId: string) {
})
if (flow)
await flowingByFlow(flow)
}
}
18 changes: 9 additions & 9 deletions server/middleware/update-site-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import { appRouter } from '@/server/trpc/routers'

export default eventHandler(async (e) => {
const caller = appRouter.createCaller({ prisma: e.context.prisma })
const caller = appRouter.createCaller({ prisma: e.context.prisma })

const config = await caller.config.get()
// eslint-disable-next-line no-console
console.log(config.siteName)
// updateSiteConfig({
// name: config.siteName,
// description: config.siteDescription,
// url: config.siteUrl,
// })
const config = await caller.config.get()
// eslint-disable-next-line no-console
console.log(config.siteName)
// updateSiteConfig({
// name: config.siteName,
// description: config.siteDescription,
// url: config.siteUrl,
// })
})
28 changes: 14 additions & 14 deletions stores/useGlobalStore.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
interface Catalog {
title: string;
anchor: string;
active: boolean;
title: string
anchor: string
active: boolean
}

interface State {
catalog: Catalog[]
catalog: Catalog[]
}

export default defineStore("global", {
state: () => <State>({
catalog: [],
}),
actions: {
setCatalog(catalog: Catalog[]) {
this.catalog = catalog
}
},
})
export default defineStore('global', {
state: () => <State>({
catalog: [],
}),
actions: {
setCatalog(catalog: Catalog[]) {
this.catalog = catalog
},
},
})
2 changes: 1 addition & 1 deletion utils/date.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dayjs from 'dayjs'

export function formatDateTime(source: string | number) {
return dayjs(source).format('MMMM DD, YYYY');
return dayjs(source).format('MMMM DD, YYYY')
}

0 comments on commit 1c16ddc

Please sign in to comment.