refactor: refactor post preview and private post view.

pull/59/head
ruibaby 2019-12-19 17:50:23 +08:00
parent 1bed506ff7
commit c911ace252
12 changed files with 74 additions and 71 deletions

4
.npmignore Normal file
View File

@ -0,0 +1,4 @@
/node_modules/*
/.idea/*
/.git/*
/.github/*

View File

@ -1,7 +1,6 @@
{ {
"name": "halo-admin", "name": "halo-admin",
"version": "1.2.0-beta.1", "version": "1.2.0-beta.1",
"private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build", "build": "vue-cli-service build",
@ -126,5 +125,16 @@
"> 1%", "> 1%",
"last 2 versions", "last 2 versions",
"not ie <= 10" "not ie <= 10"
] ],
"description": "Halo admin client.",
"repository": {
"type": "git",
"url": "git+https://github.com/halo-dev/halo-admin.git"
},
"author": "halo-dev",
"license": "ISC",
"bugs": {
"url": "https://github.com/halo-dev/halo-admin/issues"
},
"homepage": "https://github.com/halo-dev/halo-admin#readme"
} }

View File

@ -116,4 +116,14 @@ adminApi.getLogFiles = lines => {
}) })
} }
adminApi.downloadLogFiles = lines => {
return service({
url: `${baseUrl}/halo/logfile/download`,
params: {
lines: lines
},
method: 'get'
})
}
export default adminApi export default adminApi

View File

@ -36,3 +36,12 @@ Vue.filter('fileSizeFormat', function(value) {
size = size.toFixed(2) size = size.toFixed(2)
return size + ' ' + unitArr[index] return size + ' ' + unitArr[index]
}) })
Vue.filter('dayTime', function(value) {
var days = Math.floor(value / 86400)
var hours = Math.floor((value % 86400) / 3600)
var minutes = Math.floor(((value % 86400) % 3600) / 60)
var seconds = Math.floor(((value % 86400) % 3600) % 60)
var duration = days + 'd ' + hours + 'h ' + minutes + 'm ' + seconds + 's'
return duration
})

View File

@ -122,17 +122,11 @@
> >
<a-list-item-meta> <a-list-item-meta>
<a <a
v-if="item.status=='PUBLISHED'" v-if="item.status=='PUBLISHED' || item.status == 'INTIMATE'"
slot="title" slot="title"
:href="options.blog_url+'/archives/'+item.url" :href="options.blog_url+'/archives/'+item.url"
target="_blank" target="_blank"
>{{ item.title }}</a> >{{ item.title }}</a>
<a
v-else-if="item.status == 'INTIMATE'"
slot="title"
:href="options.blog_url+'/archives/'+item.url+'/password'"
target="_blank"
>{{ item.title }}</a>
<a <a
v-else-if="item.status=='DRAFT'" v-else-if="item.status=='DRAFT'"
slot="title" slot="title"

View File

@ -18,13 +18,9 @@
:href="item.authorUrl" :href="item.authorUrl"
target="_blank" target="_blank"
>{{ item.author }}</a> 发表在 <a >{{ item.author }}</a> 发表在 <a
v-if="item.post.status=='PUBLISHED'" v-if="item.post.status=='PUBLISHED' || item.post.status=='INTIMATE'"
:href="options.blog_url+'/archives/'+item.post.url" :href="options.blog_url+'/archives/'+item.post.url"
target="_blank" target="_blank"
>{{ item.post.title }}</a><a
v-else-if="item.post.status=='INTIMATE'"
:href="options.blog_url+'/archives/'+item.post.url+'/password'"
target="_blank"
>{{ item.post.title }}</a><a >{{ item.post.title }}</a><a
v-else-if="item.post.status=='DRAFT'" v-else-if="item.post.status=='DRAFT'"
href="javascript:void(0)" href="javascript:void(0)"

View File

@ -236,7 +236,7 @@
style="margin-right: 3px;" style="margin-right: 3px;"
/> />
<a <a
v-if="item.status=='PUBLISHED'" v-if="item.status=='PUBLISHED' || item.status == 'INTIMATE'"
:href="options.blog_url+'/archives/'+item.url" :href="options.blog_url+'/archives/'+item.url"
target="_blank" target="_blank"
style="text-decoration: none;" style="text-decoration: none;"
@ -246,17 +246,6 @@
:title="'点击访问【'+item.title+'】'" :title="'点击访问【'+item.title+'】'"
>{{ item.title }}</a-tooltip> >{{ item.title }}</a-tooltip>
</a> </a>
<a
v-else-if="item.status == 'INTIMATE'"
:href="options.blog_url+'/archives/'+item.url+'/password'"
target="_blank"
style="text-decoration: none;"
>
<a-tooltip
placement="top"
:title="'点击访问【'+item.title+'】'"
>{{ item.title }}</a-tooltip>
</a>
<a <a
v-else-if="item.status=='DRAFT'" v-else-if="item.status=='DRAFT'"
href="javascript:void(0)" href="javascript:void(0)"
@ -328,7 +317,7 @@
style="margin-right: 3px;" style="margin-right: 3px;"
/> />
<a <a
v-if="record.status=='PUBLISHED'" v-if="record.status=='PUBLISHED' || record.status == 'INTIMATE'"
:href="options.blog_url+'/archives/'+record.url" :href="options.blog_url+'/archives/'+record.url"
target="_blank" target="_blank"
style="text-decoration: none;" style="text-decoration: none;"
@ -338,17 +327,6 @@
:title="'点击访问【'+text+'】'" :title="'点击访问【'+text+'】'"
>{{ text }}</a-tooltip> >{{ text }}</a-tooltip>
</a> </a>
<a
v-else-if="record.status == 'INTIMATE'"
:href="options.blog_url+'/archives/'+record.url+'/password'"
target="_blank"
style="text-decoration: none;"
>
<a-tooltip
placement="top"
:title="'点击访问【'+text+'】'"
>{{ text }}</a-tooltip>
</a>
<a <a
v-else-if="record.status=='DRAFT'" v-else-if="record.status=='DRAFT'"
href="javascript:void(0)" href="javascript:void(0)"

View File

@ -181,7 +181,7 @@
</a-menu-item> </a-menu-item>
<a-menu-item v-else-if="item.status === 'RECYCLE'"> <a-menu-item v-else-if="item.status === 'RECYCLE'">
<a-popconfirm <a-popconfirm
:title="'你确定要发布【' + item.title + '】文章'" :title="'你确定要发布【' + item.title + '】页面'"
@confirm="handleEditStatusClick(item.id,'PUBLISHED')" @confirm="handleEditStatusClick(item.id,'PUBLISHED')"
okText="确定" okText="确定"
cancelText="取消" cancelText="取消"
@ -191,7 +191,7 @@
</a-menu-item> </a-menu-item>
<a-menu-item v-if="item.status === 'PUBLISHED' || item.status === 'DRAFT'"> <a-menu-item v-if="item.status === 'PUBLISHED' || item.status === 'DRAFT'">
<a-popconfirm <a-popconfirm
:title="'你确定要将【' + item.title + '】文章移到回收站?'" :title="'你确定要将【' + item.title + '】页面移到回收站?'"
@confirm="handleEditStatusClick(item.id,'RECYCLE')" @confirm="handleEditStatusClick(item.id,'RECYCLE')"
okText="确定" okText="确定"
cancelText="取消" cancelText="取消"
@ -201,7 +201,7 @@
</a-menu-item> </a-menu-item>
<a-menu-item v-else-if="item.status === 'RECYCLE'"> <a-menu-item v-else-if="item.status === 'RECYCLE'">
<a-popconfirm <a-popconfirm
:title="'你确定要永久删除【' + item.title + '】文章'" :title="'你确定要永久删除【' + item.title + '】页面'"
@confirm="handleDeleteClick(item.id)" @confirm="handleDeleteClick(item.id)"
okText="确定" okText="确定"
cancelText="取消" cancelText="取消"
@ -245,13 +245,6 @@
slot="title" slot="title"
style="max-width: 300px;display: block;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" style="max-width: 300px;display: block;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"
> >
<a-icon
type="pushpin"
v-if="item.topPriority!=0"
theme="twoTone"
twoToneColor="red"
style="margin-right: 3px;"
/>
<a <a
v-if="item.status=='PUBLISHED'" v-if="item.status=='PUBLISHED'"
:href="options.blog_url+'/archives/'+item.url" :href="options.blog_url+'/archives/'+item.url"
@ -263,17 +256,6 @@
:title="'点击访问【'+item.title+'】'" :title="'点击访问【'+item.title+'】'"
>{{ item.title }}</a-tooltip> >{{ item.title }}</a-tooltip>
</a> </a>
<a
v-else-if="item.status == 'INTIMATE'"
:href="options.blog_url+'/archives/'+item.url+'/password'"
target="_blank"
style="text-decoration: none;"
>
<a-tooltip
placement="top"
:title="'点击访问【'+item.title+'】'"
>{{ item.title }}</a-tooltip>
</a>
<a <a
v-else-if="item.status=='DRAFT'" v-else-if="item.status=='DRAFT'"
href="javascript:void(0)" href="javascript:void(0)"

View File

@ -127,7 +127,7 @@ export default {
title: '版本要求', title: '版本要求',
alert: { alert: {
type: 'warning', type: 'warning',
message: '注意:要求 Halo server 版本大于 v1.1.3!你可以在 【系统 | 关于】 里面找到系统的版本信息。' message: '注意:要求 Halo server 版本大于 v1.1.1!你可以在 【系统 | 关于】 里面找到系统的版本信息。'
} }
} }
] ]

View File

@ -161,7 +161,7 @@
</tr> </tr>
<tr> <tr>
<td>已启动时间</td> <td>已启动时间</td>
<td>{{ system.process.uptime }} </td> <td>{{ system.process.uptime | dayTime }} </td>
</tr> </tr>
<tr> <tr>
<td>启动目录</td> <td>启动目录</td>

View File

@ -13,10 +13,6 @@
</a-skeleton> </a-skeleton>
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-button
type="primary"
style="margin-right: 8px;"
>下载</a-button>
<a-select <a-select
defaultValue="200" defaultValue="200"
style="margin-right: 8px;width: 100px" style="margin-right: 8px;width: 100px"
@ -28,9 +24,11 @@
<a-select-option value="1000">1000 </a-select-option> <a-select-option value="1000">1000 </a-select-option>
</a-select> </a-select>
<a-button <a-button
type="dash" type="primary"
style="margin-right: 8px;"
@click="()=>this.loadLogs()" @click="()=>this.loadLogs()"
>刷新</a-button> >刷新</a-button>
<a-button type="dash" @click="handleDownloadLogFile()"></a-button>
</a-form-item> </a-form-item>
</a-form> </a-form>
</template> </template>
@ -67,6 +65,11 @@ export default {
this.loading = false this.loading = false
}) })
}, },
handleDownloadLogFile() {
adminApi.downloadLogFiles(this.logLines).then(response => {
this.$message.success('下载成功!')
})
},
handleLinesChange(value) { handleLinesChange(value) {
this.logLines = value this.logLines = value
} }

View File

@ -29,11 +29,22 @@
<a-table <a-table
:rowKey="record => record.name" :rowKey="record => record.name"
:columns="columns" :columns="columns"
:dataSource="statics" :dataSource="sortedStatics"
:pagination="false" :pagination="false"
size="middle" size="middle"
:loading="loading" :loading="loading"
> >
<span
slot="name"
slot-scope="name"
>
<ellipsis
length="64"
tooltip
>
{{ name }}
</ellipsis>
</span>
<span <span
slot="createTime" slot="createTime"
slot-scope="createTime" slot-scope="createTime"
@ -130,12 +141,12 @@ const columns = [
{ {
title: '文件名', title: '文件名',
dataIndex: 'name', dataIndex: 'name',
scopedSlots: { customRender: 'key' } scopedSlots: { customRender: 'name' }
}, },
{ {
title: '文件类型', title: '文件类型',
dataIndex: 'mediaType', dataIndex: 'mimeType',
scopedSlots: { customRender: 'mediaType' } scopedSlots: { customRender: 'mimeType' }
}, },
{ {
title: '上传时间', title: '上传时间',
@ -168,7 +179,13 @@ export default {
this.loadStaticList() this.loadStaticList()
}, },
computed: { computed: {
...mapGetters(['options']) ...mapGetters(['options']),
sortedStatics() {
const data = this.statics.slice(0)
return data.sort(function(a, b) {
return b.createTime - a.createTime
})
}
}, },
methods: { methods: {
loadStaticList() { loadStaticList() {