管理后台链接跳转

dev
truthhun 1 year ago
parent 5d4ec8f5ab
commit e74738bc93

@ -107,6 +107,9 @@
<template v-else>-</template>
</span>
<!-- -->
<span v-else-if="item.type==='html'">
<span v-html="scope.row[item.prop]"></span>
</span>
<span v-else>{{ scope.row[item.prop] || '-' }}</span>
</template>
</el-table-column>

@ -28,7 +28,7 @@
@deleteRow="deleteRow"
>
<!-- -->
<template slot="actions" slot-scope="scope">
<!-- <template slot="actions" slot-scope="scope">
<nuxt-link
target="_blank"
:to="{
@ -40,7 +40,7 @@
></el-button
>
</nuxt-link>
</template>
</template> -->
</TableList>
</el-card>
<el-card shadow="never" class="mgt-20px">
@ -78,6 +78,7 @@ import { listArticle, deleteArticle, getArticle } from '~/api/article'
import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue'
import FormArticle from '~/components/FormArticle.vue'
import { genLinkHTML } from '~/utils/utils'
import { mapGetters } from 'vuex'
export default {
components: { TableList, FormSearch, FormArticle },
@ -139,7 +140,14 @@ export default {
this.loading = true
const res = await listArticle(this.search)
if (res.status === 200) {
this.articles = res.data.article
let articles = res.data.article || []
articles.map((item) => {
item.title_html = genLinkHTML(
item.title,
`/article/${item.identifier}`
)
})
this.articles = articles
this.total = res.data.total
} else {
this.$message.error(res.data.message)
@ -250,7 +258,13 @@ export default {
initTableListFields() {
this.tableListFields = [
{ prop: 'id', label: 'ID', width: 80, type: 'number', fixed: 'left' },
{ prop: 'title', label: '', minWidth: 150, fixed: 'left' },
{
prop: 'title_html',
label: '',
minWidth: 150,
fixed: 'left',
type: 'html',
},
{ prop: 'identifier', label: '', width: 200 },
{ prop: 'view_count', label: '', width: 80, type: 'number' },
{ prop: 'keywords', label: '', width: 200 },

@ -84,7 +84,7 @@ import {
} from '~/api/comment'
import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue'
import { parseQueryIntArray } from '~/utils/utils'
import { parseQueryIntArray, genLinkHTML } from '~/utils/utils'
export default {
components: { TableList, FormSearch },
layout: 'admin',
@ -143,6 +143,14 @@ export default {
if (res.status === 200) {
this.comments = (res.data.comment || []).map((item) => {
item.username = item.user.username
item.document_title_html = genLinkHTML(
item.document_title,
`/document/${item.document_id}`
)
item.username_html = genLinkHTML(
item.username,
`/user/${item.user_id}`
)
return item
})
this.total = res.data.total
@ -280,9 +288,14 @@ export default {
0: { label: '', value: 0 },
},
},
{ prop: 'document_title', label: '', minWidth: 150 },
{
prop: 'document_title_html',
label: '',
minWidth: 150,
type: 'html',
},
{ prop: 'content', label: '', minWidth: 150 },
{ prop: 'username', label: '', minWidth: 150 },
{ prop: 'username_html', label: '', minWidth: 150, type: 'html' },
{ prop: 'created_at', label: '', width: 160, type: 'datetime' },
{ prop: 'updated_at', label: '', width: 160, type: 'datetime' },
]

@ -57,7 +57,7 @@
:show-edit="true"
:show-delete="true"
:show-select="true"
:actions-min-width="160"
:actions-min-width="100"
@editRow="editRow"
@viewRow="viewRow"
@selectRow="selectRow"
@ -90,11 +90,11 @@
@click="recommendDocument(scope.row)"
></el-button
>
<nuxt-link :to="`/document/${scope.row.id}`" target="_blank"
<!-- <nuxt-link :to="`/document/${scope.row.id}`" target="_blank"
><el-button type="text" icon="el-icon-view" size="small"
></el-button
></nuxt-link
>
> -->
</template>
</TableList>
</el-card>
@ -157,6 +157,7 @@ import {
categoryToTrees,
parseQueryIntArray,
parseQueryBoolArray,
genLinkHTML,
} from '~/utils/utils'
import { documentStatusOptions, boolOptions } from '~/utils/enum'
import FormUpdateDocument from '~/components/FormUpdateDocument.vue'
@ -261,6 +262,11 @@ export default {
this.categoryMap[id].title
)
})
item.title_html = genLinkHTML(item.title, `/document/${item.id}`)
item.username_html = genLinkHTML(
item.username,
`/user/${item.user_id}`
)
})
this.documents = documents
@ -426,9 +432,15 @@ export default {
})
this.tableListFields = [
{ prop: 'id', label: 'ID', width: 80, type: 'number', fixed: 'left' },
{ prop: 'title', label: '', minWidth: 200, fixed: 'left' },
{
prop: 'title_html',
label: '',
minWidth: 200,
fixed: 'left',
type: 'html',
},
{ prop: 'ext', label: '', width: 70 },
{ prop: 'username', label: '', width: 120 },
{ prop: 'username_html', label: '', width: 120, type: 'html' },
{
prop: 'status',
label: '',

@ -91,7 +91,7 @@ import {
} from '~/api/document'
import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue'
import { categoryToTrees, parseQueryIntArray } from '~/utils/utils'
import { categoryToTrees, parseQueryIntArray, genLinkHTML } from '~/utils/utils'
import { documentStatusOptions } from '~/utils/enum'
import { mapGetters } from 'vuex'
export default {
@ -186,6 +186,11 @@ export default {
this.categoryMap[id].title || '-' // 有可能分类已经被删除
)
})
item.title_html = genLinkHTML(item.title, `/document/${item.id}`)
item.username_html = genLinkHTML(
item.username,
`/user/${item.user_id}`
)
})
this.documents = documents
@ -347,8 +352,14 @@ export default {
})
this.tableListFields = [
{ prop: 'id', label: 'ID', width: 80, type: 'number', fixed: 'left' },
{ prop: 'title', label: '', minWidth: 200, fixed: 'left' },
{ prop: 'username', label: '', width: 120 },
{
prop: 'title_html',
label: '',
minWidth: 200,
fixed: 'left',
type: 'html',
},
{ prop: 'username_html', label: '', width: 120, type: 'html' },
{ prop: 'deleted_username', label: '', width: 120 },
{ prop: 'deleted_at', label: '', width: 160, type: 'datetime' },
{

@ -64,7 +64,7 @@ import {
deleteFriendlink,
getFriendlink,
} from '~/api/friendlink'
import { parseQueryIntArray } from '~/utils/utils'
import { genLinkHTML, parseQueryIntArray } from '~/utils/utils'
import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue'
import FormFriendlink from '~/components/FormFriendlink.vue'
@ -123,7 +123,11 @@ export default {
this.loading = true
const res = await listFriendlink(this.search)
if (res.status === 200) {
this.friendlinks = res.data.friendlink
let friendlinks = res.data.friendlink || []
friendlinks.map((item) => {
item.title_html = genLinkHTML(item.title, item.link)
})
this.friendlinks = friendlinks
this.total = res.data.total
} else {
this.$message.error(res.data.message)
@ -245,7 +249,13 @@ export default {
type: 'bool',
fixed: 'left',
},
{ prop: 'title', label: '', minWidth: 150, fixed: 'left' },
{
prop: 'title_html',
label: '',
minWidth: 150,
fixed: 'left',
type: 'html',
},
{ prop: 'link', label: '', minWidth: 250 },
{ prop: 'sort', label: '', width: 80, type: 'number' },
{ prop: 'description', label: '', minWidth: 250 },

@ -62,7 +62,7 @@
<script>
import { listReport, deleteReport } from '~/api/report'
import { reportOptions } from '~/utils/enum'
import { parseQueryIntArray } from '~/utils/utils'
import { parseQueryIntArray, genLinkHTML } from '~/utils/utils'
import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue'
import FormReport from '~/components/FormReport.vue'
@ -121,7 +121,18 @@ export default {
this.loading = true
const res = await listReport(this.search)
if (res.status === 200) {
this.reports = res.data.report
let reports = res.data.report || []
reports.map((item) => {
item.username_html = genLinkHTML(
item.username,
`/user/${item.user_id}`
)
item.document_title_html = genLinkHTML(
item.document_title,
`/document/${item.document_id}`
)
})
this.reports = reports
this.total = res.data.total
} else {
this.$message.error(res.data.message)
@ -243,7 +254,13 @@ export default {
type: 'bool',
fixed: 'left',
},
{ prop: 'document_title', label: '', minWidth: 150, fixed: 'left' },
{
prop: 'document_title_html',
label: '',
minWidth: 150,
fixed: 'left',
type: 'html',
},
{
prop: 'reason',
label: '',
@ -252,9 +269,10 @@ export default {
enum: reasonEnum,
},
{
prop: 'username',
prop: 'username_html',
label: '',
width: 100,
type: 'html',
},
{ prop: 'remark', label: '', minWidth: 150 },
{ prop: 'created_at', label: '', width: 160, type: 'datetime' },

@ -18,11 +18,11 @@
:loading="loading"
:fields="listFields"
:show-actions="true"
:show-view="true"
:show-view="false"
:show-edit="true"
:show-delete="true"
:show-select="true"
:actions-min-width="140"
:actions-min-width="100"
@editRow="editRow"
@viewRow="viewRow"
@deleteRow="deleteRow"
@ -86,7 +86,7 @@
import { deleteUser, getUser, listUser } from '~/api/user'
import { listGroup } from '~/api/group'
import { userStatusOptions } from '~/utils/enum'
import { parseQueryIntArray } from '~/utils/utils'
import { parseQueryIntArray, genLinkHTML } from '~/utils/utils'
import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue'
import FormUser from '~/components/FormUser.vue'
@ -107,6 +107,7 @@ export default {
},
formUserVisible: false,
formUserProfileVisible: false,
formRechargeVisible: false,
groups: [],
users: [],
user: { id: 0 },
@ -153,7 +154,11 @@ export default {
this.loading = true
const res = await listUser(this.search)
if (res.status === 200) {
this.users = res.data.user
let users = res.data.user || []
users.map((item) => {
item.username_html = genLinkHTML(item.username, `/user/${item.id}`)
})
this.users = users
this.total = res.data.total
} else {
this.$message.error(res.data.message)
@ -307,8 +312,15 @@ export default {
type: 'avatar',
fixed: 'left',
},
{ prop: 'username', label: '', width: 150, fixed: 'left' },
{
prop: 'username_html',
label: '',
width: 150,
fixed: 'left',
type: 'html',
},
{ prop: 'doc_count', label: '', width: 80, type: 'number' },
{ prop: 'credit_count', label: '', width: 100, type: 'number' },
{ prop: 'follow_count', label: '', width: 80, type: 'number' },
{ prop: 'fans_count', label: '', width: 80, type: 'number' },
{ prop: 'favorite_count', label: '', width: 80, type: 'number' },

@ -231,3 +231,11 @@ export function requireLogin(settings, user, route, permissions = []) {
}
return false
}
export function genLinkHTML(title, href) {
return `<a href="${href}" target="_blank" class="el-link el-link--primary">${(
title || '-'
)
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')}</a>`
}

Loading…
Cancel
Save