Skip to content

Commit

Permalink
1.首页新增知乎日报
Browse files Browse the repository at this point in the history
2.新增一个tab面包屑导航
  • Loading branch information
BoBoooooo committed Jan 18, 2018
1 parent 7f74646 commit 93777ec
Show file tree
Hide file tree
Showing 20 changed files with 659 additions and 217 deletions.
9 changes: 9 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ module.exports = {
pathRewrite: {
'^/douban': ''//这里理解成用‘/api’代替target里面的地址,后面组件中我们掉接口时直接用api代替 比如我要调用'http://40.00.100.100:3002/user/add',直接写‘/api/user/add’即可
}
},
'/report': {
target: 'https://news-at.zhihu.com/api/4/news',//设置你调用的接口域名和端口号 别忘了加http
changeOrigin: true,
pathRewrite: {
'^/report': ''//这里理解成用‘/api’代替target里面的地址,后面组件中我们掉接口时直接用api代替 比如我要调用'http://40.00.100.100:3002/user/add',直接写‘/api/user/add’即可
}
}


},
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>vue-admin</title>
<title>Anshare_Vue</title>
</head>
<body>
<div id="app"></div>
Expand Down
8 changes: 8 additions & 0 deletions src/api/system/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ export function GetRoles(params){
})
}

export function GetRolesOptions(){
return fetch({
url: '/admin/pullrolelist',
method: 'post',

})
}

