Skip to content

Commit

Permalink
chore: 更新依赖并修改 ESLint 和 Prettier 配置
Browse files Browse the repository at this point in the history
  • Loading branch information
st1020 committed Jan 19, 2025
1 parent c84e32b commit ecdf189
Show file tree
Hide file tree
Showing 13 changed files with 2,265 additions and 2,994 deletions.
4 changes: 0 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
pnpm-lock.yaml
docs/api/
docs/dev-api/
**/*.ts
**/*.js
**/*.vue
**/*.jsonc
10 changes: 9 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"semi": false,
"singleQuote": true
"singleQuote": true,
"overrides": [
{
"files": "*.jsonc",
"options": {
"trailingComma": "none"
}
}
]
}
44 changes: 1 addition & 43 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,5 @@
// Pytest
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,

// Enable the ESlint flat config support
"eslint.useFlatConfig": true,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"[javascript][typescript][vue]": {
"editor.codeActionsOnSave": {
"source.organizeImports": "never"
}
},

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off" },
{ "rule": "format/*", "severity": "off" },
{ "rule": "*-indent", "severity": "off" },
{ "rule": "*-spacing", "severity": "off" },
{ "rule": "*-spaces", "severity": "off" },
{ "rule": "*-order", "severity": "off" },
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml"
]
"python.testing.pytestEnabled": true
}
36 changes: 19 additions & 17 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ export default defineConfig({
['link', { rel: 'manifest', href: '/manifest.json' }],
['meta', { name: 'theme-color', content: '#ffffff' }],
['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }],
['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }],
[
'meta',
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black' },
],
['link', { rel: 'apple-touch-icon', href: '/icons/apple-touch-icon.png' }],
['link', { rel: 'mask-icon', href: '/icons/safari-pinned-tab.svg' }],
['meta', { name: 'msapplication-TileImage', content: '/icons/mstile-150x150.png' }],
[
'meta',
{ name: 'msapplication-TileImage', content: '/icons/mstile-150x150.png' },
],
['meta', { name: 'msapplication-TileColor', content: '#2d89ef' }],
],

Expand All @@ -48,7 +54,8 @@ export default defineConfig({
},

editLink: {
pattern: 'https://github.com/AliceBotProject/alicebot/edit/master/docs/:path',
pattern:
'https://github.com/AliceBotProject/alicebot/edit/master/docs/:path',
text: '在 GitHub 上编辑此页',
},

Expand All @@ -65,9 +72,7 @@ export default defineConfig({
},

vite: {
plugins: [
Unocss(),
],
plugins: [Unocss()],
},
})

Expand Down Expand Up @@ -95,15 +100,13 @@ function getSidebarChildrenItems(dir: string): DefaultTheme.SidebarItem[] {
return false
}
return (
!name.startsWith('.')
&& fs.statSync(path.join(baseDir, dir, name)).isFile()
!name.startsWith('.') &&
fs.statSync(path.join(baseDir, dir, name)).isFile()
)
})
if (readme_flag)
temp.unshift('index.md')
return temp.map(item => getSidebarItem(path.join(dir, item)))
}
catch {
if (readme_flag) temp.unshift('index.md')
return temp.map((item) => getSidebarItem(path.join(dir, item)))
} catch {
return []
}
}
Expand Down Expand Up @@ -161,10 +164,9 @@ function sidebarDevelop(): DefaultTheme.SidebarItem[] {
{
text: '开发者指南',
collapsed: false,
items: [
'/develop/plugin.md',
'/develop/contributing.md',
].map(getSidebarItem),
items: ['/develop/plugin.md', '/develop/contributing.md'].map(
getSidebarItem,
),
},
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
<script setup lang="ts">
import type { MetaData, PyPIData } from './types'
import { onMounted, ref } from 'vue'
import type { MetaData, PyPIData } from './types'
const props = defineProps<{ item: MetaData }>()
const pypiJson = ref<PyPIData | undefined>(undefined)
const description = ref<string >()
const author = ref<string >('')
const homepage = ref<string >('')
const tags = ref<string[] >([])
const description = ref<string>()
const author = ref<string>('')
const homepage = ref<string>('')
const tags = ref<string[]>([])
const openHomepageLink = () => window.open(homepage.value)
async function copyInstallLink() {
if ('pypi_name' in props.item)
if ('pypi_name' in props.item) {
await navigator.clipboard.writeText(`pip install ${props.item.pypi_name}`)
}
}
onMounted(async () => {
if (!('pypi_name' in props.item)) {
description.value = props.item.description
author.value = props.item.author
homepage.value = props.item.homepage
tags.value = props.item.tags.split(/[,\s]/).filter(tag => tag !== '')
tags.value = props.item.tags.split(/[,\s]/).filter((tag) => tag !== '')
return
}
Expand All @@ -31,14 +32,20 @@ onMounted(async () => {
).json()
if (pypiJson.value != null) {
description.value = pypiJson.value.info.summary
if (pypiJson.value.info.author?.length)
if (pypiJson.value.info.author?.length) {
author.value = pypiJson.value.info.author
else
author.value = pypiJson.value.info.author_email.match(/([^<>]*)<.*?>/)?.[1].trim() ?? ''
homepage.value = pypiJson.value.info.project_urls.Repository ?? pypiJson.value.info.project_urls.Homepage ?? ''
tags.value = pypiJson.value.info.keywords
.split(/[,\s]/)
.filter(tag => tag !== '') ?? []
} else {
author.value =
pypiJson.value.info.author_email.match(/([^<>]*)<.*?>/)?.[1].trim() ??
''
}
homepage.value =
pypiJson.value.info.project_urls.Repository ??
pypiJson.value.info.project_urls.Homepage ??
''
tags.value =
pypiJson.value.info.keywords.split(/[,\s]/).filter((tag) => tag !== '') ??
[]
}
})
</script>
Expand All @@ -50,15 +57,25 @@ onMounted(async () => {
<div class="flex justify-between">
<div class="flex items-center font-bold">
{{ item.name }}
<div v-if="item.is_official" class="i-mdi-check-decagram ml-1 h-5 w-5 text-vp-brand-1" />
<div
v-if="item.is_official"
class="i-mdi-check-decagram ml-1 h-5 w-5 text-vp-brand-1"
/>
</div>
<div class="i-mdi-github h-8 w-8 cursor-pointer text-vp-neutral hover:text-vp-brand-1" @click="openHomepageLink" />
<div
class="i-mdi-github h-8 w-8 cursor-pointer text-vp-neutral hover:text-vp-brand-1"
@click="openHomepageLink"
/>
</div>
<div class="my-1 text-sm text-vp-text-2">
{{ description }}
</div>
<div v-if="tags?.length" class="mt-2 flex flex-wrap gap-2 text-sm">
<div v-for="(tag, index) in tags" :key="index" class="rounded bg-vp-default-soft px-2 py-0.5">
<div
v-for="(tag, index) in tags"
:key="index"
class="rounded bg-vp-default-soft px-2 py-0.5"
>
{{ tag }}
</div>
</div>
Expand Down
66 changes: 48 additions & 18 deletions docs/store/components/StoreList.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { MetaData } from './types'
import { computed, ref, watchEffect } from 'vue'
import Card from './Card.vue'
import Pagination from './Pagination.vue'
import StoreCard from './StoreCard.vue'
import StorePagination from './StorePagination.vue'
import type { MetaData } from './types'
enum StoreType {
Plugins = 'plugins',
Expand All @@ -15,53 +15,71 @@ const dataItems = ref<MetaData[]>([])
const searchText = ref<string>('')
const searchedItems = computed<MetaData[]>(() => {
if (searchText.value)
return dataItems.value.filter(item => item.name.includes(searchText.value))
if (searchText.value) {
return dataItems.value.filter((item) =>
item.name.includes(searchText.value),
)
}
return dataItems.value.toSorted((a, b) => b.time - a.time)
})
const pageSize = 10
const pageNumber = ref<number>(1)
const pageTotal = computed<number>(() => Math.ceil(searchedItems.value.length / pageSize))
const pageTotal = computed<number>(() =>
Math.ceil(searchedItems.value.length / pageSize),
)
const pageItems = computed(() => {
if (searchedItems.value.length === 0)
if (searchedItems.value.length === 0) {
return []
}
return searchedItems.value.slice(
(pageNumber.value - 1) * pageSize,
pageNumber.value * pageSize,
)
})
watchEffect(async () => {
dataItems.value = await (await fetch(`https://store.alicebot.dev/${storeType.value}.json`)).json()
dataItems.value = await (
await fetch(`https://store.alicebot.dev/${storeType.value}.json`)
).json()
searchText.value = ''
})
</script>

<template>
<div>
<div class="mt-10 flex items-center text-sm text-vp-text-1">
<div class="mr-8">
类型
</div>
<div class="mr-8">类型</div>
<div class="flex flex-wrap gap-2">
<button
class="cursor-pointer rounded bg-vp-bg-soft px-2 py-0.5 hover:bg-vp-brand-soft hover:text-vp-brand-1"
:class="storeType === StoreType.Plugins ? 'bg-vp-brand-soft text-vp-brand-1' : ''"
:class="
storeType === StoreType.Plugins
? 'bg-vp-brand-soft text-vp-brand-1'
: ''
"
@click="storeType = StoreType.Plugins"
>
插件
</button>
<button
class="cursor-pointer rounded bg-vp-bg-soft px-2 py-0.5 hover:bg-vp-brand-soft hover:text-vp-brand-1"
:class="storeType === StoreType.Adapters ? 'bg-vp-brand-soft text-vp-brand-1' : ''"
:class="
storeType === StoreType.Adapters
? 'bg-vp-brand-soft text-vp-brand-1'
: ''
"
@click="storeType = StoreType.Adapters"
>
适配器
</button>
<button
class="cursor-pointer rounded bg-vp-bg-soft px-2 py-0.5 hover:bg-vp-brand-soft hover:text-vp-brand-1"
:class="storeType === StoreType.Bots ? 'bg-vp-brand-soft text-vp-brand-1' : ''"
:class="
storeType === StoreType.Bots
? 'bg-vp-brand-soft text-vp-brand-1'
: ''
"
@click="storeType = StoreType.Bots"
>
机器人
Expand All @@ -78,14 +96,26 @@ watchEffect(async () => {
type="text"
role="search"
placeholder="Search..."
>
/>
</div>
<div class="h-px bg-neutral-700 opacity-15" />
</div>
<Pagination key="topPagination" v-model="pageNumber" :total="pageTotal" />
<StorePagination
key="topPagination"
v-model="pageNumber"
:total="pageTotal"
/>
<div class="grid grid-cols-1 gap-6 md:grid-cols-2">
<Card v-for="(item, index) in pageItems" :key="index.toString() + item.name" :item="item" />
<StoreCard
v-for="(item, index) in pageItems"
:key="index.toString() + item.name"
:item="item"
/>
</div>
<Pagination key="bottomPagination" v-model="pageNumber" :total="pageTotal" />
<Pagination
key="bottomPagination"
v-model="pageNumber"
:total="pageTotal"
/>
</div>
</template>
Loading

0 comments on commit ecdf189

Please sign in to comment.