Skip to content

Commit d535f65

Browse files
authored
chore: 更新依赖并修改 ESLint 和 Prettier 配置 (#159)
1 parent c84e32b commit d535f65

File tree

13 files changed

+2265
-2994
lines changed

13 files changed

+2265
-2994
lines changed

.prettierignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
pnpm-lock.yaml
22
docs/api/
33
docs/dev-api/
4-
**/*.ts
5-
**/*.js
6-
**/*.vue
7-
**/*.jsonc

.prettierrc.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{
22
"semi": false,
3-
"singleQuote": true
3+
"singleQuote": true,
4+
"overrides": [
5+
{
6+
"files": "*.jsonc",
7+
"options": {
8+
"trailingComma": "none"
9+
}
10+
}
11+
]
412
}

.vscode/settings.json

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,5 @@
22
// Pytest
33
"python.testing.pytestArgs": ["tests"],
44
"python.testing.unittestEnabled": false,
5-
"python.testing.pytestEnabled": true,
6-
7-
// Enable the ESlint flat config support
8-
"eslint.useFlatConfig": true,
9-
10-
// Auto fix
11-
"editor.codeActionsOnSave": {
12-
"source.fixAll.eslint": "explicit"
13-
},
14-
"[javascript][typescript][vue]": {
15-
"editor.codeActionsOnSave": {
16-
"source.organizeImports": "never"
17-
}
18-
},
19-
20-
// Silent the stylistic rules in you IDE, but still auto fix them
21-
"eslint.rules.customizations": [
22-
{ "rule": "style/*", "severity": "off" },
23-
{ "rule": "format/*", "severity": "off" },
24-
{ "rule": "*-indent", "severity": "off" },
25-
{ "rule": "*-spacing", "severity": "off" },
26-
{ "rule": "*-spaces", "severity": "off" },
27-
{ "rule": "*-order", "severity": "off" },
28-
{ "rule": "*-dangle", "severity": "off" },
29-
{ "rule": "*-newline", "severity": "off" },
30-
{ "rule": "*quotes", "severity": "off" },
31-
{ "rule": "*semi", "severity": "off" }
32-
],
33-
34-
// Enable eslint for all supported languages
35-
"eslint.validate": [
36-
"javascript",
37-
"javascriptreact",
38-
"typescript",
39-
"typescriptreact",
40-
"vue",
41-
"html",
42-
"markdown",
43-
"json",
44-
"jsonc",
45-
"yaml",
46-
"toml"
47-
]
5+
"python.testing.pytestEnabled": true
486
}

