Commit d4aecbb4 authored by caimeng's avatar caimeng

修复npm包造成的问题

parent b4a76166
BASE_URL=''
VUE_APP_API_PATH=/api
BASE_URL=''
VUE_APP_API_PATH=http://crm.newbuytek.com
BASE_URL=''
VUE_APP_API_PATH=http://testcrm.newbuytek.com
const data = [
'alphabetical_sorting',
'advance',
'address_book',
'alphabetical_sorting',
'advertising',
'alarm_clock',
'area_chart',
'approval',
'answers',
'approve',
'assistant',
'audio_file',
'automotive',
'automatic',
'bad_decision',
'bar_chart',
'bearish',
'biomass',
'biohazard',
'binoculars',
'bookmark',
'briefcase',
'biotech',
'broken_link',
'business',
'bullish',
'business_contact',
'businesswoman',
'cable_release',
'calculator',
'businessman',
'calendar',
'butting_in',
'call_transfer',
'callback',
'camcorder',
'camera',
'camcorder_pro',
'cancel',
'camera_addon',
'camera_identificatio',
'capacitor',
'candle_sticks',
'checkmark',
'circuit',
'charge_battery',
'clear_filters',
'clapperboard',
'clock',
'close_up_mode',
'collaboration',
'cell_phone',
'collapse',
'collect',
'cloth',
'combo_chart',
'comments',
'conference_call',
'compact_camera',
'contacts',
'copyleft',
'copyright',
'crystal_oscillator',
'cursor',
'currency_exchange',
'customer_support',
'dam',
'data_backup',
'data_configuration',
'data_encryption',
'data_protection',
'data_recovery',
'database',
'data_sheet',
'debt',
'decision',
'delete_column',
'delete_database',
'department',
'delete_row',
'deployment',
'dislike',
'disapprove',
'disclaimer',
'display',
'document',
'do_not_insert',
'do_not_mix',
'do_not_inhale',
'donate',
'down',
'doughnut_chart',
'down_left',
'down_right',
'download',
'edit_image',
'electrical_sensor',
'electrical_threshold',
'electricity',
'electro_devices',
'electronics',
'empty_battery',
'empty_filter',
'empty_trash',
'end_call',
'engineering',
'entering_heaven_aliv',
'expand',
'export',
'expired',
'factory',
'factory_breakdown',
'external',
'faq',
'feed_in',
'file',
'feedback',
'film',
'filled_filter',
'filing_cabinet',
'film_reel',
'flash_auto',
'fine_print',
'flash_off',
'flash_on',
'flow_chart',
'folder',
'frame',
'full_battery',
'full_trash',
'gallery',
'generic_sorting_asc',
'generic_sorting_desc',
'genealogy',
'globe',
'good_decision',
'headset',
'grid',
'graduation_cap',
'heat_map',
'high_priority',
'high_battery',
'image_file',
'home',
'idea',
'import',
'in_transit',
'integrated_webcam',
'inspection',
'invite',
'internal',
'ipad',
'info',
'iphone',
'kindle',
'key',
'landscape',
'left',
'left_down',
'left_up',
'leave',
'like_placeholder',
'light_at_the_end_of_',
'library',
'line_chart',
'link',
'like',
'lock',
'list',
'lock_landscape',
'low_battery',
'lock_portrait',
'low_priority',
'make_decision',
'medium_priority',
'manager',
'menu',
'middle_battery',
'minus',
'missed_call',
'mind_map',
'mms',
'multiple_cameras',
'money_transfer',
'music',
'multiple_devices',
'multiple_smartphones',
'multiple_inputs',
'negative_dynamic',
'neutral_decision',
'night_landscape',
'news',
'neutral_trading',
'night_portrait',
'no_idea',
'next',
'no_video',
'nook',
'ok',
'org_unit',
'opened_folder',
'old_time_camera',
'online_support',
'organization',
'package',
'paid',
'parallel_tasks',
'overtime',
'panorama',
'phone',
'phone_android',
'photo_reel',
'pie_chart',
'picture',
'planner',
'plus',
'podium_with_audience',
'podium_without_speak',
'podium_with_speaker',
'previous',
'portrait_mode',
'positive_dynamic',
'privacy',
'process',
'puzzle',
'questions',
'print',
'radar_plot',
'rating',
'ratings',
'reading',
'redo',
'reading_ebook',
'refresh',
'registered_trademark',
'right',
'reuse',
'remove_image',
'right_down',
'right_up',
'rotate_to_portrait',
'rules',
'rotate_camera',
'rotate_to_landscape',
'ruler',
'scatter_plot',
'search',
'safe',
'self_service_kiosk',
'selfie',
'serial_tasks',
'sales_performance',
'settings',
'services',
'share',
'shipped',
'sim_card',
'shop',
'service_mark',
'sim_card_chip',
'signature',
'smartphone_tablet',
'sound_recording_copy',
'sms',
'speaker',
'slr_back_side',
'start',
'stack_of_photos',
'statistics',
'sports_mode',
'support',
'synchronize',
'switch_camera',
'survey',
'tablet_android',
'template',
'trademark',
'todo_list',
'touchscreen_smartpho',
'timeline',
'tree_structure',
'undo',
'up_left',
'two_smartphones',
'unlock',
'up',
'up_right',
'upload',
'video_call',
'video_file',
'view_details',
'video_projector',
'vip',
'voice_presentation',
'webcam',
'voicemail',
'workflow',
'about',
'accept_database',
'add_image',
'add_column',
'add_database',
'add_row',
]
module.exports = [
{
url: '/colorfulIcon/getList',
type: 'get',
response(config) {
const { title, pageNo = 1, pageSize = 72 } = config.query
let mockList = data.filter((item) => {
if (title && item.indexOf(title) < 0) return false
return true
})
const pageList = mockList.filter(
(item, index) =>
index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
)
return {
code: 200,
msg: 'success',
totalCount: mockList.length,
data: pageList,
}
},
},
]
const List = [
{
id: 'root',
createTime: '@datetime',
name: '根节点',
order: 0,
children: [
{
id: '1',
parentId: 'root',
parentName: '根节点',
createTime: '@datetime',
name: '桃花坞',
order: 0,
},
{
id: '2',
parentId: 'root',
parentName: '根节点',
createTime: '@datetime',
name: '少林寺',
order: 1,
children: [
{
id: '@uuid',
parentId: '2',
parentName: '少林寺',
createTime: '@datetime',
name: '达摩院',
order: 0,
},
{
id: '@uuid',
parentId: '2',
parentName: '少林寺',
createTime: '@datetime',
name: '戒律堂',
order: 1,
},
],
},
],
},
]
module.exports = [
{
url: '/departmentManagement/getList',
type: 'get',
response: (config) => {
const { name, pageNo = 1, pageSize = 20 } = config.query
let mockList = List.filter((item) => {
return !(name && item.name.indexOf(name) < 0)
})
const pageList = mockList.filter(
(item, index) =>
index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
)
return {
code: 200,
msg: 'success',
totalCount: mockList.length,
data: pageList,
}
},
},
{
url: '/departmentManagement/doEdit',
type: 'post',
response: () => {
return {
code: 200,
msg: '模拟保存成功',
}
},
},
{
url: '/departmentManagement/doDelete',
type: 'post',
response: () => {
return {
code: 200,
msg: '模拟删除成功',
}
},
},
]
const data = {
description:
' 作者寄语:静坐常思己过,闲谈不论人非,vue-admin-beautiful-pro目前已支持5种布局、5种主题,共计25种风格无缝切换,支持三级路由以上缓存,提供最细致的权限处理,支持中英文切换,同时兼容电脑、平板、手机。',
}
module.exports = [
{
url: '/description/getList',
type: 'get',
response: () => {
return {
code: 200,
msg: 'success',
data,
}
},
},
]
const List = [
{
uuid: '@uuid',
icon: 'file-pdf-line',
title: 'pdf打印',
price: '0',
type: '组件',
isRecommend: 1,
},
]
module.exports = [
{
url: '/goods/getList',
type: 'get',
response(config) {
const { title, pageNo = 1, pageSize = 20 } = config.query
let mockList = List.filter((item) => {
return !(title && item.title.indexOf(title) < 0)
})
const pageList = mockList.filter(
(item, index) =>
index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
)
return {
code: 200,
msg: 'success',
totalCount: mockList.length,
data: pageList,
}
},
},
]
module.exports = [
{
url: '/menuManagement/getTree',
type: 'get',
response() {
return {
code: 200,
msg: 'success',
totalCount: 999,
data: [
{
id: 'root',
label: '全部角色',
children: [
{
id: '@id',
role: 'admin',
label: 'admin角色',
},
{
id: '@id',
role: 'editor',
label: 'editor角色',
},
],
},
],
}
},
},
{
url: '/menuManagement/doEdit',
type: 'post',
response() {
return {
code: 200,
msg: '模拟保存成功',
}
},
},
{
url: '/menuManagement/doDelete',
type: 'post',
response() {
return {
code: 200,
msg: '模拟删除成功',
}
},
},
]
const data = [
{
email: '@email',
image: 'https://i.gtimg.cn/club/item/face/img/2/15922_100.gif',
notice: '官方QQ群1:972435319、官方QQ群2:1139183756',
},
{
email: '@email',
image: 'https://i.gtimg.cn/club/item/face/img/8/15918_100.gif',
notice:
"github开源地址:<a target='_blank' href='https://github.com/chuzhixin/vue-admin-beautiful'>https://github.com/chuzhixin/vue-admin-beautiful</a>",
},
{
email: '@email',
image: 'https://i.gtimg.cn/club/item/face/img/0/15640_100.gif',
notice:
"开源中国地址:<a target='_blank' href='https://www.oschina.net/p/vue-admin-beautiful'>https://www.oschina.net/p/vue-admin-beautiful</a>",
},
{
email: '@email',
image: 'https://i.gtimg.cn/club/item/face/img/9/15919_100.gif',
notice:
"gitee开源地址:<a target='_blank' href='https://gitee.com/chu1204505056/vue-admin-beautiful'>https://gitee.com/chu1204505056/vue-admin-beautiful</a>",
},
{
email: '@email',
image: 'https://i.gtimg.cn/club/item/face/img/8/15918_100.gif',
notice:
"vue3.0 体验地址:<a target='_blank' href='https://chu1204505056.gitee.io/vue-admin-beautiful-antdv'>'https://chu1204505056.gitee.io/vue-admin-beautiful-antdv</a>",
},
]
module.exports = [
{
url: '/notice/getList',
type: 'get',
response: () => {
return {
code: 200,
msg: 'success',
data,
}
},
},
]
This diff is collapsed.
const List = [
{
id: '@id',
role: 'admin',
},
{
id: '@id',
role: 'editor',
},
]
module.exports = [
{
url: '/roleManagement/getList',
type: 'get',
response(config) {
const { role, pageNo = 1, pageSize = 20 } = config.query
let mockList = List.filter((item) => {
return !(role && item.title.indexOf(role) < 0)
})
const pageList = mockList.filter(
(item, index) =>
index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
)
return {
code: 200,
msg: 'success',
totalCount: mockList.length,
data: pageList,
}
},
},
{
url: '/roleManagement/doEdit',
type: 'post',
response() {
return {
code: 200,
msg: '模拟保存成功',
}
},
},
{
url: '/roleManagement/doDelete',
type: 'post',
response() {
return {
code: 200,
msg: '模拟删除成功',
}
},
},
]
This diff is collapsed.
const data = [
{
url: 'https://github.com/chuzhixin/vue-admin-beautiful',
value:
'中国最好用的框架企业级、中后台、通用型前端框架vue-admin-beautiful-pro',
},
{
url:
'https://www.baidu.com/s?wd=vue-admin-beautiful%E6%96%87%E6%A1%A3&rsv_spt=1&rsv_iqid=0xb8393f250000e09a&issp=1&f=3&rsv_bp=1&rsv_idx=2&ie=utf-8&rqlang=cn&tn=baiduhome_pg&rsv_enter=1&rsv_dl=ts_0&oq=vue-admin-beautiful&rsv_t=780fn2RNJdwKpBcnXhafmyPjUPAduXDbHgYYngJ2QKBQluEnKOClb2r3SE4W%2BzhtF6fV&rsv_btype=t&inputT=459&rsv_sug3=5&rsv_sug1=5&rsv_sug7=100&rsv_pq=ed30ea5500032c4b&rsv_sug2=0&prefixsug=vue-admin-beautiful&rsp=0&rsv_sug4=1793',
value: 'vue-admin-beautiful文档',
},
{
url:
'https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=2&tn=baiduhome_pg&wd=beautiful.panm.cn&oq=beautiful.panm.cn&rsv_pq=bf312c2f00026019&rsv_t=a6b8%2Fo1W16TeYRYzViSwSXsVMosb255PaiEfKTXMKKNx0dwOtxpowxPYRP%2FJ%2BgMgtcAo&rqlang=cn&rsv_enter=1&rsv_dl=tb&rsv_btype=t&inputT=2&rsv_sug3=61&rsv_sug2=0&rsv_sug4=883&bs=beautiful.panm.cn',
value: 'vue-admin-beautiful官网',
},
]
module.exports = [
{
url: '/search/getList',
type: 'get',
response: () => {
return {
code: 200,
msg: 'success',
data,
}
},
},
]
const { mock } = require('mockjs')
const { handleRandomImage } = require('../utils')
const List = []
const count = 50
for (let i = 0; i < count; i++) {
List.push(
mock({
uuid: '@uuid',
id: '@id',
title: '@title(1, 2)',
description: '@csentence',
'status|1': ['published', 'draft', 'deleted'],
author: '@cname',
datetime: '@datetime',
pageViews: '@integer(300, 5000)',
img: handleRandomImage(228, 228),
switch: '@boolean',
percent: '@integer(80,99)',
'rate|1': [1, 2, 3, 4, 5],
a: '@title(1, 2)',
b: '@title(1, 2)',
c: '@title(1, 2)',
d: '@title(1, 2)',
e: '@title(1, 2)',
f: '@title(1, 2)',
g: '@title(1, 2)',
})
)
}
module.exports = [
{
url: '/table/getList',
type: 'get',
response(config) {
const { title, pageNo = 1, pageSize = 20 } = config.query
let mockList = List.filter((item) => {
return !(title && item.title.indexOf(title) < 0)
})
const pageList = mockList.filter(
(item, index) =>
index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
)
return {
code: 200,
msg: 'success',
totalCount: mockList.length,
data: pageList,
}
},
},
{
url: '/table/doEdit',
type: 'post',
response() {
return {
code: 200,
msg: '模拟保存成功',
}
},
},
{
url: '/table/doDelete',
type: 'post',
response() {
return {
code: 200,
msg: '模拟删除成功',
}
},
},
]
const accessTokens = {
admin: 'admin-accessToken',
editor: 'editor-accessToken',
test: 'test-accessToken',
}
module.exports = [
{
url: '/publicKey',
type: 'post',
response() {
return {
code: 200,
msg: 'success',
data: {
mockServer: true,
publicKey:
'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBT2vr+dhZElF73FJ6xiP181txKWUSNLPQQlid6DUJhGAOZblluafIdLmnUyKE8mMHhT3R+Ib3ssZcJku6Hn72yHYj/qPkCGFv0eFo7G+GJfDIUeDyalBN0QsuiE/XzPHJBuJDfRArOiWvH0BXOv5kpeXSXM8yTt5Na1jAYSiQ/wIDAQAB',
},
}
},
},
{
url: '/login',
type: 'post',
response(config) {
const { username } = config.body
const accessToken = accessTokens[username]
if (!accessToken) {
return {
code: 500,
msg: '帐户或密码不正确',
}
}
return {
code: 200,
msg: 'success',
data: { accessToken },
}
},
},
{
url: '/socialLogin',
type: 'post',
response(config) {
const { code } = config.body
if (!code) {
return {
code: 500,
msg: '未成功获取Token',
}
}
return {
code: 200,
msg: 'success',
data: { accessToken: accessTokens['admin'] },
}
},
},
{
url: '/register',
type: 'post',
response() {
return {
code: 200,
msg: '模拟注册成功',
}
},
},
{
url: '/userInfo',
type: 'post',
response(config) {
const { accessToken } = config.body
let roles = ['admin']
let ability = ['READ']
let username = 'admin'
if ('admin-accessToken' === accessToken) {
roles = ['admin']
ability = ['READ', 'WRITE', 'DELETE']
username = 'admin'
}
if ('editor-accessToken' === accessToken) {
roles = ['editor']
ability = ['READ', 'WRITE']
username = 'editor'
}
if ('test-accessToken' === accessToken) {
roles = ['admin', 'editor']
ability = ['READ']
username = 'test'
}
return {
code: 200,
msg: 'success',
data: {
roles,
ability,
username,
'avatar|1': [
'https://i.gtimg.cn/club/item/face/img/2/15922_100.gif',
'https://i.gtimg.cn/club/item/face/img/8/15918_100.gif',
],
},
}
},
},
{
url: '/logout',
type: 'post',
response() {
return {
code: 200,
msg: 'success',
}
},
},
]
const List = [
{
id: '@id',
username: 'admin',
password: 'admin',
email: '@email',
roles: ['admin'],
datatime: '@datetime',
},
{
id: '@id',
username: 'editor',
password: 'editor',
email: '@email',
roles: ['editor'],
datatime: '@datetime',
},
{
id: '@id',
username: 'test',
password: 'test',
email: '@email',
roles: ['admin', 'editor'],
datatime: '@datetime',
},
]
module.exports = [
{
url: '/userManagement/getList',
type: 'get',
response(config) {
const { username, pageNo = 1, pageSize = 20 } = config.query
let mockList = List.filter((item) => {
return !(username && item.username.indexOf(username) < 0)
})
const pageList = mockList.filter(
(item, index) =>
index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
)
return {
code: 200,
msg: 'success',
totalCount: mockList.length,
data: pageList,
}
},
},
{
url: '/userManagement/doEdit',
type: 'post',
response() {
return {
code: 200,
msg: '模拟保存成功',
}
},
},
{
url: '/userManagement/doDelete',
type: 'post',
response() {
return {
code: 200,
msg: '模拟删除成功',
}
},
},
]
/**
* @description 导入所有 controller 模块,npm run serve时在node环境中自动输出controller文件夹下Mock接口,请勿修改。
*/
const { handleMockArray } = require('./utils')
const mocks = []
const mockArray = handleMockArray()
mockArray.forEach((item) => {
const obj = require(item)
mocks.push(...obj)
})
module.exports = {
mocks,
}
const chokidar = require("chokidar");
const bodyParser = require("body-parser");
const chalk = require("chalk");
const path = require("path");
const Mock = require("mockjs");
const { baseURL } = require("../src/config");
const mockDir = path.join(process.cwd(), "mock");
/**
*
* @param app
* @returns {{mockStartIndex: number, mockRoutesLength: number}}
*/
const registerRoutes = (app) => {
let mockLastIndex;
const { mocks } = require("./index.js");
const mocksForServer = mocks.map((route) => {
return responseFake(route.url, route.type, route.response);
});
for (const mock of mocksForServer) {
app[mock.type](mock.url, mock.response);
mockLastIndex = app._router.stack.length;
}
const mockRoutesLength = Object.keys(mocksForServer).length;
return {
mockRoutesLength: mockRoutesLength,
mockStartIndex: mockLastIndex - mockRoutesLength,
};
};
/**
*
* @param url
* @param type
* @param respond
* @returns {{response(*=, *=): void, type: (*|string), url: RegExp}}
*/
const responseFake = (url, type, respond) => {
return {
url: new RegExp(`${baseURL}${url}`),
type: type || "get",
response(req, res) {
res.status(200);
if (JSON.stringify(req.body) !== "{}") {
console.log(chalk.green(`> 请求地址:${req.path}`));
console.log(chalk.green(`> 请求参数:${JSON.stringify(req.body)}\n`));
} else {
console.log(chalk.green(`> 请求地址:${req.path}\n`));
}
res.json(
Mock.mock(respond instanceof Function ? respond(req, res) : respond)
);
},
};
};
/**
*
* @param app
*/
module.exports = (app) => {
app.use(bodyParser.json());
app.use(
bodyParser.urlencoded({
extended: true,
})
);
const mockRoutes = registerRoutes(app);
let mockRoutesLength = mockRoutes.mockRoutesLength;
let mockStartIndex = mockRoutes.mockStartIndex;
chokidar
.watch(mockDir, {
ignored: /mock-server/,
ignoreInitial: true,
})
.on("all", (event) => {
if (event === "change" || event === "add") {
try {
app._router.stack.splice(mockStartIndex, mockRoutesLength);
Object.keys(require.cache).forEach((item) => {
if (item.includes(mockDir)) {
delete require.cache[require.resolve(item)];
}
});
const mockRoutes = registerRoutes(app);
mockRoutesLength = mockRoutes.mockRoutesLength;
mockStartIndex = mockRoutes.mockStartIndex;
} catch (error) {
console.log(chalk.red(error));
}
}
});
};
const { Random } = require('mockjs')
const { join } = require('path')
const fs = require('fs')
/**
* @description 随机生成图片url。
* @param width
* @param height
* @returns {string}
*/
function handleRandomImage(width = 50, height = 50) {
return `https://picsum.photos/${width}/${height}?random=${Random.guid()}`
}
/**
* @description 处理所有 controller 模块,npm run serve时在node环境中自动输出controller文件夹下Mock接口,请勿修改。
* @returns {[]}
*/
function handleMockArray() {
const mockArray = []
const getFiles = (jsonPath) => {
const jsonFiles = []
const findJsonFile = (path) => {
const files = fs.readdirSync(path)
files.forEach((item) => {
const fPath = join(path, item)
const stat = fs.statSync(fPath)
if (stat.isDirectory() === true) findJsonFile(item)
if (stat.isFile() === true) jsonFiles.push(item)
})
}
findJsonFile(jsonPath)
jsonFiles.forEach((item) => mockArray.push(`./controller/${item}`))
}
getFiles('mock/controller')
return mockArray
}
module.exports = {
handleRandomImage,
handleMockArray,
}
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 20m;
server {
listen 80;
server_name localhost;
location / {
root /home/web;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
"js-cookie": "^2.2.1", "js-cookie": "^2.2.1",
"jsencrypt": "^3.0.0-rc.1", "jsencrypt": "^3.0.0-rc.1",
"jsplumb": "^2.14.6", "jsplumb": "^2.14.6",
"less-loader": "^10.2.0",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
...@@ -85,11 +84,12 @@ ...@@ -85,11 +84,12 @@
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-vue": "^7.0.1", "eslint-plugin-vue": "^7.0.1",
"filemanager-webpack-plugin": "^2.0.5", "filemanager-webpack-plugin": "^2.0.5",
"less-loader": "^5.0.0",
"lint-staged": "^10.4.0", "lint-staged": "^10.4.0",
"plop": "^2.7.4", "plop": "^2.7.4",
"prettier": "^2.1.2", "prettier": "^2.1.2",
"raw-loader": "^4.0.1", "raw-loader": "^4.0.1",
"sass": "^1.26.12", "sass": "^1.32.12",
"sass-loader": "^10.0.2", "sass-loader": "^10.0.2",
"stylelint": "^13.7.2", "stylelint": "^13.7.2",
"stylelint-config-prettier": "^8.0.2", "stylelint-config-prettier": "^8.0.2",
......
const viewGenerator = require('zx-templates/view/prompt') const viewGenerator = require('zx-templates/view/prompt')
const curdGenerator = require('zx-templates/curd/prompt') const curdGenerator = require('zx-templates/curd/prompt')
const componentGenerator = require('zx-templates/component/prompt') const componentGenerator = require('zx-templates/component/prompt')
const mockGenerator = require('zx-templates/mock/prompt') //const mockGenerator = require('zx-templates/mock/prompt')
const vuexGenerator = require('zx-templates/vuex/prompt') const vuexGenerator = require('zx-templates/vuex/prompt')
module.exports = (plop) => { module.exports = (plop) => {
plop.setGenerator('view', viewGenerator) plop.setGenerator('view', viewGenerator)
plop.setGenerator('curd', curdGenerator) plop.setGenerator('curd', curdGenerator)
plop.setGenerator('component', componentGenerator) plop.setGenerator('component', componentGenerator)
plop.setGenerator('mock&api', mockGenerator) //plop.setGenerator('mock&api', mockGenerator)
plop.setGenerator('vuex', vuexGenerator) plop.setGenerator('vuex', vuexGenerator)
} }
...@@ -6,7 +6,7 @@ module.exports = { ...@@ -6,7 +6,7 @@ module.exports = {
singleQuote: true, singleQuote: true,
quoteProps: 'as-needed', quoteProps: 'as-needed',
jsxSingleQuote: false, jsxSingleQuote: false,
trailingComma: 'es5', trailingComma: 'es6',
bracketSpacing: true, bracketSpacing: true,
jsxBracketSameLine: false, jsxBracketSameLine: false,
arrowParens: 'always', arrowParens: 'always',
......
<template>
<!--页头-->
<div class="block-header">
<div class="b-header-inner">
<h3>{{ title }}</h3>
</div>
</div>
</template>
<script>
export default {
name:"BlockHeader",
props: ['title']
}
</script>
<style lang="less" scoped>
.block-header {
display: flex;
justify-content: flex-start;
align-content: center;
padding: 10px 12px;
min-height: 40px;
box-sizing: border-box;
margin-bottom: 16px;
background: #f7f8fa;
}
.b-header-inner {
display: flex;
align-items: center;
}
.b-header-inner::before {
content: "";
background-color: #155bd4;
width: 3px;
height: 14px;
margin-right: 8px;
}
.b-header-inner h3 {
font-size: 14px;
line-height: 20px;
color: #323233;
font-weight: 500;
margin: 0;
padding: 0;
}
</style>
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
* @description 导出自定义配置,用来覆盖默认配置 * @description 导出自定义配置,用来覆盖默认配置
**/ **/
const config = { const config = {
title:'贷超管理后台',
layout: 'gallery', layout: 'gallery',
templateFolder: 'project', templateFolder: 'project',
authentication: 'intelligence', authentication: 'intelligence', // all , intelligence
} }
module.exports = config module.exports = config
...@@ -13,8 +13,7 @@ const setting = { ...@@ -13,8 +13,7 @@ const setting = {
//进行编译的依赖 //进行编译的依赖
transpileDependencies: ['vue-echarts', 'resize-detector'], transpileDependencies: ['vue-echarts', 'resize-detector'],
//默认的接口地址 如果是开发环境和生产环境走vab-mock-server,当然你也可以选择自己配置成需要的接口地址 //默认的接口地址 如果是开发环境和生产环境走vab-mock-server,当然你也可以选择自己配置成需要的接口地址
baseURL: baseURL:process.env.NODE_ENV === 'development' ? 'api' : '',
process.env.NODE_ENV === 'development' ? 'mock-server' : 'mock-server',
//标题 (包括初次加载雪花屏的标题 页面的标题 浏览器的标题) //标题 (包括初次加载雪花屏的标题 页面的标题 浏览器的标题)
title: '管理后台框架', title: '管理后台框架',
//标题分隔符 //标题分隔符
...@@ -58,7 +57,7 @@ const setting = { ...@@ -58,7 +57,7 @@ const setting = {
//是否开启登录RSA加密 //是否开启登录RSA加密
loginRSA: false, loginRSA: false,
//intelligence(前端导出路由)和all(后端导出路由)两种方式 //intelligence(前端导出路由)和all(后端导出路由)两种方式
authentication: 'intelligence', authentication: 'all',
//是否开启roles字段进行角色权限控制(如果是all模式后端完全处理角色并进行json组装,可设置false不处理路由中的roles字段) //是否开启roles字段进行角色权限控制(如果是all模式后端完全处理角色并进行json组装,可设置false不处理路由中的roles字段)
rolesControl: true, rolesControl: true,
//vertical gallery comprehensive common布局时是否只保持一个子菜单的展开 //vertical gallery comprehensive common布局时是否只保持一个子菜单的展开
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
const theme = { const theme = {
//布局种类 horizontal vertical gallery comprehensive common //布局种类 horizontal vertical gallery comprehensive common
layout: 'gallery', layout: 'vertical',
//主题名称 default ocean green glory white //主题名称 default ocean green glory white
themeName: 'default', themeName: 'default',
//是否固定头部 //是否固定头部
......
import Vue from 'vue' import Vue from 'vue'
import App from './App' import App from "@/App"
import i18n from './i18n' import i18n from './i18n'
import store from './store' import store from './store'
import router from './router' import router from './router'
import '@/vab' import '@/vab'
/**
* @description 正式环境默认使用mock,正式项目记得注释后再打包
*/
if (process.env.NODE_ENV === 'production') {
const { mockXHR } = require('@/utils/static')
mockXHR()
}
Vue.config.productionTip = false Vue.config.productionTip = false
new Vue({ new Vue({
el: '#root', el: '#root',
......
...@@ -81,101 +81,67 @@ export const asyncRoutes = [ ...@@ -81,101 +81,67 @@ export const asyncRoutes = [
], ],
}, },
{ {
path: '/device', path: '/merchant',
name: 'DeviceManagement', name: 'DeviceManagement',
component: Layout, component: Layout,
redirect: '/device/fence', redirect: '/merchant/list',
meta: { meta: {
title: '设备明细', title: '机构管理',
remixIcon: 'device-recover-line', remixIcon: 'device-recover-line',
roles: ['admin'], roles: ['admin'],
}, },
children: [ children: [
{ {
path: 'fence', path: 'list',
name: 'fence', name: 'MerchantList',
component: () => import('@/views/device/fence'), component: () => import('@/views/merchant/list'),
meta: { meta: {
title: '栅栏信息', title: '机构列表',
remixIcon: 'user-3-line', remixIcon: 'user-3-line',
}, },
}, },
{ {
path: 'guardrail', path: 'new',
name: 'guardrail', name: 'MerchantNew',
component: () => import('@/views/device/guardrail'), component: () => import('@/views/merchant/new'),
meta: { meta: {
title: '护栏信息', title: '新增机构',
remixIcon: 'shape-line', remixIcon: 'shape-line',
}, },
}, hidden:true
{ }
path: 'passageway',
name: 'passageway',
component: () => import('@/views/device/passageway'),
meta: {
title: '通道信息',
remixIcon: 'compasses-line',
},
},
], ],
}, },
{ {
path: '/summary', path: '/prod',
name: 'SummaryManagement', name: 'Prod',
component: Layout, component: Layout,
redirect: '/summary/company', redirect: '/prod/list',
meta: { meta: {
title: '设备汇总', title: '产品列表',
remixIcon: 'line-chart-line', remixIcon: 'line-chart-line',
roles: ['admin'], roles: ['admin'],
}, },
children: [ children: [
{ {
path: 'company', path: 'list',
name: 'company', name: 'ProdList',
component: () => import('@/views/summary/company'), component: () => import('@/views/prod/list'),
meta: { meta: {
title: '单位汇总', title: '产品列表',
remixIcon: 'user-3-line', remixIcon: 'user-3-line',
}, },
}, },
{ {
path: 'line', path: 'new',
name: 'line', name: 'ProdNew',
component: () => import('@/views/summary/line'), component: () => import('@/views/prod/new'),
meta: { meta: {
title: '线路汇总', title: '产品新增',
remixIcon: 'admin-line', remixIcon: 'admin-line',
}, },
}, hidden: true
{ }
path: 'category',
name: 'category',
component: () => import('@/views/summary/category'),
meta: {
title: '类别汇总',
remixIcon: 'group-line',
},
},
{
path: 'region',
name: 'region',
component: () => import('@/views/summary/category'),
meta: {
title: '省市汇总',
remixIcon: 'group-line',
},
},
{
path: 'WorkArea',
name: 'WorkArea',
component: () => import('@/views/summary/WorkArea'),
meta: {
title: '工区汇总',
remixIcon: 'group-line',
},
},
], ],
}, },
{ {
......
import request from '@/utils/request' import request from '@/utils/request'
// 登录 // 登录
export function login(params) { export default {
return request({ // 登录
url: '/colorfulIcon/getList', login(data) {
method: 'get', return request({
params, url: '/sysUser/login',
}) method: 'post',
data,
})
},
// 发送验证码
send_msg_code(data) {
return request({
url: '/sysUser/transmitCode',
method: 'post',
data,
})
},
// 获取菜单列表
menu(params) {
return request({
url: '/sysUser/getRouters',
method: 'get',
params,
})
},
// 商户列表
merchant_list(data) {
return request({
url: '/macy/selectMacyList',
method: 'post',
data,
})
},
// 商户新增
merchant_add(data) {
return request({
url: '/macy/createdMacy',
method: 'post',
data,
})
},
// 商户更新
merchant_update(data) {
return request({
url: '/macy/editMacy',
method: 'post',
data,
})
},
// 商户详情
merchant_view(params) {
return request({
url: '/macy/selectMacyByTenantNo',
method: 'get',
params,
})
},
// 产品列表
prod_list(data) {
return request({
url: '/macy/selectProductPageList',
method: 'post',
data,
})
},
// 产品新增
prod_add(data) {
return request({
url: '/macy/createdProductInfo',
method: 'post',
data,
})
},
// 产品编辑
prod_update(data) {
return request({
url: '/macy/editProductInfo',
method: 'post',
data,
})
},
// 产品查看
prod_view(params) {
return request({
url: '/macy/selectProductInfoByappNo',
method: 'get',
params,
})
}
} }
/** /**
* @description 路由拦截状态管理,目前两种模式:all模式与intelligence模式,其中partialRoutes是菜单暂未使用 * @description 路由拦截状态管理,目前两种模式:all模式与intelligence模式,其中partialRoutes是菜单暂未使用
*/ */
import { asyncRoutes, constantRoutes } from '@/router' import { asyncRoutes, constantRoutes } from "@/router";
import { getRouterList } from '@/api/router' import { getRouterList } from "@/api/router";
import { convertRouter, filterRoutes } from '@/utils/routes' import { convertRouter, filterRoutes } from "@/utils/routes";
import API from "@/server/api";
import Layout from "@/vab/layouts";
const state = { routes: [], partialRoutes: [] } const state = { routes: [], partialRoutes: [] };
const getters = { const getters = {
routes: (state) => state.routes, routes: (state) => state.routes,
partialRoutes: (state) => state.partialRoutes, partialRoutes: (state) => state.partialRoutes
} };
const mutations = { const mutations = {
setRoutes(state, routes) { setRoutes(state, routes) {
state.routes = routes state.routes = routes;
}, },
setPartialRoutes(state, routes) { setPartialRoutes(state, routes) {
state.partialRoutes = routes state.partialRoutes = routes;
}, }
} };
const actions = { const actions = {
/** /**
* @description 多模式设置路由 * @description 多模式设置路由
...@@ -25,17 +27,74 @@ const actions = { ...@@ -25,17 +27,74 @@ const actions = {
* @param mode * @param mode
* @returns * @returns
*/ */
async setRoutes({ commit }, mode = 'intelligence') { async setRoutes({ commit }, mode) {
let routes = asyncRoutes let routes = asyncRoutes;
if (mode === 'all') { if (mode === "all") {
let { data } = await getRouterList() let data = [
if (data[data.length - 1].path !== '*') {
data.push({ path: '*', redirect: '/404', hidden: true }) path: '/',
routes = convertRouter(data) component: 'Layout',
redirect: '/index',
name: 'Home',
meta: {
title: '首页',
remixIcon: 'home-4-line',
affix: true,
},
children: [
{
path: 'index',
name: 'Index',
component: '@/views/index',
meta: {
title: '首页',
remixIcon: 'home-4-line',
affix: true,
}
},
{
path: 'dash',
name: 'Dash',
meta: {
title: '统计首页',
remixIcon: 'shopping-cart-line',
},
component: '@/views/statistics/index'
}
],
},
{
path: '/user',
name: 'User',
component: 'Layout',
redirect: '/user/list',
meta: {
title: '用户管理',
remixIcon: 'apps-line',
roles: ['admin'],
},
children: [
{
path: 'list',
name: '用户列表',
component: '@/views/user/list',
meta: {
title: '用户列表',
remixIcon: 'shopping-cart-line',
}
}
]
}
];
//let { data } = await API.menu();
if (data[data.length - 1].path !== "*"){
data.push({ path: "*", redirect: "/404", hidden: true });
}
routes = convertRouter(data);
} }
const finallyRoutes = filterRoutes([...constantRoutes, ...routes]) const finallyRoutes = filterRoutes([...constantRoutes, ...routes]);
commit('setRoutes', finallyRoutes) commit("setRoutes", finallyRoutes);
return [...routes] return [...routes];
}, },
/** /**
* @description 画廊布局、综合布局设置路由 * @description 画廊布局、综合布局设置路由
...@@ -43,7 +102,7 @@ const actions = { ...@@ -43,7 +102,7 @@ const actions = {
* @param accessedRoutes 画廊布局、综合布局设置路由 * @param accessedRoutes 画廊布局、综合布局设置路由
*/ */
setPartialRoutes({ commit }, accessedRoutes) { setPartialRoutes({ commit }, accessedRoutes) {
commit('setPartialRoutes', accessedRoutes) commit("setPartialRoutes", accessedRoutes);
}, }
} };
export default { state, getters, mutations, actions } export default { state, getters, mutations, actions };
/** /**
* @description 登录、获取用户信息、退出登录、清除accessToken逻辑,不建议修改 * @description 登录、获取用户信息、退出登录、清除accessToken逻辑,不建议修改
*/ */
import Vue from 'vue' import Vue from "vue";
import { getUserInfo, login, logout, socialLogin } from '@/api/user' import { getUserInfo, logout } from "@/api/user";
import { import { getAccessToken, removeAccessToken, setAccessToken } from "@/utils/accessToken";
getAccessToken, import { resetRouter } from "@/router";
removeAccessToken, import { title, tokenName } from "@/config";
setAccessToken,
} from '@/utils/accessToken' import API from "@/server/api";
import { resetRouter } from '@/router'
import { title, tokenName } from '@/config'
const state = { const state = {
accessToken: getAccessToken(), accessToken: getAccessToken(),
username: '', username: "",
avatar: '', avatar: "",
} user: null
};
const getters = { const getters = {
accessToken: (state) => state.accessToken, accessToken: (state) => state.accessToken,
username: (state) => state.username, username: (state) => state.username,
avatar: (state) => state.avatar, avatar: (state) => state.avatar,
} user: (state) => state.user
};
const mutations = { const mutations = {
/**
* @description 设置accessToken
* @param {*} state
* @param {*} accessToken
*/
setAccessToken(state, accessToken) { setAccessToken(state, accessToken) {
state.accessToken = accessToken state.accessToken = accessToken;
setAccessToken(accessToken) setAccessToken(accessToken);
}, },
/**
* @description 设置用户名
* @param {*} state
* @param {*} username
*/
setUsername(state, username) { setUsername(state, username) {
state.username = username state.username = username;
}, },
/**
* @description 设置头像
* @param {*} state
* @param {*} avatar
*/
setAvatar(state, avatar) { setAvatar(state, avatar) {
state.avatar = avatar state.avatar = avatar;
}, },
} setUser(state, user) {
state.user = user;
}
};
const actions = { const actions = {
/** /**
* @description 登录拦截放行时,设置虚拟角色 * @description 登录拦截放行时,设置虚拟角色
* @param {*} { commit, dispatch } * @param {*} { commit, dispatch }
*/ */
setVirtualRoles({ commit, dispatch }) { setVirtualRoles({ commit, dispatch }) {
dispatch('acl/setFull', true, { root: true }) dispatch("acl/setFull", true, { root: true });
commit('setAvatar', 'https://i.gtimg.cn/club/item/face/img/2/15922_100.gif') commit("setAvatar", "https://i.gtimg.cn/club/item/face/img/2/15922_100.gif");
commit('setUsername', 'admin(未开启登录拦截)') commit("setUsername", "admin(未开启登录拦截)");
}, },
/** /**
* @description 登录 * @description 登录
* @param {*} { commit }
* @param {*} userInfo
*/ */
async login({ commit }, userInfo) { async login({ commit }, userInfo) {
const { data } = await login(userInfo) const result = await API.login(userInfo);
if (!data) { if (result.success) {
Vue.prototype.$baseMessage( const user = result.result;
'登录核心接口异常,请检查返回JSON格式是否正确,data字段是否为数组', commit("setUser", user);
'error'
)
return false
} }
const accessToken = data[tokenName]
// 设置假的token
const accessToken = "mmcai";
if (accessToken) { if (accessToken) {
commit('setAccessToken', accessToken) commit("setAccessToken", accessToken);
const hour = new Date().getHours()
const thisTime =
hour < 8
? '早上好'
: hour <= 11
? '上午好'
: hour <= 13
? '中午好'
: hour < 18
? '下午好'
: '晚上好'
Vue.prototype.$baseNotify(`${thisTime}!`, `欢迎登录${title}`)
} else {
Vue.prototype.$baseMessage(
`登录接口异常,未正确返回${tokenName}...`,
'error'
)
} }
}, },
/** /**
* @description 第三方登录 * @description 获取验证码
* @param {*} {}
* @param {*} tokenData
*/ */
async socialLogin({}, tokenData) { async send_msg_code({ commit }, userInfo) {
const { data } = await socialLogin(tokenData) const result = await API.send_msg_code(userInfo);
if (!data) { if (result.success) {
Vue.prototype.$baseMessage( return result;
'登录核心接口异常,请检查返回JSON格式是否正确,data字段是否为数组',
'error'
)
return false
}
const accessToken = data[tokenName]
if (accessToken) {
const hour = new Date().getHours()
const thisTime =
hour < 8
? '早上好'
: hour <= 11
? '上午好'
: hour <= 13
? '中午好'
: hour < 18
? '下午好'
: '晚上好'
Vue.prototype.$baseNotify(`欢迎登录${title}`, `${thisTime}!`)
} else {
Vue.prototype.$baseMessage(
`login核心接口异常,请检查返回JSON格式是否正确,是否正确返回${tokenName}...`,
'error'
)
} }
}, },
/** /**
...@@ -135,32 +78,18 @@ const actions = { ...@@ -135,32 +78,18 @@ const actions = {
* @returns * @returns
*/ */
async getUserInfo({ commit, dispatch, state }) { async getUserInfo({ commit, dispatch, state }) {
const { data } = await getUserInfo(state.accessToken) let { username, avatar, roles, ability } = state.user;
if (!data) { //if (username && avatar) {
Vue.prototype.$baseMessage( commit("setUsername", userName);
'getUserInfo核心接口异常,请检查返回JSON格式是否正确,data字段是否为数组', commit("setAvatar", '');
'error'
)
return false
}
let { username, avatar, roles, ability } = data
if (username && avatar) {
commit('setUsername', username)
commit('setAvatar', avatar)
// 当不传递roles或ability时,默认使用管理员权限,可查看所有路由和按钮 // 当不传递roles或ability时,默认使用管理员权限,可查看所有路由和按钮
if (!roles && !ability) dispatch('acl/setFull', true, { root: true }) dispatch("acl/setFull", true, { root: true });
// 当返回数据包含roles(角色)或ability(权限),保存至vuex // 当返回数据包含roles(角色)或ability(权限),保存至vuex
// 如不使用roles权限控制,请不要传递roles,可删除以下代码 // 如不使用roles权限控制,请不要传递roles,可删除以下代码
if (roles instanceof Array) dispatch('acl/setRole', roles, { root: true }) //if (roles instanceof Array) dispatch("acl/setRole", roles, { root: true });
// 如不使用ability权限控制,请不要传递ability,可删除以下代码 // 如不使用ability权限控制,请不要传递ability,可删除以下代码
if (ability instanceof Array) //if (ability instanceof Array) dispatch("acl/setAbility", ability, { root: true });
dispatch('acl/setAbility', ability, { root: true }) //}
} else {
Vue.prototype.$baseMessage(
'getUserInfo核心接口异常,请检查返回JSON格式是否正确,roles字段是否为数组,是否与路由roles匹配',
'error'
)
}
}, },
/** /**
...@@ -168,26 +97,28 @@ const actions = { ...@@ -168,26 +97,28 @@ const actions = {
* @param {*} { dispatch } * @param {*} { dispatch }
*/ */
async logout({ dispatch }) { async logout({ dispatch }) {
await logout(state.accessToken) await logout(state.accessToken);
await dispatch('resetAll') await dispatch("resetAll");
}, },
/** /**
* @description 重置accessToken、roles、ability、router等 * @description 重置accessToken、roles、ability、router等
* @param {*} { commit, dispatch } * @param {*} { commit, dispatch }
*/ */
async resetAll({ dispatch }) { async resetAll({ dispatch }) {
await dispatch('setAccessToken', '') await dispatch("setAccessToken", "");
await dispatch('acl/setFull', false, { root: true }) await dispatch("acl/setFull", false, { root: true });
await dispatch('acl/setRole', [], { root: true }) await dispatch("acl/setRole", [], { root: true });
await dispatch('acl/setAbility', [], { root: true }) await dispatch("acl/setAbility", [], { root: true });
await resetRouter() await resetRouter();
removeAccessToken() removeAccessToken();
}, },
/** // 设置token
* @description 设置token
*/
setAccessToken({ commit }, accessToken) { setAccessToken({ commit }, accessToken) {
commit('setAccessToken', accessToken) commit("setAccessToken", accessToken);
}, },
} // 设置用户
export default { state, getters, mutations, actions } setUser({ commit }, user) {
commit("setUser", user);
}
};
export default { state, getters, mutations, actions };
import Vue from 'vue' import Vue from 'vue'
import axios from 'axios' import axios from 'axios'
import { import {
baseURL,
contentType, contentType,
debounce, debounce,
requestTimeout, requestTimeout,
...@@ -13,6 +12,10 @@ import qs from 'qs' ...@@ -13,6 +12,10 @@ import qs from 'qs'
import router from '@/router' import router from '@/router'
import { isArray } from '@/utils/validate' import { isArray } from '@/utils/validate'
const API_URL = process.env.VUE_APP_API_PATH;
console.log(API_URL,'是啥');
let loadingInstance let loadingInstance
// 操作正常Code数组 // 操作正常Code数组
...@@ -37,19 +40,21 @@ const CODE_MESSAGE = { ...@@ -37,19 +40,21 @@ const CODE_MESSAGE = {
504: '网关超时', 504: '网关超时',
} }
//code: "500"
//message: "验证码发送过于频繁请稍后重试!"
//result: null
//success: false
const handleData = ({ config, data, status, statusText }) => { const handleData = ({ config, data, status, statusText }) => {
if (loadingInstance) loadingInstance.close() if (loadingInstance) loadingInstance.close()
// 若data.code存在,覆盖默认code // 若data.code存在,覆盖默认code
let code = data && data.code ? data.code : status let code = data && data.code ? data.code : status
// 若code属于操作正常code,则status修改为200 // 若code属于操作正常code,则status修改为200
if (codeVerificationArray.includes(code)) code = 200 if (codeVerificationArray.includes(code)) code = 200
// 若data.msg存在,覆盖默认提醒消息 // 若data.msg存在,覆盖默认提醒消息
const msg = !data const msg = !data ? `后端接口 ${config.url} 异常 ${code}${CODE_MESSAGE[code]}` : !data.message ? `后端接口 ${config.url} 异常 ${code}${statusText}` : data.message
? `后端接口 ${config.url} 异常 ${code}${CODE_MESSAGE[code]}`
: !data.msg code = code*1;
? `后端接口 ${config.url} 异常 ${code}${statusText}`
: data.msg
switch (code) { switch (code) {
case 200: case 200:
...@@ -66,7 +71,8 @@ const handleData = ({ config, data, status, statusText }) => { ...@@ -66,7 +71,8 @@ const handleData = ({ config, data, status, statusText }) => {
store.dispatch('user/resetAll').catch(() => {}) store.dispatch('user/resetAll').catch(() => {})
break break
case 403: case 403:
router.push({ path: '/403' }).catch(() => {}) store.dispatch('user/resetAll').catch(() => {})
router.push({ path: '/login' }).catch(() => {})
break break
default: default:
Vue.prototype.$baseMessage(msg, 'error') Vue.prototype.$baseMessage(msg, 'error')
...@@ -79,7 +85,7 @@ const handleData = ({ config, data, status, statusText }) => { ...@@ -79,7 +85,7 @@ const handleData = ({ config, data, status, statusText }) => {
* @description axios初始化 * @description axios初始化
*/ */
const instance = axios.create({ const instance = axios.create({
baseURL, baseURL:API_URL,
timeout: requestTimeout, timeout: requestTimeout,
headers: { headers: {
'Content-Type': contentType, 'Content-Type': contentType,
......
/**
* @description 导入所有 controller 模块,浏览器环境中自动输出controller文件夹下Mock接口,请勿修改。
*/
import Mock from 'mockjs'
import { paramObj } from '@/utils/index'
const mocks = []
const files = require.context('../../mock/controller', false, /\.js$/)
files.keys().forEach((key) => {
mocks.push(...files(key))
})
export function mockXHR() {
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function () {
if (this.custom.xhr) {
this.custom.xhr.withCredentials = this.withCredentials || false
if (this.responseType) {
this.custom.xhr.responseType = this.responseType
}
}
this.proxy_send(...arguments)
}
function XHRHttpRequst(respond) {
return function (options) {
let result
if (respond instanceof Function) {
const { body, type, url } = options
result = respond({
method: type,
body: JSON.parse(body),
query: paramObj(url),
})
} else {
result = respond
}
return Mock.mock(result)
}
}
mocks.forEach((item) => {
Mock.mock(
new RegExp(item.url),
item.type || 'get',
XHRHttpRequst(item.response)
)
})
}
/** /**
* @description 路由守卫,目前两种模式:all模式与intelligence模式 * @description 路由守卫,目前两种模式:all模式与intelligence模式
*/ */
import router from '@/router' import router from "@/router";
import store from '@/store' import store from "@/store";
import VabProgress from 'nprogress' import VabProgress from "nprogress";
import 'nprogress/nprogress.css' import "nprogress/nprogress.css";
import getPageTitle from '@/utils/pageTitle' import getPageTitle from "@/utils/pageTitle";
import { import {
authentication, authentication,
loginInterception, loginInterception,
recordRoute, recordRoute,
routesWhiteList, routesWhiteList
} from '@/config' } from "@/config";
VabProgress.configure({ VabProgress.configure({
easing: 'ease', easing: "ease",
speed: 500, speed: 500,
trickleSpeed: 200, trickleSpeed: 200,
showSpinner: false, showSpinner: false
}) });
console.log(router.getRoutes(), '路由信息') console.log(router.getRoutes(), "路由信息");
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
console.log(from, to, '路由') const showProgressBar = store.getters["settings/showProgressBar"];
const showProgressBar = store.getters['settings/showProgressBar'] if (showProgressBar) VabProgress.start();
if (showProgressBar) VabProgress.start() let hasToken = store.getters["user/accessToken"];
let hasToken = store.getters['user/accessToken']
if (!loginInterception) hasToken = true if (!loginInterception) hasToken = true;
if (routesWhiteList.indexOf(to.path) !== -1) { if (routesWhiteList.indexOf(to.path) !== -1) {
if (to.path === '/login' && hasToken) next({ path: '/' }) if (to.path === "/login" && hasToken) next({ path: "/" });
else next() else next();
} else { } else {
if (hasToken) { if (hasToken) {
const hasAccess = const hasAccess = store.getters["acl/admin"];
store.getters['acl/admin'] ||
store.getters['acl/role'].length > 0 ||
store.getters['acl/ability'].length > 0
console.log(to, '又来')
if (hasAccess) { if (hasAccess) {
next() next();
} else { } else {
try { try {
if (loginInterception) await store.dispatch('user/getUserInfo') if (!loginInterception) await store.dispatch("user/getUserInfo");
//settings.js loginInterception为false(关闭登录拦截时)时,创建虚拟角色 //settings.js loginInterception为false(关闭登录拦截时)时,创建虚拟角色
else await store.dispatch('user/setVirtualRoles') else await store.dispatch("user/setVirtualRoles");
//根据路由模式添加路由 //根据路由模式添加路由
router.addRoutes( router.addRoutes(
await store.dispatch('routes/setRoutes', authentication) await store.dispatch("routes/setRoutes", authentication)
) );
next({ ...to, replace: true }) next({ ...to, replace: true });
} catch { } catch(err) {
console.log('你知道') console.log(err,'啥错误');
await store.dispatch('user/resetAll') await store.dispatch("user/resetAll");
if (recordRoute && to.path !== '/') if (recordRoute && to.path !== "/") {
next({ next({
path: '/login', path: "/login",
query: { redirect: to.path }, query: { redirect: to.path },
replace: true, replace: true
}) });
else next({ path: '/login', replace: true }) } else {
next({ path: "/login", replace: true });
}
} }
} }
} else { } else {
if (recordRoute && to.path !== '/') if (recordRoute && to.path !== "/")
next({ path: '/login', query: { redirect: to.path }, replace: true }) next({ path: "/login", query: { redirect: to.path }, replace: true });
else next({ path: '/login', replace: true }) else next({ path: "/login", replace: true });
} }
} }
}) });
router.afterEach((to) => { router.afterEach((to) => {
document.title = getPageTitle(to.meta.title) document.title = getPageTitle(to.meta.title);
if (VabProgress.status) VabProgress.done() if (VabProgress.status) VabProgress.done();
}) });
...@@ -42,7 +42,8 @@ Vue.prototype.$baseColorfullLoading = (index, text) => { ...@@ -42,7 +42,8 @@ Vue.prototype.$baseColorfullLoading = (index, text) => {
spinner: 'dots-loader', spinner: 'dots-loader',
background: 'hsla(0,0%,100%,.8)', background: 'hsla(0,0%,100%,.8)',
}) })
} else { }
else {
switch (index) { switch (index) {
case 1: case 1:
index = 'dots' index = 'dots'
......
...@@ -32,7 +32,7 @@ $base: '.vab'; ...@@ -32,7 +32,7 @@ $base: '.vab';
html { html {
overflow: hidden; overflow: hidden;
body { body {
overflow: hidden; overflow: auto;
position: relative; position: relative;
box-sizing: border-box; box-sizing: border-box;
height: 100vh; height: 100vh;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<template> <template>
<el-col :span="24"> <el-col :span="24">
<el-card class="page-header" shadow="never"> <el-card
<el-avatar :src="avatar" class="page-header-avatar"></el-avatar> class="page-header"
shadow="never"
>
<el-avatar
:src="avatar"
class="page-header-avatar"
/>
<div class="page-header-tip"> <div class="page-header-tip">
<p class="page-header-tip-title"> <p class="page-header-tip-title">
{{ handleTips() }} {{ handleTips() }}
</p> </p>
<p class="page-header-tip-description">{{ description }}</p> <p class="page-header-tip-description">
{{ description }}
</p>
</div> </div>
</el-card> </el-card>
</el-col> </el-col>
...@@ -28,7 +36,7 @@ ...@@ -28,7 +36,7 @@
}), }),
}, },
created() { created() {
this.fetchData() //this.fetchData()
}, },
methods: { methods: {
handleTips() { handleTips() {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -2,6 +2,5 @@ module.exports = { ...@@ -2,6 +2,5 @@ module.exports = {
//开发工具控制台名字显示 //开发工具控制台名字显示
webpackBarName: 'vue-admin-beautiful-pro', webpackBarName: 'vue-admin-beautiful-pro',
//浏览器注释显示 //浏览器注释显示
webpackBanner: webpackBanner: ' build: vue-admin-beautiful-pro \n copyright: chuzhixin 1204505056@qq.com \n time: ',
' build: vue-admin-beautiful-pro \n copyright: chuzhixin 1204505056@qq.com \n time: ',
} }
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment