LI WENHAO

add blog-admin part

add server\admin UI
server:
  blog manage\label manage\message manage\upload\user
admin UI:login mode\home\user\auth\label\article\
Showing 87 changed files with 4912 additions and 0 deletions
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=0" />
<title>Document</title>
</head>
<body>
<div id="app"></div>
</body>
</html>
\ No newline at end of file
<template>
<div id="app">
<router-view></router-view>
</div>
</template>
<script>
export default {
name: "app",
};
</script>
\ No newline at end of file
import axios from "utils/request";
/**
* 获取博客列表
* @param data
* @returns {AxiosPromise}
*/
export function apiGetBlogList(params) {
return axios.get("/blog/list", params);
}
/**
* 获取博客详情
* @param data
* @returns {AxiosPromise}
*/
export function apiGetBlogDetail(params) {
return axios.get("/blog/info", params);
}
/**
* 新增博客
* @param data
* @returns {AxiosPromise}
*/
export function apiAddBlog(params) {
return axios.postFile("/blog/add", params);
}
/**
* 修改博客
* @param data
* @returns {AxiosPromise}
*/
export function apiUpdateBlog(params) {
return axios.postFile("/blog/update", params);
}
/**
* 删除博客
* @param data
* @returns {AxiosPromise}
*/
export function apiDelBlog(params) {
return axios.get("/blog/del", params);
}
import axios from "utils/request";
/**
* 获取标签列表
* @param data
* @returns {AxiosPromise}
*/
export function apiGetLabelList(params) {
return axios.get("/label/list", params);
}
/**
* 新增标签
* @param data
* @returns {AxiosPromise}
*/
export function apiAddLabel(params) {
return axios.postFile("/label/add", params);
}
/**
* 修改标签
* @param data
* @returns {AxiosPromise}
*/
export function apiUpdateLabel(params) {
return axios.post("/label/update", params);
}
/**
* 删除标签
* @param data
* @returns {AxiosPromise}
*/
export function apiDelLabel(params) {
return axios.get("/label/del", params);
}
import axios from "utils/request";
/**
* 获取留言列表
* @param data
* @returns {AxiosPromise}
*/
export function apiGetMessageList(params) {
return axios.get("/message/list", params);
}
/**
* 删除留言
* @param data
* @returns {AxiosPromise}
*/
export function apiDelMessage(params) {
return axios.get("/message/del", params);
}
/**
* 删除回复
* @param data
* @returns {AxiosPromise}
*/
export function apiDelReply(params) {
return axios.postFile("/message/delReply", params);
}
import axios from "utils/request";
/**
* 上传图片
* @param data
* @returns {AxiosPromise}
*/
export function apiUploadImg(params) {
return axios.postFile("/uploadImage", params);
}
/**
* 删除图片
* @param data
* @returns {AxiosPromise}
*/
export function apiDelUploadImg(params) {
return axios.post("/delUploadImage", params);
}
<template>
<div id="markdowm">
<div class="md-title">
<ul class="cf">
<li>
<span>图片</span>
<input type="file" class="uploadFile" @change="insertImg" />
</li>
<li @click="insertCode">
<span>代码块</span>
</li>
<li @click="setCursorPosition($refs.text, '***')">
<span>分割线</span>
</li>
<li @click="setCursorPosition($refs.text, '****', 2)">
<span>粗体</span>
</li>
<li @click="setCursorPosition($refs.text, '**', 1)">
<span>斜体</span>
</li>
<li @click="setCursorPosition($refs.text, '> ', 2)">
<span>引用</span>
</li>
</ul>
</div>
<textarea v-model="val" ref="text" @keydown.tab="tabMarkdown"></textarea>
<div class="render fmt" v-html="renderHtml"></div>
</div>
</template>
<script>
import marked from "marked";
import highlightJs from "highlight.js";
import { apiUploadImg } from "src/api/upload";
export default {
props: ["value"],
computed: {
renderHtml() {
marked.setOptions({
renderer: new marked.Renderer(),
gfm: true, //允许 Git Hub标准的markdown.
tables: true, //允许支持表格语法。该选项要求 gfm 为true。
breaks: true, //允许回车换行。该选项要求 gfm 为true。
pedantic: false, //尽可能地兼容 markdown.pl的晦涩部分。不纠正原始模型任何的不良行为和错误。
sanitize: true, //对输出进行过滤(清理),将忽略任何已经输入的html代码(标签)
smartLists: true, //使用比原生markdown更时髦的列表。 旧的列表将可能被作为pedantic的处理内容过滤掉.
smartypants: false, //使用更为时髦的标点,比如在引用语法中加入破折号。
highlight: function (code) {
return highlightJs.highlightAuto(code).value;
},
});
return marked(this.val);
},
},
watch: {
val(newVal) {
this.handleModelInput(newVal);
},
},
data() {
return {
val: this.value,
link: "",
textarea: null,
};
},
mounted() {
this.textarea = this.$refs.text;
},
methods: {
handleModelInput(newVal) {
this.$emit("input", newVal);
},
tabMarkdown(e) {
// tab键
e.preventDefault();
let indent = " ";
let start = this.textarea.selectionStart;
let end = this.textarea.selectionEnd;
let selected = window.getSelection().toString();
selected = indent + selected.replace(/\n/g, "\n" + indent);
this.textarea.value =
this.textarea.value.substring(0, start) +
selected +
this.textarea.value.substring(end);
this.textarea.setSelectionRange(
start + indent.length,
start + selected.length
);
},
insertImg(e) {
// 插入图片
let formData = new FormData(),
img = "";
formData.append("markdown_img", e.target.files[0]);
return apiUploadImg(formData)
.then((res) => {
img = res.data.markdown_img;
let val = `![图片描述](${img})`;
this.setCursorPosition(this.$refs.text, val, 6);
})
.catch((err) => {
console.log(err);
})
.finally(() => {});
},
insertCode() {
let val = `
\`\`\`
\`\`\``;
this.setCursorPosition(this.$refs.text, val, val.length - 8);
},
setCursorPosition(dom, val, posLen) {
// 设置光标位置
var cursorPosition = 0;
if (dom.selectionStart) {
cursorPosition = dom.selectionStart;
}
this.insertAtCursor(dom, val);
dom.focus();
dom.setSelectionRange(
dom.value.length,
cursorPosition + (posLen || val.length)
);
this.val = dom.value;
},
insertAtCursor(dom, val) {
// 光标所在位置插入字符
if (document.selection) {
dom.focus();
sel = document.selection.createRange();
sel.text = val;
sel.select();
} else if (dom.selectionStart || dom.selectionStart == "0") {
let startPos = dom.selectionStart;
let endPos = dom.selectionEnd;
let restoreTop = dom.scrollTop;
dom.value =
dom.value.substring(0, startPos) +
val +
dom.value.substring(endPos, dom.value.length);
if (restoreTop > 0) {
dom.scrollTop = restoreTop;
}
dom.focus();
dom.selectionStart = startPos + val.length;
dom.selectionEnd = startPos + val.length;
} else {
dom.value += val;
dom.focus();
}
},
},
};
</script>
<style lang="less" scoped>
@import "./markdown.less";
@import "../../../../../node_modules/highlight.js/styles/tomorrow-night-eighties.css";
@md-bd-color: #dcdfe6;
@md-title-color: rgb(233, 234, 237);
@md-bg-color: #fff;
@btn-hover: #3b7cff;
#markdowm {
width: 100%;
height: 500px;
text-align: left;
overflow: hidden;
border: 1px solid @md-bd-color;
position: relative;
.md-title {
width: 100%;
height: 40px;
border-bottom: 1px solid #dcdfe6;
background: @md-title-color;
position: absolute;
left: 0;
top: 0;
z-index: 99;
li {
width: 100px;
height: 100%;
text-align: center;
position: relative;
float: left;
cursor: pointer;
color: #606266;
&:hover {
color: @btn-hover;
}
&:after {
content: "";
position: absolute;
left: 100%;
top: 50%;
transform: translateY(-50%);
width: 1px;
height: 20px;
background: @borderBoldColor;
}
&:last-child::after {
content: none;
}
.uploadFile {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
}
}
}
textarea,
.render {
float: left;
width: 50%;
height: 100%;
vertical-align: top;
box-sizing: border-box;
line-height: 22px;
padding: 0 20px;
}
textarea {
border: none;
border-right: 1px solid @md-bd-color;
resize: none;
outline: none;
background-color: @md-bg-color;
color: @mainColor;
font-size: 14px;
line-height: 22px;
padding: 20px;
padding-top: 50px;
}
.render {
background-color: @md-title-color;
overflow-y: scroll;
padding-top: 50px;
}
.mask {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: 10;
}
.link-text {
width: 500px;
text-align: center;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
.link-input {
width: 400px;
}
}
}
</style>
\ No newline at end of file
.fmt {
line-height: 1.6;
word-wrap: break-word;
color: @mainColor;
}
.fmt a {
color: #009a61;
text-decoration: none;
}
.fmt h1 {
font-size: 2.25em;
}
.fmt h2 {
font-size: 1.75em;
}
.fmt h3 {
font-size: 1.5em;
}
.fmt h4 {
font-size: 1.25em;
}
.fmt h5 {
font-size: 1em;
}
.fmt h6 {
font-size: 0.86em;
}
.fmt p {
margin-top: 0.86em;
line-height: 1.8em;
}
.fmt h1,
.fmt h2,
.fmt h3,
.fmt h4,
.fmt h5,
.fmt h6 {
margin-top: 1.2em;
}
.fmt h1 + .widget-codetool + pre,
.fmt h2 + .widget-codetool + pre,
.fmt h3 + .widget-codetool + pre {
margin-top: 1.2em !important;
}
.fmt h1,
.fmt h2 {
border-bottom: 1px solid #eee;
padding-bottom: 10px;
}
.fmt > h1:first-child,
.fmt h2:first-child,
.fmt h3:first-child,
.fmt h4:first-child,
.fmt p:first-child,
.fmt ul:first-child,
.fmt ol:first-child,
.fmt blockquote:first-child {
margin-top: 0;
}
.fmt ul,
.fmt ol {
margin-left: 2em;
margin-top: 0.86em;
padding-left: 0;
}
.fmt ul li,
.fmt ol li {
margin: 0.3em 0;
list-style: unset;
}
.fmt ul ul,
.fmt ul ol,
.fmt ol ul,
.fmt ol ol {
margin-top: 0;
margin-bottom: 0;
}
.fmt ul p,
.fmt ol p {
margin: 0;
}
.fmt p:last-child {
margin-bottom: 0;
}
.fmt p > p:empty,
.fmt div > p:empty,
.fmt p > div:empty,
.fmt div > div:empty,
.fmt div > br:only-child,
.fmt p + br,
.fmt img + br {
display: none;
}
.fmt img,
.fmt video,
.fmt audio {
position: static !important;
max-width: 100%;
}
.fmt img {
padding: 3px;
border: 1px solid #ddd;
}
.fmt img.emoji {
padding: 0;
border: none;
}
.fmt blockquote {
border-left: 2px solid #009a61;
background: @thinBgColor;
color: @thinColor;
font-size: 1em;
}
.fmt pre,
.fmt code {
font-size: 0.93em;
margin-top: 0.86em;
}
.fmt pre {
font-family: "Source Code Pro", Consolas, Menlo, Monaco, "Courier New",
monospace;
padding: 1em;
margin-top: 0.86em;
border: none;
overflow: auto;
line-height: 1.45;
max-height: 35em;
position: relative;
background: url("./blueprint.png") @thinBgColor;
background-size: 30px, 30px;
font-size: 12px;
-webkit-overflow-scrolling: touch;
border-radius: 5px;
}
.fmt pre code {
background: none;
font-size: 1em;
overflow-wrap: normal;
white-space: inherit;
}
.fmt hr {
margin: 1.5em auto;
border-top: 2px dotted #eee;
}
.fmt kbd {
margin: 0 4px;
padding: 3px 4px;
background: #eee;
color: @thinColor;
}
.fmt .x-scroll {
overflow-x: auto;
}
.fmt table {
width: 100%;
}
.fmt table th,
.fmt table td {
border: 1px solid #e6e6e6;
padding: 5px 8px;
word-break: normal;
}
.fmt table th {
background: #f3f3f3;
}
.fmt a:not(.btn) {
border-bottom: 1px solid rgba(0, 154, 97, 0.25);
padding-bottom: 1px;
}
.fmt a:not(.btn):hover {
border-bottom: 1px solid #009a61;
text-decoration: none;
}
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
color: @mainColor;
background: #f8f8f8;
}
.hljs-comment,
.hljs-quote {
color: #998;
font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
color: @mainColor;
font-weight: bold;
}
.hljs-number,
.hljs-literal,
.hljs-variable,
.hljs-template-variable,
.hljs-tag .hljs-attr {
color: #008080;
}
.hljs-string,
.hljs-doctag {
color: #d14;
}
.hljs-title,
.hljs-section,
.hljs-selector-id {
color: #900;
font-weight: bold;
}
.hljs-subst {
font-weight: normal;
}
.hljs-type,
.hljs-class .hljs-title {
color: #458;
font-weight: bold;
}
.hljs-tag,
.hljs-name,
.hljs-attribute {
color: #000080;
font-weight: normal;
}
.hljs-regexp,
.hljs-link {
color: #009926;
}
.hljs-symbol,
.hljs-bullet {
color: #990073;
}
.hljs-built_in,
.hljs-builtin-name {
color: #0086b3;
}
.hljs-meta {
color: @assistColor;
font-weight: bold;
}
.hljs-deletion {
background: #fdd;
}
.hljs-addition {
background: #dfd;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}
/**
* 注入公共组件
*/
import Vue from "vue";
// 检索当前目录的vue文件,便检索子文件夹
const componentsContext = require.context("./", true, /.vue$/);
componentsContext.keys().forEach((component) => {
// 获取文件中的 default 模块
const componentConfig = componentsContext(component).default;
componentConfig.name && Vue.component(componentConfig.name, componentConfig);
});
<template>
<zp-page>
<!-- 页面标题 -->
<div slot="header">
<zp-page-header :back="back" @back="$emit('back')">
<slot name="header">{{ header }}</slot>
</zp-page-header>
</div>
<!-- 主体body -->
<div class="zp-page-edit">
<slot></slot>
<!-- 保存等操作按钮 -->
<div class="zp-page-edit-button" v-if="this.$slots.button">
<slot name="button"></slot>
</div>
</div>
</zp-page>
</template>
<script>
import zpPage from "./zp-page";
import zpPageHeader from "./zp-page-header";
export default {
name: "zpPageEdit",
components: {
zpPage,
zpPageHeader,
},
props: {
header: {
type: String,
default: "",
},
back: {
type: Boolean,
default: true,
},
},
created() {},
methods: {},
};
</script>
<style lang="less" scope>
.zp-page-edit {
.el-form {
margin-top: 20px;
}
.el-input {
width: 220px;
}
.el-textarea {
width: 440px;
.el-textarea__inner {
min-height: 100px !important;
}
}
.zp-notice-subtitle {
width: 540px;
box-sizing: border-box;
}
}
.zp-page-edit-button {
padding: 20px 20px 20px 120px;
}
</style>
<template>
<div class="zp-page-filter">
<el-form ref="pageFilter" :inline="true" :label-width="labelWidth + 'px'">
<el-form-item
v-for="(searchItem, searchIndex) in searchForm"
:key="searchIndex"
:label="searchItem.label"
>
<!-- 输入框 -->
<el-input
v-if="searchItem.type == 'text'"
v-model="searchItem.value"
:placeholder="searchItem.placeholder || '请输入' + searchItem.label"
/>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
name: "zpPageFilter",
components: {},
props: {
labelWidth: {
type: Number,
default: 100,
},
searchForm: {
type: Array,
default: () => [],
},
},
data() {
return {};
},
watch: {},
methods: {},
};
</script>
<style lang="less" scope></style>
<!--
* @Descripttion:
* @Author: givon.chen
* @Date: 2020-06-02 14:48:49
* @LastEditTime: 2020-06-30 15:41:59
-->
<template>
<div class="zp-page-header">
<!-- 带返回 -->
<el-page-header
:class="{ hideBack: !back }"
@back="$emit('back')"
:title="title"
>
<template v-slot:content>
<slot>
{{ header }}
</slot>
</template>
</el-page-header>
</div>
</template>
<script>
export default {
name: "zpPageHeader",
props: {
header: {
type: String,
default: "",
},
back: {
type: Boolean,
default: false,
},
title: {
type: String,
default: "返回",
},
},
};
</script>
<style lang="less" scope>
.zp-page-header {
display: flex;
align-items: center;
height: 54px;
font-weight: bold;
.el-page-header {
flex-grow: 1;
padding-left: 0;
box-shadow: none;
line-height: 28px !important;
.el-page-header__content {
// header 里 tabs的情形
.el-tabs {
.el-tabs__header {
margin: 0;
.el-tabs__nav-wrap {
padding-left: 0;
}
}
}
}
}
.hideBack {
.el-page-header__left {
display: none;
}
}
}
</style>
<!--
* @Descripttion:
* @Author: givon.chen
* @Date: 2020-05-07 21:05:06
* @LastEditTime: 2020-06-29 12:09:31
-->
<template>
<zp-page>
<!-- 页面标题 -->
<template v-slot:header v-if="!hideHeader">
<zp-page-header :back="back" @back="back && $emit('back')">
<slot name="header">{{ header }}</slot>
</zp-page-header>
</template>
<!-- 搜索框 -->
<div class="zp-page-filter" v-if="this.$slots['filter']">
<slot name="filter"></slot>
</div>
<!-- 搜索框按钮组 -->
<div class="zp-search-button" v-if="this.$slots['button']">
<slot name="button"></slot>
</div>
<!-- 列表、分页 -->
<div class="zp-page-list">
<slot name="list"></slot>
</div>
</zp-page>
</template>
<script>
import zpPage from "./zp-page";
import zpPageHeader from "./zp-page-header";
export default {
name: "zpPageList",
components: {
zpPage,
zpPageHeader,
},
props: {
back: {
type: Boolean,
default: false,
},
header: {
type: String,
default: "",
},
hideHeader: {
type: Boolean,
default: false,
},
},
created() {},
methods: {},
};
</script>
<style lang="less" scope>
.zp-search-button {
padding-bottom: 20px;
padding-top: 0;
.el-button {
border-radius: 1px;
width: 100px !important;
}
}
.el-table {
th {
font-size: 14px;
}
td {
font-size: 13px;
}
.el-button--text {
padding-top: 0;
padding-bottom: 0;
height: 18px;
line-height: 18px;
font-size: 13px;
border: 0 none;
span {
vertical-align: top;
display: inline-block;
line-height: 18px;
}
}
}
.el-pagination {
padding-bottom: 0 !important;
margin-top: 24px;
}
.el-pagination__sizes {
.el-select {
.el-input {
.el-input__inner {
padding-left: 0 !important;
}
}
}
}
</style>
<!--
* @Descripttion:
* @Author: givon.chen
* @Date: 2020-05-15 12:48:29
* @LastEditTime: 2020-06-30 15:43:16
-->
<template>
<div class="zp-page-container">
<el-card class="zp-page-el-card" shadow="never">
<template v-slot:header class="clearfix" v-if="this.$slots.header">
<slot name="header"></slot>
</template>
<div class="zp-page-body">
<slot></slot>
</div>
</el-card>
</div>
</template>
<script>
export default {
name: "zpPage",
created() {},
methods: {},
};
</script>
<style lang="less" scope>
.zp-page-container {
background-color: #fff;
.zp-page-el-card {
border-radius: 0;
border: 0 none;
.el-card__header {
font-size: 16px;
font-weight: bold;
color: $strongFontColor;
background: #ffffff;
padding: 0px 20px !important;
line-height: 28px;
}
}
.el-icon-edit {
position: relative;
width: 16px;
height: 16px;
display: inline-block !important;
vertical-align: middle !important;
padding: 10px;
cursor: pointer;
&:before {
position: absolute;
left: 10px;
top: 10px;
content: "" !important;
width: 16px;
height: 16px;
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAByUExURUxpcTx//z1//zt9/zx8/zt9/zt8/z9//zt8/2aZ/zt8/z1//z59/z19/zx9/zx8/z9//z1//zt9/zx//zt//zt8/zt8/zx9/zt8/zt8/zt8/zt8/zt8/zt8/zt8/zt8/z9//z9//zyH/zx8/zt8/zt8/4mnP5MAAAAldFJOUwAuQoqu0usU0QW9MjVPO0wwPkVIOPf4rfXw8/bt8vnvCAwRx4muFNzGAAAAtklEQVRIx+3Q2Q6DIBCF4SloUbvv+955/1dsK6kOpoTDlUnjuSTfj0Gibv+362YU5W8FnycR/v5g5vUCD5782WoOB3lSFgcFaaPzb7GdIT7lpCr2Y8SzKE5LxMtiN0S8LC4DxMviOA34TPXdogh4Qz2neB8EPDkF4mWhIS8KwjyRKt+rvT5reHuQmpY8/fbe/0kUeb8NIu63QcT9boB4GUBeBJivA+C9VVAv7CnWN77grK2gm38vXdQ1SLUwEaMAAAAASUVORK5CYII=")
no-repeat;
background-size: 16px;
}
}
}
</style>
<!--
table 配置项:
1. loading
2. source: 数据list
3. count: 数据总数
4. columns: 列配置
同el-table-column 属性
补充:
1. zpMark: 特殊几个字段固定宽度,具体查看 @zpAdmin/utils/config/styleConfig
2. slot: 自定义列名
5. leftFix: 左侧固定列栏数
6. rightFix: 右侧固定列栏数
7. pageable: 是否显示分页
8. pageSize: 默认每页条数
9. layout: 分页配置
事件:
1. sizeChange: 分页切换 | 参数: { pageNo, pageSize }
2. selectChange: 多选切换 | 参数: 同element table
-->
<template>
<div class="zp-table-list">
<el-table
ref="table"
v-loading="loading"
:stripe="stripe"
:data="source"
:row-key="rowKey"
:show-header="showHeader"
:empty-text="loading ? ' ' : '暂无数据'"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange"
>
<template v-for="(column, columnKey) in columns">
<template v-if="column.type">
<template v-if="column.type === 'selection'">
<!-- 选择栏固定宽度 -->
<el-table-column
type="selection"
width="55"
:show-overflow-tooltip="column.showTooltip"
:align="column.align"
:key="columnKey"
:reserve-selection="column.reserveSelection"
:selectable="
column.selectable
? column.selectable
: () => {
return true;
}
"
></el-table-column>
</template>
</template>
<template v-else>
<el-table-column
:type="column.type"
:key="column.prop"
:prop="column.prop"
:label="column.label"
:width="getWidth(column)"
:fixed="getFixed(columnKey)"
:class-name="column.className"
:min-width="column.minWidth"
:render-header="column.renderHeader"
:show-overflow-tooltip="column.showTooltip"
:align="column.align"
:header-align="column.headerAlign"
:label-class-name="column.labelClassName"
:formatter="column.formatter"
:sortable="column.sortable || false"
>
<template v-if="column.slotHeader" slot="header">
<slot :name="column.slotHeader"></slot>
</template>
<template slot-scope="scope">
<!-- 自定义列: 比如操作列 start -->
<slot
v-if="column.slot"
:name="column.slot"
:$index="scope.$index"
:column="scope.column"
:row="scope.row"
></slot>
<!-- 自定义列: 比如操作列 end -->
<template v-else>
<template v-if="column.formatter">
{{ column.formatter(scope.row, column) }}
</template>
<template v-else>
{{ scope.row[column.prop] }}
</template>
</template>
</template>
</el-table-column>
</template>
</template>
</el-table>
<el-pagination
v-if="pageable && count > 0"
@size-change="(value) => handleSizeChange(value)"
@current-change="(value) => handleCurrentChange(value)"
:current-page="page"
:page-sizes="pageSizes"
:page-size="currentPageSize"
:layout="pageLayout"
:total="count"
></el-pagination>
</div>
</template>
<script>
import { tableFixWidths } from "src/utils/config/styleConfig";
export default {
name: "zpTableList",
data() {
return {
page: 1,
currentPageSize: 20,
pageSizes: [10, 20, 30, 50],
pageLayout: "",
};
},
props: {
// 是否显示表头
showHeader: {
type: Boolean,
default: true,
},
// 是否斑马纹
stripe: {
type: Boolean,
default: true,
},
// 加载状态
loading: {
type: Boolean,
default: false,
},
// 数据资源
source: {
type: Array,
default: () => [],
},
// 列配置
columns: {
type: Array,
default: () => [],
},
// 列表总数量
count: {
type: Number,
default: 0,
},
// 左侧固定列栏数
leftFix: {
type: Number,
default: 1,
},
// 右侧固定列栏数
rightFix: {
type: Number,
default: 1,
},
// 是否分页
pageable: {
type: Boolean,
default: true,
},
// 每页条数
pageSize: {
type: Number,
default: 10,
},
// 分页组件布局
layout: {
type: String,
default: "total, sizes, prev, pager, next, jumper",
},
rowKey: [String, Function],
},
watch: {
count: {
handler(value) {
// 解决查询列表,分页器页码没同步更新问题
if (value === 0) {
this.page = 1;
}
},
},
pageSize: {
handler(value) {
value && (this.currentPageSize = value);
},
immediate: true,
},
layout: {
handler(value) {
value && (this.pageLayout = value);
},
immediate: true,
},
},
created() {},
methods: {
doLayout() {
this.$refs.table.doLayout();
},
handleSortChange(value) {
console.log(value);
this.$emit("sort-change", value);
},
/**
* 选择操作
* @param value
*/
handleSelectionChange(value) {
this.$emit("selection-change", value);
},
/**
* 当前页码变化
* @param val
*/
handleCurrentChange(val) {
this.page = val;
this.$emit("current-change", val);
},
/**
* 每页数量变化
* @param val
*/
handleSizeChange(val) {
this.currentPageSize = val;
this.$emit("size-change", val);
},
// 是否固定
getFixed(columnKey) {
if (columnKey < this.leftFix) {
return "left";
} else if (columnKey > this.columns.length - this.rightFix - 1) {
return "right";
}
return false;
},
// 宽度
getWidth(column) {
// 1. 优先 zpMark 固定宽度项
// 2. width属性
// 3. 不设宽度
if (column.zpMark) {
if (Object.keys(tableFixWidths).includes(column.zpMark)) {
return tableFixWidths[column.zpMark];
}
}
if (column.width) {
return column.width;
}
return "";
},
},
};
</script>
<style lang="less" scope>
.zp-table-list {
.el-table {
.el-button--text {
padding: 0 2px;
}
.el-tag {
height: 24px;
line-height: 22px;
border-radius: 12px;
}
}
.el-table__fixed,
.el-table__fixed-right {
&:before {
background-color: transparent;
}
}
}
</style>
<style lang="less" scoped>
.zp-table-list {
height: 100%;
display: flex;
flex-direction: column;
.el-pagination {
text-align: right;
.el-pagination__total {
float: left;
}
}
}
</style>
<template>
<svg class="icon" aria-hidden="true">
<use :xlink:href="iconName"></use>
</svg>
</template>
<script>
export default {
name: "Icon",
props: {
name: {
type: String,
required: true,
},
},
computed: {
iconName() {
return `#icon-${this.name}`;
},
},
};
</script>
<template>
<el-dialog
:title="title"
class="zp-dialog__wrapper"
v-bind="$attrs"
v-on="$listeners"
>
<template v-slot:title v-if="this.$slots.title">
<slot name="title"></slot>
</template>
<template v-slot:footer>
<slot name="footer"></slot>
</template>
<slot></slot>
</el-dialog>
</template>
<script>
export default {
name: "ZpDialog",
components: {},
props: {
title: {
type: String,
default: "",
},
},
computed: {},
data() {
return {};
},
watch: {},
created() {},
mounted() {},
beforeDestroy() {},
methods: {},
};
</script>
<style lang="less" scoped>
.zp-dialog__wrapper {
/deep/ .el-dialog {
.el-dialog__body {
box-sizing: border-box;
max-height: calc(~"85vh - 112px");
overflow-y: auto;
}
}
}
</style>
<template>
<div class="zp-single-img-upload__container">
<el-upload
ref="upload"
:action="action"
:accept="accept"
:file-list="fileList"
:headers="headers"
:data="data"
list-type="picture-card"
:auto-upload="true"
:on-change="onChange"
:on-success="onSuccess"
:before-upload="beforeUpload"
>
<div ref="triggerWrapper" class="zp-single-img-upload__trigger-wrapper">
<slot v-if="this.$slots['trigger']" name="trigger"></slot>
<i v-else slot="default" class="el-icon-plus"></i>
</div>
<div
class="zp-single-img-upload__img-wrapper"
slot="file"
slot-scope="{ file }"
>
<el-image
ref="zpSingleImg"
class="zp-single-img-upload__img"
v-if="imgUrl"
:src="imgUrl"
:preview-src-list="[imgUrl]"
fit="contain"
></el-image>
<span class="el-upload-list__item-actions" v-if="preview">
<span
class="el-upload-list__item-preview"
@click="handlePictureCardPreview(file)"
>
<i class="el-icon-zoom-in"></i>
</span>
<span class="el-upload-list__item-delete" @click="handleDelete()">
<i class="el-icon-delete"></i>
</span>
</span>
<div class="zp-single-img-upload__reload" @click="handleReload" v-else>
更换图片
</div>
</div>
<div class="el-upload__tip" slot="tip">
<slot v-if="this.$slots['tip']" name="tip"></slot>
<div v-else>支持图片格式:jpg、png</div>
</div>
</el-upload>
</div>
</template>
<script>
import { getToken } from "utils/auth";
export default {
name: "zpSingleImgUpload",
props: {
//图片url
imgUrl: {
type: String,
default: "",
},
//图片上传接口地址
action: {
type: String,
default: "/admin_api/uploadImage",
},
//支持的图片格式
accept: {
type: String,
default: "image/*",
},
//文件最大大小(M)
maxSize: {
type: Number,
default: 6,
},
//文件存储是否公有(公有存储读取的时候不需要签名,敏感文件私有,否则公有)
public: {
type: Boolean,
default: false,
},
//是否可以预览图片
preview: {
type: Boolean,
default: false,
},
},
model: {
prop: "imgUrl",
event: "input",
},
data() {
return {
headers: {}, //请求头
data: {}, //请求额外参数
fileList: [], //文件列表
limitCount: 1, //最多支持个数
};
},
watch: {
imgUrl: {
immediate: true,
handler(val) {
console.log("imgUrl:", val);
if (val) {
this.fileList = [{ url: val }];
} else {
this.fileList = [];
}
},
},
},
computed: {},
created() {
this.headers["Token-Auth"] = getToken();
if (this.public) {
this.data["acl"] = "public-read";
}
},
methods: {
/**
* 上传图片校验
*/
beforeUpload(file) {
let isIMG;
const regList = this.accept.split(",");
if (this.accept === "image/*") {
isIMG = /image/i.test(file.type);
} else {
isIMG = regList.includes(file.type); // 是否符合类型
}
const isLt6M = file.size / 1024 / 1024 < this.maxSize;
if (!isIMG) {
this.fileList = [];
this.$message.error("图片格式仅支持png、jpg,请更换图片!");
}
if (!isLt6M) {
this.$message.error(`上传图片大小不能超过${this.maxSize}MB!`);
}
console.log("beforeUpload", file, isIMG && isLt6M);
return isIMG && isLt6M;
},
/**
* 文件修改
*/
onChange(file, fileList) {
console.log("onChange file:", file);
console.log("onChange fileList:", fileList);
const overMaxSize = file.size / 1024 / 1024 < this.maxSize;
if (overMaxSize && fileList.length > 0) {
this.fileList = [fileList[fileList.length - 1]];
} else {
this.fileList = [];
}
},
/**
* 上传成功
*/
onSuccess(res, file, fileList) {
console.log("onSuccess res:", res);
console.log("onSuccess file:", file);
console.log("onSuccess fileList:", fileList);
const { data } = res;
this.$emit("input", data.file);
},
/**
* 删除
*/
handleDelete() {
console.log("handleDelete");
this.$emit("input", "");
},
/**
* 预览
* @param file
*/
handlePictureCardPreview(file) {
this.$refs.zpSingleImg.clickHandler();
},
handleReload() {
this.$refs.triggerWrapper.click();
},
},
};
</script>
<style lang="less" scoped>
.zp-single-img-upload__container {
display: inline-block;
width: 148px;
margin-right: 16px;
/deep/ .el-upload {
border: 1px dashed #d8dce5;
}
/deep/ .el-upload-list__item {
border: 1px solid #d8dce5;
}
.zp-single-img-upload__img-wrapper {
height: 100%;
.zp-single-img-upload__img {
height: 100%;
width: 100%;
}
}
.zp-single-img-upload__reload {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
text-align: center;
background: rgba(51, 51, 51, 0.8);
color: #fff;
font-size: 12px;
cursor: pointer;
}
/deep/ .el-upload-list {
position: absolute;
}
}
</style>
<template>
<a
:href="githubLink"
target="_blank"
class="github-corner"
aria-label="View source on Github"
>
<svg
width="80"
height="80"
viewBox="0 0 250 250"
style=""
aria-hidden="true"
>
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
fill="currentColor"
style="transform-origin: 130px 106px"
class="octo-arm"
></path>
<path
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
fill="currentColor"
class="octo-body"
></path>
</svg>
</a>
</template>
<script>
export default {
name: "Github",
props: {
githubLink: {
type: String,
default: null,
},
},
};
</script>
<style lang="less" scoped>
.github-corner {
fill: #4ab7bd;
color: #fff;
position: absolute;
top: 50px;
border: 0;
right: 0;
&:hover .octo-arm {
animation: octocat-wave 560ms ease-in-out;
}
}
@keyframes octocat-wave {
0%,
100% {
transform: rotate(0);
}
20%,
60% {
transform: rotate(-25deg);
}
40%,
80% {
transform: rotate(10deg);
}
}
</style>
<template>
<div>
<svg
t="1492500959545"
@click="toggleClick"
class="wscn-icon hamburger"
:class="{ 'is-active': isActive }"
style=""
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="1691"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="64"
height="64"
>
<path
d="M966.8023 568.849776 57.196677 568.849776c-31.397081 0-56.850799-25.452695-56.850799-56.850799l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 543.397081 998.200404 568.849776 966.8023 568.849776z"
p-id="1692"
></path>
<path
d="M966.8023 881.527125 57.196677 881.527125c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 856.07443 998.200404 881.527125 966.8023 881.527125z"
p-id="1693"
></path>
<path
d="M966.8023 256.17345 57.196677 256.17345c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.850799 56.850799-56.850799l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.850799l0 0C1023.653099 230.720755 998.200404 256.17345 966.8023 256.17345z"
p-id="1694"
></path>
</svg>
</div>
</template>
<script>
export default {
name: "hamburger",
props: {
isActive: {
type: Boolean,
default: false,
},
toggleClick: {
type: Function,
default: null,
},
},
};
</script>
<style scoped>
.hamburger {
display: inline-block;
cursor: pointer;
width: 20px;
height: 20px;
transform: rotate(0deg);
transition: 0.38s;
transform-origin: 50% 50%;
}
.hamburger.is-active {
transform: rotate(90deg);
}
</style>
// 来源
export const sources = [
{ name: "原创", id: 1 },
{ name: "转载", id: 2 },
{ name: "翻译", id: 3 },
];
/**
* 时间日期格式化
* 用法 formatTime(new Date(), 'yyyy-MM-dd hh:mm:ss')
* @param time
* @param fmt
*/
export function formatTime(time, fmt) {
time = parseInt(time);
if (!time) {
return "";
}
const date = new Date(time);
let o = {
"M+": date.getMonth() + 1, // 月份
"d+": date.getDate(), // 日
"h+": date.getHours(), // 小时
"m+": date.getMinutes(), // 分
"s+": date.getSeconds(), // 秒
"q+": Math.floor((date.getMonth() + 3) / 3), // 季度
S: date.getMilliseconds(), // 毫秒
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(
RegExp.$1,
(date.getFullYear() + "").substr(4 - RegExp.$1.length)
);
}
for (let k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(
RegExp.$1,
RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)
);
}
}
return fmt;
}
import Vue from "vue";
import App from "./App.vue";
import router from "./router/permission";
import store from "./store";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import "./styles/index.less";
import pageInfoMixin from "src/mixins/pageInfo";
import "./utils/config/iconfont";
import "src/components/common/index.js";
import * as filters from "./filters";
Object.keys(filters).forEach((key) => {
Vue.filter(key, filters[key]);
});
Vue.mixin(pageInfoMixin);
Vue.use(ElementUI);
new Vue({
el: "#app",
router,
store,
template: "<App/>",
components: { App },
});
/**
* 1、先引入 pageInfo 的mixin文件,注入mixin
* 2、给 requestPageData 方法赋值页面翻页查询方法
*/
export default {
data() {
return {
requestPageData: null, // 每个table组建的数据源获取方法
pageInfo: {
total: 0,
pageNum: 1,
pageSize: 10,
},
};
},
watch: {
"pageInfo.pageNum"() {
this.requestPageData && this.requestPageData();
},
"pageInfo.pageSize"() {
this.requestPageData && this.requestPageData();
},
},
methods: {
handleCurrentChange(page) {
this.pageInfo.pageNum = page;
},
handleSizeChange(val) {
this.pageInfo.pageSize = val;
},
},
};
import Vue from "vue";
import Router from "vue-router";
Vue.use(Router);
// 解决同一页面,参数不同的路由报错
const VueRouterPush = Router.prototype.push;
Router.prototype.push = function push(to) {
return VueRouterPush.call(this, to).catch((err) => err);
};
/**
* 加载模块
* @param {string | Component} component 路径或组件
* @param {boolean} lazy 是否懒加载
* @returns {Function | object} 懒加载方法或组件对象
*/
const loadComponent = (component, lazy = true) =>
lazy ? () => import(`views/${component}.vue`) : component;
export const constantRouterMap = [
{
path: "/login",
name: "登录",
component: loadComponent("Login/index"),
hidden: true,
},
{
path: "/",
name: "首页",
component: loadComponent("Layout/index"),
redirect: "/home",
icon: "home",
children: [
{ path: "home", component: loadComponent("Home/index"), name: "首页" },
],
},
];
export const asyncRouterMap = [
{
path: "/permission",
name: "权限管理",
meta: { role: ["admin"] },
component: loadComponent("Layout/index"),
redirect: "/permission/list",
requireAuth: true, // 是否需要登录
dropdown: true,
icon: "authority",
children: [
{
path: "list",
component: loadComponent("Permission/list"),
name: "管理员列表",
},
{
path: "add",
component: loadComponent("Permission/add"),
name: "添加管理员",
},
],
},
{
path: "/article",
name: "文章管理",
component: loadComponent("Layout/index"),
redirect: "/article/list",
dropdown: true,
icon: "article",
children: [
{
path: "list",
component: loadComponent("Article/list"),
name: "文章列表",
},
{
path: "edit",
component: loadComponent("Article/edit"),
name: "文章编辑",
hidden: true,
},
{
path: "add",
component: loadComponent("Article/add"),
name: "添加文章",
},
],
},
{
path: "/label",
name: "标签管理",
component: loadComponent("Layout/index"),
redirect: "/label/list",
dropdown: true,
icon: "label",
children: [
{
path: "list",
component: loadComponent("Label/list"),
name: "标签列表",
},
{
path: "add",
component: loadComponent("Label/add"),
name: "添加标签",
},
],
},
{
path: "/message",
name: "留言管理",
component: loadComponent("Layout/index"),
redirect: "/message/list",
dropdown: true,
icon: "message",
children: [
{
path: "list",
component: loadComponent("Message/list"),
name: "留言列表",
},
{
path: "reply",
component: loadComponent("Message/replyList"),
name: "回复列表",
},
],
},
];
export const router = new Router({
// mode: 'history',
routes: constantRouterMap,
});
import store from "../store";
import { getToken } from "src/utils/auth";
import { router } from "./index";
import NProgress from "nprogress"; // Progress 进度条
import "nprogress/nprogress.css"; // Progress 进度条样式
router.beforeEach((to, from, next) => {
NProgress.start();
if (getToken()) {
if (!store.state.user.roles) {
// 重新拉取用户信息
store.dispatch("getUserInfo").then((res) => {
// 如果token过期,则需重新登录
if (res.code === 401) {
next("/login");
} else {
let roles = res.data.roles;
store.dispatch("setRoutes", { roles }).then(() => {
// 根据权限动态添加路由
router.addRoutes(store.state.permission.addRouters);
next({ ...to }); // hash模式 确保路由加载完成
});
}
});
} else {
next();
}
} else {
to.path === "/login" ? next() : next("/login");
}
});
router.afterEach((to, from) => {
document.title = to.name;
NProgress.done();
});
export default router;
const getters = {
userName: (state) => state.user.username,
userList: (state) => state.user.list,
userTotal: (state) => state.user.total,
};
export default getters;
import Vue from "vue";
import Vuex from "vuex";
import getters from "./getters";
import app from "./modules/app";
import user from "./modules/user";
import permission from "./modules/permission";
Vue.use(Vuex);
const store = new Vuex.Store({
modules: {
app,
user,
permission,
},
getters,
});
export default store;
import { Local } from "src/utils/storage";
const app = {
state: {
slideBar: {
opened: Local.get("slideBarStatus"),
},
tagViews: JSON.parse(Local.get("tagViews")) || [],
is_add_router: false,
},
mutations: {
TOGGLE_SIDEBAR(state) {
if (state.slideBar.opened) {
Local.set("slideBarStatus", false);
} else {
Local.set("slideBarStatus", true);
}
state.slideBar.opened = !state.slideBar.opened;
},
ADD_TAGVIEW(state, tag) {
if (state.tagViews.some((v) => v.name === tag.name)) return;
state.tagViews.push({ name: tag.name, path: tag.path });
Local.set("tagViews", JSON.stringify(state.tagViews));
},
DEL_TAGVIEW(state, tag) {
let index;
for (let [i, v] of state.tagViews.entries()) {
if (v.name === tag.name) index = i;
}
state.tagViews.splice(index, 1);
Local.set("tagViews", JSON.stringify(state.tagViews));
},
},
actions: {
toggleSideBar({ commit }) {
commit("TOGGLE_SIDEBAR");
},
addTagView({ commit }, tag) {
commit("ADD_TAGVIEW", tag);
},
delTagView({ commit }, tag) {
commit("DEL_TAGVIEW", tag);
},
},
};
export default app;
import { constantRouterMap, asyncRouterMap } from "src/router";
/**
* 通过meta.role判断是否与当前用户权限匹配
* @param role
* @param route
*/
const hasPermission = (roles, route) => {
if (route.meta && route.meta.role) {
return roles.some((role) => route.meta.role.indexOf(role) >= 0);
} else {
return true;
}
};
/**
* 递归过滤异步路由表,返回符合用户角色权限的路由表
* @param asyncRouterMap
* @param role
*/
const filterAsyncRouter = (asyncRouterMap, roles) => {
const accessedRouters = asyncRouterMap.filter((route) => {
if (hasPermission(roles, route)) {
if (route.children && route.children.length) {
route.children = filterAsyncRouter(route.children, roles);
}
return true;
}
return false;
});
return accessedRouters;
};
const permission = {
state: {
routes: constantRouterMap.concat(asyncRouterMap),
addRouters: [],
},
mutations: {
SETROUTES(state, routers) {
state.addRouters = routers;
state.routes = constantRouterMap.concat(routers);
},
},
actions: {
setRoutes({ commit }, info) {
return new Promise((resolve, reject) => {
let { roles } = info;
let accessedRouters = [];
if (roles.indexOf("admin") >= 0) {
accessedRouters = asyncRouterMap;
} else {
accessedRouters = filterAsyncRouter(asyncRouterMap, roles);
}
commit("SETROUTES", accessedRouters);
resolve();
});
},
},
};
export default permission;
import axios from "src/utils/request";
import { getToken } from "src/utils/auth";
import md5 from "js-md5";
const user = {
state: {
list: [],
total: 0,
username: "",
roles: null,
token: getToken(),
otherList: [],
},
mutations: {
SET_TOKEN(state, token) {
state.token = token;
},
SET_USERINFO(state, info) {
state.username = info.username;
state.roles = info.roles;
},
USERLIST(state, data) {
state.list = data.list;
state.total = data.list.length || 0;
},
GET_INFOLIST(state, data) {
state.otherList = data;
},
CLEARINFO(state) {
state.username = "";
state.roles = null;
},
},
actions: {
clearInfo({ commit }) {
commit("CLEARINFO");
},
userLogin({ state, commit }, info) {
let { username, pwd } = info;
return new Promise((resolve, reject) => {
axios
.post("/user/login", {
username: username,
pwd: md5(pwd),
})
.then((res) => {
state.token = getToken();
resolve(res);
})
.catch((err) => {
reject(err);
});
});
},
getUserInfo({ state, commit }) {
return new Promise((resolve, reject) => {
axios
.get("/user/info", {
token: state.token,
})
.then((res) => {
commit("SET_USERINFO", res.data);
resolve(res);
})
.catch((err) => {
// console.log(err)
reject(err);
});
});
},
getUserList({ commit }, params) {
return new Promise((resolve, reject) => {
axios
.get("/user/list", params)
.then((res) => {
commit("USERLIST", res.data);
resolve(res);
})
.catch((err) => {
// console.log(err)
reject(err);
});
});
},
addUser({ commit }, info) {
info.pwd = md5(info.pwd);
return new Promise((resolve, reject) => {
axios
.post("/user/add", info)
.then((res) => {
resolve(res);
})
.catch((err) => {
reject(err);
});
});
},
delUser({ commit }, id) {
return new Promise((resolve, reject) => {
axios
.get("/user/del", { id: id })
.then((res) => {
resolve(res);
})
.catch((err) => {
reject(err);
});
});
},
updateUser({ commit }, info) {
info.pwd = md5(info.pwd);
info.old_pwd = md5(info.old_pwd);
return new Promise((resolve, reject) => {
axios
.post("/user/update", info)
.then((res) => {
resolve(res);
})
.catch((err) => {
reject(err);
});
});
},
},
};
export default user;
@import "./less/reset.less";
@import "./less/init.less";
@import "./less/element-ui.less";
@bg-color: #324157;
@font-color: #bfcbd9;
@font-hover-color: #48576a;
@active-font-color: #409EFF;
@submenu-color: #1f2d3d;
.el-menu-vertical {
background-color: @bg-color;
.el-submenu__title {
color: @font-color;
background-color: @bg-color;
}
.el-submenu .el-menu {
background-color: @submenu-color;
.el-menu-item {
background: transparent;
}
}
.el-menu-item {
color: @font-color;
background: @bg-color;
}
.el-menu-item:hover,
.el-submenu__title:hover {
background-color: @font-hover-color;
}
.el-menu-item.is-active {
color: @active-font-color;
background-color: transparent;
}
}
.music-cover-uploader {
.el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.el-upload:hover {
border-color: #409EFF;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
.avatar {
width: 178px;
height: 178px;
display: block;
}
}
.el-breadcrumb__inner, .el-breadcrumb__inner a {
color: #48576a;
font-weight: 400;
}
.el-breadcrumb__item:last-child .el-breadcrumb__inner, .el-breadcrumb__item:last-child .el-breadcrumb__inner a, .el-breadcrumb__item:last-child .el-breadcrumb__inner a:hover, .el-breadcrumb__item:last-child .el-breadcrumb__inner:hover {
color: #97a8be;
cursor: text;
font-weight: 400;
}
\ No newline at end of file
.icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
}
::-webkit-scrollbar {
width: 4px;
height: 4px;
}
::-webkit-scrollbar-thumb {
opacity: 0.8;
background: #ddd;
border-radius: 4px;
transition: all 0.5s;
}
/* normalize.css */
html {
line-height: 1.15; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
}
body {
margin: 0;
}
article,
aside,
footer,
header,
nav,
section {
display: block;
}
h1 {
font-size: 2em;
margin: 0.67em 0;
}
figcaption,
figure,
main {
/* 1 */
display: block;
}
figure {
margin: 1em 40px;
}
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
pre {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
a {
background-color: transparent; /* 1 */
-webkit-text-decoration-skip: objects; /* 2 */
}
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
}
b,
strong {
font-weight: inherit;
}
b,
strong {
font-weight: bolder;
}
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
dfn {
font-style: italic;
}
mark {
background-color: #ff0;
color: @mainColor;
}
small {
font-size: 80%;
}
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
audio,
video {
display: inline-block;
}
audio:not([controls]) {
display: none;
height: 0;
}
img {
border-style: none;
}
svg:not(:root) {
overflow: hidden;
}
button,
input,
optgroup,
select,
textarea {
font-family: sans-serif; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
button,
input {
/* 1 */
overflow: visible;
}
button,
select {
/* 1 */
text-transform: none;
}
button,
html [type="button"], /* 1 */
[type="reset"],
[type="submit"] {
-webkit-appearance: button; /* 2 */
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
fieldset {
padding: 0.35em 0.75em 0.625em;
}
legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding: 0; /* 3 */
white-space: normal; /* 1 */
}
progress {
display: inline-block; /* 1 */
vertical-align: baseline; /* 2 */
}
textarea {
overflow: auto;
}
[type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
[type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
details, /* 1 */
menu {
display: block;
}
summary {
display: list-item;
}
canvas {
display: inline-block;
}
template {
display: none;
}
[hidden] {
display: none;
}
/* reset */
* {
box-sizing: border-box;
}
html,
body {
font: Oswald, "Open Sans", Helvetica, Arial, sans-serif;
}
/* 禁止长按链接与图片弹出菜单 */
a,
img {
-webkit-touch-callout: none;
}
/*ios android去除自带阴影的样式*/
a,
input {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
input[type="text"] {
-webkit-appearance: none;
}
html,
body,
h1,
h2,
h3,
h4,
h5,
h6,
div,
dl,
dt,
dd,
ul,
ol,
li,
p,
blockquote,
pre,
hr,
figure,
table,
caption,
th,
td,
form,
fieldset,
legend,
input,
button,
textarea,
menu {
margin: 0;
padding: 0;
}
header,
footer,
section,
article,
aside,
nav,
hgroup,
address,
figure,
figcaption,
menu,
details {
display: block;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
caption,
th {
text-align: left;
font-weight: normal;
}
html,
body,
fieldset,
img,
iframe,
abbr {
border: 0;
}
i,
cite,
em,
var,
address,
dfn {
font-style: normal;
}
[hidefocus],
summary {
outline: 0;
}
li {
list-style: none;
}
h1,
h2,
h3,
h4,
h5,
h6,
small {
font-size: 100%;
}
sup,
sub {
font-size: 83%;
}
pre,
code,
kbd,
samp {
font-family: inherit;
}
q:before,
q:after {
content: none;
}
textarea {
overflow: auto;
resize: none;
}
label,
summary {
cursor: default;
}
a,
button {
cursor: pointer;
}
h1,
h2,
h3,
h4,
h5,
h6,
em,
strong,
b {
font-weight: bold;
}
del,
ins,
u,
s,
a,
a:hover {
text-decoration: none;
}
import { Cookie } from "./storage";
const TokenKey = "Token-Auth";
export function getToken() {
return Cookie.get(TokenKey);
}
export function setToken(token) {
return Cookie.set(TokenKey, token);
}
export function removeToken() {
return Cookie.remove(TokenKey);
}
This diff is collapsed. Click to expand it.
/*
列表表格里 固定宽度 栏
*/
const TABLE_FIX_WIDTH_PHONE = 'phone'; // 手机号
const TABLE_FIX_WIDTH_USERNAME = 'username'; // 名字
const TABLE_FIX_WIDTH_ID_CARD = 'idCard'; // 身份证
const TABLE_FIX_WIDTH_BANK_CARD = 'bankCard'; // 银行卡号码
const TABLE_FIX_WIDTH_LABEL = 'label'; // 标签
const TABLE_FIX_WIDTH_TIME = 'datetime'; // 时间
const TABLE_FIX_WIDTH_DATE = 'date'; // 日期
const tableFixWidths = {
[TABLE_FIX_WIDTH_PHONE]: 120,
[TABLE_FIX_WIDTH_USERNAME]: 88,
[TABLE_FIX_WIDTH_LABEL]: 88,
[TABLE_FIX_WIDTH_TIME]: 168,
[TABLE_FIX_WIDTH_DATE]: 120,
[TABLE_FIX_WIDTH_ID_CARD]: 180,
[TABLE_FIX_WIDTH_BANK_CARD]: 190,
};
export {
TABLE_FIX_WIDTH_PHONE,
TABLE_FIX_WIDTH_USERNAME,
TABLE_FIX_WIDTH_LABEL,
TABLE_FIX_WIDTH_TIME,
TABLE_FIX_WIDTH_DATE,
TABLE_FIX_WIDTH_ID_CARD,
TABLE_FIX_WIDTH_BANK_CARD,
tableFixWidths,
};
import axios from 'axios';
import qs from 'qs';
import { Message } from 'element-ui';
import { removeToken } from './auth';
axios.defaults.withCredentials = true;
// 发送时
axios.interceptors.request.use(
(config) => config,
(err) => Promise.reject(err)
);
// 响应时
axios.interceptors.response.use(
(response) => response,
(err) => Promise.resolve(err.response)
);
// 检查状态码
function checkStatus(res) {
if (res.status === 200 || res.status === 304) {
return res.data;
}
// token过期清掉
if (res.status === 401) {
removeToken();
Message({
message: res.data,
type: 'error',
duration: 2 * 1000,
});
return {
code: 401,
msg: res.data || res.statusText,
data: res.data,
};
}
return {
code: 0,
msg: res.data.msg || res.statusText,
data: res.statusText,
};
}
// 检查CODE值
function checkCode(res) {
if (res.code === 0) {
Message({
message: res.msg,
type: 'error',
duration: 2 * 1000,
});
throw new Error(res.msg);
}
return res;
}
const prefix = '/admin_api';
export default {
get(url, params) {
if (!url) return;
return axios({
method: 'get',
url: prefix + url,
params,
timeout: 30000,
})
.then(checkStatus)
.then(checkCode);
},
post(url, data) {
if (!url) return;
return axios({
method: 'post',
url: prefix + url,
data: qs.stringify(data),
timeout: 30000,
})
.then(checkStatus)
.then(checkCode);
},
postFile(url, data) {
if (!url) return;
return axios({
method: 'post',
url: prefix + url,
data,
})
.then(checkStatus)
.then(checkCode);
},
};
const ls = window.localStorage;
const ss = window.sessionStorage;
export const Cookie = {
get(key) {
let arr = document.cookie.split('; ');
for (let i = 0; i < arr.length; i++) {
let arr2 = arr[i].trim().split('=');
if (arr2[0] == key) {
return arr2[1];
}
}
return '';
},
set(key, value, day) {
let setting = arguments[0];
if (Object.prototype.toString.call(setting).slice(8, -1) === 'Object') {
for (let i in setting) {
let oDate = new Date();
oDate.setDate(oDate.getDate() + day);
document.cookie = i + '=' + setting[i] + ';expires=' + oDate;
}
} else {
let oDate = new Date();
oDate.setDate(oDate.getDate() + day);
document.cookie = key + '=' + value + ';expires=' + oDate;
}
},
remove(key) {
this.set(key, 1, -1);
},
};
export const Local = {
get(key) {
if (key) return JSON.parse(ls.getItem(key));
return null;
},
set(key, val) {
const setting = arguments[0];
if (Object.prototype.toString.call(setting).slice(8, -1) === 'Object') {
for (const i in setting) {
ls.setItem(i, JSON.stringify(setting[i]));
}
} else {
ls.setItem(key, JSON.stringify(val));
}
},
remove(key) {
ls.removeItem(key);
},
clear() {
ls.clear();
},
};
export const Session = {
get(key) {
if (key) return JSON.parse(ss.getItem(key));
return null;
},
set(key, val) {
const setting = arguments[0];
if (Object.prototype.toString.call(setting).slice(8, -1) === 'Object') {
for (const i in setting) {
ss.setItem(i, JSON.stringify(setting[i]));
}
} else {
ss.setItem(key, JSON.stringify(val));
}
},
remove(key) {
ss.removeItem(key);
},
clear() {
ss.clear();
},
};
<template>
<div class="article-add">
<zp-page-edit :back="true" @back="$router.back()">
<div slot="header">
{{ header }}
</div>
<el-form
:model="info"
:rules="rules"
ref="form"
label-width="100px"
class="form"
>
<el-form-item label="博客类型:" prop="type">
<el-select
v-model="info.type"
multiple
clearable
placeholder="请选择博客类型"
class="block"
>
<el-option
v-for="item in labelList"
:key="item.label"
:label="item.label"
:value="item.label"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="文章标题:" prop="title">
<el-input type="text" v-model="info.title"></el-input>
</el-form-item>
<el-form-item label="文章描述:" prop="desc">
<el-input type="textarea" v-model="info.desc"></el-input>
</el-form-item>
<el-form-item label="文章封面:" prop="fileCoverImgUrl">
<zp-single-img-upload v-model="info.fileCoverImgUrl" :public="true">
</zp-single-img-upload>
</el-form-item>
<el-form-item label="文章内容:" prop="markdown" class="markdown">
<Markdown v-model="info.markdown"></Markdown>
</el-form-item>
<el-form-item label="级别:" prop="album">
<el-select
v-model="info.level"
placeholder="请选择级别"
class="block"
>
<el-option
v-for="item in [1, 2, 3, 4, 5, 6]"
:key="item"
:label="item"
:value="item"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="来源:" prop="source">
<el-select
v-model="info.source"
placeholder="请选择来源"
class="block"
>
<el-option
v-for="item in sources"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="Github:" prop="github">
<el-input type="text" v-model="info.github"></el-input>
</el-form-item>
<el-form-item label="Auth:" prop="auth">
<el-input type="text" v-model="info.auth"></el-input>
</el-form-item>
<el-form-item label="是否可见:" prop="isVisible" class="left-item">
<el-switch v-model="info.isVisible"></el-switch>
</el-form-item>
<el-form-item>
<el-button
type="primary"
@click="handleSubmit('form')"
:loading="loading"
>立即创建</el-button
>
</el-form-item>
</el-form>
</zp-page-edit>
</div>
</template>
<script>
import { sources } from "src/constant/classify";
import { apiGetLabelList } from "src/api/label";
import { apiAddBlog } from "src/api/blog";
import Markdown from "components/markdown";
export default {
name: "articleAdd",
components: { Markdown },
computed: {},
data() {
return {
sources,
header: "添加文章",
labelList: [],
info: {
type: ["JavaScript"],
title: "",
desc: "",
fileCoverImgUrl: "",
html: "",
markdown: "",
level: 1,
source: 1,
github: "",
auth: "",
isVisible: true,
releaseTime: new Date().getTime() + "",
},
loading: false,
rules: {
type: [
{
required: true,
message: "请选择至少选择一个文章类型",
trigger: "change",
type: "array",
},
],
title: [{ required: true, message: "请填写文章标题", trigger: "blur" }],
desc: [{ required: true, message: "请填写文章描述", trigger: "blur" }],
isVisible: [
{
required: true,
message: "请选择",
trigger: "change",
type: "boolean",
},
],
fileCoverImgUrl: [
{ required: true, message: "请上传文章封面", trigger: "change" },
],
},
};
},
created() {
this.getLabelList();
},
methods: {
handleSubmit(formName) {
this.loading = true;
if (!this.info.markdown) {
this.$message.warning("请填写文章内容");
this.loading = false;
return;
}
this.$refs[formName].validate((valid) => {
if (valid) {
this.info.html = this.info.markdown;
this.handleAddBlog();
} else {
this.loading = false;
return false;
}
});
},
handleAddBlog() {
return apiAddBlog(this.info)
.then((res) => {
this.$message.success("新增文章成功");
this.$router.push("/article/list");
})
.catch((err) => {
console.log(err);
this.$message.info("新增文章失败");
})
.finally(() => {
this.loading = false;
});
},
getLabelList() {
let params = {
pageindex: 1,
pagesize: 50,
};
return apiGetLabelList(params)
.then((res) => {
let { list } = res.data;
this.labelList = list;
})
.catch((err) => {
console.log(err);
})
.finally(() => {
});
},
},
};
</script>
<style lang="less" scoped>
/deep/ .markdown {
.el-form-item__content {
width: 1400px;
}
}
</style>
\ No newline at end of file
<template>
<div class="article-edit" v-show="hasLoad">
<zp-page-edit :back="true" @back="$router.back()">
<div slot="header">
{{ header }}
</div>
<el-form
:model="info"
:rules="rules"
ref="form"
label-width="100px"
class="form"
>
<el-form-item label="文章类型:" prop="type">
<el-select
v-model="info.type"
multiple
clearable
placeholder="请选择文章类型"
class="block"
>
<el-option
v-for="item in labelList"
:key="item.label"
:label="item.label"
:value="item.label"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="文章标题:" prop="title">
<el-input type="text" v-model="info.title"></el-input>
</el-form-item>
<el-form-item label="文章描述:" prop="desc">
<el-input type="textarea" v-model="info.desc"></el-input>
</el-form-item>
<el-form-item label="文章封面:" prop="fileCoverImgUrl">
<zp-single-img-upload v-model="info.fileCoverImgUrl" :public="true">
</zp-single-img-upload>
</el-form-item>
<el-form-item
label="文章内容:"
prop="markdown"
v-if="info.markdown"
class="markdown"
>
<Markdown v-model="info.markdown"></Markdown>
</el-form-item>
<el-form-item label="级别:" prop="album">
<el-select
v-model="info.level"
placeholder="请选择级别"
class="block"
>
<el-option
v-for="item in [1, 2, 3, 4, 5, 6]"
:key="item"
:label="item"
:value="item"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="来源:" prop="source">
<el-select
v-model="info.source"
placeholder="请选择来源"
class="block"
>
<el-option
v-for="item in sources"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="Github:" prop="github">
<el-input type="text" v-model="info.github"></el-input>
</el-form-item>
<el-form-item label="Auth:" prop="auth">
<el-input type="text" v-model="info.auth"></el-input>
</el-form-item>
<el-form-item label="是否可见:" prop="isVisible" class="left-item">
<el-switch v-model="info.isVisible"></el-switch>
</el-form-item>
<el-form-item>
<el-button
type="primary"
@click="handleSubmit('form')"
:loading="loading"
>更新</el-button
>
</el-form-item>
</el-form>
</zp-page-edit>
</div>
</template>
<script>
import { apiUpdateBlog, apiGetBlogDetail } from "src/api/blog";
import { apiGetLabelList } from "src/api/label";
import { sources } from "src/constant/classify";
import Markdown from "components/markdown";
export default {
name: "articleEdit",
components: { Markdown },
props: {},
computed: {},
data() {
return {
sources,
header: "文章编辑",
loading: false,
hasLoad: false,
labelList: [],
info: {},
id: "", // 文章id
rules: {
type: [
{
required: true,
message: "请选择至少选择一个文章类型",
trigger: "change",
type: "array",
},
],
title: [{ required: true, message: "请填写文章标题", trigger: "blur" }],
desc: [{ required: true, message: "请填写文章描述", trigger: "blur" }],
markdown: [
{ required: true, message: "请填写文章内容", trigger: "blur" },
],
fileCoverImgUrl: [
{ required: true, message: "请上传文章封面", trigger: "change" },
],
},
};
},
watch: {},
async created() {
this.id = this.$route.query["id"];
await this.getLabelList();
await this.getBlogDetail();
},
mounted() { },
beforeDestroy() { },
methods: {
handleSubmit(formName) {
this.loading = true;
this.$refs[formName].validate((valid) => {
if (valid) {
this.info.releaseTime = new Date().getTime() + "";
this.info.html = this.info.markdown;
this.handleUpdateBlog();
} else {
console.log("error submit!!");
return false;
}
});
},
getBlogDetail() {
return apiGetBlogDetail({ _id: this.id })
.then((res) => {
this.info = res.data;
})
.catch((err) => {
console.log(err);
this.$message.info("获取文章详情失败");
})
.finally(() => {
this.hasLoad = true;
});
},
handleUpdateBlog() {
return apiUpdateBlog(this.info)
.then((res) => {
this.$message.success("修改文章成功");
this.$router.push("/article/list");
})
.catch((err) => {
console.log(err);
this.$message.info("修改文章失败");
})
.finally(() => {
this.loading = false;
});
},
getLabelList() {
let params = {
pageindex: 1,
pagesize: 50,
};
return apiGetLabelList(params)
.then((res) => {
let { list } = res.data;
this.labelList = list;
})
.catch((err) => {
console.log(err);
})
.finally(() => {
});
},
},
};
</script>
<style lang="less" scoped>
/deep/ .markdown {
.el-form-item__content {
width: 1400px;
}
}
</style>
<template>
<div class="article-list">
<zp-page-list>
<template v-slot:header>
<span>文章列表</span>
</template>
<!-- filter start -->
<div slot="filter">
<el-form
ref="searchForm"
class="zp-search-form"
:inline="true"
:model="searchForm"
>
<el-form-item label="关键词:" prop="keyword">
<el-input
placeholder="请输入类型、标题"
v-model="searchForm.keyword"
@keydown.enter.native="getBlogList(true)"
></el-input>
</el-form-item>
<el-button type="primary" @click="getBlogList(true)">
查询
</el-button>
</el-form>
</div>
<!-- filter end -->
<!-- list start -->
<div slot="list">
<zp-table-list
ref="sensitiveBehaviorRecordList"
:loading="listLoading"
:source="blogList"
:count="pageInfo.total"
:columns="columns"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
>
<template slot="_id" slot-scope="scope">
<el-button
icon="el-icon-document-copy"
type="primary"
size="mini"
class="clipboardBtn"
:data-clipboard-text="scope.row._id"
@click="handleCopyId"
>复制
</el-button>
</template>
<template slot="isVisible" slot-scope="scope">
{{ scope.row.isVisible ? "是" : "否" }}
</template>
<template slot="fileCoverImgUrl" slot-scope="scope">
<img
:src="scope.row.fileCoverImgUrl"
style="width: 60px; object-fit: contain"
/>
</template>
<template slot="source" slot-scope="scope">
{{
scope.row.source === 1
? "原创"
: scope.row.source === 2
? "转载"
: "翻译"
}}
</template>
<template slot="releaseTime" slot-scope="scope">
{{ scope.row.releaseTime | formatTime("yyyy-MM-dd hh:mm:ss") }}
</template>
<template slot="type" slot-scope="scope">
<el-tag
class="tag"
type="primary"
close-transition
v-for="(tag, index) in scope.row.type"
:key="index"
>{{ tag }}</el-tag
>
</template>
<template slot="operate" slot-scope="scope">
<el-button size="mini" type="primary" @click="handleEdit(scope.row)"
>编辑</el-button
>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.row)"
>删除</el-button
>
</template>
</zp-table-list>
</div>
<!-- list end -->
</zp-page-list>
</div>
</template>
<script>
import Clipboard from "clipboard";
import { apiGetBlogList, apiDelBlog } from "src/api/blog";
import { apiDelUploadImg } from "src/api/upload";
export default {
name: "articleList",
components: {},
computed: {},
data() {
return {
listLoading: false,
searchForm: {
keyword: "",
},
blogList: [],
columns: [
{
label: "_id",
prop: "_id",
slot: "_id",
},
{
label: "类型",
prop: "type",
slot: "type",
showTooltip: true,
width: "120",
},
{
label: "标题",
prop: "title",
width: "160",
},
{
label: "描述",
prop: "desc",
width: "160",
showTooltip: true,
},
{
label: "封面",
slot: "fileCoverImgUrl",
prop: "fileCoverImgUrl",
},
{
label: "来源",
prop: "source",
slot: "source",
},
{
label: "级别",
prop: "level",
},
{
label: "发布时间",
prop: "releaseTime",
slot: "releaseTime",
width: "160",
},
{
label: "是否可见",
prop: "isVisible",
slot: "isVisible",
},
{
label: "作者",
prop: "auth",
},
{
label: "浏览量",
prop: "pv",
},
{
label: "点赞数",
prop: "likes",
},
{
label: "评论数",
prop: "comments",
},
{
label: "操作",
slot: "operate",
width: "150",
},
],
};
},
created() {
this.requestPageData = this.getBlogList;
this.getBlogList();
},
mounted() { },
methods: {
handleCopyId() {
let clipboard = new Clipboard(".clipboardBtn");
clipboard.on("success", (e) => {
this.$message.success("复制成功");
clipboard.destroy();
});
clipboard.on("error", (e) => {
this.$message.error("该浏览器不支持自动复制");
clipboard.destroy();
});
},
getBlogList() {
let params = {
keyword: this.searchForm.keyword,
pageindex: this.pageInfo.pageNum,
pagesize: this.pageInfo.pageSize,
};
this.listLoading = true;
return apiGetBlogList(params)
.then((res) => {
let { list, total } = res.data;
this.blogList = list;
this.pageInfo.total = total;
})
.catch((err) => {
this.listLoading = false;
console.log(err);
})
.finally(() => {
this.listLoading = false;
});
},
handleDeleteBlog(id) {
return apiDelBlog({ id })
.then((res) => {
this.$message.success("删除成功");
this.getBlogList(true);
})
.catch((err) => {
console.log(err);
this.$message.info("删除失败");
})
.finally(() => { });
},
// 删除本地图片
handleDeleteImg(fileName) {
return apiDelUploadImg({ fileName })
.then((res) => { })
.catch((err) => {
console.log(err);
});
},
handleDelete(row) {
this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(async () => {
await this.handleDeleteBlog(row._id);
let index = row.fileCoverImgUrl.lastIndexOf('/');
let fileName = row.fileCoverImgUrl.substring(index + 1);
this.handleDeleteImg(fileName);
})
.catch(() => {
this.$message.info("已取消删除");
});
},
handleEdit(row) {
this.$router.push({ path: "edit", query: { id: row._id } });
},
},
};
</script>
<style lang="less" scoped>
.tag {
margin: 0 10px;
}
</style>
<template>
<div class="home-container">home</div>
</template>
<script>
export default {
name: "home",
components: {},
computed: {},
data() {
return {};
},
created() {},
mounted() {},
methods: {},
};
</script>
<style lang="less" scoped>
</style>
<template>
<div class="label-add">
<zp-page-edit :back="true" @back="$router.back()">
<div slot="header">
{{ header }}
</div>
<el-form
:model="info"
:rules="rules"
ref="form"
label-width="100px"
class="form"
>
<el-form-item label="标签:" prop="label">
<el-input type="text" v-model="info.label"></el-input>
</el-form-item>
<el-form-item label="背景色:" prop="bgColor">
<el-input readonly :value="currentColor"></el-input>
</el-form-item>
<el-form-item>
<sketch-picker
v-model="currentColor"
@input="colorValueChange"
></sketch-picker>
</el-form-item>
<el-form-item label="预览:" v-if="info.label">
<div class="label-box" :style="{ backgroundColor: currentColor }">
{{ info.label }}
</div>
</el-form-item>
<el-form-item>
<el-button
type="primary"
@click="handleSubmit('form')"
:loading="loading"
>立即创建</el-button
>
</el-form-item>
</el-form>
</zp-page-edit>
</div>
</template>
<script>
import { Sketch } from 'vue-color'
import { apiAddLabel } from "src/api/label";
export default {
name: "permissionAdd",
components: {
'sketch-picker': Sketch
},
data() {
return {
header: "添加标签",
info: {
label: "",
bgColor: "rgba(70, 70, 70, 0.9)",
},
currentColor: 'rgba(70, 70, 70, 0.9)',
loading: false,
rules: {
label: [
{ required: true, message: "请填写标签", trigger: "blur" },
],
bgColor: [{ required: true, message: "请填写背景色", trigger: "blur" }],
},
};
},
methods: {
handleSubmit(formName) {
this.loading = true;
this.$refs[formName].validate(async (valid) => {
if (valid) {
return apiAddLabel(this.info)
.then((res) => {
this.$message.success("新增成功");
this.$router.push("/label/list");
})
.catch((err) => {
console.log(err);
this.$message.info("新增失败");
})
.finally(() => {
this.loading = false;
});
} else {
console.log("error submit!!");
this.loading = false;
return false;
}
});
},
// 颜色值改变事件处理
colorValueChange(fmtObj) {
// 取颜色对象的 rgba 值
const { r, g, b, a } = fmtObj.rgba;
this.currentColor = `rgba(${r}, ${g}, ${b}, ${a})`;
this.info.bgColor = this.currentColor;
}
},
};
</script>
<style lang="less" scoped>
.label-box {
color: #fff;
border-radius: 12px;
font-size: 14px;
text-align: center;
max-width: 150px;
}
</style>
\ No newline at end of file
<template>
<zp-dialog
title="标签编辑"
:visible.sync="dialogTableVisible"
@close="close"
width="480px"
:destroy-on-close="true"
v-bind="$attrs"
v-on="$listeners"
>
<el-form :model="info" :rules="rules" ref="form">
<el-form-item label="标签:" prop="label">
<el-input type="text" v-model="info.label"></el-input>
</el-form-item>
<el-form-item label="背景色:" prop="bgColor">
<el-input readonly :value="currentColor"></el-input>
</el-form-item>
<el-form-item style="margin-left: 80px">
<sketch-picker
v-model="currentColor"
@input="colorValueChange"
></sketch-picker>
</el-form-item>
<el-form-item label="预览:" v-if="info.label">
<div class="label-box" :style="{ backgroundColor: currentColor }">
{{ info.label }}
</div>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close">取消</el-button>
<el-button
type="primary"
:loading="loading"
@click="handleSubmit('form')"
>
确定
</el-button>
</div>
</zp-dialog>
</template>
<script>
import { Sketch } from 'vue-color'
import { apiUpdateLabel } from "src/api/label";
export default {
props: ["info"],
components: {
'sketch-picker': Sketch
},
data() {
return {
loading: false,
dialogTableVisible: true,
currentColor: '',
rules: {
label: [
{ required: true, message: "请填写标签名", trigger: "blur" },
],
bgColor: [{ required: true, message: "请填写背景色", trigger: "blur" }],
},
};
},
created() {
this.currentColor = this.info.bgColor;
},
methods: {
// 颜色值改变事件处理
colorValueChange(fmtObj) {
// 取颜色对象的 rgba 值
const { r, g, b, a } = fmtObj.rgba;
this.currentColor = `rgba(${r}, ${g}, ${b}, ${a})`;
this.info.bgColor = this.currentColor;
},
close() {
this.$emit("close");
},
handleSubmit(formName) {
this.loading = true;
this.$refs[formName].validate(async (valid) => {
if (valid) {
return apiUpdateLabel(this.info)
.then((res) => {
this.$message.success("编辑成功");
this.$emit("close");
})
.catch((err) => {
console.log(err);
this.$message.info("编辑失败");
})
.finally(() => {
this.loading = false;
});
} else {
console.log("error submit!!");
this.loading = false;
return false;
}
});
},
},
};
</script>
<style lang="less" scoped>
.el-form {
.el-form-item {
display: flex;
align-items: center;
/deep/ .el-form-item__label {
min-width: 80px;
}
/deep/.el-form-item__content {
margin-left: 0 !important;
width: 260px;
.el-select {
width: 260px;
}
}
}
}
.label-box {
color: #fff;
border-radius: 12px;
font-size: 14px;
text-align: center;
max-width: 150px;
}
</style>
\ No newline at end of file
<template>
<div class="label-list">
<zp-page-list>
<template v-slot:header>
<span>标签列表</span>
</template>
<!-- filter start -->
<div slot="filter">
<el-form
ref="searchForm"
class="zp-search-form"
:inline="true"
:model="searchForm"
>
<el-form-item label="关键词:" prop="keyword">
<el-input
placeholder="请输入标签、背景色"
v-model="searchForm.keyword"
@keydown.enter.native="getLabelList"
></el-input>
</el-form-item>
<el-button type="primary" @click="getLabelList"> 查询 </el-button>
</el-form>
</div>
<!-- filter end -->
<!-- list start -->
<div slot="list">
<zp-table-list
:loading="listLoading"
:source="labelList"
:count="pageInfo.total"
:columns="columns"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
>
<template slot="_id" slot-scope="scope">
<el-button
icon="el-icon-document-copy"
type="primary"
size="mini"
class="clipboardBtn"
:data-clipboard-text="scope.row._id"
@click="handleCopyId"
>复制
</el-button>
</template>
<template slot="label" slot-scope="scope">
<div
class="label-box"
:style="{ backgroundColor: scope.row.bgColor }"
>
{{ scope.row.label }}
</div>
</template>
<template slot="operate" slot-scope="scope">
<el-button size="mini" type="primary" @click="handleEdit(scope.row)"
>编辑</el-button
>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.row)"
>删除</el-button
>
</template>
</zp-table-list>
</div>
<!-- list end -->
</zp-page-list>
<editDialog
v-if="editShow"
:info="labelInfo"
@close="handleClose"
></editDialog>
</div>
</template>
<script>
import Clipboard from "clipboard";
import editDialog from "./components/editDialog";
import { apiGetLabelList, apiDelLabel } from "src/api/label";
export default {
components: {
editDialog,
},
computed: {
},
data() {
return {
listLoading: false,
editShow: false,
searchForm: {
keyword: "",
},
labelList: [],
columns: [
{
label: "_id",
prop: "_id",
slot: "_id",
},
{
label: "标签",
prop: "label",
slot: "label",
},
{
label: "背景色",
prop: "bgColor",
},
{
label: "操作",
slot: "operate",
width: "150",
},
],
};
},
mounted() {
this.requestPageData = this.getLabelList;
this.getLabelList();
},
methods: {
getLabelList() {
let params = {
keyword: this.searchForm.keyword,
pageindex: this.pageInfo.pageNum,
pagesize: this.pageInfo.pageSize,
};
this.listLoading = true;
return apiGetLabelList(params)
.then((res) => {
let { list, total } = res.data;
this.labelList = list;
this.pageInfo.total = total;
})
.catch((err) => {
this.listLoading = false;
console.log(err);
})
.finally(() => {
this.listLoading = false;
});
},
handleCopyId() {
let clipboard = new Clipboard(".clipboardBtn");
clipboard.on("success", (e) => {
this.$message.success("复制成功");
clipboard.destroy();
});
clipboard.on("error", (e) => {
this.$message.error("该浏览器不支持自动复制");
clipboard.destroy();
});
},
handleClose() {
this.editShow = false;
},
handleDelete(row) {
this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(async () => {
try {
await this.handleDeleteLabel(row._id);;
} catch (e) {
this.$message.error("删除失败");
console.log(e);
}
})
.catch(() => {
this.$message.info("已取消删除");
});
},
handleDeleteLabel(id) {
return apiDelLabel({ id })
.then((res) => {
this.$message.success("删除成功");
this.getLabelList(true);
})
.catch((err) => {
console.log(err);
this.$message.info("删除失败");
})
.finally(() => { });
},
handleEdit(row) {
this.editShow = true;
this.labelInfo = row;
},
},
};
</script>
<style lang="less" scoped>
.label-box {
color: #fff;
padding: 4px 0;
border-radius: 12px;
font-size: 14px;
text-align: center;
max-width: 150px;
}
</style>
<template>
<div class="sign_out">
<el-dropdown>
<div class="el-dropdown-link">
<Icon name="avatar" class="avatar"></Icon>
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>{{ userName }}</el-dropdown-item>
<el-dropdown-item @click.native="removeCookie">退出</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</template>
<script>
import { removeToken } from "../../utils/auth";
import { mapGetters } from "vuex";
export default {
methods: {
removeCookie() {
removeToken();
this.$store.dispatch("clearInfo");
this.$router.push("/login");
},
},
computed: {
...mapGetters(["userName"]),
},
};
</script>
<style lang="less" scoped>
.sign_out {
float: right;
margin-right: 20px;
> * {
display: inline-block;
vertical-align: middle;
}
.avatar {
font-size: 40px;
margin-top: 5px;
color: @highlightColor;
}
img {
width: 40px;
height: 40px;
border-radius: 10px;
margin-top: 5px;
}
.sign_out_icon {
color: #5a5e66;
font-size: 20px;
cursor: pointer;
&:hover {
color: #aaa;
}
}
}
</style>
\ No newline at end of file
<template>
<div class="content-wrapper">
<transition>
<router-view></router-view>
</transition>
</div>
</template>
export { default as NavBar } from './navBar'
export { default as SlideBar } from './slideBar'
export { default as ContentView } from './content'
<template>
<div class="app-wrapper" :class="{hideSidebar: $store.state.app.slideBar.opened}">
<SlideBar class="slidebar-container"></SlideBar>
<div class="main-container">
<NavBar></NavBar>
<ContentView></ContentView>
</div>
</div>
</template>
<script>
import { SlideBar, NavBar, ContentView } from './index'
export default {
name: 'layout',
components: {
SlideBar,
NavBar,
ContentView
}
}
</script>
<style lang="less" scoped>
.app-wrapper {
&.hideSidebar {
.slidebar-container{
width: 64px;
overflow: inherit;
}
.main-container {
margin-left: 64px;
}
}
.slidebar-container {
height: 100%;
position: fixed;
top: 0;
bottom: 0;
left: 0;
z-index: 1001;
overflow-y: auto;
transition: width 0.28s ease-out;
}
.main-container {
min-height: 100%;
margin-left: 200px;
transition: margin-left 0.28s ease-out;
}
}
</style>
<template>
<el-breadcrumb class="levelbar-wrapper" separator="/">
<el-breadcrumb-item v-for="(item, index) in levelList" :key="index">
<router-link :to="item.path">{{ item.name }}</router-link>
</el-breadcrumb-item>
</el-breadcrumb>
</template>
<script>
export default {
created() {
this.getBreadcrumb();
},
data() {
return {
levelList: []
};
},
methods: {
getBreadcrumb() {
let matched = this.$route.matched.filter(item => item.name);
let first = matched[0],
second = matched[1];
if (first && first.name !== '首页' && first.name !== '') {
matched = [{ name: '首页', path: '/' }].concat(matched);
}
if (second && second.name === '首页') {
this.levelList = [second];
} else {
this.levelList = matched;
}
}
},
watch: {
$route() {
this.getBreadcrumb();
}
}
};
</script>
<style lang="less" scoped>
.levelbar-wrapper.el-breadcrumb {
display: inline-block;
font-size: 14px;
line-height: 50px;
margin-left: 10px;
.no-redirect {
color: #97a8be;
cursor: text;
}
}
</style>
\ No newline at end of file
<template>
<div class="nav-bar-wrapper" separator="/">
<Hamburger
class="hamburger"
:toggleClick="toggleSlideBar"
:isActive="app.slideBar.opened"
></Hamburger>
<Levelbar class="levelbar"></Levelbar>
<TabsView class="tabsview"></TabsView>
<Account></Account>
</div>
</template>
<script>
import { mapState } from "vuex";
import Hamburger from "components/hamburger";
import Levelbar from "./levelbar";
import TabsView from "./tabsView";
import Account from "./account";
export default {
components: {
Hamburger,
Levelbar,
TabsView,
Account,
},
methods: {
toggleSlideBar() {
this.$store.dispatch("toggleSideBar");
},
},
computed: {
...mapState(["app"]),
},
};
</script>
<style lang="less" scoped>
.nav-bar-wrapper {
height: 50px;
// line-height: 50px;
background: #eef1f6;
> * {
display: inline-block;
vertical-align: middle;
}
.hamburger {
line-height: 58px;
width: 40px;
height: 50px;
padding: 0 10px;
}
.levelbar {
font-size: 14px;
line-height: 50px;
margin-left: 10px;
}
.tabsview {
margin-left: 10px;
}
}
</style>
<template>
<div class="silde-bar-wrapper">
<el-menu
class="el-menu-vertical"
:default-active="$route.path"
unique-opened
router
:collapse="$store.state.app.slideBar.opened"
>
<template v-for="item in $store.state.permission.routes">
<el-menu-item
v-if="!item.hidden && !item.dropdown"
:index="
(item.path === '/' ? item.path : item.path + '/') +
item.children[0].path
"
:key="item.path"
>
<Icon :name="item.icon" class="slide-icon"></Icon>
<span slot="title">{{ item.name }}</span>
</el-menu-item>
<el-submenu
v-if="!item.hidden && item.dropdown"
:index="item.path"
:key="item.path"
>
<template slot="title">
<Icon :name="item.icon" class="slide-icon"></Icon>
<span>{{ item.name }}</span>
</template>
<template v-for="child in getSubMenuHiddleList(item.children)">
<el-menu-item
:index="item.path + '/' + child.path"
:key="child.path"
>{{ child.name }}</el-menu-item
>
</template>
</el-submenu>
</template>
</el-menu>
</div>
</template>
<script>
export default {
computed: {
getSubMenuHiddleList() {
return (list) =>
list.filter(item => !item.hidden)
},
},
data() {
return {
}
},
methods: {
}
};
</script>
<style lang="less" scoped>
.silde-bar-wrapper {
.el-menu-vertical:not(.el-menu--collapse) {
width: 200px;
height: 100%;
}
.el-menu-vertical {
height: 100%;
}
.el-menu {
border-right: none;
}
.slide-icon {
width: 24px;
font-size: 20px;
text-align: center;
vertical-align: middle;
}
}
</style>
\ No newline at end of file
<template>
<div class="tabs-wwrapper">
<router-link
class="tab-view"
:to="tag.path"
v-for="tag in getTags"
:key="tag.name"
>
<el-tag
size="small"
closable
:type="getIsActive(tag) ? '' : 'info'"
@close="closeTagView(tag, $event)"
>
{{ tag.name }}
</el-tag>
</router-link>
</div>
</template>
<script>
export default {
computed: {
getTags() {
let tagArr = this.$store.state.app.tagViews;
return tagArr.filter((item) => item.path !== "/article/edit").slice(-6);
},
},
watch: {
$route() {
this.addTagView();
},
},
mounted() {
this.getIsActive();
},
methods: {
getIsActive(tag) {
if (!tag) return;
return tag.path === this.$route.path;
},
closeTagView(tag, e) {
this.$store.dispatch("delTagView", tag);
e.preventDefault();
},
generateRoute() {
if (this.$route.matched[this.$route.matched.length - 1].name) {
return this.$route.matched[this.$route.matched.length - 1];
}
return this.$route.matched[0];
},
addTagView() {
this.$store.dispatch("addTagView", this.generateRoute());
},
},
};
</script>
<style lang="less" scoped>
.tab-view {
margin-left: 10px;
}
</style>
\ No newline at end of file
<template>
<div class="login-wrapper">
<el-form class="login-form">
<h3>博客系统登录</h3>
<el-form-item prop="username">
<Icon name="user" class="icon-user"></Icon>
<el-input
type="text"
placeholder="请输入用户名"
class="username"
v-model="loginInfo.username"
@keydown.enter.native="login"
/>
</el-form-item>
<el-form-item prop="password">
<Icon name="password" class="icon-pwd"></Icon>
<el-input
type="password"
placeholder="请输入密码"
class="pwd"
v-model="loginInfo.pwd"
@keydown.enter.native="login"
/>
</el-form-item>
<el-button type="primary" class="submit" @click="login" :loading="loading"
>登录</el-button
>
</el-form>
</div>
</template>
<script>
export default {
name: "login",
data() {
return {
loading: false,
msg: "",
loginInfo: {
username: "",
pwd: "",
},
};
},
methods: {
async login() {
this.loading = true;
if (!this.loginInfo.username) {
this.msg = "请输入用户名";
} else if (!this.loginInfo.pwd) {
this.msg = "请输入密码";
}
if (this.msg) {
this.$message({
message: this.msg,
type: "warning",
});
this.msg = "";
this.loading = false;
return;
}
try {
await this.$store.dispatch("userLogin", this.loginInfo);
this.$router.push("/article/list");
} catch (e) {
console.log(e);
}
this.loading = false;
},
},
};
</script>
<style lang="less">
.login-wrapper {
width: 100%;
height: 100%;
position: fixed;
background: #2d3a4b;
.login-form {
width: 400px;
padding: 35px;
position: absolute;
left: 0%;
right: 0%;
top: 20%;
margin: auto;
}
.el-form-item {
border: 1px solid rgba(255, 255, 255, 0.1);
background: rgba(0, 0, 0, 0.1);
border-radius: 5px;
color: #454545;
}
h3 {
font-size: 26px;
color: #fff;
margin-bottom: 50px;
text-align: center;
}
.icon {
color: #889aa4;
vertical-align: middle;
width: 1em;
height: 1em;
display: inline-block;
margin-left: 10px;
}
.icon-user,
.icon-pwd {
width: 1.5em;
height: 1.5em;
margin-left: 8px;
}
input {
background: transparent;
border: 0px;
-webkit-appearance: none;
border-radius: 0px;
padding: 12px 5px 12px 15px;
color: #889aa4;
height: 47px;
vertical-align: middle;
color: #eee;
}
.username input {
padding: 12px 5px 12px 10px;
}
.el-input {
display: inline-block;
height: 47px;
width: 85%;
}
.submit {
width: 100%;
}
}
</style>
\ No newline at end of file
<template>
<div class="message-list">
<zp-page-list>
<template v-slot:header>
<span>留言列表</span>
</template>
<!-- filter start -->
<div slot="filter">
<el-form
ref="searchForm"
class="zp-search-form"
:inline="true"
:model="searchForm"
>
<el-form-item label="关键词:" prop="keyword">
<el-input
placeholder="请输入内容、昵称"
v-model="searchForm.keyword"
@keydown.enter.native="getMessageList(true)"
></el-input>
</el-form-item>
<el-button type="primary" @click="getMessageList(true)">
查询
</el-button>
</el-form>
</div>
<!-- filter end -->
<!-- list start -->
<div slot="list">
<zp-table-list
ref="sensitiveBehaviorRecordList"
:loading="listLoading"
:source="messageList"
:count="pageInfo.total"
:columns="columns"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
>
<template slot="_id" slot-scope="scope">
<el-button
icon="el-icon-document-copy"
type="primary"
size="mini"
class="clipboardBtn"
:data-clipboard-text="scope.row._id"
@click="handleCopyId"
>复制
</el-button>
</template>
<template slot="content" slot-scope="scope">
<div v-html="scope.row.content"></div>
</template>
<template slot="createTime" slot-scope="scope">
{{ scope.row.createTime | formatTime("yyyy-MM-dd hh:mm:ss") }}
</template>
<template slot="operate" slot-scope="scope">
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.row)"
>删除</el-button
>
</template>
</zp-table-list>
</div>
<!-- list end -->
</zp-page-list>
</div>
</template>
<script>
import Clipboard from "clipboard";
import { apiGetMessageList, apiDelMessage } from "src/api/message";
export default {
name: "messageList",
components: {},
computed: {},
data() {
return {
listLoading: false,
searchForm: {
keyword: "",
},
messageList: [],
columns: [
{
label: "_id",
prop: "_id",
slot: "_id",
},
{
label: "昵称",
prop: "nickname",
},
{
label: "头像颜色",
prop: "headerColor",
},
{
label: "评论内容",
prop: "content",
slot: "content",
showTooltip: true,
},
{
label: "时间",
prop: "createTime",
slot: "createTime",
},
{
label: "点赞数",
prop: "likes",
},
{
label: "操作",
slot: "operate",
width: "150",
},
],
};
},
created() {
this.requestPageData = this.getMessageList;
this.getMessageList();
},
mounted() { },
methods: {
getMessageList() {
let params = {
keyword: this.searchForm.keyword,
pageindex: this.pageInfo.pageNum,
pagesize: this.pageInfo.pageSize,
};
this.listLoading = true;
return apiGetMessageList(params)
.then((res) => {
let { list, total } = res.data;
this.messageList = list;
this.pageInfo.total = total;
})
.catch((err) => {
this.listLoading = false;
console.log(err);
})
.finally(() => {
this.listLoading = false;
this.hasLoad = true;
});
},
handleCopyId() {
let clipboard = new Clipboard(".clipboardBtn");
clipboard.on("success", (e) => {
this.$message.success("复制成功");
clipboard.destroy();
});
clipboard.on("error", (e) => {
this.$message.error("该浏览器不支持自动复制");
clipboard.destroy();
});
},
handleDeleteMessage(id) {
return apiDelMessage({ id })
.then((res) => {
this.$message.success("删除成功");
this.getMessageList(true);
})
.catch((err) => {
console.log(err);
this.$message.info("删除失败");
})
.finally(() => { });
},
handleDelete(row) {
this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.handleDeleteMessage(row._id);
})
.catch(() => {
this.$message.info("已取消删除");
});
},
},
};
</script>
<style lang="less" scoped>
</style>
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.