docs/.vitepress/config.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ export default defineConfig({
2222
['link', { rel: 'manifest', href: '/manifest.json' }],
2323
['meta', { name: 'theme-color', content: '#ffffff' }],
2424
['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }],
25-
['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }],
25+
[
26+
'meta',
27+
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black' },
28+
],
2629
['link', { rel: 'apple-touch-icon', href: '/icons/apple-touch-icon.png' }],
2730
['link', { rel: 'mask-icon', href: '/icons/safari-pinned-tab.svg' }],
28-
['meta', { name: 'msapplication-TileImage', content: '/icons/mstile-150x150.png' }],
31+
[
32+
'meta',
33+
{ name: 'msapplication-TileImage', content: '/icons/mstile-150x150.png' },
34+
],
2935
['meta', { name: 'msapplication-TileColor', content: '#2d89ef' }],
3036
],
3137

@@ -48,7 +54,8 @@ export default defineConfig({
4854
},
4955

5056
editLink: {
51-
pattern: 'https://github.com/AliceBotProject/alicebot/edit/master/docs/:path',
57+
pattern:
58+
'https://github.com/AliceBotProject/alicebot/edit/master/docs/:path',
5259
text: '在 GitHub 上编辑此页',
5360
},
5461

@@ -65,9 +72,7 @@ export default defineConfig({
6572
},
6673

6774
vite: {
68-
plugins: [
69-
Unocss(),
70-
],
75+
plugins: [Unocss()],
7176
},
7277
})
7378

@@ -95,15 +100,13 @@ function getSidebarChildrenItems(dir: string): DefaultTheme.SidebarItem[] {
95100
return false
96101
}
97102
return (
98-
!name.startsWith('.')
99-
&& fs.statSync(path.join(baseDir, dir, name)).isFile()
103+
!name.startsWith('.') &&
104+
fs.statSync(path.join(baseDir, dir, name)).isFile()
100105
)
101106
})
102-
if (readme_flag)
103-
temp.unshift('index.md')
104-
return temp.map(item => getSidebarItem(path.join(dir, item)))
105-
}
106-
catch {
107+
if (readme_flag) temp.unshift('index.md')
108+
return temp.map((item) => getSidebarItem(path.join(dir, item)))
109+
} catch {
107110
return []
108111
}
109112
}
@@ -161,10 +164,9 @@ function sidebarDevelop(): DefaultTheme.SidebarItem[] {
161164
{
162165
text: '开发者指南',
163166
collapsed: false,
164-
items: [
165-
'/develop/plugin.md',
166-
'/develop/contributing.md',
167-
].map(getSidebarItem),
167+
items: ['/develop/plugin.md', '/develop/contributing.md'].map(
168+
getSidebarItem,
169+
),
168170
},
169171
]
170172
}
Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
<script setup lang="ts">
2-
import type { MetaData, PyPIData } from './types'
32
import { onMounted, ref } from 'vue'
3+
import type { MetaData, PyPIData } from './types'
44
55
const props = defineProps<{ item: MetaData }>()
66
77
const pypiJson = ref<PyPIData | undefined>(undefined)
8-
const description = ref<string >()
9-
const author = ref<string >('')
10-
const homepage = ref<string >('')
11-
const tags = ref<string[] >([])
8+
const description = ref<string>()
9+
const author = ref<string>('')
10+
const homepage = ref<string>('')
11+
const tags = ref<string[]>([])
1212
1313
const openHomepageLink = () => window.open(homepage.value)
1414
1515
async function copyInstallLink() {
16-
if ('pypi_name' in props.item)
16+
if ('pypi_name' in props.item) {
1717
await navigator.clipboard.writeText(`pip install ${props.item.pypi_name}`)
18+
}
1819
}
1920
2021
onMounted(async () => {
2122
if (!('pypi_name' in props.item)) {
2223
description.value = props.item.description
2324
author.value = props.item.author
2425
homepage.value = props.item.homepage
25-
tags.value = props.item.tags.split(/[,\s]/).filter(tag => tag !== '')
26+
tags.value = props.item.tags.split(/[,\s]/).filter((tag) => tag !== '')
2627
return
2728
}
2829
@@ -31,14 +32,20 @@ onMounted(async () => {
3132
).json()
3233
if (pypiJson.value != null) {
3334
description.value = pypiJson.value.info.summary
34-
if (pypiJson.value.info.author?.length)
35+
if (pypiJson.value.info.author?.length) {
3536
author.value = pypiJson.value.info.author
36-
else
37-
author.value = pypiJson.value.info.author_email.match(/([^<>]*)<.*?>/)?.[1].trim() ?? ''
38-
homepage.value = pypiJson.value.info.project_urls.Repository ?? pypiJson.value.info.project_urls.Homepage ?? ''
39-
tags.value = pypiJson.value.info.keywords
40-
.split(/[,\s]/)
41-
.filter(tag => tag !== '') ?? []
37+
} else {
38+
author.value =
39+
pypiJson.value.info.author_email.match(/([^<>]*)<.*?>/)?.[1].trim() ??
40+
''
41+
}
42+
homepage.value =
43+
pypiJson.value.info.project_urls.Repository ??
44+
pypiJson.value.info.project_urls.Homepage ??
45+
''
46+
tags.value =
47+
pypiJson.value.info.keywords.split(/[,\s]/).filter((tag) => tag !== '') ??
48+
[]
4249
}
4350
})
4451
</script>
@@ -50,15 +57,25 @@ onMounted(async () => {
5057
<div class="flex justify-between">
5158
<div class="flex items-center font-bold">
5259
{{ item.name }}
53-
<div v-if="item.is_official" class="i-mdi-check-decagram ml-1 h-5 w-5 text-vp-brand-1" />
60+
<div
61+
v-if="item.is_official"
62+
class="i-mdi-check-decagram ml-1 h-5 w-5 text-vp-brand-1"
63+
/>
5464
</div>
55-
<div class="i-mdi-github h-8 w-8 cursor-pointer text-vp-neutral hover:text-vp-brand-1" @click="openHomepageLink" />
65+
<div
66+
class="i-mdi-github h-8 w-8 cursor-pointer text-vp-neutral hover:text-vp-brand-1"
67+
@click="openHomepageLink"
68+
/>
5669
</div>
5770
<div class="my-1 text-sm text-vp-text-2">
5871
{{ description }}
5972
</div>
6073
<div v-if="tags?.length" class="mt-2 flex flex-wrap gap-2 text-sm">
61-
<div v-for="(tag, index) in tags" :key="index" class="rounded bg-vp-default-soft px-2 py-0.5">
74+
<div
75+
v-for="(tag, index) in tags"
76+
:key="index"
77+
class="rounded bg-vp-default-soft px-2 py-0.5"
78+
>
6279
{{ tag }}
6380
</div>
6481
</div>
Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
2-
import type { MetaData } from './types'
32
import { computed, ref, watchEffect } from 'vue'
4-
import Card from './Card.vue'
5-
import Pagination from './Pagination.vue'
3+
import StoreCard from './StoreCard.vue'
4+
import StorePagination from './StorePagination.vue'
5+
import type { MetaData } from './types'
66
77
enum StoreType {
88
Plugins = 'plugins',
@@ -15,53 +15,71 @@ const dataItems = ref<MetaData[]>([])
1515
1616
const searchText = ref<string>('')
1717
const searchedItems = computed<MetaData[]>(() => {
18-
if (searchText.value)
19-
return dataItems.value.filter(item => item.name.includes(searchText.value))
18+
if (searchText.value) {
19+
return dataItems.value.filter((item) =>
20+
item.name.includes(searchText.value),
21+
)
22+
}
2023
return dataItems.value.toSorted((a, b) => b.time - a.time)
2124
})
2225
2326
const pageSize = 10
2427
const pageNumber = ref<number>(1)
25-
const pageTotal = computed<number>(() => Math.ceil(searchedItems.value.length / pageSize))
28+
const pageTotal = computed<number>(() =>
29+
Math.ceil(searchedItems.value.length / pageSize),
30+
)
2631
const pageItems = computed(() => {
27-
if (searchedItems.value.length === 0)
32+
if (searchedItems.value.length === 0) {
2833
return []
34+
}
2935
return searchedItems.value.slice(
3036
(pageNumber.value - 1) * pageSize,
3137
pageNumber.value * pageSize,
3238
)
3339
})
3440
3541
watchEffect(async () => {
36-
dataItems.value = await (await fetch(`https://store.alicebot.dev/${storeType.value}.json`)).json()
42+
dataItems.value = await (
43+
await fetch(`https://store.alicebot.dev/${storeType.value}.json`)
44+
).json()
3745
searchText.value = ''
3846
})
3947
</script>
4048

4149
<template>
4250
<div>
4351
<div class="mt-10 flex items-center text-sm text-vp-text-1">
44-
<div class="mr-8">
45-
类型
46-
</div>
52+
<div class="mr-8">类型</div>
4753
<div class="flex flex-wrap gap-2">
4854
<button
4955
class="cursor-pointer rounded bg-vp-bg-soft px-2 py-0.5 hover:bg-vp-brand-soft hover:text-vp-brand-1"
50-
:class="storeType === StoreType.Plugins ? 'bg-vp-brand-soft text-vp-brand-1' : ''"
56+
:class="
57+
storeType === StoreType.Plugins
58+
? 'bg-vp-brand-soft text-vp-brand-1'
59+
: ''
60+
"
5161
@click="storeType = StoreType.Plugins"
5262
>
5363
插件
5464
</button>
5565
<button
5666
class="cursor-pointer rounded bg-vp-bg-soft px-2 py-0.5 hover:bg-vp-brand-soft hover:text-vp-brand-1"
57-
:class="storeType === StoreType.Adapters ? 'bg-vp-brand-soft text-vp-brand-1' : ''"
67+
:class="
68+
storeType === StoreType.Adapters
69+
? 'bg-vp-brand-soft text-vp-brand-1'
70+
: ''
71+
"
5872
@click="storeType = StoreType.Adapters"
5973
>
6074
适配器
6175
</button>
6276
<button
6377
class="cursor-pointer rounded bg-vp-bg-soft px-2 py-0.5 hover:bg-vp-brand-soft hover:text-vp-brand-1"
64-
:class="storeType === StoreType.Bots ? 'bg-vp-brand-soft text-vp-brand-1' : ''"
78+
:class="
79+
storeType === StoreType.Bots
80+
? 'bg-vp-brand-soft text-vp-brand-1'
81+
: ''
82+
"
6583
@click="storeType = StoreType.Bots"
6684
>
6785
机器人
@@ -78,14 +96,26 @@ watchEffect(async () => {
7896
type="text"
7997
role="search"
8098
placeholder="Search..."
81-
>
99+
/>
82100
</div>
83101
<div class="h-px bg-neutral-700 opacity-15" />
84102
</div>
85-
<Pagination key="topPagination" v-model="pageNumber" :total="pageTotal" />
103+
<StorePagination
104+
key="topPagination"
105+
v-model="pageNumber"
106+
:total="pageTotal"
107+
/>
86108
<div class="grid grid-cols-1 gap-6 md:grid-cols-2">
87-
<Card v-for="(item, index) in pageItems" :key="index.toString() + item.name" :item="item" />
109+
<StoreCard
110+
v-for="(item, index) in pageItems"
111+
:key="index.toString() + item.name"
112+
:item="item"
113+
/>
88114
</div>
89-
<Pagination key="bottomPagination" v-model="pageNumber" :total="pageTotal" />
115+
<Pagination
116+
key="bottomPagination"
117+
v-model="pageNumber"
118+
:total="pageTotal"
119+
/>
90120
</div>
91121
</template>

0 commit comments

Comments
 (0)