Skip to content

Commit

Permalink
refactor: 修正所有eslint问题
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Oct 27, 2023
1 parent 27829b6 commit 37831d1
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 145 deletions.
1 change: 0 additions & 1 deletion config/default/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Created by bangbang93 on 2017/4/28.
*/
'use strict'
/* eslint-disable @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires */

const streams = [
{
Expand Down
69 changes: 10 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
"vue-tsc": "^1.8.20"
},
"dependencies": {
"@element-plus/icons-vue": "^2.1.0",
"element-plus": "^2.4.1",
"font-awesome": "^4.7.0",
"ky": "^1.1.0",
"mavon-editor": "^3.0.1",
"vue": "^3.3.6",
"vue-fetch": "^2.0.0",
"vue-fetch": "^3.0.0-2",
"vue-router": "^4.2.5"
}
}
24 changes: 18 additions & 6 deletions packages/admin/src/components/attachment-card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,35 @@
</el-card>
</template>

<script>
export default {
<script lang="ts">
import {defineComponent, PropType} from 'vue'
interface IAttachment {
_id: string
path: string
filename: string
createdAt: string
}
export default defineComponent({
name: 'FreyjaAttachmentCard',
props: {
attachment: Object,
attachment: {
type: Object as PropType<IAttachment>,
required: true,
},
},
computed: {
time() {
return new Date(this.attachment.createdAt).toLocaleString()
},
},
methods: {
view(path) {
window.location.href = path
view(path: string) {
window.open(path)
},
},
}
})
</script>

<style lang="scss" scoped>
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/pages/article/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ export default defineComponent({
article.tags = article.tags || []
this.article = article
this.edit.id = article._id
;(this.$refs.categories as typeof ElTree).setCheckedKeys(article.categories)
;(this.$refs.categories as InstanceType<typeof ElTree>).setCheckedKeys(article.categories)
},
async submit() {
const data = {...this.article}
data.attachments = this.attachments
data.categories = (this.$refs.categories as typeof ElTree).getCheckedKeys() as string[]
data.categories = (this.$refs.categories as InstanceType<typeof ElTree>).getCheckedKeys() as string[]
let resp
if (this.edit.id) {
resp = await this.$fetch.put(`/api/admin/article/${this.edit.id}`, data)
Expand Down
35 changes: 22 additions & 13 deletions packages/admin/src/pages/article/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,21 @@
</div>
</template>

<script>
export default {
<script lang="ts">
import {ElMessageBox} from 'element-plus'
import {defineComponent} from 'vue'
interface IArticle {
_id: string
content: string
createdAt: string
}
export default defineComponent({
name: 'FreyjaArticleList',
data() {
return {
articles: [],
articles: [] as IArticle[],
pageSize: 20,
total: 0,
currentPage: 1,
Expand All @@ -61,26 +70,26 @@ export default {
let resp = await this.$fetch.get('/api/admin/article', {
page: this.currentPage,
})
let body = await resp.json()
const body = await resp.json() as IArticle[]
body.forEach((article) => {
article.createdAt = new Date(article.createdAt).toLocaleString()
})
this.articles = body
resp = await this.$fetch.get('/api/admin/article/count')
body = await resp.json()
this.total = body.count
const body1 = await resp.json() as {count: number}
this.total = body1.count
},
handleEdit($index, row) {
handleEdit(_: number, row: IArticle) {
this.$router.push({
name: 'article.edit',
params: {
id: row._id,
},
})
},
async handleDelete($index, row) {
async handleDelete(_: number, row: IArticle) {
try {
const result = await this.$confirm('确定删除', 'Freyja')
const result = await ElMessageBox.confirm('确定删除', 'Freyja')
if (result === 'confirm') {
const resp = await this.$fetch.del(`/api/admin/article/${row._id}`)
if (resp.status === 204) {
Expand All @@ -96,12 +105,12 @@ export default {
async onRerenderAllClick() {
const resp = await this.$fetch.get('/api/admin/article/rerender-all')
if (resp.status === 200) {
this.$alert('渲染成功')
await ElMessageBox.alert('渲染成功')
} else {
const body = await resp.json()
this.$alert(body.message || body.msg)
const body = await resp.json() as Record<string, string>
await ElMessageBox.alert(body.message || body.msg)
}
},
},
}
})
</script>
19 changes: 12 additions & 7 deletions packages/admin/src/pages/attachment/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,24 @@
</div>
</template>

<script>
<script lang="ts">
import {Upload as ElIconUpload} from '@element-plus/icons-vue'
import {defineComponent} from 'vue'
import FreyjaAttachmentCard from '../../components/attachment-card.vue'
export default {
interface IAttachment {
_id: string
}
export default defineComponent({
name: 'FreyjaAttachmentList',
components: {
FreyjaAttachmentCard,
ElIconUpload,
},
data() {
return {
attachments: [],
attachments: [] as IAttachment[],
pageSize: 20,
total: 0,
currentPage: 1,
Expand All @@ -60,14 +65,14 @@ export default {
methods: {
async initData() {
let resp = await this.$fetch.get('/api/admin/attachment')
let body = await resp.json()
const body = await resp.json() as IAttachment[]
this.attachments = body
resp = await this.$fetch.get('/api/admin/attachment/count')
body = await resp.json()
this.total = body.count
const body1 = await resp.json() as {count: number}
this.total = body1.count
},
},
}
})
</script>

<style lang="scss" scoped>
Expand Down
19 changes: 13 additions & 6 deletions packages/admin/src/pages/comment/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@
</div>
</template>

<script>
export default {
<script lang="ts">
import {defineComponent} from 'vue'
interface IComment {
_id: string
content: string
}
export default defineComponent({
name: 'FreyjaCommentList',
data() {
return {
comments: [],
comments: [] as IComment[],
currentPage: 1,
pageSize: 20,
total: 0,
Expand All @@ -52,14 +59,14 @@ export default {
const resp = await this.$fetch.get('/api/admin/comment', {
page: this.currentPage,
})
this.comments = await resp.json()
this.comments = await resp.json() as IComment[]
},
async handleDelete(index, row) {
async handleDelete(_: number, row: IComment) {
const resp = await this.$fetch.del(`/api/admin/comment/${row._id}`)
if (resp.status === 204) {
await this.initData()
}
},
},
}
})
</script>
Loading

0 comments on commit 37831d1

Please sign in to comment.