export function DeleteRole(ID){
return fetch({
url: '/admin/Delrole',
Expand Down
8 changes: 3 additions & 5 deletions src/components/Breadcrumb/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
<el-breadcrumb class="app-breadcrumb" separator="/">
<transition-group name="breadcrumb">
<el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path" v-if='item.meta.title'>
<span v-if='item.redirect==="noredirect"||index==levelList.length-1' class="no-redirect">{{generateTitle(item.meta.title)}}</span>
<router-link v-else :to="item.redirect||item.path">{{generateTitle(item.meta.title)}}</router-link>
<span v-if='item.meta.father||index==levelList.length-1' class="no-redirect">{{item.meta.title}}</span>
<router-link v-else :to="item.redirect||item.path">{{item.meta.title}}</router-link>
</el-breadcrumb-item>
</transition-group>
</el-breadcrumb>
</template>

<script>
import { generateTitle } from '@/utils/i18n'
export default {
created() {
Expand All @@ -27,12 +26,11 @@ export default {
}
},
methods: {
generateTitle,
getBreadcrumb() {
let matched = this.$route.matched.filter(item => item.name)
const first = matched[0]
if (first && first.name !== 'dashboard') {
matched = [{ path: '/dashboard', meta: { title: 'dashboard' }}].concat(matched)
matched = [{ path: '/dashboard', meta: { title: '首页' }}].concat(matched)
}
this.levelList = matched
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/GithubCorner/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<a href="https://github.com/PanJiaChen/vue-element-admin" target="_blank" class="github-corner" aria-label="View source on Github">
<a href="https://github.com/BoBoooooo" target="_blank" class="github-corner" aria-label="Follow me on Github" title="Follow me on Github">
<svg width="80" height="80" viewBox="0 0 250 250" style="fill:#40c9c6; color:#fff; position: absolute; top: 84px; border: 0; right: 0;"
aria-hidden="true">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
Expand Down
104 changes: 104 additions & 0 deletions src/filters/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
function pluralize(time, label) {
if (time === 1) {
return time + label
}
return time + label + 's'
}

export function timeAgo(time) {
const between = Date.now() / 1000 - Number(time)
if (between < 3600) {
return pluralize(~~(between / 60), ' minute')
} else if (between < 86400) {
return pluralize(~~(between / 3600), ' hour')
} else {
return pluralize(~~(between / 86400), ' day')
}
}

export function parseTime(time, cFormat) {
if (arguments.length === 0) {
return null
}

if ((time + '').length === 10) {
time = +time * 1000
}

const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'object') {
date = time
} else {
date = new Date(parseInt(time))
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
if (key === 'a') return ['一', '二', '三', '四', '五', '六', '日'][value - 1]
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
}

export function formatTime(time, option) {
time = +time * 1000
const d = new Date(time)
const now = Date.now()

const diff = (now - d) / 1000

if (diff < 30) {
return '刚刚'
} else if (diff < 3600) { // less 1 hour
return Math.ceil(diff / 60) + '分钟前'
} else if (diff < 3600 * 24) {
return Math.ceil(diff / 3600) + '小时前'
} else if (diff < 3600 * 24 * 2) {
return '1天前'
}
if (option) {
return parseTime(time, option)
} else {
return d.getMonth() + 1 + '月' + d.getDate() + '日' + d.getHours() + '时' + d.getMinutes() + '分'
}
}

/* 数字 格式化*/
export function nFormatter(num, digits) {
const si = [
{ value: 1E18, symbol: 'E' },
{ value: 1E15, symbol: 'P' },
{ value: 1E12, symbol: 'T' },
{ value: 1E9, symbol: 'G' },
{ value: 1E6, symbol: 'M' },
{ value: 1E3, symbol: 'k' }
]
for (let i = 0; i < si.length; i++) {
if (num >= si[i].value) {
return (num / si[i].value + 0.1).toFixed(digits).replace(/\.0+$|(\.[0-9]*[1-9])0+$/, '$1') + si[i].symbol
}
}
return num.toString()
}

export function html2Text(val) {
const div = document.createElement('div')
div.innerHTML = val
return div.textContent || div.innerText
}

export function toThousandslsFilter(num) {
return (+num || 0).toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
}
1 change: 1 addition & 0 deletions src/icons/svg/sunny.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import '@/icons' // icon
import '@/permission' // 权限import axios from 'axios';
import axios from 'axios'
import $ from 'jquery'
Vue.use(ElementUI)
import * as filters from './filters' // global filters

Vue.use(ElementUI)
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key])
})
Vue.config.productionTip = false

new Vue({
Expand Down
91 changes: 49 additions & 42 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ export const constantRouterMap = [
{
path: '/',
component: Layout,
redirect: '/dashboard',
name: '首页',
hidden: true,
children: [{ path: 'dashboard', component: _import('dashboard/index') }]
}
redirect: 'dashboard',
noDropdown:true,
hidden:true,
children: [{
path: 'dashboard',
component: _import('dashboard/index'),
name: 'dashboard',
meta: { title: '首页', icon: 'dashboard', noCache: true }
}]
},
]

export default new Router({
Expand All @@ -36,58 +41,60 @@ export default new Router({

export const asyncRouterMap = [


{
path: '/system',
path: '/DouBan',
component: Layout,
redirect: 'noredirect',
name: '系统设置',
icon: 'zujian',
meta: { role: ['system']},
children: [
{ path: 'users', name: '用户设置', icon: 'icons', component: _import('system/users'),meta: { role: ['system'] }},

{ path: 'role', name: '角色设置', icon: 'icons', component: _import('system/role'),meta: { role: ['system'] }},
{ path: 'dept', name: '部门设置', icon: 'icons', component: _import('system/dept'),meta: { role: ['system'] }},


]
redirect: '/DouBan/movie',
name:"DouBan",
meta: { role: ['user','system'],title:"豆瓣查询" ,icon:'tubiao',father:true},
children: [{ path: 'movie', name: 'movie', component: _import('DouBan/movie'), meta: { role: ['user','system'],title:"热门电影" }},
{ path: 'music', name: 'music', component: _import('DouBan/music'), meta: { role: ['user','system'] ,title:"音乐排行"}},
{ path: 'book', name: 'book', component: _import('DouBan/book'), meta: { role: ['user','system'] ,title:"热门图书"}}]
},

{
path: '/table',
path: '/KaoQin',
component: Layout,
redirect: '/table/index',
icon: 'tubiao',
noDropdown: true,
children: [{ path: 'index', name: 'Table', component: _import('table/index'), meta: { role: ['admin'] }}]
redirect: '/KaoQin/person',
name:"人员信息",
meta: { role: ['user','system'],title:"人员信息" ,icon:'zonghe',father:true},
children: [{ path: 'person', name: 'person', component: _import('KaoQin/person'), meta: { role: ['user','system'] ,title:"人员信息录入"}}]
},

{
path: '/DouBan',
path: '/KaoQin',
component: Layout,
redirect: 'noredirect',
name:"豆瓣查询",
icon: 'tubiao',
children: [{ path: 'movie', name: '热门电影', component: _import('DouBan/movie'), meta: { role: ['user','system'] }},
{ path: 'music', name: '音乐排行', component: _import('DouBan/music'), meta: { role: ['user','system'] }},
{ path: 'book', name: '热门图书', component: _import('DouBan/book'), meta: { role: ['user','system'] }}]
redirect: '/KaoQin/import',
name:"KaoQin",
meta: { role: ['user','system'],title:"考勤管理" ,icon:'zonghe',father:true},
children: [{ path: 'import', name: 'import', component: _import('KaoQin/import'), meta: { role: ['user','system'] ,title:"考勤信息录入"}},
{ path: 'count', name: 'count', component: _import('KaoQin/count'), meta: { role: ['user','system'] ,title:"考勤信息汇总"}}]
},
{
path: '/KaoQin',
path: '/table',
component: Layout,
redirect: 'noredirect',
name:"人员信息",
icon: 'theme',
children: [{ path: 'person', name: '人员信息录入', component: _import('KaoQin/person'), meta: { role: ['user','system'] }}]
redirect: '/table/index',
noDropdown:true,
meta: { role: ['user','system'],title:"Table" ,icon:'zonghe',father:true},
meta: { role: ['user','system'],title:"table" ,icon:'zonghe'},
children: [{ path: 'import', name: 'table1', component: _import('table/index'), meta: { role: ['user','system'] ,title:"表格"}}]
},

{
path: '/KaoQin',
path: '/system',
component: Layout,
redirect: 'noredirect',
name:"考勤管理",
icon: 'zonghe',
children: [{ path: 'import', name: '考勤信息录入', component: _import('KaoQin/import'), meta: { role: ['user','system'] }},
{ path: 'count', name: '考勤信息汇总', component: _import('KaoQin/count'), meta: { role: ['user','system'] }}]
name: 'system',
meta: { role: ['system'],title:"系统设置",icon:'zujian',father:true},
children: [
{ path: 'users', name: 'users', icon: 'icons', component: _import('system/users'),meta: { role: ['system'],title:"用户设置" }},

{ path: 'role', name: 'role', icon: 'icons', component: _import('system/role'),meta: { role: ['system'] ,title:"角色设置"}},
{ path: 'dept', name: 'dept', icon: 'icons', component: _import('system/dept'),meta: { role: ['system'],title:"部门设置" }},


]
},


{ path: '*', redirect: '/404', hidden: true }
]
2 changes: 2 additions & 0 deletions src/store/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const getters = {
sidebar: state => state.app.sidebar,
token: state => state.user.token,
// avatar: state => state.user.avatar,
visitedViews: state => state.tagsView.visitedViews,
cachedViews: state => state.tagsView.cachedViews,
realname:state=>state.user.realname,
name: state => state.user.name,
roles: state => state.user.roles,
Expand Down
3 changes: 3 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Vuex from 'vuex'
import app from './modules/app'
import user from './modules/user'
import permission from './modules/permission'
import tagsView from './modules/tagsView'

import getters from './getters'

Vue.use(Vuex)
Expand All @@ -11,6 +13,7 @@ const store = new Vuex.Store({
modules: {
app,
user,
tagsView,
permission
},
getters
Expand Down
Loading

0 comments on commit 93777ec

Please sign in to comment.