eslint style fix
This commit is contained in:
parent
101f2e082b
commit
999ae23e4c
@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import { pos } from 'ipx'
|
||||
|
||||
const props = defineProps<{
|
||||
post: IPost
|
||||
|
@ -1,103 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
|
||||
const currentPost = ref<IPost | null>(null),
|
||||
|
||||
onOpenPost = (e: IPost) => {
|
||||
currentPost.value = e
|
||||
},
|
||||
|
||||
onClosePost = () => {
|
||||
currentPost.value = null
|
||||
},
|
||||
|
||||
thumbUrl = computed(() => {
|
||||
if (currentPost.value && currentPost.value.fields.thumb.value) {
|
||||
return currentPost.value.fields.thumb.value
|
||||
}
|
||||
return getAssetURL(`${Math.floor(Math.random() * (7 - 1 + 1)) + 1}.jpg`)
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
emitter.on('openPost', onOpenPost)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
emitter.off('openPost', onOpenPost)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="currentPost"
|
||||
class="fixed top-0 right-0 bottom-0 left-0 z-20 bg-black bg-opacity-60"
|
||||
>
|
||||
<div class="container mx-auto my-10 max-h-full overflow-hidden overscroll-y-contain rounded-3xl bg-white">
|
||||
<!-- 标题栏 -->
|
||||
<div class="relative w-full border-b-2 border-b-gray-200">
|
||||
<!-- 文章头图 -->
|
||||
<div class="min-h-52">
|
||||
<img
|
||||
:src="thumbUrl"
|
||||
alt=""
|
||||
class="max-h-64 w-full object-cover object-center"
|
||||
>
|
||||
</div>
|
||||
<!-- 预览标题 -->
|
||||
<div
|
||||
class="absolute top-0 right-0 left-0 h-12 truncate bg-black bg-opacity-60 pr-16 pl-8 text-white backdrop-blur-3xl py-1.5"
|
||||
>
|
||||
<span
|
||||
:title="currentPost.title"
|
||||
class="text-3xl font-bold"
|
||||
>
|
||||
文章预览 /
|
||||
</span>
|
||||
</div>
|
||||
<!-- 关闭按钮 -->
|
||||
<div
|
||||
class="absolute top-0 right-2 flex h-9 w-9 cursor-pointer items-center justify-center rounded-full text-white transition-all my-1.5 hover:bg-gray-200 hover:text-black"
|
||||
@click="onClosePost"
|
||||
>
|
||||
<font-awesome-icon
|
||||
:icon="['fas', 'xmark']"
|
||||
class="p-2"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 正文 -->
|
||||
<div
|
||||
class="container overflow-y-auto p-8 h-[60vh] preview"
|
||||
v-html="currentPost.digest"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.preview {
|
||||
h1 {
|
||||
@apply mb-2 border-l-8 border-l-blue-400 text-3xl font-bold;
|
||||
}
|
||||
|
||||
h2 {
|
||||
@apply mb-2 border-l-4 border-l-blue-400 text-2xl font-bold;
|
||||
}
|
||||
|
||||
h3 {
|
||||
@apply mb-2 border-l-2 border-l-blue-400 text-xl font-bold;
|
||||
}
|
||||
|
||||
h4 {
|
||||
@apply text-lg font-bold;
|
||||
}
|
||||
|
||||
h5 {
|
||||
@apply text-sm font-bold;
|
||||
}
|
||||
|
||||
ul {
|
||||
@apply line-clamp-1;
|
||||
}
|
||||
}
|
||||
</style>
|
@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
type Widget = {
|
||||
interface Widget {
|
||||
icon: string[]
|
||||
url: string
|
||||
title: string
|
||||
|
@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
|
||||
type Widget = {
|
||||
interface Widget {
|
||||
icon: string[]
|
||||
url: string
|
||||
title: string
|
||||
@ -33,7 +33,7 @@ const props = defineProps({
|
||||
},
|
||||
],
|
||||
// Const logoUrl = getAssetURL("w.png")
|
||||
logoType: string = 'logo',
|
||||
logoType = 'logo',
|
||||
showLogo = computed(() => logoType === 'text'),
|
||||
isExpended = ref<boolean>(false),
|
||||
route = useRoute(),
|
||||
|
@ -1,14 +1,12 @@
|
||||
<script lang="ts" setup>
|
||||
const router = useRouter()
|
||||
type Entry = {
|
||||
interface Entry {
|
||||
title: string
|
||||
url: boolean
|
||||
to: string
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'onGo'): void
|
||||
}>()
|
||||
const emit = defineEmits<(e: 'onGo') => void>()
|
||||
|
||||
defineProps<{
|
||||
title: string
|
||||
@ -18,9 +16,12 @@ defineProps<{
|
||||
}>()
|
||||
|
||||
const onClick = (to: string | undefined, url: boolean) => {
|
||||
if (to === undefined) { return }
|
||||
if (to === undefined)
|
||||
return
|
||||
|
||||
if (url)
|
||||
window.open(to)
|
||||
|
||||
if (url) { window.open(to) }
|
||||
emit('onGo')
|
||||
router.push({ name: to })
|
||||
}
|
||||
|
@ -1,13 +1,16 @@
|
||||
export const getAssetURL = (image: string) => {
|
||||
// 参数一: 相对路径
|
||||
// 参数二: 当前路径的URL
|
||||
if (import.meta.client) { return new URL(`../assets/images/${image}`, import.meta.url).href }
|
||||
if (import.meta.client) {
|
||||
return new URL(`../assets/images/${image}`, import.meta.url).href
|
||||
}
|
||||
return `/_nuxt/assets/images/${image}`
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
export const debounce = (fn: Function, delay: number) => {
|
||||
let timeoutId: NodeJS.Timeout
|
||||
return (...args: any[]) => {
|
||||
return (...args: unknown[]) => {
|
||||
clearTimeout(timeoutId)
|
||||
timeoutId = setTimeout(() => {
|
||||
fn(...args)
|
||||
|
@ -8,11 +8,13 @@ export function requestCore<DataT>(url: string, options: UseFetchOptions<DataT>)
|
||||
retry: false,
|
||||
timeout: 3000,
|
||||
onRequest({ options }) {
|
||||
let token: string = ''
|
||||
let token = ''
|
||||
if (import.meta.client) {
|
||||
token = localStorage.getItem('token') || ''
|
||||
}
|
||||
if (!options.headers.get('Authorization')) { options.headers.set('Authorization', `Bearer ${token}`) }
|
||||
if (!options.headers.get('Authorization')) {
|
||||
options.headers.set('Authorization', `Bearer ${token}`)
|
||||
}
|
||||
},
|
||||
onResponse({ response }) {
|
||||
// HTTP状态码2XX/3XX执行,否则不执行
|
||||
@ -41,7 +43,9 @@ export function get<DataT, ErrorT>(url: string, options?: UseFetchOptions<DataT>
|
||||
return async (): Promise<DataT> => {
|
||||
if (result != null) {
|
||||
await result.refresh()
|
||||
if (result.status.value === 'success') { return result.data.value }
|
||||
if (result.status.value === 'success') {
|
||||
return result.data.value
|
||||
}
|
||||
throw result.error
|
||||
}
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
import js from '@eslint/js'
|
||||
import withNuxt from './.nuxt/eslint.config.mjs'
|
||||
|
||||
export default withNuxt([
|
||||
js.configs.all,
|
||||
{ files: ['**/*.ts', '**/*.tsx'] },
|
||||
])
|
3
eslint.config.mts
Normal file
3
eslint.config.mts
Normal file
@ -0,0 +1,3 @@
|
||||
import withNuxt from './.nuxt/eslint.config.mjs'
|
||||
|
||||
export default withNuxt()
|
@ -1,4 +1,6 @@
|
||||
export default defineNuxtRouteMiddleware((to, _) => {
|
||||
if (to.meta.maintenance === true && import.meta.env.DEV) { return navigateTo('/error/maintenance') }
|
||||
export default defineNuxtRouteMiddleware((to) => {
|
||||
if (to.meta.maintenance === true && import.meta.env.DEV) {
|
||||
return navigateTo('/error/maintenance')
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
@ -37,9 +37,9 @@
|
||||
"@types/markdown-it": "^14.1.2",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint-config-google": "^0.14.0",
|
||||
"eslint-plugin-vue": "^9.32.0",
|
||||
"globals": "^15.14.0",
|
||||
"jiti": "^2.4.2",
|
||||
"postcss": "^8.4.49",
|
||||
"sass-embedded": "^1.81.0",
|
||||
"tailwindcss": "^3.4.5",
|
||||
|
@ -2,9 +2,6 @@
|
||||
navigateTo('/error/404')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
|
@ -3,7 +3,7 @@ const route = useRoute(),
|
||||
cid = route.params.cid as string,
|
||||
content = ref<IBlogResponse<IPostFull>>(),
|
||||
|
||||
getPost = get<IBlogResponse<IPostFull>, any>('/blog/index.php/api/post', {
|
||||
getPost = get<IBlogResponse<IPostFull>, unknown>('/blog/index.php/api/post', {
|
||||
params: {
|
||||
cid,
|
||||
md: false,
|
||||
|
@ -3,6 +3,7 @@
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>auth view</h1>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
@ -10,9 +10,6 @@ if (import.meta.server) {
|
||||
else { showError({ statusCode: errorCode }) }
|
||||
</script>
|
||||
|
||||
<template>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
type errObj = {
|
||||
interface errObj {
|
||||
blog?: object
|
||||
git?: object
|
||||
}
|
||||
@ -23,13 +23,13 @@ const { $mitt } = useNuxtApp(),
|
||||
}),
|
||||
|
||||
config = useRuntimeConfig(),
|
||||
getBlogRecentPost = get<IBlogResponse<IPostsData>, any>('/blog/index.php/api/posts', {
|
||||
getBlogRecentPost = get<IBlogResponse<IPostsData>, unknown>('/blog/index.php/api/posts', {
|
||||
params: {
|
||||
showDigest: 'excerpt',
|
||||
limit: 100,
|
||||
},
|
||||
}),
|
||||
getActivity = get<IActivity[], any>('/git/api/v1/users/cantyonion/activities/feeds', {
|
||||
getActivity = get<IActivity[], unknown>('/git/api/v1/users/cantyonion/activities/feeds', {
|
||||
headers: {
|
||||
Authorization: ` ${config.public.gitApiKey}`,
|
||||
},
|
||||
@ -41,12 +41,18 @@ const { $mitt } = useNuxtApp(),
|
||||
hasPosts = computed(() => (recentPosts.value ?? []).length > 0),
|
||||
hasActivities = computed(() => (recentActivities.value ?? []).length > 0),
|
||||
postsData = computed(() => {
|
||||
if (!recentPosts.value) { return [] }
|
||||
if (recentPosts.value.length > 4) { return recentPosts.value.slice(0, 4) }
|
||||
if (!recentPosts.value) {
|
||||
return []
|
||||
}
|
||||
if (recentPosts.value.length > 4) {
|
||||
return recentPosts.value.slice(0, 4)
|
||||
}
|
||||
return recentPosts.value
|
||||
}),
|
||||
activitiesData = computed((): IActivity<IContent>[] => {
|
||||
if (!Array.isArray(recentActivities.value)) { return [] }
|
||||
if (!Array.isArray(recentActivities.value)) {
|
||||
return []
|
||||
}
|
||||
return recentActivities.value.map((item) => {
|
||||
try {
|
||||
if (item.op_type === 'commit_repo') {
|
||||
@ -58,6 +64,7 @@ const { $mitt } = useNuxtApp(),
|
||||
return null
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e)
|
||||
return null
|
||||
}
|
||||
}).filter(item => item !== null)
|
||||
@ -68,7 +75,9 @@ const { $mitt } = useNuxtApp(),
|
||||
isLoading.value.blog = true
|
||||
isError.value.blog = false
|
||||
const postData = await getBlogRecentPost()
|
||||
if (postData !== null) { recentPosts.value = postData.data.dataSet }
|
||||
if (postData !== null) {
|
||||
recentPosts.value = postData.data.dataSet
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
isError.value.blog = true
|
||||
@ -102,6 +111,7 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="main">
|
||||
<!-- 个人介绍 -->
|
||||
<card-full-screen-intro-card />
|
||||
|
||||
@ -159,6 +169,7 @@ onMounted(() => {
|
||||
</card-section-card>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
@ -1,6 +1,4 @@
|
||||
import { config, library } from '@fortawesome/fontawesome-svg-core'
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
||||
import { faClock, faFolder } from '@fortawesome/free-regular-svg-icons'
|
||||
import {
|
||||
faBars,
|
||||
faBlog,
|
||||
@ -18,7 +16,9 @@ import {
|
||||
faPen,
|
||||
faXmark,
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
import { faClock, faFolder } from '@fortawesome/free-regular-svg-icons'
|
||||
import { faGithubAlt, faQq, faSteamSymbol, faWeibo } from '@fortawesome/free-brands-svg-icons'
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
||||
|
||||
// 因为默认添加了 nuxt会造成一些错误,所以不自动添加样式
|
||||
config.autoAddCss = false
|
||||
|
@ -1,40 +1,14 @@
|
||||
import md, { type Options } from 'markdown-it'
|
||||
// @ts-ignore
|
||||
import mm from 'markdown-it-mathjax3'
|
||||
|
||||
const options: Options = {
|
||||
// Enable HTML tags in source
|
||||
html: true,
|
||||
|
||||
// Use '/' to close single tags (<br />).
|
||||
// This is only for full CommonMark compatibility.
|
||||
xhtmlOut: true,
|
||||
|
||||
// Convert '\n' in paragraphs into <br>
|
||||
breaks: true,
|
||||
|
||||
// CSS language prefix for fenced blocks. Can be
|
||||
// Useful for external highlighters.
|
||||
html: true,
|
||||
langPrefix: 'language-',
|
||||
|
||||
// Autoconvert URL-like text to links
|
||||
linkify: true,
|
||||
|
||||
// Enable some language-neutral replacement + quotes beautification
|
||||
// For the full list of replacements, see https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.mjs
|
||||
typographer: true,
|
||||
|
||||
// Double + single quotes replacement pairs, when typographer enabled,
|
||||
// And smartquotes on. Could be either a String or an Array.
|
||||
//
|
||||
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
||||
// And ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
||||
quotes: '“”‘’',
|
||||
|
||||
// Highlighter function. Should return escaped HTML,
|
||||
// Or '' if the source string is not changed and should be escaped externally.
|
||||
// If result starts with <pre... internal wrapper is skipped.
|
||||
highlight(/* Str, lang */) { return '' },
|
||||
typographer: true,
|
||||
xhtmlOut: true,
|
||||
}
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import mitt from 'mitt'
|
||||
|
||||
type Events = {
|
||||
interface Events {
|
||||
openPost: IPost
|
||||
startLoading: boolean
|
||||
eventBus: INotification
|
||||
|
@ -1,4 +1,4 @@
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error: 'vue3-typed-js' has no types
|
||||
import VueTyped from 'vue3-typed-js'
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
|
69
types/blog.d.ts
vendored
69
types/blog.d.ts
vendored
@ -1,69 +0,0 @@
|
||||
declare interface IBlogResponse<T> {
|
||||
status: string
|
||||
message: string
|
||||
data: T
|
||||
}
|
||||
|
||||
declare interface IPostsData {
|
||||
page: number
|
||||
pageSize: number
|
||||
pages: number
|
||||
count: number
|
||||
dataSet: []
|
||||
}
|
||||
|
||||
declare interface IPost {
|
||||
cid: string
|
||||
title: string
|
||||
created: string
|
||||
modified: string
|
||||
slug: string
|
||||
commentsNum: string
|
||||
type: string
|
||||
digest: string
|
||||
password: string
|
||||
categories: ICategory[]
|
||||
category: string
|
||||
directory: string[]
|
||||
date: IDate
|
||||
year: string
|
||||
month: string
|
||||
day: string
|
||||
hidden: boolean
|
||||
pathinfo: string
|
||||
permalink: string
|
||||
url: string
|
||||
isMarkdown: boolean
|
||||
feedUrl: string
|
||||
feedRssUrl: string
|
||||
feedAtomUrl: string
|
||||
fields: any
|
||||
}
|
||||
|
||||
declare interface ICategory {
|
||||
mid: string
|
||||
name: string
|
||||
slug: string
|
||||
type: string
|
||||
description: string
|
||||
count: string
|
||||
order: string
|
||||
parent: string
|
||||
cid: string
|
||||
directory: string[]
|
||||
url: string
|
||||
feedUrl: string
|
||||
feedRssUrl: string
|
||||
feedAtomUrl: string
|
||||
}
|
||||
|
||||
declare interface IDate {
|
||||
timeStamp: number
|
||||
year: string
|
||||
month: string
|
||||
day: string
|
||||
}
|
||||
|
||||
declare interface IPostFull extends IPost {
|
||||
text: string
|
||||
}
|
72
types/blog.ts
Normal file
72
types/blog.ts
Normal file
@ -0,0 +1,72 @@
|
||||
declare global {
|
||||
interface IBlogResponse<T> {
|
||||
status: string
|
||||
message: string
|
||||
data: T
|
||||
}
|
||||
|
||||
interface IPostsData {
|
||||
page: number
|
||||
pageSize: number
|
||||
pages: number
|
||||
count: number
|
||||
dataSet: []
|
||||
}
|
||||
|
||||
interface IPost {
|
||||
cid: string
|
||||
title: string
|
||||
created: string
|
||||
modified: string
|
||||
slug: string
|
||||
commentsNum: string
|
||||
type: string
|
||||
digest: string
|
||||
password: string
|
||||
categories: ICategory[]
|
||||
category: string
|
||||
directory: string[]
|
||||
date: IDate
|
||||
year: string
|
||||
month: string
|
||||
day: string
|
||||
hidden: boolean
|
||||
pathinfo: string
|
||||
permalink: string
|
||||
url: string
|
||||
isMarkdown: boolean
|
||||
feedUrl: string
|
||||
feedRssUrl: string
|
||||
feedAtomUrl: string
|
||||
fields: unknown
|
||||
}
|
||||
|
||||
interface ICategory {
|
||||
mid: string
|
||||
name: string
|
||||
slug: string
|
||||
type: string
|
||||
description: string
|
||||
count: string
|
||||
order: string
|
||||
parent: string
|
||||
cid: string
|
||||
directory: string[]
|
||||
url: string
|
||||
feedUrl: string
|
||||
feedRssUrl: string
|
||||
feedAtomUrl: string
|
||||
}
|
||||
|
||||
interface IDate {
|
||||
timeStamp: number
|
||||
year: string
|
||||
month: string
|
||||
day: string
|
||||
}
|
||||
|
||||
interface IPostFull extends IPost {
|
||||
text: string
|
||||
}
|
||||
|
||||
}
|
27
types/git.d.ts
vendored
27
types/git.d.ts
vendored
@ -1,27 +0,0 @@
|
||||
declare interface IActivity<T = string> {
|
||||
id: string
|
||||
content: T
|
||||
op_type: string
|
||||
repo: {
|
||||
name: string
|
||||
html_url: string
|
||||
}
|
||||
created: string
|
||||
}
|
||||
|
||||
declare interface IContent {
|
||||
Commits: ICommit[]
|
||||
HeadCommit: ICommit
|
||||
CompareURL: string
|
||||
Len: number
|
||||
}
|
||||
|
||||
declare interface ICommit {
|
||||
Sha1: string
|
||||
Message: string
|
||||
AuthorEmail: string
|
||||
AuthorName: string
|
||||
CommitterEmail: string
|
||||
CommitterName: string
|
||||
Timestamp: string
|
||||
}
|
29
types/git.ts
Normal file
29
types/git.ts
Normal file
@ -0,0 +1,29 @@
|
||||
declare global {
|
||||
interface IActivity<T = string> {
|
||||
id: string
|
||||
content: T
|
||||
op_type: string
|
||||
repo: {
|
||||
name: string
|
||||
html_url: string
|
||||
}
|
||||
created: string
|
||||
}
|
||||
|
||||
interface IContent {
|
||||
Commits: ICommit[]
|
||||
HeadCommit: ICommit
|
||||
CompareURL: string
|
||||
Len: number
|
||||
}
|
||||
|
||||
interface ICommit {
|
||||
Sha1: string
|
||||
Message: string
|
||||
AuthorEmail: string
|
||||
AuthorName: string
|
||||
CommitterEmail: string
|
||||
CommitterName: string
|
||||
Timestamp: string
|
||||
}
|
||||
}
|
5
types/index.d.ts
vendored
5
types/index.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
declare interface IBlogResponse<T = null> {
|
||||
status: string
|
||||
message: string
|
||||
data: T
|
||||
}
|
7
types/index.ts
Normal file
7
types/index.ts
Normal file
@ -0,0 +1,7 @@
|
||||
declare global {
|
||||
interface IBlogResponse<T = null> {
|
||||
status: string
|
||||
message: string
|
||||
data: T
|
||||
}
|
||||
}
|
5
types/notification.d.ts
vendored
5
types/notification.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
declare interface INotification {
|
||||
level: 'warning' | 'error' | 'info' | 'success'
|
||||
title: string
|
||||
message: string
|
||||
}
|
7
types/notification.ts
Normal file
7
types/notification.ts
Normal file
@ -0,0 +1,7 @@
|
||||
declare global {
|
||||
interface INotification {
|
||||
level: 'warning' | 'error' | 'info' | 'success'
|
||||
title: string
|
||||
message: string
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user