refactor: optimized loading of newer versions of the about page. (#211)

pull/212/head
Ryan Wang 2020-07-11 16:56:29 +08:00 committed by GitHub
parent 7b06be9e0d
commit 014413ef48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 289 additions and 207 deletions

34
package-lock.json generated
View File

@ -1349,6 +1349,22 @@
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==", "integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==",
"dev": true "dev": true
}, },
"@simonwep/pickr": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/@simonwep/pickr/-/pickr-1.7.1.tgz",
"integrity": "sha512-ftbskrPKAkRLYVj8IhV4Bn86g16It9Uq/p4G0FdjRz36pKKjW0JdxdDWDIVuAev0Urg8604Ho98js6JmjXdiZQ==",
"requires": {
"core-js": "^3.6.5",
"nanopop": "^1.3.0"
},
"dependencies": {
"core-js": {
"version": "3.6.5",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.5.tgz",
"integrity": "sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA=="
}
}
},
"@soda/friendly-errors-webpack-plugin": { "@soda/friendly-errors-webpack-plugin": {
"version": "1.7.1", "version": "1.7.1",
"resolved": "https://registry.npmjs.org/@soda/friendly-errors-webpack-plugin/-/friendly-errors-webpack-plugin-1.7.1.tgz", "resolved": "https://registry.npmjs.org/@soda/friendly-errors-webpack-plugin/-/friendly-errors-webpack-plugin-1.7.1.tgz",
@ -2801,12 +2817,13 @@
} }
}, },
"ant-design-vue": { "ant-design-vue": {
"version": "1.6.2", "version": "1.6.3",
"resolved": "https://registry.npmjs.org/ant-design-vue/-/ant-design-vue-1.6.2.tgz", "resolved": "https://registry.npmjs.org/ant-design-vue/-/ant-design-vue-1.6.3.tgz",
"integrity": "sha512-VEwWomHxY+0rt0RKRd4FqrW+udCr7cpFt0GwVOCJPwIdulkZkB3GjK64GslEl9XtBp/rKzcorfAx4t1ues6Izg==", "integrity": "sha512-Zt0z0SXzHCgow0chv4OA8lONxVOzXf7iLmZxdVHlsS3IaPn5n8QNPCzBUh3z0IXBdaDPiX9tjELQCXf9vdXdlw==",
"requires": { "requires": {
"@ant-design/icons": "^2.1.1", "@ant-design/icons": "^2.1.1",
"@ant-design/icons-vue": "^2.0.0", "@ant-design/icons-vue": "^2.0.0",
"@simonwep/pickr": "~1.7.0",
"add-dom-event-listener": "^1.0.2", "add-dom-event-listener": "^1.0.2",
"array-tree-filter": "^2.1.0", "array-tree-filter": "^2.1.0",
"async-validator": "^3.0.3", "async-validator": "^3.0.3",
@ -10729,9 +10746,9 @@
} }
}, },
"lodash": { "lodash": {
"version": "4.17.15", "version": "4.17.19",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ=="
}, },
"lodash.defaultsdeep": { "lodash.defaultsdeep": {
"version": "4.6.1", "version": "4.6.1",
@ -11363,6 +11380,11 @@
"to-regex": "^3.0.1" "to-regex": "^3.0.1"
} }
}, },
"nanopop": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/nanopop/-/nanopop-1.3.0.tgz",
"integrity": "sha512-DQDhHyPhKLKrXOjVkChsAoWh/WpKuVINDKl4qvFbguqokRJWQBSNSlPzMS+Xy3yBQKeQ39rICMB2asDvdUiVxw=="
},
"natural-compare": { "natural-compare": {
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",

View File

@ -9,7 +9,7 @@
"test:unit": "vue-cli-service test:unit" "test:unit": "vue-cli-service test:unit"
}, },
"dependencies": { "dependencies": {
"ant-design-vue": "^1.6.2", "ant-design-vue": "^1.6.3",
"axios": "^0.19.2", "axios": "^0.19.2",
"enquire.js": "^2.1.6", "enquire.js": "^2.1.6",
"filepond": "^4.18.0", "filepond": "^4.18.0",

View File

@ -1,14 +1,15 @@
import Vue from 'vue' import Vue from 'vue'
// pro components
import Ellipsis from '@/components/Ellipsis' import Ellipsis from '@/components/Ellipsis'
import FooterToolbar from '@/components/FooterToolbar' import FooterToolbar from '@/components/FooterToolbar'
import FilePondUpload from '@/components/Upload/FilePondUpload' import FilePondUpload from '@/components/Upload/FilePondUpload'
import AttachmentSelectDrawer from './Attachment/AttachmentSelectDrawer'
const _components = { const _components = {
Ellipsis, Ellipsis,
FooterToolbar, FooterToolbar,
FilePondUpload FilePondUpload,
AttachmentSelectDrawer
} }
const components = {} const components = {}

View File

@ -35,6 +35,8 @@
<a-select <a-select
v-model="queryParam.attachmentType" v-model="queryParam.attachmentType"
@change="handleQuery()" @change="handleQuery()"
:loading="typesLoading"
allowClear
> >
<a-select-option <a-select-option
v-for="item in types" v-for="item in types"
@ -54,6 +56,8 @@
<a-select <a-select
v-model="queryParam.mediaType" v-model="queryParam.mediaType"
@change="handleQuery()" @change="handleQuery()"
:loading="mediaTypesLoading"
allowClear
> >
<a-select-option <a-select-option
v-for="(item, index) in mediaTypes" v-for="(item, index) in mediaTypes"
@ -219,7 +223,9 @@ export default {
selectAttachment: {}, selectAttachment: {},
attachments: [], attachments: [],
mediaTypes: [], mediaTypes: [],
mediaTypesLoading: false,
types: [], types: [],
typesLoading: false,
editable: false, editable: false,
pagination: { pagination: {
page: 1, page: 1,
@ -288,14 +294,30 @@ export default {
}) })
}, },
loadMediaTypes() { loadMediaTypes() {
attachmentApi.getMediaTypes().then(response => { this.mediaTypesLoading = true
attachmentApi
.getMediaTypes()
.then(response => {
this.mediaTypes = response.data.data this.mediaTypes = response.data.data
}) })
.finally(() => {
setTimeout(() => {
this.mediaTypesLoading = false
}, 200)
})
}, },
loadTypes() { loadTypes() {
attachmentApi.getTypes().then(response => { this.typesLoading = true
attachmentApi
.getTypes()
.then(response => {
this.types = response.data.data this.types = response.data.data
}) })
.finally(() => {
setTimeout(() => {
this.typesLoading = false
}, 200)
})
}, },
handleShowDetailDrawer(attachment) { handleShowDetailDrawer(attachment) {
this.selectAttachment = attachment this.selectAttachment = attachment

View File

@ -27,6 +27,7 @@
v-model="queryParam.status" v-model="queryParam.status"
placeholder="请选择评论状态" placeholder="请选择评论状态"
@change="handleQuery()" @change="handleQuery()"
allowClear
> >
<a-select-option <a-select-option
v-for="status in Object.keys(commentStatus)" v-for="status in Object.keys(commentStatus)"
@ -574,10 +575,16 @@ export default {
this.queryParam.page = this.pagination.page - 1 this.queryParam.page = this.pagination.page - 1
this.queryParam.size = this.pagination.size this.queryParam.size = this.pagination.size
this.queryParam.sort = this.pagination.sort this.queryParam.sort = this.pagination.sort
commentApi.queryComment(this.type, this.queryParam).then(response => { commentApi
.queryComment(this.type, this.queryParam)
.then(response => {
this.comments = response.data.data.content this.comments = response.data.data.content
this.pagination.total = response.data.data.total this.pagination.total = response.data.data.total
})
.finally(() => {
setTimeout(() => {
this.loading = false this.loading = false
}, 200)
}) })
}, },
handleQuery() { handleQuery() {

View File

@ -288,9 +288,9 @@ export default {
data() { data() {
return { return {
logType: logApi.logType, logType: logApi.logType,
activityLoading: true, activityLoading: false,
writeLoading: true, writeLoading: false,
logLoading: true, logLoading: false,
statisticsLoading: true, statisticsLoading: true,
logListDrawerVisible: false, logListDrawerVisible: false,
latestPosts: [], latestPosts: [],
@ -340,22 +340,43 @@ export default {
}, },
methods: { methods: {
async listLatestPosts() { async listLatestPosts() {
postApi.listLatest(5).then(response => { this.activityLoading = true
postApi
.listLatest(5)
.then(response => {
this.latestPosts = response.data.data this.latestPosts = response.data.data
})
.finally(() => {
setTimeout(() => {
this.activityLoading = false this.activityLoading = false
}, 200)
}) })
}, },
async listLatestLogs() { async listLatestLogs() {
logApi.listLatest(5).then(response => { this.logLoading = true
this.writeLoading = true
logApi
.listLatest(5)
.then(response => {
this.latestLogs = response.data.data this.latestLogs = response.data.data
})
.finally(() => {
setTimeout(() => {
this.logLoading = false this.logLoading = false
this.writeLoading = false this.writeLoading = false
}, 200)
}) })
}, },
async getStatistics() { async getStatistics() {
statisticsApi.statistics().then(response => { statisticsApi
.statistics()
.then(response => {
this.statisticsData = response.data.data this.statisticsData = response.data.data
})
.finally(() => {
setTimeout(() => {
this.statisticsLoading = false this.statisticsLoading = false
}, 200)
}) })
}, },
handleEditPostClick(post) { handleEditPostClick(post) {

View File

@ -196,9 +196,7 @@
>获取</a-button> >获取</a-button>
</a-form-item> </a-form-item>
</a-form> </a-form>
<a-tabs <a-tabs v-else>
v-else
>
<a-tab-pane <a-tab-pane
tab="稳定版" tab="稳定版"
key="1" key="1"
@ -341,9 +339,15 @@ export default {
methods: { methods: {
loadThemes() { loadThemes() {
this.themeLoading = true this.themeLoading = true
themeApi.listAll().then(response => { themeApi
.listAll()
.then(response => {
this.themes = response.data.data this.themes = response.data.data
})
.finally(() => {
setTimeout(() => {
this.themeLoading = false this.themeLoading = false
}, 200)
}) })
}, },
@ -398,9 +402,7 @@ export default {
return return
} }
this.fetchButtonLoading = true this.fetchButtonLoading = true
themeApi themeApi.fetchingBranches(this.fetchingUrl).then(response => {
.fetchingBranches(this.fetchingUrl)
.then(response => {
this.branches = response.data.data this.branches = response.data.data
this.fetchBranches = true this.fetchBranches = true
}) })
@ -414,18 +416,14 @@ export default {
}) })
}, },
handleBranchFetching() { handleBranchFetching() {
themeApi themeApi.fetchingBranch(this.fetchingUrl, this.branches[this.selectedBranch].branch).then(response => {
.fetchingBranch(this.fetchingUrl, this.branches[this.selectedBranch].branch)
.then(response => {
this.$message.success('拉取成功') this.$message.success('拉取成功')
this.uploadThemeVisible = false this.uploadThemeVisible = false
this.loadThemes() this.loadThemes()
}) })
}, },
handleReleaseFetching() { handleReleaseFetching() {
themeApi themeApi.fetchingRelease(this.fetchingUrl, this.releases[this.selectedBranch].branch).then(response => {
.fetchingRelease(this.fetchingUrl, this.releases[this.selectedBranch].branch)
.then(response => {
this.$message.success('拉取成功') this.$message.success('拉取成功')
this.uploadThemeVisible = false this.uploadThemeVisible = false
this.loadThemes() this.loadThemes()

View File

@ -231,6 +231,7 @@
<a-button <a-button
type="primary" type="primary"
@click="handleSaveSettings" @click="handleSaveSettings"
:loading="saving"
>保存</a-button> >保存</a-button>
</footer-tool-bar> </footer-tool-bar>
</a-drawer> </a-drawer>
@ -238,7 +239,6 @@
<script> <script>
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer'
import FooterToolBar from '@/components/FooterToolbar' import FooterToolBar from '@/components/FooterToolbar'
import Verte from 'verte' import Verte from 'verte'
import 'verte/dist/verte.css' import 'verte/dist/verte.css'
@ -247,7 +247,6 @@ export default {
name: 'ThemeSetting', name: 'ThemeSetting',
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
components: { components: {
AttachmentSelectDrawer,
FooterToolBar, FooterToolBar,
Verte Verte
}, },
@ -267,7 +266,8 @@ export default {
}, },
viewMode: false, viewMode: false,
formColValue: 12, formColValue: 12,
clientHeight: document.documentElement.clientHeight clientHeight: document.documentElement.clientHeight,
saving: false
} }
}, },
model: { model: {
@ -320,12 +320,20 @@ export default {
}) })
}, },
handleSaveSettings() { handleSaveSettings() {
themeApi.saveSettings(this.selectedTheme.id, this.themeSettings).then(response => { this.saving = true
themeApi
.saveSettings(this.selectedTheme.id, this.themeSettings)
.then(response => {
this.$message.success('保存成功!') this.$message.success('保存成功!')
if (this.viewMode) { if (this.viewMode) {
document.getElementById('themeViewIframe').contentWindow.location.reload(true) document.getElementById('themeViewIframe').contentWindow.location.reload(true)
} }
}) })
.finally(() => {
setTimeout(() => {
this.saving = false
}, 200)
})
}, },
onClose() { onClose() {
this.$emit('close', false) this.$emit('close', false)

View File

@ -249,7 +249,6 @@
<script> <script>
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import CategorySelectTree from './components/CategorySelectTree' import CategorySelectTree from './components/CategorySelectTree'
import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer'
import categoryApi from '@/api/category' import categoryApi from '@/api/category'
import menuApi from '@/api/menu' import menuApi from '@/api/menu'
@ -281,7 +280,7 @@ const columns = [
} }
] ]
export default { export default {
components: { CategorySelectTree, AttachmentSelectDrawer }, components: { CategorySelectTree },
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
data() { data() {
return { return {

View File

@ -74,7 +74,7 @@ import moment from 'moment'
import PostSettingDrawer from './components/PostSettingDrawer' import PostSettingDrawer from './components/PostSettingDrawer'
import AttachmentDrawer from '../attachment/components/AttachmentDrawer' import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
import FooterToolBar from '@/components/FooterToolbar' import FooterToolBar from '@/components/FooterToolbar'
import MarkdownEditor from '@/components/editor/MarkdownEditor' import MarkdownEditor from '@/components/Editor/MarkdownEditor'
// import RichTextEditor from '@/components/editor/RichTextEditor' // import RichTextEditor from '@/components/editor/RichTextEditor'
import postApi from '@/api/post' import postApi from '@/api/post'

View File

@ -27,6 +27,7 @@
v-model="queryParam.status" v-model="queryParam.status"
placeholder="请选择文章状态" placeholder="请选择文章状态"
@change="handleQuery()" @change="handleQuery()"
allowClear
> >
<a-select-option <a-select-option
v-for="status in Object.keys(postStatus)" v-for="status in Object.keys(postStatus)"
@ -45,6 +46,8 @@
v-model="queryParam.categoryId" v-model="queryParam.categoryId"
placeholder="请选择分类" placeholder="请选择分类"
@change="handleQuery()" @change="handleQuery()"
:loading="categoriesLoading"
allowClear
> >
<a-select-option <a-select-option
v-for="category in categories" v-for="category in categories"
@ -513,11 +516,11 @@
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import PostSettingDrawer from './components/PostSettingDrawer' import PostSettingDrawer from './components/PostSettingDrawer'
import TargetCommentDrawer from '../comment/components/TargetCommentDrawer' import TargetCommentDrawer from '../comment/components/TargetCommentDrawer'
import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer'
import TagSelect from './components/TagSelect' import TagSelect from './components/TagSelect'
import CategoryTree from './components/CategoryTree' import CategoryTree from './components/CategoryTree'
import categoryApi from '@/api/category' import categoryApi from '@/api/category'
import postApi from '@/api/post' import postApi from '@/api/post'
const columns = [ const columns = [
{ {
title: '标题', title: '标题',
@ -570,7 +573,6 @@ const columns = [
export default { export default {
name: 'PostList', name: 'PostList',
components: { components: {
AttachmentSelectDrawer,
TagSelect, TagSelect,
CategoryTree, CategoryTree,
PostSettingDrawer, PostSettingDrawer,
@ -606,6 +608,7 @@ export default {
], ],
posts: [], posts: [],
postsLoading: false, postsLoading: false,
categoriesLoading: false,
postSettingVisible: false, postSettingVisible: false,
postCommentVisible: false, postCommentVisible: false,
selectedPost: {}, selectedPost: {},
@ -665,16 +668,30 @@ export default {
this.queryParam.page = this.pagination.page - 1 this.queryParam.page = this.pagination.page - 1
this.queryParam.size = this.pagination.size this.queryParam.size = this.pagination.size
this.queryParam.sort = this.pagination.sort this.queryParam.sort = this.pagination.sort
postApi.query(this.queryParam).then(response => { postApi
.query(this.queryParam)
.then(response => {
this.posts = response.data.data.content this.posts = response.data.data.content
this.pagination.total = response.data.data.total this.pagination.total = response.data.data.total
})
.finally(() => {
setTimeout(() => {
this.postsLoading = false this.postsLoading = false
}, 200)
}) })
}, },
loadCategories() { loadCategories() {
categoryApi.listAll(true).then(response => { this.categoriesLoading = true
categoryApi
.listAll(true)
.then(response => {
this.categories = response.data.data this.categories = response.data.data
}) })
.finally(() => {
setTimeout(() => {
this.categoriesLoading = false
}, 200)
})
}, },
handleEditClick(post) { handleEditClick(post) {
this.$router.push({ name: 'PostEdit', query: { postId: post.id } }) this.$router.push({ name: 'PostEdit', query: { postId: post.id } })

View File

@ -122,10 +122,8 @@
<script> <script>
import tagApi from '@/api/tag' import tagApi from '@/api/tag'
import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer'
export default { export default {
components: { AttachmentSelectDrawer },
data() { data() {
return { return {
tags: [], tags: [],

View File

@ -309,7 +309,6 @@ import moment from 'moment'
import CategoryTree from './CategoryTree' import CategoryTree from './CategoryTree'
import CategorySelectTree from './CategorySelectTree' import CategorySelectTree from './CategorySelectTree'
import TagSelect from './TagSelect' import TagSelect from './TagSelect'
import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import categoryApi from '@/api/category' import categoryApi from '@/api/category'
import postApi from '@/api/post' import postApi from '@/api/post'
@ -320,8 +319,7 @@ export default {
components: { components: {
CategoryTree, CategoryTree,
CategorySelectTree, CategorySelectTree,
TagSelect, TagSelect
AttachmentSelectDrawer
}, },
data() { data() {
return { return {

View File

@ -69,7 +69,7 @@ import moment from 'moment'
import SheetSettingDrawer from './components/SheetSettingDrawer' import SheetSettingDrawer from './components/SheetSettingDrawer'
import AttachmentDrawer from '../attachment/components/AttachmentDrawer' import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
import FooterToolBar from '@/components/FooterToolbar' import FooterToolBar from '@/components/FooterToolbar'
import MarkdownEditor from '@/components/editor/MarkdownEditor' import MarkdownEditor from '@/components/Editor/MarkdownEditor'
// import RichTextEditor from '@/components/editor/RichTextEditor' // import RichTextEditor from '@/components/editor/RichTextEditor'
import sheetApi from '@/api/sheet' import sheetApi from '@/api/sheet'

View File

@ -440,10 +440,16 @@ export default {
this.queryParam.page = this.pagination.page - 1 this.queryParam.page = this.pagination.page - 1
this.queryParam.size = this.pagination.size this.queryParam.size = this.pagination.size
this.queryParam.sort = this.pagination.sort this.queryParam.sort = this.pagination.sort
sheetApi.list(this.queryParam).then(response => { sheetApi
.list(this.queryParam)
.then(response => {
this.sheets = response.data.data.content this.sheets = response.data.data.content
this.pagination.total = response.data.data.total this.pagination.total = response.data.data.total
})
.finally(() => {
setTimeout(() => {
this.loading = false this.loading = false
}, 200)
}) })
}, },
handleEditClick(sheet) { handleEditClick(sheet) {

View File

@ -16,9 +16,7 @@
> >
<template slot="actions"> <template slot="actions">
<span> <span>
<router-link <router-link :to="{name:item.routeName}">
:to="{name:item.routeName}"
>
<a-icon type="edit" /> <a-icon type="edit" />
</router-link> </router-link>
</span> </span>
@ -83,9 +81,7 @@
slot="action" slot="action"
slot-scope="text, record" slot-scope="text, record"
> >
<router-link <router-link :to="{name:record.routeName}">
:to="{name:record.routeName}"
>
<a href="javascript:void(0);">管理</a> <a href="javascript:void(0);">管理</a>
</router-link> </router-link>
<a-divider type="vertical" /> <a-divider type="vertical" />
@ -144,9 +140,15 @@ export default {
methods: { methods: {
loadIndependentSheets() { loadIndependentSheets() {
this.loading = true this.loading = true
sheetApi.listIndependent().then(response => { sheetApi
.listIndependent()
.then(response => {
this.independentSheets = response.data.data this.independentSheets = response.data.data
})
.finally(() => {
setTimeout(() => {
this.loading = false this.loading = false
}, 200)
}) })
} }
} }

View File

@ -216,16 +216,12 @@
<script> <script>
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import moment from 'moment' import moment from 'moment'
import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import themeApi from '@/api/theme' import themeApi from '@/api/theme'
import sheetApi from '@/api/sheet' import sheetApi from '@/api/sheet'
export default { export default {
name: 'SheetSettingDrawer', name: 'SheetSettingDrawer',
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
components: {
AttachmentSelectDrawer
},
data() { data() {
return { return {
thumbDrawerVisible: false, thumbDrawerVisible: false,

View File

@ -138,7 +138,10 @@
>保存</a-button> >保存</a-button>
</template> </template>
<a-form layout="vertical"> <a-form layout="vertical">
<a-form-item label="页面标题:" help="* 需要主题进行适配"> <a-form-item
label="页面标题:"
help="* 需要主题进行适配"
>
<a-input v-model="options.photos_title" /> <a-input v-model="options.photos_title" />
</a-form-item> </a-form-item>
<a-form-item label="每页显示条数:"> <a-form-item label="每页显示条数:">
@ -330,14 +333,10 @@
<script> <script>
import { mapActions } from 'vuex' import { mapActions } from 'vuex'
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer'
import photoApi from '@/api/photo' import photoApi from '@/api/photo'
import optionApi from '@/api/option' import optionApi from '@/api/option'
export default { export default {
components: {
AttachmentSelectDrawer
},
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
data() { data() {
return { return {

View File

@ -26,8 +26,11 @@
:title="isLatest?'当前为最新版本':'有新版本'" :title="isLatest?'当前为最新版本':'有新版本'"
> >
<template slot="content"> <template slot="content">
<p>{{ `当前版本:${environments.version}` }}{{ isLatest?`已经是最新版本。`:`新版本:${latestData.name},你可以点击下方按钮查看详情。` }}</p> <p>{{ versionMessage }}</p>
<a-button type="dashed" :href="latestData.html_url" target="_blank">查看详情</a-button> <a-button
type="dashed"
@click="handleShowVersionContent"
>查看详情</a-button>
</template> </template>
<a-button <a-button
:loading="checking" :loading="checking"
@ -90,17 +93,30 @@
</a-card> </a-card>
</a-card> </a-card>
</a-col> </a-col>
<a-col :span="24">
</a-col>
</a-row> </a-row>
<a-modal
:title="versionContentModalTitle"
:visible="versionContentVisible"
ok-text="查看更多"
@cancel="versionContentVisible=false"
@ok="handleOpenVersionUrl"
>
<div v-html="versionContent"></div>
</a-modal>
</div> </div>
</template> </template>
<script> <script>
import adminApi from '@/api/admin' import adminApi from '@/api/admin'
import axios from 'axios' import axios from 'axios'
import marked from 'marked'
export default { export default {
data() { data() {
return { return {
adminVersion: this.VERSION,
environments: {}, environments: {},
contributors: [ contributors: [
{ {
@ -128,35 +144,38 @@ export default {
contributorsLoading: true, contributorsLoading: true,
checking: false, checking: false,
isLatest: false, isLatest: false,
latestData: {} latestData: {},
versionContentVisible: false
}
},
computed: {
versionMessage() {
return `当前版本:${this.environments.version}${
this.isLatest ? '已经是最新版本。' : `新版本:${this.latestData.name},你可以点击下方按钮查看详情。`
}`
},
versionContent() {
if (this.latestData && this.latestData.body) {
return marked(this.latestData.body)
} else {
return '暂无内容'
}
},
versionContentModalTitle() {
return `${this.latestData.name} 更新内容`
} }
}, },
created() { created() {
this.getEnvironments() this.getEnvironments()
this.fetchContributors() this.fetchContributors()
this.checkServerUpdate()
// this.checkAdminUpdate()
}, },
methods: { methods: {
getEnvironments() { async getEnvironments() {
adminApi.environments().then(response => { await adminApi.environments().then(response => {
this.environments = response.data.data this.environments = response.data.data
}) })
this.checkServerUpdate()
}, },
// confirmUpdate() {
// this.updating = true
// adminApi
// .updateAdminAssets()
// .then(response => {
// this.$notification.success({
// message: '',
// description: ''
// })
// })
// .finally(() => {
// this.updating = false
// })
// },
handleCopyEnvironments() { handleCopyEnvironments() {
const text = `版本:${this.environments.version} const text = `版本:${this.environments.version}
数据库${this.environments.database} 数据库${this.environments.database}
@ -172,22 +191,26 @@ User Agent${navigator.userAgent}`
this.$message.error('复制失败!') this.$message.error('复制失败!')
}) })
}, },
async fetchContributors() { fetchContributors() {
this.contributorsLoading = true
const _this = this const _this = this
_this.contributorsLoading = true
axios axios
.get('https://api.github.com/repos/halo-dev/halo/contributors') .get('https://api.github.com/repos/halo-dev/halo/contributors')
.then(response => { .then(response => {
_this.contributors = response.data _this.contributors = response.data
this.contributorsLoading = false
}) })
.catch(function(error) { .catch(function(error) {
console.error('Fetch contributors error', error) console.error('Fetch contributors error', error)
}) })
.finally(() => {
setTimeout(() => {
_this.contributorsLoading = false
}, 200)
})
}, },
async checkServerUpdate() { checkServerUpdate() {
const _this = this const _this = this
this.checking = true _this.checking = true
axios axios
.get('https://api.github.com/repos/halo-dev/halo/releases/latest') .get('https://api.github.com/repos/halo-dev/halo/releases/latest')
.then(response => { .then(response => {
@ -202,11 +225,9 @@ User Agent${navigator.userAgent}`
_this.isLatest = true _this.isLatest = true
return return
} }
_this.isLatest = false
const title = '新版本提醒' const title = '新版本提醒'
const content = '检测到 Halo 新版本:' + data.name + ',点击下方按钮查看最新版本。' const content = '检测到 Halo 新版本:' + data.name + ',点击下方按钮查看最新版本。'
const url = data.html_url _this.$notification.open({
this.$notification.open({
message: title, message: title,
description: content, description: content,
icon: <a-icon type="smile" style="color: #108ee9" />, icon: <a-icon type="smile" style="color: #108ee9" />,
@ -219,7 +240,7 @@ User Agent${navigator.userAgent}`
size: 'small' size: 'small'
}, },
on: { on: {
click: () => window.open(url, '_blank') click: () => this.handleShowVersionContent()
} }
}, },
'去看看' '去看看'
@ -231,51 +252,17 @@ User Agent${navigator.userAgent}`
console.error('Check update fail', error) console.error('Check update fail', error)
}) })
.finally(() => { .finally(() => {
setTimeout(() => {
this.checking = false this.checking = false
}, 200)
}) })
}, },
// async checkAdminUpdate() { handleShowVersionContent() {
// const _this = this this.versionContentVisible = true
},
// axios handleOpenVersionUrl() {
// .get('https://api.github.com/repos/halo-dev/halo-admin/releases/latest') window.open(this.latestData.html_url, '_blank')
// .then(response => { },
// const data = response.data
// if (data.draft || data.prerelease) {
// return
// }
// const current = _this.calculateIntValue(_this.adminVersion)
// const latest = _this.calculateIntValue(data.name)
// if (current >= latest) {
// return
// }
// const title = ''
// const content = ' Admin ' + data.name + ''
// this.$notification.open({
// message: title,
// description: content,
// icon: <a-icon type="smile" style="color: #108ee9" />,
// btn: h => {
// return h(
// 'a-button',
// {
// props: {
// type: 'primary',
// size: 'small'
// },
// on: {
// click: () => _this.confirmUpdate()
// }
// },
// ''
// )
// }
// })
// })
// .catch(function(error) {
// console.error('Check update fail', error)
// })
// },
calculateIntValue(version) { calculateIntValue(version) {
version = version.replace(/v/g, '') version = version.replace(/v/g, '')
const ss = version.split('.') const ss = version.split('.')

View File

@ -27,6 +27,7 @@
v-model="queryParam.type" v-model="queryParam.type"
placeholder="请选择类型" placeholder="请选择类型"
@change="handleQuery()" @change="handleQuery()"
allowClear
> >
<a-select-option <a-select-option
v-for="item in Object.keys(optionType)" v-for="item in Object.keys(optionType)"
@ -224,7 +225,7 @@ export default {
size: 10, size: 10,
sort: null, sort: null,
keyword: null, keyword: null,
status: null type: null
}, },
optionToStage: {}, optionToStage: {},
loading: false, loading: false,

View File

@ -65,12 +65,8 @@
</template> </template>
<script> <script>
import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer'
export default { export default {
name: 'GeneralTab', name: 'GeneralTab',
components: {
AttachmentSelectDrawer
},
props: { props: {
options: { options: {
type: Object, type: Object,

View File

@ -234,7 +234,7 @@
:keyboard="false" :keyboard="false"
:centered="true" :centered="true"
:destroyOnClose="true" :destroyOnClose="true"
:width="300" :width="400"
> >
<a-form v-if="mfaUsed"> <a-form v-if="mfaUsed">
<a-form-item extra="* 需要验证两步验证码"> <a-form-item extra="* 需要验证两步验证码">
@ -255,8 +255,11 @@
<a-form v-else> <a-form v-else>
<a-form-item <a-form-item
label="1. 请扫描二维码或导入 key" label="1. 请扫描二维码或导入 key"
:extra="`MFAKey:${mfaParam.mfaKey}`" :help="`MFAKey:${mfaParam.mfaKey}`"
> >
<template slot="extra">
<span style="color:red">* 建议保存此二维码或 MFAKey验证设备丢失将无法找回只能通过重置密码关闭二步验证</span>
</template>
<img <img
width="100%" width="100%"
:src="mfaParam.qrImage" :src="mfaParam.qrImage"
@ -281,19 +284,15 @@
</template> </template>
<script> <script>
import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer'
import userApi from '@/api/user' import userApi from '@/api/user'
import statisticsApi from '@/api/statistics' import statisticsApi from '@/api/statistics'
import { mapMutations, mapGetters } from 'vuex' import { mapMutations, mapGetters } from 'vuex'
import MD5 from 'md5.js' import MD5 from 'md5.js'
export default { export default {
components: {
AttachmentSelectDrawer
},
data() { data() {
return { return {
statisticsLoading: true, statisticsLoading: false,
attachmentDrawerVisible: false, attachmentDrawerVisible: false,
user: {}, user: {},
statistics: {}, statistics: {},
@ -348,12 +347,17 @@ export default {
methods: { methods: {
...mapMutations({ setUser: 'SET_USER' }), ...mapMutations({ setUser: 'SET_USER' }),
getStatistics() { getStatistics() {
statisticsApi.statisticsWithUser().then(response => { this.statisticsLoading = true
statisticsApi
.statisticsWithUser()
.then(response => {
this.user = response.data.data.user this.user = response.data.data.user
this.statistics = response.data.data this.statistics = response.data.data
this.statisticsLoading = false
this.mfaParam.mfaType = this.user.mfaType && this.user.mfaType this.mfaParam.mfaType = this.user.mfaType && this.user.mfaType
}) })
.finally(() => {
this.statisticsLoading = false
}, 200)
}, },
handleUpdatePassword() { handleUpdatePassword() {
// Check confirm password // Check confirm password