🎉代码规范强制使用单引号并取消行末分号

This commit is contained in:
chuzhixin 2020-10-08 13:32:23 +08:00
parent 17b7022545
commit f6c412f4e9
149 changed files with 6875 additions and 6885 deletions

View File

@ -3,24 +3,24 @@ module.exports = {
env: { env: {
node: true, node: true,
}, },
extends: ["plugin:vue/recommended", "@vue/prettier"], extends: ['plugin:vue/recommended', '@vue/prettier'],
rules: { rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off", 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
"vue/no-v-html": "off", 'vue/no-v-html': 'off',
}, },
parserOptions: { parserOptions: {
parser: "babel-eslint", parser: 'babel-eslint',
}, },
overrides: [ overrides: [
{ {
files: [ files: [
"**/__tests__/*.{j,t}s?(x)", '**/__tests__/*.{j,t}s?(x)',
"**/tests/unit/**/*.spec.{j,t}s?(x)", '**/tests/unit/**/*.spec.{j,t}s?(x)',
], ],
env: { env: {
jest: true, jest: true,
}, },
}, },
], ],
}; }

View File

@ -1,3 +1,3 @@
module.exports = { module.exports = {
extends: ["stylelint-config-recess-order", "stylelint-config-prettier"], extends: ['stylelint-config-recess-order', 'stylelint-config-prettier'],
}; }

View File

@ -1,3 +1,3 @@
module.exports = { module.exports = {
presets: ["@vue/cli-plugin-babel/preset"], presets: ['@vue/cli-plugin-babel/preset'],
}; }

View File

@ -1,23 +1,23 @@
const data = [ const data = [
{ {
title: "vue-admin-beautiful-pro 1.7版本已发布,点我提前体验", title: 'vue-admin-beautiful-pro 1.7版本已发布,点我提前体验',
url: "https://chu1204505056.gitee.io/vue-admin-beautiful-pro/#/index", url: 'https://chu1204505056.gitee.io/vue-admin-beautiful-pro/#/index',
}, },
{ {
title: "vue-admin-beautifulantdv vue3.0版本已发布,点我提前体验", title: 'vue-admin-beautifulantdv vue3.0版本已发布,点我提前体验',
url: "https://chu1204505056.gitee.io/vue-admin-beautiful-mini/#/index", url: 'https://chu1204505056.gitee.io/vue-admin-beautiful-mini/#/index',
}, },
]; ]
module.exports = [ module.exports = [
{ {
url: "/ad/getList", url: '/ad/getList',
type: "get", type: 'get',
response() { response() {
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
data, data,
}; }
}, },
}, },
]; ]

View File

@ -1,194 +1,194 @@
const data = [ const data = [
{ {
content: "在github上获得了第一个star感恩一位名叫Bequiet2014的github用户", content: '在github上获得了第一个star感恩一位名叫Bequiet2014的github用户',
timestamp: "2020-03-23", timestamp: '2020-03-23',
}, },
{ {
content: "增加更换主题功能", content: '增加更换主题功能',
timestamp: "2020-04-10", timestamp: '2020-04-10',
}, },
{ {
content: "大幅精简代码", content: '大幅精简代码',
timestamp: "2020-04-14", timestamp: '2020-04-14',
}, },
{ {
content: "修复群友反馈的bug", content: '修复群友反馈的bug',
timestamp: "2020-04-16", timestamp: '2020-04-16',
}, },
{ {
content: "剔除maptalks", content: '剔除maptalks',
timestamp: "2020-04-17", timestamp: '2020-04-17',
}, },
{ {
content: content:
"换行符统一修改为lf 支持苹果 linux windows协同开发 强制开启最严格eslint规则 不要哭 严格是有好处的", '换行符统一修改为lf 支持苹果 linux windows协同开发 强制开启最严格eslint规则 不要哭 严格是有好处的',
timestamp: "2020-04-17", timestamp: '2020-04-17',
}, },
{ {
content: "彻底完成手机端适配,记录这一天熬夜到了晚上三点", content: '彻底完成手机端适配,记录这一天熬夜到了晚上三点',
timestamp: "2020-04-18", timestamp: '2020-04-18',
}, },
{ {
content: content:
"删除babel-polyfill 提高打包速度 减少压缩体积放弃ie是这个项目做出的最伟大的决定", '删除babel-polyfill 提高打包速度 减少压缩体积放弃ie是这个项目做出的最伟大的决定',
timestamp: "2020-04-18", timestamp: '2020-04-18',
}, },
{ {
content: "源码精简至800k", content: '源码精简至800k',
timestamp: "2020-04-19", timestamp: '2020-04-19',
}, },
{ {
content: "添加视频播放器组件", content: '添加视频播放器组件',
timestamp: "2020-04-20", timestamp: '2020-04-20',
}, },
{ {
content: "修复路由懒加载 完善主题配色", content: '修复路由懒加载 完善主题配色',
timestamp: "2020-04-22", timestamp: '2020-04-22',
}, },
{ {
content: "修复全局axios拦截 加快动画展示效果 修改登录页样式", content: '修复全局axios拦截 加快动画展示效果 修改登录页样式',
timestamp: "2020-04-24", timestamp: '2020-04-24',
}, },
{ {
content: "简化权限与登录逻辑 更新mockServer", content: '简化权限与登录逻辑 更新mockServer',
timestamp: "2020-04-25", timestamp: '2020-04-25',
}, },
{ {
content: "优化登录退出逻辑 代码更清晰 退出不再重载网页 改为重载路由形式", content: '优化登录退出逻辑 代码更清晰 退出不再重载网页 改为重载路由形式',
timestamp: "2020-04-26", timestamp: '2020-04-26',
}, },
{ {
content: "无端的指责只会让我更加努力 修复sidebar 简化permission", content: '无端的指责只会让我更加努力 修复sidebar 简化permission',
timestamp: "2020-04-28", timestamp: '2020-04-28',
}, },
{ {
content: "又是一个深夜 实现了表格增删改查的一键生成", content: '又是一个深夜 实现了表格增删改查的一键生成',
timestamp: "2020-04-30", timestamp: '2020-04-30',
}, },
{ {
content: "大幅优化tagsview标签动画", content: '大幅优化tagsview标签动画',
timestamp: "2020-05-02", timestamp: '2020-05-02',
}, },
{ {
content: "三种图标组件实现mock模拟分页", content: '三种图标组件实现mock模拟分页',
timestamp: "2020-05-03", timestamp: '2020-05-03',
}, },
{ {
content: "添加了markdown编辑器组件", content: '添加了markdown编辑器组件',
timestamp: "2020-05-04", timestamp: '2020-05-04',
}, },
{ {
content: "添加stylelint-plus自动规整排序样式", content: '添加stylelint-plus自动规整排序样式',
timestamp: "2020-05-06", timestamp: '2020-05-06',
}, },
{ {
content: "添加商城模板", content: '添加商城模板',
timestamp: "2020-05-12", timestamp: '2020-05-12',
}, },
{ {
content: "github标星超过1000 感恩", content: 'github标星超过1000 感恩',
timestamp: "2020-05-13", timestamp: '2020-05-13',
}, },
{ {
content: "添加验证码组件", content: '添加验证码组件',
timestamp: "2020-05-14", timestamp: '2020-05-14',
}, },
{ {
content: "修复横向菜单bug", content: '修复横向菜单bug',
timestamp: "2020-05-16", timestamp: '2020-05-16',
}, },
{ {
content: "又被人骂了 挺好的 让我下定决心重写了tabsBar", content: '又被人骂了 挺好的 让我下定决心重写了tabsBar',
timestamp: "2020-05-20", timestamp: '2020-05-20',
}, },
{ {
content: "仿ant-design 添加雪花屏", content: '仿ant-design 添加雪花屏',
timestamp: "2020-05-26", timestamp: '2020-05-26',
}, },
{ {
content: "添加人员管理模块", content: '添加人员管理模块',
timestamp: "2020-06-02", timestamp: '2020-06-02',
}, },
{ {
content: "github标星超过2000 感恩", content: 'github标星超过2000 感恩',
timestamp: "2020-06-03", timestamp: '2020-06-03',
}, },
{ {
content: "添加炫酷地图组件", content: '添加炫酷地图组件',
timestamp: "2020-06-11", timestamp: '2020-06-11',
}, },
{ {
content: "抽离更多公共配置,框架使用更顺手", content: '抽离更多公共配置,框架使用更顺手',
timestamp: "2020-06-19", timestamp: '2020-06-19',
}, },
{ {
content: "彻底完成了tabsBar多标签页的重构", content: '彻底完成了tabsBar多标签页的重构',
timestamp: "2020-06-22", timestamp: '2020-06-22',
}, },
{ {
content: "感恩github标星过3.0K 祝大家端午节快乐", content: '感恩github标星过3.0K 祝大家端午节快乐',
timestamp: "2020-06-25", timestamp: '2020-06-25',
}, },
{ {
content: "彻底重构了SideBar与TopBar 大幅精简dom渲染逻辑 全球首发", content: '彻底重构了SideBar与TopBar 大幅精简dom渲染逻辑 全球首发',
timestamp: "2020-06-25", timestamp: '2020-06-25',
}, },
{ {
content: "添加菜单管理", content: '添加菜单管理',
timestamp: "2020-07-7", timestamp: '2020-07-7',
}, },
{ {
content: "首次采用sass-loader 9.0写法感谢github用户 shaonialife", content: '首次采用sass-loader 9.0写法感谢github用户 shaonialife',
timestamp: "2020-07-7", timestamp: '2020-07-7',
}, },
{ {
content: "添加vue-amap组件", content: '添加vue-amap组件',
timestamp: "2020-07-11", timestamp: '2020-07-11',
}, },
{ {
content: "修改zx-layouts引入方式", content: '修改zx-layouts引入方式',
timestamp: "2020-07-15", timestamp: '2020-07-15',
}, },
{ {
content: content:
"记录这一天vue-admin-beautiful在插件市场、百度已花费超过1万元广告费用希望一切都值得", '记录这一天vue-admin-beautiful在插件市场、百度已花费超过1万元广告费用希望一切都值得',
timestamp: "2020-07-18", timestamp: '2020-07-18',
}, },
{ {
content: "主题配置添加绿荫草场、荣耀典藏、暗黑之子模式", content: '主题配置添加绿荫草场、荣耀典藏、暗黑之子模式',
timestamp: "2020-07-18", timestamp: '2020-07-18',
}, },
{ {
content: "全局axios请求全面支持Status Code拦截处理", content: '全局axios请求全面支持Status Code拦截处理',
timestamp: "2020-07-29", timestamp: '2020-07-29',
}, },
{ {
content: "重构全局loadding加载代码", content: '重构全局loadding加载代码',
timestamp: "2020-07-31", timestamp: '2020-07-31',
}, },
{ {
content: "升级stylelint自动排序功能", content: '升级stylelint自动排序功能',
timestamp: "2020-08-25", timestamp: '2020-08-25',
}, },
{ {
content: "修复视频播放器组件重载路由失效的bug", content: '修复视频播放器组件重载路由失效的bug',
timestamp: "2020-09-03", timestamp: '2020-09-03',
}, },
{ {
content: "修复极个别情况image-loader打包报错", content: '修复极个别情况image-loader打包报错',
timestamp: "2020-09-18", timestamp: '2020-09-18',
}, },
{ {
content: "全网首个基于vue3.0开发的admin框架已发布具体请访问github", content: '全网首个基于vue3.0开发的admin框架已发布具体请访问github',
timestamp: "2020-09-22", timestamp: '2020-09-22',
}, },
{ {
content: "完善路由后端渲染方案,弃用之前写法", content: '完善路由后端渲染方案,弃用之前写法',
timestamp: "2020-09-30", timestamp: '2020-09-30',
}, },
{ {
content: "大版本迭代请关注github tag", content: '大版本迭代请关注github tag',
timestamp: "2020-09-30", timestamp: '2020-09-30',
}, },
/* { /* {
content: content:
@ -196,22 +196,22 @@ const data = [
timestamp: "2020-10-01", timestamp: "2020-10-01",
}, */ }, */
{ {
content: "凌晨两点我累了移除无用组件精简package", content: '凌晨两点我累了移除无用组件精简package',
timestamp: "2020-10-02", timestamp: '2020-10-02',
}, },
]; ]
module.exports = [ module.exports = [
{ {
url: "/changeLog/getList", url: '/changeLog/getList',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
totalCount: 999, totalCount: 999,
data: data, data: data,
}; }
}, },
}, },
]; ]

View File

@ -1,324 +1,324 @@
const data = [ const data = [
"alphabetical_sorting", 'alphabetical_sorting',
"alphabetical_sorting", 'alphabetical_sorting',
"alarm_clock", 'alarm_clock',
"area_chart", 'area_chart',
"approval", 'approval',
"answers", 'answers',
"approve", 'approve',
"assistant", 'assistant',
"automotive", 'automotive',
"automatic", 'automatic',
"bad_decision", 'bad_decision',
"bar_chart", 'bar_chart',
"bearish", 'bearish',
"biomass", 'biomass',
"biohazard", 'biohazard',
"binoculars", 'binoculars',
"bookmark", 'bookmark',
"briefcase", 'briefcase',
"biotech", 'biotech',
"broken_link", 'broken_link',
"business", 'business',
"bullish", 'bullish',
"business_contact", 'business_contact',
"businesswoman", 'businesswoman',
"cable_release", 'cable_release',
"calculator", 'calculator',
"businessman", 'businessman',
"calendar", 'calendar',
"butting_in", 'butting_in',
"call_transfer", 'call_transfer',
"callback", 'callback',
"camcorder", 'camcorder',
"camera", 'camera',
"camcorder_pro", 'camcorder_pro',
"cancel", 'cancel',
"camera_addon", 'camera_addon',
"camera_identificatio", 'camera_identificatio',
"capacitor", 'capacitor',
"candle_sticks", 'candle_sticks',
"checkmark", 'checkmark',
"circuit", 'circuit',
"charge_battery", 'charge_battery',
"clear_filters", 'clear_filters',
"clapperboard", 'clapperboard',
"clock", 'clock',
"close_up_mode", 'close_up_mode',
"collaboration", 'collaboration',
"cell_phone", 'cell_phone',
"collapse", 'collapse',
"collect", 'collect',
"cloth", 'cloth',
"combo_chart", 'combo_chart',
"comments", 'comments',
"conference_call", 'conference_call',
"compact_camera", 'compact_camera',
"contacts", 'contacts',
"copyleft", 'copyleft',
"copyright", 'copyright',
"crystal_oscillator", 'crystal_oscillator',
"cursor", 'cursor',
"currency_exchange", 'currency_exchange',
"customer_support", 'customer_support',
"dam", 'dam',
"data_backup", 'data_backup',
"data_configuration", 'data_configuration',
"data_encryption", 'data_encryption',
"data_protection", 'data_protection',
"data_recovery", 'data_recovery',
"database", 'database',
"data_sheet", 'data_sheet',
"debt", 'debt',
"decision", 'decision',
"delete_column", 'delete_column',
"delete_database", 'delete_database',
"department", 'department',
"delete_row", 'delete_row',
"deployment", 'deployment',
"dislike", 'dislike',
"disapprove", 'disapprove',
"disclaimer", 'disclaimer',
"display", 'display',
"document", 'document',
"do_not_insert", 'do_not_insert',
"do_not_mix", 'do_not_mix',
"do_not_inhale", 'do_not_inhale',
"donate", 'donate',
"down", 'down',
"doughnut_chart", 'doughnut_chart',
"down_left", 'down_left',
"down_right", 'down_right',
"download", 'download',
"edit_image", 'edit_image',
"electrical_sensor", 'electrical_sensor',
"electrical_threshold", 'electrical_threshold',
"electricity", 'electricity',
"electro_devices", 'electro_devices',
"electronics", 'electronics',
"empty_battery", 'empty_battery',
"empty_filter", 'empty_filter',
"empty_trash", 'empty_trash',
"end_call", 'end_call',
"engineering", 'engineering',
"entering_heaven_aliv", 'entering_heaven_aliv',
"expand", 'expand',
"export", 'export',
"expired", 'expired',
"factory", 'factory',
"factory_breakdown", 'factory_breakdown',
"external", 'external',
"faq", 'faq',
"feed_in", 'feed_in',
"file", 'file',
"feedback", 'feedback',
"film", 'film',
"filled_filter", 'filled_filter',
"filing_cabinet", 'filing_cabinet',
"film_reel", 'film_reel',
"flash_auto", 'flash_auto',
"fine_print", 'fine_print',
"flash_off", 'flash_off',
"flash_on", 'flash_on',
"flow_chart", 'flow_chart',
"folder", 'folder',
"frame", 'frame',
"full_battery", 'full_battery',
"full_trash", 'full_trash',
"gallery", 'gallery',
"generic_sorting_asc", 'generic_sorting_asc',
"generic_sorting_desc", 'generic_sorting_desc',
"genealogy", 'genealogy',
"globe", 'globe',
"good_decision", 'good_decision',
"headset", 'headset',
"grid", 'grid',
"graduation_cap", 'graduation_cap',
"heat_map", 'heat_map',
"high_priority", 'high_priority',
"high_battery", 'high_battery',
"image_file", 'image_file',
"home", 'home',
"idea", 'idea',
"import", 'import',
"in_transit", 'in_transit',
"integrated_webcam", 'integrated_webcam',
"inspection", 'inspection',
"invite", 'invite',
"internal", 'internal',
"ipad", 'ipad',
"info", 'info',
"iphone", 'iphone',
"kindle", 'kindle',
"key", 'key',
"landscape", 'landscape',
"left", 'left',
"left_down", 'left_down',
"left_up", 'left_up',
"leave", 'leave',
"like_placeholder", 'like_placeholder',
"light_at_the_end_of_", 'light_at_the_end_of_',
"library", 'library',
"line_chart", 'line_chart',
"link", 'link',
"like", 'like',
"lock", 'lock',
"list", 'list',
"lock_landscape", 'lock_landscape',
"low_battery", 'low_battery',
"lock_portrait", 'lock_portrait',
"low_priority", 'low_priority',
"make_decision", 'make_decision',
"medium_priority", 'medium_priority',
"manager", 'manager',
"menu", 'menu',
"middle_battery", 'middle_battery',
"minus", 'minus',
"missed_call", 'missed_call',
"mind_map", 'mind_map',
"mms", 'mms',
"multiple_cameras", 'multiple_cameras',
"money_transfer", 'money_transfer',
"music", 'music',
"multiple_devices", 'multiple_devices',
"multiple_smartphones", 'multiple_smartphones',
"multiple_inputs", 'multiple_inputs',
"negative_dynamic", 'negative_dynamic',
"neutral_decision", 'neutral_decision',
"night_landscape", 'night_landscape',
"news", 'news',
"neutral_trading", 'neutral_trading',
"night_portrait", 'night_portrait',
"no_idea", 'no_idea',
"next", 'next',
"no_video", 'no_video',
"nook", 'nook',
"ok", 'ok',
"org_unit", 'org_unit',
"opened_folder", 'opened_folder',
"old_time_camera", 'old_time_camera',
"online_support", 'online_support',
"organization", 'organization',
"package", 'package',
"paid", 'paid',
"parallel_tasks", 'parallel_tasks',
"overtime", 'overtime',
"panorama", 'panorama',
"phone", 'phone',
"phone_android", 'phone_android',
"photo_reel", 'photo_reel',
"pie_chart", 'pie_chart',
"picture", 'picture',
"planner", 'planner',
"plus", 'plus',
"podium_with_audience", 'podium_with_audience',
"podium_without_speak", 'podium_without_speak',
"podium_with_speaker", 'podium_with_speaker',
"previous", 'previous',
"portrait_mode", 'portrait_mode',
"positive_dynamic", 'positive_dynamic',
"privacy", 'privacy',
"process", 'process',
"puzzle", 'puzzle',
"questions", 'questions',
"print", 'print',
"radar_plot", 'radar_plot',
"rating", 'rating',
"ratings", 'ratings',
"reading", 'reading',
"redo", 'redo',
"reading_ebook", 'reading_ebook',
"refresh", 'refresh',
"registered_trademark", 'registered_trademark',
"right", 'right',
"reuse", 'reuse',
"remove_image", 'remove_image',
"right_down", 'right_down',
"right_up", 'right_up',
"rotate_to_portrait", 'rotate_to_portrait',
"rules", 'rules',
"rotate_camera", 'rotate_camera',
"rotate_to_landscape", 'rotate_to_landscape',
"ruler", 'ruler',
"scatter_plot", 'scatter_plot',
"search", 'search',
"safe", 'safe',
"self_service_kiosk", 'self_service_kiosk',
"selfie", 'selfie',
"serial_tasks", 'serial_tasks',
"sales_performance", 'sales_performance',
"settings", 'settings',
"services", 'services',
"share", 'share',
"shipped", 'shipped',
"sim_card", 'sim_card',
"shop", 'shop',
"service_mark", 'service_mark',
"sim_card_chip", 'sim_card_chip',
"signature", 'signature',
"smartphone_tablet", 'smartphone_tablet',
"sound_recording_copy", 'sound_recording_copy',
"sms", 'sms',
"speaker", 'speaker',
"slr_back_side", 'slr_back_side',
"start", 'start',
"stack_of_photos", 'stack_of_photos',
"statistics", 'statistics',
"sports_mode", 'sports_mode',
"support", 'support',
"synchronize", 'synchronize',
"switch_camera", 'switch_camera',
"survey", 'survey',
"tablet_android", 'tablet_android',
"template", 'template',
"trademark", 'trademark',
"todo_list", 'todo_list',
"touchscreen_smartpho", 'touchscreen_smartpho',
"timeline", 'timeline',
"tree_structure", 'tree_structure',
"undo", 'undo',
"up_left", 'up_left',
"two_smartphones", 'two_smartphones',
"unlock", 'unlock',
"up", 'up',
"up_right", 'up_right',
"upload", 'upload',
"video_call", 'video_call',
"video_file", 'video_file',
"view_details", 'view_details',
"video_projector", 'video_projector',
"vip", 'vip',
"voice_presentation", 'voice_presentation',
"webcam", 'webcam',
"voicemail", 'voicemail',
"workflow", 'workflow',
"about", 'about',
"accept_database", 'accept_database',
"add_image", 'add_image',
"add_column", 'add_column',
"add_database", 'add_database',
"add_row", 'add_row',
]; ]
module.exports = [ module.exports = [
{ {
url: "/colorfulIcon/getList", url: '/colorfulIcon/getList',
type: "post", type: 'post',
response(config) { response(config) {
const { title, pageNo = 1, pageSize = 72 } = config.body; const { title, pageNo = 1, pageSize = 72 } = config.body
let mockList = data.filter((item) => { let mockList = data.filter((item) => {
if (title && item.indexOf(title) < 0) return false; if (title && item.indexOf(title) < 0) return false
return true; return true
}); })
const pageList = mockList.filter( const pageList = mockList.filter(
(item, index) => (item, index) =>
index < pageSize * pageNo && index >= pageSize * (pageNo - 1) index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
); )
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
totalCount: mockList.length, totalCount: mockList.length,
data: pageList, data: pageList,
}; }
}, },
}, },
]; ]

View File

@ -1,43 +1,43 @@
const { mock } = require("mockjs"); const { mock } = require('mockjs')
const List = []; const List = []
const count = 999; const count = 999
let num = 0; let num = 0
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
List.push( List.push(
mock({ mock({
uuid: "@uuid", uuid: '@uuid',
image: `https://picsum.photos/300/600?random=${num++}`, image: `https://picsum.photos/300/600?random=${num++}`,
title: "@ctitle", title: '@ctitle',
description: "@csentence", description: '@csentence',
link: "https://www.baidu.com", link: 'https://www.baidu.com',
price: "@integer(100, 500)", price: '@integer(100, 500)',
"status|1": [1, 0], 'status|1': [1, 0],
"isRecommend|1": [1, 0], 'isRecommend|1': [1, 0],
}) })
); )
} }
module.exports = [ module.exports = [
{ {
url: "/goodsList/getList", url: '/goodsList/getList',
type: "post", type: 'post',
response(config) { response(config) {
const { title = "", pageNo = 1, pageSize = 20 } = config.body; const { title = '', pageNo = 1, pageSize = 20 } = config.body
let mockList = List.filter((item) => { let mockList = List.filter((item) => {
if (title && item.title.indexOf(title) < 0) return false; if (title && item.title.indexOf(title) < 0) return false
return true; return true
}); })
const pageList = mockList.filter( const pageList = mockList.filter(
(item, index) => (item, index) =>
index < pageSize * pageNo && index >= pageSize * (pageNo - 1) index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
); )
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
totalCount: count, totalCount: count,
data: pageList, data: pageList,
}; }
}, },
}, },
]; ]

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +1,51 @@
module.exports = [ module.exports = [
{ {
url: "/menuManagement/getTree", url: '/menuManagement/getTree',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
totalCount: 999, totalCount: 999,
data: [ data: [
{ {
id: "root", id: 'root',
label: "全部角色", label: '全部角色',
children: [ children: [
{ {
id: "@id", id: '@id',
permission: "admin", permission: 'admin',
label: "admin角色", label: 'admin角色',
}, },
{ {
id: "@id", id: '@id',
permission: "editor", permission: 'editor',
label: "editor角色", label: 'editor角色',
}, },
], ],
}, },
], ],
}; }
}, },
}, },
{ {
url: "/menuManagement/doEdit", url: '/menuManagement/doEdit',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "模拟保存成功", msg: '模拟保存成功',
}; }
}, },
}, },
{ {
url: "/menuManagement/doDelete", url: '/menuManagement/doDelete',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "模拟删除成功", msg: '模拟删除成功',
}; }
}, },
}, },
]; ]

View File

@ -1,33 +1,33 @@
const data = [ const data = [
{ {
title: title:
"鸣谢尤雨溪、蒋豪群、element-ui、唐金州、花裤衩、贤心、iView、uView的开源项目给我带来的很多的灵感弱小的人才习惯嘲讽与否定内心强大的人从不吝啬赞美与鼓励人生在世得到每个人的认可几乎是痴心妄想我也只是一条略懂前端的咸鱼可我仍一直怀揣着改变世界的梦想希望我们每个人不管过程怎样结局都是美好的。", '鸣谢尤雨溪、蒋豪群、element-ui、唐金州、花裤衩、贤心、iView、uView的开源项目给我带来的很多的灵感弱小的人才习惯嘲讽与否定内心强大的人从不吝啬赞美与鼓励人生在世得到每个人的认可几乎是痴心妄想我也只是一条略懂前端的咸鱼可我仍一直怀揣着改变世界的梦想希望我们每个人不管过程怎样结局都是美好的。',
closable: false, closable: false,
type: "success", type: 'success',
}, },
{ {
title: title:
"作者寄语感谢Star感恩相遇愿世间美好与我们环环相扣加油屏幕前的我们打破桎梏坚守初心。其实人生改变命运的机会并没有太多我们并不是不优秀我们也并不是一无是处我们也希望驻足山巅被众人仰望也许我们缺少的只是一个机会缺少的只是生命中的导师我希望这个框架帮助到更多的人希望有一天我们面试的时候不再胆怯希望有一天别人看到的不仅仅是你的努力还有你的功成名就出人头地。", '作者寄语感谢Star感恩相遇愿世间美好与我们环环相扣加油屏幕前的我们打破桎梏坚守初心。其实人生改变命运的机会并没有太多我们并不是不优秀我们也并不是一无是处我们也希望驻足山巅被众人仰望也许我们缺少的只是一个机会缺少的只是生命中的导师我希望这个框架帮助到更多的人希望有一天我们面试的时候不再胆怯希望有一天别人看到的不仅仅是你的努力还有你的功成名就出人头地。',
closable: false, closable: false,
type: "warning", type: 'warning',
}, },
{ {
title: title:
"随笔:我一直在寻找开源的真谛,我一直再想什么是开源,我一开始觉得免费就是开源,好像又不是。我理解的开源是:你也开源,我也开源,大家一起贡献,相互帮助。我最担心的事情是:我一个小人物,去伺候一众的伸手党,我想,这不是开源该有的氛围。我还太年轻,不懂什么是格局,我只知道,无私的帮助他人,能给我带来快乐,却不能给我带来收入,当然,有时候,快乐对我来说就已经足够了。可惜我是一个人,没有精力帮助到每一个人,可惜这个世界需要赚钱,才能过上平凡的生活,可惜了我的梦想,这个物欲横流的时代,理想主义的我们,即使内心坚决如铁,也似乎寸步难行。", '随笔:我一直在寻找开源的真谛,我一直再想什么是开源,我一开始觉得免费就是开源,好像又不是。我理解的开源是:你也开源,我也开源,大家一起贡献,相互帮助。我最担心的事情是:我一个小人物,去伺候一众的伸手党,我想,这不是开源该有的氛围。我还太年轻,不懂什么是格局,我只知道,无私的帮助他人,能给我带来快乐,却不能给我带来收入,当然,有时候,快乐对我来说就已经足够了。可惜我是一个人,没有精力帮助到每一个人,可惜这个世界需要赚钱,才能过上平凡的生活,可惜了我的梦想,这个物欲横流的时代,理想主义的我们,即使内心坚决如铁,也似乎寸步难行。',
closable: false, closable: false,
type: "success", type: 'success',
}, },
]; ]
module.exports = [ module.exports = [
{ {
url: "/notice/getList", url: '/notice/getList',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
data, data,
}; }
}, },
}, },
]; ]

View File

@ -1,42 +1,42 @@
const { mock } = require("mockjs"); const { mock } = require('mockjs')
module.exports = [ module.exports = [
{ {
url: "/personalCenter/getList", url: '/personalCenter/getList',
type: "post", type: 'post',
response(config) { response(config) {
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
totalCount: 999, totalCount: 999,
data: mock({ data: mock({
"data|10": [ 'data|10': [
{ {
id: "@id", id: '@id',
}, },
], ],
}).data, }).data,
}; }
}, },
}, },
{ {
url: "/personalCenter/doEdit", url: '/personalCenter/doEdit',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "模拟保存成功", msg: '模拟保存成功',
}; }
}, },
}, },
{ {
url: "/personalCenter/doDelete", url: '/personalCenter/doDelete',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "模拟删除成功", msg: '模拟删除成功',
}; }
}, },
}, },
]; ]

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +1,53 @@
const totalCount = 2; const totalCount = 2
const List = [ const List = [
{ {
id: "@id", id: '@id',
permission: "admin", permission: 'admin',
}, },
{ {
id: "@id", id: '@id',
permission: "editor", permission: 'editor',
}, },
]; ]
module.exports = [ module.exports = [
{ {
url: "/roleManagement/getList", url: '/roleManagement/getList',
type: "post", type: 'post',
response(config) { response(config) {
const { title = "", pageNo = 1, pageSize = 20 } = config.body; const { title = '', pageNo = 1, pageSize = 20 } = config.body
let mockList = List.filter((item) => { let mockList = List.filter((item) => {
return !(title && item.title.indexOf(title) < 0); return !(title && item.title.indexOf(title) < 0)
}); })
const pageList = mockList.filter( const pageList = mockList.filter(
(item, index) => (item, index) =>
index < pageSize * pageNo && index >= pageSize * (pageNo - 1) index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
); )
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
totalCount, totalCount,
data: pageList, data: pageList,
}; }
}, },
}, },
{ {
url: "/roleManagement/doEdit", url: '/roleManagement/doEdit',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "模拟保存成功", msg: '模拟保存成功',
}; }
}, },
}, },
{ {
url: "/roleManagement/doDelete", url: '/roleManagement/doDelete',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "模拟删除成功", msg: '模拟删除成功',
}; }
}, },
}, },
]; ]

View File

@ -1,317 +1,317 @@
const data = [ const data = [
{ {
path: "/", path: '/',
component: "Layout", component: 'Layout',
redirect: "index", redirect: 'index',
children: [ children: [
{ {
path: "index", path: 'index',
name: "Index", name: 'Index',
component: "@/views/index/index", component: '@/views/index/index',
meta: { meta: {
title: "首页", title: '首页',
icon: "home", icon: 'home',
affix: true, affix: true,
}, },
}, },
], ],
}, },
{ {
path: "/personnelManagement", path: '/personnelManagement',
component: "Layout", component: 'Layout',
redirect: "noRedirect", redirect: 'noRedirect',
name: "PersonnelManagement", name: 'PersonnelManagement',
meta: { title: "人员", icon: "users-cog", permissions: ["admin"] }, meta: { title: '人员', icon: 'users-cog', permissions: ['admin'] },
children: [ children: [
{ {
path: "userManagement", path: 'userManagement',
name: "UserManagement", name: 'UserManagement',
component: "@/views/personnelManagement/userManagement/index", component: '@/views/personnelManagement/userManagement/index',
meta: { title: "用户管理" }, meta: { title: '用户管理' },
}, },
{ {
path: "roleManagement", path: 'roleManagement',
name: "RoleManagement", name: 'RoleManagement',
component: "@/views/personnelManagement/roleManagement/index", component: '@/views/personnelManagement/roleManagement/index',
meta: { title: "角色管理" }, meta: { title: '角色管理' },
}, },
{ {
path: "menuManagement", path: 'menuManagement',
name: "MenuManagement", name: 'MenuManagement',
component: "@/views/personnelManagement/menuManagement/index", component: '@/views/personnelManagement/menuManagement/index',
meta: { title: "菜单管理", badge: "New" }, meta: { title: '菜单管理', badge: 'New' },
}, },
], ],
}, },
{ {
path: "/vab", path: '/vab',
component: "Layout", component: 'Layout',
redirect: "noRedirect", redirect: 'noRedirect',
name: "Vab", name: 'Vab',
alwaysShow: true, alwaysShow: true,
meta: { title: "组件", icon: "cloud" }, meta: { title: '组件', icon: 'cloud' },
children: [ children: [
{ {
path: "permissions", path: 'permissions',
name: "Permission", name: 'Permission',
component: "@/views/vab/permissions/index", component: '@/views/vab/permissions/index',
meta: { meta: {
title: "权限控制", title: '权限控制',
permissions: ["admin", "editor"], permissions: ['admin', 'editor'],
badge: "New", badge: 'New',
}, },
}, },
{ {
path: "icon", path: 'icon',
component: "EmptyLayout", component: 'EmptyLayout',
redirect: "noRedirect", redirect: 'noRedirect',
name: "Icon", name: 'Icon',
meta: { meta: {
title: "图标", title: '图标',
permissions: ["admin"], permissions: ['admin'],
}, },
children: [ children: [
{ {
path: "awesomeIcon", path: 'awesomeIcon',
name: "AwesomeIcon", name: 'AwesomeIcon',
component: "@/views/vab/icon/index", component: '@/views/vab/icon/index',
meta: { title: "常规图标" }, meta: { title: '常规图标' },
}, },
{ {
path: "remixIcon", path: 'remixIcon',
name: "RemixIcon", name: 'RemixIcon',
component: "@/views/vab/icon/remixIcon", component: '@/views/vab/icon/remixIcon',
meta: { title: "小清新图标" }, meta: { title: '小清新图标' },
}, },
{ {
path: "colorfulIcon", path: 'colorfulIcon',
name: "ColorfulIcon", name: 'ColorfulIcon',
component: "@/views/vab/icon/colorfulIcon", component: '@/views/vab/icon/colorfulIcon',
meta: { title: "多彩图标" }, meta: { title: '多彩图标' },
}, },
], ],
}, },
{ {
path: "table", path: 'table',
component: "@/views/vab/table/index", component: '@/views/vab/table/index',
name: "Table", name: 'Table',
meta: { meta: {
title: "表格", title: '表格',
permissions: ["admin"], permissions: ['admin'],
}, },
}, },
{ {
path: "map", path: 'map',
name: "Map", name: 'Map',
component: "@/views/vab/map/index", component: '@/views/vab/map/index',
meta: { title: "地图", permissions: ["admin"], badge: "Pro" }, meta: { title: '地图', permissions: ['admin'], badge: 'Pro' },
}, },
{ {
path: "webSocket", path: 'webSocket',
name: "WebSocket", name: 'WebSocket',
component: "@/views/vab/webSocket/index", component: '@/views/vab/webSocket/index',
meta: { title: "webSocket", permissions: ["admin"] }, meta: { title: 'webSocket', permissions: ['admin'] },
}, },
{ {
path: "form", path: 'form',
name: "Form", name: 'Form',
component: "@/views/vab/form/index", component: '@/views/vab/form/index',
meta: { title: "表单", permissions: ["admin"] }, meta: { title: '表单', permissions: ['admin'] },
}, },
{ {
path: "element", path: 'element',
name: "Element", name: 'Element',
component: "@/views/vab/element/index", component: '@/views/vab/element/index',
meta: { title: "常用组件", permissions: ["admin"] }, meta: { title: '常用组件', permissions: ['admin'] },
}, },
{ {
path: "tree", path: 'tree',
name: "Tree", name: 'Tree',
component: "@/views/vab/tree/index", component: '@/views/vab/tree/index',
meta: { title: "树", permissions: ["admin"] }, meta: { title: '树', permissions: ['admin'] },
}, },
{ {
path: "card", path: 'card',
name: "Card", name: 'Card',
component: "@/views/vab/card/index", component: '@/views/vab/card/index',
meta: { title: "卡片", permissions: ["admin"] }, meta: { title: '卡片', permissions: ['admin'] },
}, },
{ {
path: "verify", path: 'verify',
name: "Verify", name: 'Verify',
component: "@/views/vab/verify/index", component: '@/views/vab/verify/index',
meta: { title: "验证码", permissions: ["admin"] }, meta: { title: '验证码', permissions: ['admin'] },
}, },
{ {
path: "menu1", path: 'menu1',
component: "@/views/vab/nested/menu1/index", component: '@/views/vab/nested/menu1/index',
name: "Menu1", name: 'Menu1',
alwaysShow: true, alwaysShow: true,
meta: { meta: {
title: "嵌套路由 1", title: '嵌套路由 1',
permissions: ["admin"], permissions: ['admin'],
}, },
children: [ children: [
{ {
path: "menu1-1", path: 'menu1-1',
name: "Menu1-1", name: 'Menu1-1',
alwaysShow: true, alwaysShow: true,
meta: { title: "嵌套路由 1-1" }, meta: { title: '嵌套路由 1-1' },
component: "@/views/vab/nested/menu1/menu1-1/index", component: '@/views/vab/nested/menu1/menu1-1/index',
children: [ children: [
{ {
path: "menu1-1-1", path: 'menu1-1-1',
name: "Menu1-1-1", name: 'Menu1-1-1',
meta: { title: "嵌套路由 1-1-1" }, meta: { title: '嵌套路由 1-1-1' },
component: "@/views/vab/nested/menu1/menu1-1/menu1-1-1/index", component: '@/views/vab/nested/menu1/menu1-1/menu1-1-1/index',
}, },
], ],
}, },
], ],
}, },
{ {
path: "magnifier", path: 'magnifier',
name: "Magnifier", name: 'Magnifier',
component: "@/views/vab/magnifier/index", component: '@/views/vab/magnifier/index',
meta: { title: "放大镜", permissions: ["admin"] }, meta: { title: '放大镜', permissions: ['admin'] },
}, },
{ {
path: "echarts", path: 'echarts',
name: "Echarts", name: 'Echarts',
component: "@/views/vab/echarts/index", component: '@/views/vab/echarts/index',
meta: { title: "图表", permissions: ["admin"] }, meta: { title: '图表', permissions: ['admin'] },
}, },
{ {
path: "loading", path: 'loading',
name: "Loading", name: 'Loading',
component: "@/views/vab/loading/index", component: '@/views/vab/loading/index',
meta: { title: "loading", permissions: ["admin"] }, meta: { title: 'loading', permissions: ['admin'] },
}, },
{ {
path: "player", path: 'player',
name: "Player", name: 'Player',
component: "@/views/vab/player/index", component: '@/views/vab/player/index',
meta: { title: "视频播放器", permissions: ["admin"] }, meta: { title: '视频播放器', permissions: ['admin'] },
}, },
{ {
path: "markdownEditor", path: 'markdownEditor',
name: "MarkdownEditor", name: 'MarkdownEditor',
component: "@/views/vab/markdownEditor/index", component: '@/views/vab/markdownEditor/index',
meta: { title: "markdown编辑器", permissions: ["admin"] }, meta: { title: 'markdown编辑器', permissions: ['admin'] },
}, },
{ {
path: "editor", path: 'editor',
name: "Editor", name: 'Editor',
component: "@/views/vab/editor/index", component: '@/views/vab/editor/index',
meta: { title: "富文本编辑器", permissions: ["admin"], badge: "New" }, meta: { title: '富文本编辑器', permissions: ['admin'], badge: 'New' },
}, },
{ {
path: "backToTop", path: 'backToTop',
name: "BackToTop", name: 'BackToTop',
component: "@/views/vab/backToTop/index", component: '@/views/vab/backToTop/index',
meta: { title: "返回顶部", permissions: ["admin"] }, meta: { title: '返回顶部', permissions: ['admin'] },
}, },
{ {
path: "lodash", path: 'lodash',
name: "Lodash", name: 'Lodash',
component: "@/views/vab/lodash/index", component: '@/views/vab/lodash/index',
meta: { title: "lodash", permissions: ["admin"] }, meta: { title: 'lodash', permissions: ['admin'] },
}, },
{ {
path: "imgComparison", path: 'imgComparison',
name: "ImgComparison", name: 'ImgComparison',
component: "@/views/vab/imgComparison/index", component: '@/views/vab/imgComparison/index',
meta: { title: "图像拖拽比对", permissions: ["admin"] }, meta: { title: '图像拖拽比对', permissions: ['admin'] },
}, },
{ {
path: "smallComponents", path: 'smallComponents',
name: "SmallComponents", name: 'SmallComponents',
component: "@/views/vab/smallComponents/index", component: '@/views/vab/smallComponents/index',
meta: { title: "小组件", permissions: ["admin"] }, meta: { title: '小组件', permissions: ['admin'] },
}, },
{ {
path: "upload", path: 'upload',
name: "Upload", name: 'Upload',
component: "@/views/vab/upload/index", component: '@/views/vab/upload/index',
meta: { title: "上传", permissions: ["admin"] }, meta: { title: '上传', permissions: ['admin'] },
}, },
{ {
path: "log", path: 'log',
name: "Log", name: 'Log',
component: "@/views/vab/errorLog/index", component: '@/views/vab/errorLog/index',
meta: { title: "错误日志模拟", permissions: ["admin"] }, meta: { title: '错误日志模拟', permissions: ['admin'] },
}, },
{ {
path: "more", path: 'more',
name: "More", name: 'More',
component: "@/views/vab/more/index", component: '@/views/vab/more/index',
meta: { title: "关于", permissions: ["admin"] }, meta: { title: '关于', permissions: ['admin'] },
}, },
], ],
}, },
{ {
path: "/mall", path: '/mall',
component: "Layout", component: 'Layout',
redirect: "noRedirect", redirect: 'noRedirect',
name: "Mall", name: 'Mall',
meta: { meta: {
title: "商城", title: '商城',
icon: "shopping-cart", icon: 'shopping-cart',
permissions: ["admin"], permissions: ['admin'],
}, },
children: [ children: [
{ {
path: "pay", path: 'pay',
name: "Pay", name: 'Pay',
component: "@/views/mall/pay/index", component: '@/views/mall/pay/index',
meta: { meta: {
title: "支付", title: '支付',
noKeepAlive: true, noKeepAlive: true,
}, },
children: null, children: null,
}, },
{ {
path: "goodsList", path: 'goodsList',
name: "GoodsList", name: 'GoodsList',
component: "@/views/mall/goodsList/index", component: '@/views/mall/goodsList/index',
meta: { meta: {
title: "商品列表", title: '商品列表',
}, },
}, },
], ],
}, },
{ {
path: "/error", path: '/error',
component: "EmptyLayout", component: 'EmptyLayout',
redirect: "noRedirect", redirect: 'noRedirect',
name: "Error", name: 'Error',
meta: { title: "错误页", icon: "bug" }, meta: { title: '错误页', icon: 'bug' },
children: [ children: [
{ {
path: "401", path: '401',
name: "Error401", name: 'Error401',
component: "@/views/401", component: '@/views/401',
meta: { title: "401" }, meta: { title: '401' },
}, },
{ {
path: "404", path: '404',
name: "Error404", name: 'Error404',
component: "@/views/404", component: '@/views/404',
meta: { title: "404" }, meta: { title: '404' },
}, },
], ],
}, },
]; ]
module.exports = [ module.exports = [
{ {
url: "/menu/navigate", url: '/menu/navigate',
type: "post", type: 'post',
response() { response() {
return { code: 200, msg: "success", data: data }; return { code: 200, msg: 'success', data: data }
}, },
}, },
]; ]

View File

@ -1,88 +1,88 @@
const { mock } = require("mockjs"); const { mock } = require('mockjs')
const { handleRandomImage } = require("../utils"); const { handleRandomImage } = require('../utils')
const List = []; const List = []
const count = 999; const count = 999
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
List.push( List.push(
mock({ mock({
uuid: "@uuid", uuid: '@uuid',
id: "@id", id: '@id',
title: "@csentence(1, 2)", title: '@csentence(1, 2)',
"status|1": ["published", "draft", "deleted"], 'status|1': ['published', 'draft', 'deleted'],
author: "@cname", author: '@cname',
datetime: "@datetime", datetime: '@datetime',
pageViews: "@integer(300, 5000)", pageViews: '@integer(300, 5000)',
img: handleRandomImage(200, 200), img: handleRandomImage(200, 200),
smallImg: handleRandomImage(40, 40), smallImg: handleRandomImage(40, 40),
switch: "@boolean", switch: '@boolean',
percent: "@integer(80,99)", percent: '@integer(80,99)',
}) })
); )
} }
module.exports = [ module.exports = [
{ {
url: "/table/getList", url: '/table/getList',
type: "post", type: 'post',
response(config) { response(config) {
if (!config.body) { if (!config.body) {
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
totalCount: count, totalCount: count,
data: mock({ data: mock({
"data|50": [ 'data|50': [
{ {
id: "@id", id: '@id',
title: "@csentence(1, 2)", title: '@csentence(1, 2)',
"status|1": ["published", "draft", "deleted"], 'status|1': ['published', 'draft', 'deleted'],
author: "@cname", author: '@cname',
datetime: "@datetime", datetime: '@datetime',
pageViews: "@integer(300, 5000)", pageViews: '@integer(300, 5000)',
img: handleRandomImage(200, 200), img: handleRandomImage(200, 200),
smallImg: handleRandomImage(40, 40), smallImg: handleRandomImage(40, 40),
switch: "@boolean", switch: '@boolean',
percent: "@integer(80,99)", percent: '@integer(80,99)',
}, },
], ],
}).data, }).data,
}; }
} }
const { title = "", pageNo = 1, pageSize = 20 } = config.body; const { title = '', pageNo = 1, pageSize = 20 } = config.body
let mockList = List.filter((item) => { let mockList = List.filter((item) => {
return !(title && item.title.indexOf(title) < 0); return !(title && item.title.indexOf(title) < 0)
}); })
const pageList = mockList.filter( const pageList = mockList.filter(
(item, index) => (item, index) =>
index < pageSize * pageNo && index >= pageSize * (pageNo - 1) index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
); )
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
totalCount: count, totalCount: count,
data: pageList, data: pageList,
}; }
}, },
}, },
{ {
url: "/table/doEdit", url: '/table/doEdit',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "模拟保存成功", msg: '模拟保存成功',
}; }
}, },
}, },
{ {
url: "/table/doDelete", url: '/table/doDelete',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "模拟删除成功", msg: '模拟删除成功',
}; }
}, },
}, },
]; ]

View File

@ -1,38 +1,38 @@
const data = [ const data = [
{ {
id: "1", id: '1',
parentId: "0", parentId: '0',
name: "root", name: 'root',
title: "root", title: 'root',
text: "root", text: 'root',
value: "1", value: '1',
rank: 1, rank: 1,
children: [ children: [
{ {
id: "32816b88ff72423f960e7d492a386131", id: '32816b88ff72423f960e7d492a386131',
parentId: "1", parentId: '1',
name: "一级", name: '一级',
title: "一级", title: '一级',
text: "一级", text: '一级',
value: "32816b88ff72423f960e7d492a386131", value: '32816b88ff72423f960e7d492a386131',
rank: 2, rank: 2,
children: [ children: [
{ {
id: "9e11afc35d55475fb0bd3164b9684cbe", id: '9e11afc35d55475fb0bd3164b9684cbe',
parentId: "32816b88ff72423f960e7d492a386131", parentId: '32816b88ff72423f960e7d492a386131',
name: "二级", name: '二级',
title: "二级", title: '二级',
text: "二级", text: '二级',
value: "9e11afc35d55475fb0bd3164b9684cbe", value: '9e11afc35d55475fb0bd3164b9684cbe',
rank: 3, rank: 3,
children: [ children: [
{ {
id: "4cc1b04635e4444292526c5391699077", id: '4cc1b04635e4444292526c5391699077',
parentId: "9e11afc35d55475fb0bd3164b9684cbe", parentId: '9e11afc35d55475fb0bd3164b9684cbe',
name: "三级", name: '三级',
title: "三级", title: '三级',
text: "三级", text: '三级',
value: "4cc1b04635e4444292526c5391699077", value: '4cc1b04635e4444292526c5391699077',
rank: 4, rank: 4,
children: [], children: [],
}, },
@ -42,13 +42,13 @@ const data = [
}, },
], ],
}, },
]; ]
module.exports = [ module.exports = [
{ {
url: "/tree/list", url: '/tree/list',
type: "post", type: 'post',
response() { response() {
return { code: 200, msg: "success", data }; return { code: 200, msg: 'success', data }
}, },
}, },
]; ]

View File

@ -1,95 +1,95 @@
const accessTokens = { const accessTokens = {
admin: "admin-accessToken", admin: 'admin-accessToken',
editor: "editor-accessToken", editor: 'editor-accessToken',
test: "test-accessToken", test: 'test-accessToken',
}; }
module.exports = [ module.exports = [
{ {
url: "/publicKey", url: '/publicKey',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
data: { data: {
mockServer: true, mockServer: true,
publicKey: publicKey:
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBT2vr+dhZElF73FJ6xiP181txKWUSNLPQQlid6DUJhGAOZblluafIdLmnUyKE8mMHhT3R+Ib3ssZcJku6Hn72yHYj/qPkCGFv0eFo7G+GJfDIUeDyalBN0QsuiE/XzPHJBuJDfRArOiWvH0BXOv5kpeXSXM8yTt5Na1jAYSiQ/wIDAQAB", 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBT2vr+dhZElF73FJ6xiP181txKWUSNLPQQlid6DUJhGAOZblluafIdLmnUyKE8mMHhT3R+Ib3ssZcJku6Hn72yHYj/qPkCGFv0eFo7G+GJfDIUeDyalBN0QsuiE/XzPHJBuJDfRArOiWvH0BXOv5kpeXSXM8yTt5Na1jAYSiQ/wIDAQAB',
}, },
}; }
}, },
}, },
{ {
url: "/login", url: '/login',
type: "post", type: 'post',
response(config) { response(config) {
const { username } = config.body; const { username } = config.body
const accessToken = accessTokens[username]; const accessToken = accessTokens[username]
if (!accessToken) { if (!accessToken) {
return { return {
code: 500, code: 500,
msg: "帐户或密码不正确。", msg: '帐户或密码不正确。',
}; }
} }
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
data: { accessToken }, data: { accessToken },
}; }
}, },
}, },
{ {
url: "/register", url: '/register',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "模拟注册成功", msg: '模拟注册成功',
}; }
}, },
}, },
{ {
url: "/userInfo", url: '/userInfo',
type: "post", type: 'post',
response(config) { response(config) {
const { accessToken } = config.body; const { accessToken } = config.body
let permissions = ["admin"]; let permissions = ['admin']
let username = "admin"; let username = 'admin'
if ("admin-accessToken" === accessToken) { if ('admin-accessToken' === accessToken) {
permissions = ["admin"]; permissions = ['admin']
username = "admin"; username = 'admin'
} }
if ("editor-accessToken" === accessToken) { if ('editor-accessToken' === accessToken) {
permissions = ["editor"]; permissions = ['editor']
username = "editor"; username = 'editor'
} }
if ("test-accessToken" === accessToken) { if ('test-accessToken' === accessToken) {
permissions = ["admin", "editor"]; permissions = ['admin', 'editor']
username = "test"; username = 'test'
} }
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
data: { data: {
permissions, permissions,
username, username,
"avatar|1": [ 'avatar|1': [
"https://i.gtimg.cn/club/item/face/img/2/15922_100.gif", 'https://i.gtimg.cn/club/item/face/img/2/15922_100.gif',
"https://i.gtimg.cn/club/item/face/img/8/15918_100.gif", 'https://i.gtimg.cn/club/item/face/img/8/15918_100.gif',
], ],
}, },
}; }
}, },
}, },
{ {
url: "/logout", url: '/logout',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
}; }
}, },
}, },
]; ]

View File

@ -1,70 +1,70 @@
const totalCount = 3; const totalCount = 3
const List = [ const List = [
{ {
id: "@id", id: '@id',
username: "admin", username: 'admin',
password: "admin", password: 'admin',
email: "@email", email: '@email',
permissions: ["admin"], permissions: ['admin'],
datatime: "@datetime", datatime: '@datetime',
}, },
{ {
id: "@id", id: '@id',
username: "editor", username: 'editor',
password: "editor", password: 'editor',
email: "@email", email: '@email',
permissions: ["editor"], permissions: ['editor'],
datatime: "@datetime", datatime: '@datetime',
}, },
{ {
id: "@id", id: '@id',
username: "test", username: 'test',
password: "test", password: 'test',
email: "@email", email: '@email',
permissions: ["admin", "editor"], permissions: ['admin', 'editor'],
datatime: "@datetime", datatime: '@datetime',
}, },
]; ]
module.exports = [ module.exports = [
{ {
url: "/userManagement/getList", url: '/userManagement/getList',
type: "post", type: 'post',
response(config) { response(config) {
const { title = "", pageNo = 1, pageSize = 20 } = config.body; const { title = '', pageNo = 1, pageSize = 20 } = config.body
let mockList = List.filter((item) => { let mockList = List.filter((item) => {
if (title && item.title.indexOf(title) < 0) return false; if (title && item.title.indexOf(title) < 0) return false
return true; return true
}); })
const pageList = mockList.filter( const pageList = mockList.filter(
(item, index) => (item, index) =>
index < pageSize * pageNo && index >= pageSize * (pageNo - 1) index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
); )
return { return {
code: 200, code: 200,
msg: "success", msg: 'success',
totalCount, totalCount,
data: pageList, data: pageList,
}; }
}, },
}, },
{ {
url: "/userManagement/doEdit", url: '/userManagement/doEdit',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "模拟保存成功", msg: '模拟保存成功',
}; }
}, },
}, },
{ {
url: "/userManagement/doDelete", url: '/userManagement/doDelete',
type: "post", type: 'post',
response() { response() {
return { return {
code: 200, code: 200,
msg: "模拟删除成功", msg: '模拟删除成功',
}; }
}, },
}, },
]; ]

View File

@ -3,14 +3,14 @@
* @description 导入所有 controller 模块npm run serve时在node环境中自动输出controller文件夹下Mock接口请勿修改 * @description 导入所有 controller 模块npm run serve时在node环境中自动输出controller文件夹下Mock接口请勿修改
*/ */
const { handleMockArray } = require("./utils"); const { handleMockArray } = require('./utils')
const mocks = []; const mocks = []
const mockArray = handleMockArray(); const mockArray = handleMockArray()
mockArray.forEach((item) => { mockArray.forEach((item) => {
const obj = require(item); const obj = require(item)
mocks.push(...obj); mocks.push(...obj)
}); })
module.exports = { module.exports = {
mocks, mocks,
}; }

View File

@ -1,10 +1,10 @@
const chokidar = require("chokidar"); const chokidar = require('chokidar')
const bodyParser = require("body-parser"); const bodyParser = require('body-parser')
const chalk = require("chalk"); const chalk = require('chalk')
const path = require("path"); const path = require('path')
const Mock = require("mockjs"); const Mock = require('mockjs')
const { baseURL } = require("../src/config/settings"); const { baseURL } = require('../src/config/settings')
const mockDir = path.join(process.cwd(), "mock"); const mockDir = path.join(process.cwd(), 'mock')
/** /**
* *
@ -12,21 +12,21 @@ const mockDir = path.join(process.cwd(), "mock");
* @returns {{mockStartIndex: number, mockRoutesLength: number}} * @returns {{mockStartIndex: number, mockRoutesLength: number}}
*/ */
const registerRoutes = (app) => { const registerRoutes = (app) => {
let mockLastIndex; let mockLastIndex
const { mocks } = require("./index.js"); const { mocks } = require('./index.js')
const mocksForServer = mocks.map((route) => { const mocksForServer = mocks.map((route) => {
return responseFake(route.url, route.type, route.response); return responseFake(route.url, route.type, route.response)
}); })
for (const mock of mocksForServer) { for (const mock of mocksForServer) {
app[mock.type](mock.url, mock.response); app[mock.type](mock.url, mock.response)
mockLastIndex = app._router.stack.length; mockLastIndex = app._router.stack.length
} }
const mockRoutesLength = Object.keys(mocksForServer).length; const mockRoutesLength = Object.keys(mocksForServer).length
return { return {
mockRoutesLength: mockRoutesLength, mockRoutesLength: mockRoutesLength,
mockStartIndex: mockLastIndex - mockRoutesLength, mockStartIndex: mockLastIndex - mockRoutesLength,
}; }
}; }
/** /**
* *
@ -38,56 +38,56 @@ const registerRoutes = (app) => {
const responseFake = (url, type, respond) => { const responseFake = (url, type, respond) => {
return { return {
url: new RegExp(`${baseURL}${url}`), url: new RegExp(`${baseURL}${url}`),
type: type || "get", type: type || 'get',
response(req, res) { response(req, res) {
res.status(200); res.status(200)
if (JSON.stringify(req.body) !== "{}") { if (JSON.stringify(req.body) !== '{}') {
console.log(chalk.green(`> 请求地址:${req.path}`)); console.log(chalk.green(`> 请求地址:${req.path}`))
console.log(chalk.green(`> 请求参数:${JSON.stringify(req.body)}\n`)); console.log(chalk.green(`> 请求参数:${JSON.stringify(req.body)}\n`))
} else { } else {
console.log(chalk.green(`> 请求地址:${req.path}\n`)); console.log(chalk.green(`> 请求地址:${req.path}\n`))
} }
res.json( res.json(
Mock.mock(respond instanceof Function ? respond(req, res) : respond) Mock.mock(respond instanceof Function ? respond(req, res) : respond)
); )
}, },
}; }
}; }
/** /**
* *
* @param app * @param app
*/ */
module.exports = (app) => { module.exports = (app) => {
app.use(bodyParser.json()); app.use(bodyParser.json())
app.use( app.use(
bodyParser.urlencoded({ bodyParser.urlencoded({
extended: true, extended: true,
}) })
); )
const mockRoutes = registerRoutes(app); const mockRoutes = registerRoutes(app)
let mockRoutesLength = mockRoutes.mockRoutesLength; let mockRoutesLength = mockRoutes.mockRoutesLength
let mockStartIndex = mockRoutes.mockStartIndex; let mockStartIndex = mockRoutes.mockStartIndex
chokidar chokidar
.watch(mockDir, { .watch(mockDir, {
ignoreInitial: true, ignoreInitial: true,
}) })
.on("all", (event) => { .on('all', (event) => {
if (event === "change" || event === "add") { if (event === 'change' || event === 'add') {
try { try {
app._router.stack.splice(mockStartIndex, mockRoutesLength); app._router.stack.splice(mockStartIndex, mockRoutesLength)
Object.keys(require.cache).forEach((item) => { Object.keys(require.cache).forEach((item) => {
if (item.includes(mockDir)) { if (item.includes(mockDir)) {
delete require.cache[require.resolve(item)]; delete require.cache[require.resolve(item)]
} }
}); })
const mockRoutes = registerRoutes(app); const mockRoutes = registerRoutes(app)
mockRoutesLength = mockRoutes.mockRoutesLength; mockRoutesLength = mockRoutes.mockRoutesLength
mockStartIndex = mockRoutes.mockStartIndex; mockStartIndex = mockRoutes.mockStartIndex
} catch (error) { } catch (error) {
console.log(chalk.red(error)); console.log(chalk.red(error))
} }
} }
}); })
}; }

View File

@ -1,6 +1,6 @@
const { Random } = require("mockjs"); const { Random } = require('mockjs')
const { join } = require("path"); const { join } = require('path')
const fs = require("fs"); const fs = require('fs')
/** /**
* @author chuzhixin 1204505056@qq.com 不想保留author可删除 * @author chuzhixin 1204505056@qq.com 不想保留author可删除
@ -10,7 +10,7 @@ const fs = require("fs");
* @returns {string} * @returns {string}
*/ */
function handleRandomImage(width = 50, height = 50) { function handleRandomImage(width = 50, height = 50) {
return `https://picsum.photos/${width}/${height}?random=${Random.guid()}`; return `https://picsum.photos/${width}/${height}?random=${Random.guid()}`
} }
/** /**
@ -19,25 +19,25 @@ function handleRandomImage(width = 50, height = 50) {
* @returns {[]} * @returns {[]}
*/ */
function handleMockArray() { function handleMockArray() {
const mockArray = []; const mockArray = []
const getFiles = (jsonPath) => { const getFiles = (jsonPath) => {
const jsonFiles = []; const jsonFiles = []
const findJsonFile = (path) => { const findJsonFile = (path) => {
const files = fs.readdirSync(path); const files = fs.readdirSync(path)
files.forEach((item) => { files.forEach((item) => {
const fPath = join(path, item); const fPath = join(path, item)
const stat = fs.statSync(fPath); const stat = fs.statSync(fPath)
if (stat.isDirectory() === true) findJsonFile(item); if (stat.isDirectory() === true) findJsonFile(item)
if (stat.isFile() === true) jsonFiles.push(item); if (stat.isFile() === true) jsonFiles.push(item)
}); })
}; }
findJsonFile(jsonPath); findJsonFile(jsonPath)
jsonFiles.forEach((item) => mockArray.push(`./controller/${item}`)); jsonFiles.forEach((item) => mockArray.push(`./controller/${item}`))
}; }
getFiles("mock/controller"); getFiles('mock/controller')
return mockArray; return mockArray
} }
module.exports = { module.exports = {
handleRandomImage, handleRandomImage,
handleMockArray, handleMockArray,
}; }

View File

@ -16,7 +16,7 @@
"lint:style": "stylelint-config-prettier-check", "lint:style": "stylelint-config-prettier-check",
"inspect": "vue-cli-service inspect", "inspect": "vue-cli-service inspect",
"template": "plop", "template": "plop",
"clear": "rimraf node_modules&&cnpm i", "clear": "rimraf node_modules&&npm install --registry=https://registry.npm.taobao.org&&cnpm i image-webpack-loader -D",
"use:npm": "nrm use npm", "use:npm": "nrm use npm",
"use:taobao": "nrm use taobao", "use:taobao": "nrm use taobao",
"update": "ncu -u&&cnpm i", "update": "ncu -u&&cnpm i",

View File

@ -1,13 +1,13 @@
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)
}; }

View File

@ -2,15 +2,15 @@ module.exports = {
printWidth: 80, printWidth: 80,
tabWidth: 2, tabWidth: 2,
useTabs: false, useTabs: false,
semi: true, semi: false,
singleQuote: false, singleQuote: true,
quoteProps: "as-needed", quoteProps: 'as-needed',
jsxSingleQuote: false, jsxSingleQuote: false,
trailingComma: "es5", trailingComma: 'es5',
bracketSpacing: true, bracketSpacing: true,
jsxBracketSameLine: false, jsxBracketSameLine: false,
arrowParens: "always", arrowParens: 'always',
htmlWhitespaceSensitivity: "ignore", htmlWhitespaceSensitivity: 'ignore',
vueIndentScriptAndStyle: true, vueIndentScriptAndStyle: true,
endOfLine: "lf", endOfLine: 'lf',
}; }

View File

@ -17,13 +17,13 @@
<meta name="author" content="<%= VUE_APP_AUTHOR %>" /> <meta name="author" content="<%= VUE_APP_AUTHOR %>" />
<link rel="stylesheet" href="<%= BASE_URL %>static/css/loading.css" /> <link rel="stylesheet" href="<%= BASE_URL %>static/css/loading.css" />
<script> <script>
var _hmt = _hmt || []; var _hmt = _hmt || []
(function () { ;(function () {
var hm = document.createElement("script"); var hm = document.createElement('script')
hm.src = "https://hm.baidu.com/hm.js?7174bade1219f9cc272e7978f9523fc8"; hm.src = 'https://hm.baidu.com/hm.js?7174bade1219f9cc272e7978f9523fc8'
var s = document.getElementsByTagName("script")[0]; var s = document.getElementsByTagName('script')[0]
s.parentNode.insertBefore(hm, s); s.parentNode.insertBefore(hm, s)
})(); })()
</script> </script>
</head> </head>
<body> <body>
@ -45,8 +45,8 @@
</div> </div>
</div> </div>
<script> <script>
/^http(s*):\/\//.test(location.href) || ;/^http(s*):\/\//.test(location.href) ||
alert("基于vue-admin-beautiful开发的项目需要部署到服务器下访问"); alert('基于vue-admin-beautiful开发的项目需要部署到服务器下访问')
</script> </script>
</body> </body>
</html> </html>

View File

@ -6,7 +6,7 @@
<script> <script>
export default { export default {
name: "App", name: 'App',
mounted() {}, mounted() {},
}; }
</script> </script>

View File

@ -1,9 +1,9 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getList(data) { export function getList(data) {
return request({ return request({
url: "/ad/getList", url: '/ad/getList',
method: "get", method: 'get',
data, data,
}); })
} }

View File

@ -1,9 +1,9 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getList(data) { export function getList(data) {
return request({ return request({
url: "/changeLog/getList", url: '/changeLog/getList',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,9 +1,9 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getIconList(data) { export function getIconList(data) {
return request({ return request({
url: "/colorfulIcon/getList", url: '/colorfulIcon/getList',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,20 +1,20 @@
import request from "axios"; import request from 'axios'
export function getRepos(params) { export function getRepos(params) {
return request({ return request({
url: "https://api.github.com/repos/chuzhixin/vue-admin-beautiful", url: 'https://api.github.com/repos/chuzhixin/vue-admin-beautiful',
method: "get", method: 'get',
params, params,
timeout: 10000, timeout: 10000,
}); })
} }
export function getStargazers(params) { export function getStargazers(params) {
return request({ return request({
url: url:
"https://api.github.com/repos/chuzhixin/vue-admin-beautiful/stargazers", 'https://api.github.com/repos/chuzhixin/vue-admin-beautiful/stargazers',
method: "get", method: 'get',
params, params,
timeout: 10000, timeout: 10000,
}); })
} }

View File

@ -1,9 +1,9 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getList(data) { export function getList(data) {
return request({ return request({
url: "/goodsList/getList", url: '/goodsList/getList',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,9 +1,9 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getIconList(data) { export function getIconList(data) {
return request({ return request({
url: "/icon/getList", url: '/icon/getList',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,8 +1,8 @@
import request from "axios"; import request from 'axios'
export function getList() { export function getList() {
return request({ return request({
url: "https://cdn.jsdelivr.net/gh/prettier/prettier@master/docs/options.md", url: 'https://cdn.jsdelivr.net/gh/prettier/prettier@master/docs/options.md',
method: "get", method: 'get',
}); })
} }

View File

@ -1,25 +1,25 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getTree(data) { export function getTree(data) {
return request({ return request({
url: "/menuManagement/getTree", url: '/menuManagement/getTree',
method: "post", method: 'post',
data, data,
}); })
} }
export function doEdit(data) { export function doEdit(data) {
return request({ return request({
url: "/menuManagement/doEdit", url: '/menuManagement/doEdit',
method: "post", method: 'post',
data, data,
}); })
} }
export function doDelete(data) { export function doDelete(data) {
return request({ return request({
url: "/menuManagement/doDelete", url: '/menuManagement/doDelete',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,8 +1,8 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getNoticeList() { export function getNoticeList() {
return request({ return request({
url: "/notice/getList", url: '/notice/getList',
method: "post", method: 'post',
}); })
} }

View File

@ -1,25 +1,25 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getList(data) { export function getList(data) {
return request({ return request({
url: "/personalCenter/getList", url: '/personalCenter/getList',
method: "post", method: 'post',
data, data,
}); })
} }
export function doEdit(data) { export function doEdit(data) {
return request({ return request({
url: "/personalCenter/doEdit", url: '/personalCenter/doEdit',
method: "post", method: 'post',
data, data,
}); })
} }
export function doDelete(data) { export function doDelete(data) {
return request({ return request({
url: "/personalCenter/doDelete", url: '/personalCenter/doDelete',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,8 +1,8 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getPublicKey() { export function getPublicKey() {
return request({ return request({
url: "/publicKey", url: '/publicKey',
method: "post", method: 'post',
}); })
} }

View File

@ -1,9 +1,9 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getIconList(data) { export function getIconList(data) {
return request({ return request({
url: "/remixIcon/getList", url: '/remixIcon/getList',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,25 +1,25 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getList(data) { export function getList(data) {
return request({ return request({
url: "/roleManagement/getList", url: '/roleManagement/getList',
method: "post", method: 'post',
data, data,
}); })
} }
export function doEdit(data) { export function doEdit(data) {
return request({ return request({
url: "/roleManagement/doEdit", url: '/roleManagement/doEdit',
method: "post", method: 'post',
data, data,
}); })
} }
export function doDelete(data) { export function doDelete(data) {
return request({ return request({
url: "/roleManagement/doDelete", url: '/roleManagement/doDelete',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,9 +1,9 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getRouterList(data) { export function getRouterList(data) {
return request({ return request({
url: "/menu/navigate", url: '/menu/navigate',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,25 +1,25 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getList(data) { export function getList(data) {
return request({ return request({
url: "/table/getList", url: '/table/getList',
method: "post", method: 'post',
data, data,
}); })
} }
export function doEdit(data) { export function doEdit(data) {
return request({ return request({
url: "/table/doEdit", url: '/table/doEdit',
method: "post", method: 'post',
data, data,
}); })
} }
export function doDelete(data) { export function doDelete(data) {
return request({ return request({
url: "/table/doDelete", url: '/table/doDelete',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,9 +1,9 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getTreeList(data) { export function getTreeList(data) {
return request({ return request({
url: "/tree/list", url: '/tree/list',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,38 +1,38 @@
import request from "@/utils/request"; import request from '@/utils/request'
import { encryptedData } from "@/utils/encrypt"; import { encryptedData } from '@/utils/encrypt'
import { loginRSA, tokenName } from "@/config/settings"; import { loginRSA, tokenName } from '@/config/settings'
export async function login(data) { export async function login(data) {
if (loginRSA) { if (loginRSA) {
data = await encryptedData(data); data = await encryptedData(data)
} }
return request({ return request({
url: "/login", url: '/login',
method: "post", method: 'post',
data, data,
}); })
} }
export function getUserInfo(accessToken) { export function getUserInfo(accessToken) {
return request({ return request({
url: "/userInfo", url: '/userInfo',
method: "post", method: 'post',
data: { data: {
[tokenName]: accessToken, [tokenName]: accessToken,
}, },
}); })
} }
export function logout() { export function logout() {
return request({ return request({
url: "/logout", url: '/logout',
method: "post", method: 'post',
}); })
} }
export function register() { export function register() {
return request({ return request({
url: "/register", url: '/register',
method: "post", method: 'post',
}); })
} }

View File

@ -1,25 +1,25 @@
import request from "@/utils/request"; import request from '@/utils/request'
export function getList(data) { export function getList(data) {
return request({ return request({
url: "/userManagement/getList", url: '/userManagement/getList',
method: "post", method: 'post',
data, data,
}); })
} }
export function doEdit(data) { export function doEdit(data) {
return request({ return request({
url: "/userManagement/doEdit", url: '/userManagement/doEdit',
method: "post", method: 'post',
data, data,
}); })
} }
export function doDelete(data) { export function doDelete(data) {
return request({ return request({
url: "/userManagement/doDelete", url: '/userManagement/doDelete',
method: "post", method: 'post',
data, data,
}); })
} }

View File

@ -1,8 +1,8 @@
import Vue from "vue"; import Vue from 'vue'
import { ColorfullIcon } from "@/layouts/components"; import { ColorfullIcon } from '@/layouts/components'
Vue.component("VabColorfulIcon", ColorfullIcon); Vue.component('VabColorfulIcon', ColorfullIcon)
const req = require.context("./svg", false, /\.svg$/), const req = require.context('./svg', false, /\.svg$/),
requireAll = (requireContext) => { requireAll = (requireContext) => {
/*let a = requireContext.keys().map(requireContext); /*let a = requireContext.keys().map(requireContext);
let arr = []; let arr = [];
@ -12,6 +12,6 @@ const req = require.context("./svg", false, /\.svg$/),
arr.push(icon); arr.push(icon);
} }
console.log(JSON.stringify(arr));*/ console.log(JSON.stringify(arr));*/
return requireContext.keys().map(requireContext); return requireContext.keys().map(requireContext)
}; }
requireAll(req); requireAll(req)

View File

@ -32,132 +32,132 @@
<script> <script>
export default { export default {
name: "SelectTreeTemplate", name: 'SelectTreeTemplate',
props: { props: {
/* 树形结构数据 */ /* 树形结构数据 */
treeOptions: { treeOptions: {
type: Array, type: Array,
default: () => { default: () => {
return []; return []
}, },
}, },
/* 单选/多选 */ /* 单选/多选 */
selectType: { selectType: {
type: String, type: String,
default: () => { default: () => {
return "single"; return 'single'
}, },
}, },
/* 初始选中值key */ /* 初始选中值key */
selectedKey: { selectedKey: {
type: String, type: String,
default: () => { default: () => {
return ""; return ''
}, },
}, },
/* 初始选中值name */ /* 初始选中值name */
selectedValue: { selectedValue: {
type: String, type: String,
default: () => { default: () => {
return ""; return ''
}, },
}, },
/* 可做选择的层级 */ /* 可做选择的层级 */
selectLevel: { selectLevel: {
type: [String, Number], type: [String, Number],
default: () => { default: () => {
return ""; return ''
}, },
}, },
/* 可清空选项 */ /* 可清空选项 */
clearable: { clearable: {
type: Boolean, type: Boolean,
default: () => { default: () => {
return true; return true
}, },
}, },
}, },
data() { data() {
return { return {
defaultProps: { defaultProps: {
children: "children", children: 'children',
label: "name", label: 'name',
}, },
defaultSelectedKeys: [], // defaultSelectedKeys: [], //
currentNodeKey: this.selectedKey, currentNodeKey: this.selectedKey,
selectValue: selectValue:
this.selectType == "multiple" this.selectType == 'multiple'
? this.selectedValue.split(",") ? this.selectedValue.split(',')
: this.selectedValue, //label : this.selectedValue, //label
selectKey: selectKey:
this.selectType == "multiple" this.selectType == 'multiple'
? this.selectedKey.split(",") ? this.selectedKey.split(',')
: this.selectedKey, //value : this.selectedKey, //value
}; }
}, },
mounted() { mounted() {
const that = this; const that = this
this.initTree(); this.initTree()
}, },
methods: { methods: {
// //
initTree() { initTree() {
const that = this; const that = this
if (that.selectedKey) { if (that.selectedKey) {
that.defaultSelectedKeys = that.selectedKey.split(","); // that.defaultSelectedKeys = that.selectedKey.split(',') //
if (that.selectType == "single") { if (that.selectType == 'single') {
that.$refs.treeOption.setCurrentKey(that.selectedKey); // that.$refs.treeOption.setCurrentKey(that.selectedKey) //
} else { } else {
that.$refs.treeOption.setCheckedKeys(that.defaultSelectedKeys); that.$refs.treeOption.setCheckedKeys(that.defaultSelectedKeys)
} }
} }
}, },
// //
clearHandle() { clearHandle() {
const that = this; const that = this
this.selectValue = ""; this.selectValue = ''
this.selectKey = ""; this.selectKey = ''
this.defaultSelectedKeys = []; this.defaultSelectedKeys = []
this.currentNodeKey = ""; this.currentNodeKey = ''
this.clearSelected(); this.clearSelected()
if (that.selectType == "single") { if (that.selectType == 'single') {
that.$refs.treeOption.setCurrentKey(""); // that.$refs.treeOption.setCurrentKey('') //
} else { } else {
that.$refs.treeOption.setCheckedKeys([]); that.$refs.treeOption.setCheckedKeys([])
} }
}, },
/* 清空选中样式 */ /* 清空选中样式 */
clearSelected() { clearSelected() {
const allNode = document.querySelectorAll("#treeOption .el-tree-node"); const allNode = document.querySelectorAll('#treeOption .el-tree-node')
allNode.forEach((element) => element.classList.remove("is-current")); allNode.forEach((element) => element.classList.remove('is-current'))
}, },
// select // select
removeTag(val) { removeTag(val) {
this.$refs.treeOption.setCheckedKeys([]); this.$refs.treeOption.setCheckedKeys([])
}, },
// //
nodeClick(data, node, el) { nodeClick(data, node, el) {
if (data.rank >= this.selectLevel) { if (data.rank >= this.selectLevel) {
this.selectValue = data.name; this.selectValue = data.name
this.selectKey = data.id; this.selectKey = data.id
} }
}, },
// //
checkNode(data, node, el) { checkNode(data, node, el) {
const checkedNodes = this.$refs.treeOption.getCheckedNodes(); const checkedNodes = this.$refs.treeOption.getCheckedNodes()
const keyArr = []; const keyArr = []
const valueArr = []; const valueArr = []
checkedNodes.forEach((item) => { checkedNodes.forEach((item) => {
if (item.rank >= this.selectLevel) { if (item.rank >= this.selectLevel) {
keyArr.push(item.id); keyArr.push(item.id)
valueArr.push(item.name); valueArr.push(item.name)
} }
}); })
this.selectValue = valueArr; this.selectValue = valueArr
this.selectKey = keyArr; this.selectKey = keyArr
}, },
}, },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -24,12 +24,12 @@
<script> <script>
export default { export default {
name: "VabCharge", name: 'VabCharge',
props: { props: {
styleObj: { styleObj: {
type: Object, type: Object,
default: () => { default: () => {
return {}; return {}
}, },
}, },
startVal: { startVal: {
@ -44,16 +44,16 @@
data() { data() {
return { return {
decimals: 2, decimals: 2,
prefix: "", prefix: '',
suffix: "%", suffix: '%',
separator: ",", separator: ',',
duration: 3000, duration: 3000,
}; }
}, },
created() {}, created() {},
mounted() {}, mounted() {},
methods: {}, methods: {},
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -104,7 +104,7 @@
left: 50%; left: 50%;
width: 200px; width: 200px;
height: 200px; height: 200px;
content: ""; content: '';
background-color: #00ff6f; background-color: #00ff6f;
border-radius: 42% 38% 62% 49% / 45%; border-radius: 42% 38% 62% 49% / 45%;
transform: translate(-50%, -50%) rotate(0); transform: translate(-50%, -50%) rotate(0);
@ -118,7 +118,7 @@
z-index: 99; z-index: 99;
width: 176px; width: 176px;
height: 176px; height: 176px;
content: ""; content: '';
background-color: #000; background-color: #000;
border-radius: 50%; border-radius: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);

View File

@ -18,16 +18,16 @@
<script> <script>
export default { export default {
name: "VabImage", name: 'VabImage',
components: {}, components: {},
props: { props: {
bigSrc: { bigSrc: {
type: String, type: String,
default: "", default: '',
}, },
smallSrc: { smallSrc: {
type: String, type: String,
default: "", default: '',
}, },
percent: { percent: {
type: Number, type: Number,
@ -35,19 +35,19 @@
}, },
}, },
data() { data() {
return {}; return {}
}, },
created() {}, created() {},
mounted() {}, mounted() {},
methods: { methods: {
clickBig() { clickBig() {
this.$emit("click-big"); this.$emit('click-big')
}, },
clickSmall() { clickSmall() {
this.$emit("click-small"); this.$emit('click-small')
}, },
}, },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -26,40 +26,40 @@
<script> <script>
export default { export default {
name: "VabProfile", name: 'VabProfile',
props: { props: {
styleObj: { styleObj: {
type: Object, type: Object,
default: () => { default: () => {
return {}; return {}
}, },
}, },
username: { username: {
type: String, type: String,
default: "", default: '',
}, },
avatar: { avatar: {
type: String, type: String,
default: "", default: '',
}, },
iconArray: { iconArray: {
type: Array, type: Array,
default: () => { default: () => {
return [ return [
{ icon: "bell", url: "" }, { icon: 'bell', url: '' },
{ icon: "bookmark", url: "" }, { icon: 'bookmark', url: '' },
{ icon: "cloud-sun", url: "" }, { icon: 'cloud-sun', url: '' },
]; ]
}, },
}, },
}, },
data() { data() {
return {}; return {}
}, },
created() {}, created() {},
mounted() {}, mounted() {},
methods: {}, methods: {},
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -161,7 +161,7 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
color: black; color: black;
content: ""; content: '';
background: #35b9f1; background: #35b9f1;
transform: scaleX(0); transform: scaleX(0);
transform-origin: left; transform-origin: left;
@ -207,7 +207,7 @@
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
content: ""; content: '';
border-radius: inherit; border-radius: inherit;
transform: scale(0); transform: scale(0);
} }

View File

@ -6,22 +6,22 @@
<script> <script>
export default { export default {
name: "VabSnow", name: 'VabSnow',
props: { props: {
styleObj: { styleObj: {
type: Object, type: Object,
default: () => { default: () => {
return {}; return {}
}, },
}, },
}, },
data() { data() {
return {}; return {}
}, },
created() {}, created() {},
mounted() {}, mounted() {},
methods: {}, methods: {},
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -75,19 +75,19 @@
</template> </template>
<script> <script>
import { baseURL, tokenName } from "@/config/settings"; import { baseURL, tokenName } from '@/config/settings'
export default { export default {
name: "VabUpload", name: 'VabUpload',
props: { props: {
url: { url: {
type: String, type: String,
default: "/upload", default: '/upload',
required: true, required: true,
}, },
name: { name: {
type: String, type: String,
default: "file", default: 'file',
required: true, required: true,
}, },
limit: { limit: {
@ -106,106 +106,106 @@
show: false, show: false,
loading: false, loading: false,
dialogVisible: false, dialogVisible: false,
dialogImageUrl: "", dialogImageUrl: '',
action: "https://vab-unicloud-3a9da9.service.tcloudbase.com/upload", action: 'https://vab-unicloud-3a9da9.service.tcloudbase.com/upload',
headers: {}, headers: {},
fileList: [], fileList: [],
picture: "picture", picture: 'picture',
imgNum: 0, imgNum: 0,
imgSuccessNum: 0, imgSuccessNum: 0,
imgErrorNum: 0, imgErrorNum: 0,
typeList: null, typeList: null,
title: "上传", title: '上传',
dialogFormVisible: false, dialogFormVisible: false,
data: {}, data: {},
}; }
}, },
computed: { computed: {
percentage() { percentage() {
if (this.allImgNum == 0) return 0; if (this.allImgNum == 0) return 0
return this.$baseLodash.round(this.imgNum / this.allImgNum, 2) * 100; return this.$baseLodash.round(this.imgNum / this.allImgNum, 2) * 100
}, },
}, },
methods: { methods: {
submitUpload() { submitUpload() {
this.$refs.upload.submit(); this.$refs.upload.submit()
}, },
handleProgress(event, file, fileList) { handleProgress(event, file, fileList) {
this.loading = true; this.loading = true
this.show = true; this.show = true
}, },
handleChange(file, fileList) { handleChange(file, fileList) {
if (file.size > 1048576 * this.size) { if (file.size > 1048576 * this.size) {
fileList.map((item, index) => { fileList.map((item, index) => {
if (item === file) { if (item === file) {
fileList.splice(index, 1); fileList.splice(index, 1)
} }
}); })
this.fileList = fileList; this.fileList = fileList
} else { } else {
this.allImgNum = fileList.length; this.allImgNum = fileList.length
} }
}, },
handleSuccess(response, file, fileList) { handleSuccess(response, file, fileList) {
this.imgNum = this.imgNum + 1; this.imgNum = this.imgNum + 1
this.imgSuccessNum = this.imgSuccessNum + 1; this.imgSuccessNum = this.imgSuccessNum + 1
if (fileList.length === this.imgNum) { if (fileList.length === this.imgNum) {
setTimeout(() => { setTimeout(() => {
this.$baseMessage( this.$baseMessage(
`上传完成! 共上传${fileList.length}张图片`, `上传完成! 共上传${fileList.length}张图片`,
"success" 'success'
); )
}, 1000); }, 1000)
} }
setTimeout(() => { setTimeout(() => {
this.loading = false; this.loading = false
this.show = false; this.show = false
}, 1000); }, 1000)
}, },
handleError(err, file, fileList) { handleError(err, file, fileList) {
this.imgNum = this.imgNum + 1; this.imgNum = this.imgNum + 1
this.imgErrorNum = this.imgErrorNum + 1; this.imgErrorNum = this.imgErrorNum + 1
this.$baseMessage( this.$baseMessage(
`文件[${file.raw.name}]上传失败,文件大小为${this.$baseLodash.round( `文件[${file.raw.name}]上传失败,文件大小为${this.$baseLodash.round(
file.raw.size / 1024, file.raw.size / 1024,
0 0
)}KB`, )}KB`,
"error" 'error'
); )
setTimeout(() => { setTimeout(() => {
this.loading = false; this.loading = false
this.show = false; this.show = false
}, 1000); }, 1000)
}, },
handleRemove(file, fileList) { handleRemove(file, fileList) {
this.imgNum = this.imgNum - 1; this.imgNum = this.imgNum - 1
this.allNum = this.allNum - 1; this.allNum = this.allNum - 1
}, },
handlePreview(file) { handlePreview(file) {
this.dialogImageUrl = file.url; this.dialogImageUrl = file.url
this.dialogVisible = true; this.dialogVisible = true
}, },
handleExceed(files, fileList) { handleExceed(files, fileList) {
this.$baseMessage( this.$baseMessage(
`当前限制选择 ${this.limit} 个文件,本次选择了 `当前限制选择 ${this.limit} 个文件,本次选择了
${files.length} ${files.length}
个文件`, 个文件`,
"error" 'error'
); )
}, },
handleShow(data) { handleShow(data) {
this.title = "上传"; this.title = '上传'
this.data = data; this.data = data
this.dialogFormVisible = true; this.dialogFormVisible = true
}, },
handleClose() { handleClose() {
this.fileList = []; this.fileList = []
this.picture = "picture"; this.picture = 'picture'
this.allImgNum = 0; this.allImgNum = 0
this.imgNum = 0; this.imgNum = 0
this.imgSuccessNum = 0; this.imgSuccessNum = 0
this.imgErrorNum = 0; this.imgErrorNum = 0
/* if ("development" === process.env.NODE_ENV) { /* if ("development" === process.env.NODE_ENV) {
this.api = process.env.VUE_APP_BASE_API; this.api = process.env.VUE_APP_BASE_API;
} else { } else {
@ -213,10 +213,10 @@
} }
this.action = this.api + this.url; */ this.action = this.api + this.url; */
this.dialogFormVisible = false; this.dialogFormVisible = false
}, },
}, },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -2,6 +2,6 @@
* @description 导出自定义配置 * @description 导出自定义配置
**/ **/
const config = { const config = {
layout: "vertical", layout: 'vertical',
}; }
module.exports = config; module.exports = config

View File

@ -1,8 +1,8 @@
/** /**
* @description 导出默认配置(通用配置|主题配置|网络配置) * @description 导出默认配置(通用配置|主题配置|网络配置)
**/ **/
const setting = require("./setting.config"); const setting = require('./setting.config')
const theme = require("./theme.config"); const theme = require('./theme.config')
const network = require("./net.config"); const network = require('./net.config')
module.exports = { setting, theme, network }; module.exports = { setting, theme, network }

View File

@ -3,7 +3,7 @@
**/ **/
const network = { const network = {
//配后端数据的接收方式application/json;charset=UTF-8或者application/x-www-form-urlencoded;charset=UTF-8 //配后端数据的接收方式application/json;charset=UTF-8或者application/x-www-form-urlencoded;charset=UTF-8
contentType: "application/json;charset=UTF-8", contentType: 'application/json;charset=UTF-8',
//消息框消失时间 //消息框消失时间
messageDuration: 3000, messageDuration: 3000,
//最长请求时间 //最长请求时间
@ -14,5 +14,5 @@ const network = {
invalidCode: 402, invalidCode: 402,
//无权限code //无权限code
noPermissionCode: 401, noPermissionCode: 401,
}; }
module.exports = network; module.exports = network

View File

@ -3,26 +3,26 @@
*/ */
const setting = { const setting = {
// 开发以及部署时的URL // 开发以及部署时的URL
publicPath: "", publicPath: '',
// 生产环境构建文件的目录名 // 生产环境构建文件的目录名
outputDir: "dist", outputDir: 'dist',
// 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录。 // 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录。
assetsDir: "static", assetsDir: 'static',
// 开发环境每次保存时是否输出为eslint编译警告 // 开发环境每次保存时是否输出为eslint编译警告
lintOnSave: true, lintOnSave: true,
// 进行编译的依赖 // 进行编译的依赖
transpileDependencies: ["vue-echarts", "resize-detector"], transpileDependencies: ['vue-echarts', 'resize-detector'],
// 默认的接口地址 如果是开发环境和生产环境走vab-mock-server当然你也可以选择自己配置成需要的接口地址 // 默认的接口地址 如果是开发环境和生产环境走vab-mock-server当然你也可以选择自己配置成需要的接口地址
baseURL: baseURL:
process.env.NODE_ENV === "development" process.env.NODE_ENV === 'development'
? "vab-mock-server" ? 'vab-mock-server'
: "vab-mock-server", : 'vab-mock-server',
//标题 (包括初次加载雪花屏的标题 页面的标题 浏览器的标题) //标题 (包括初次加载雪花屏的标题 页面的标题 浏览器的标题)
title: "vue-admin-beautiful", title: 'vue-admin-beautiful',
//简写 //简写
abbreviation: "vab", abbreviation: 'vab',
//开发环境端口号 //开发环境端口号
devPort: "80", devPort: '80',
//版本号 //版本号
version: process.env.VUE_APP_VERSION, version: process.env.VUE_APP_VERSION,
//烦请保留package.json作者信息 即可免费商用 //烦请保留package.json作者信息 即可免费商用
@ -34,42 +34,42 @@ const setting = {
//缓存路由的最大数量 //缓存路由的最大数量
keepAliveMaxNum: 99, keepAliveMaxNum: 99,
// 路由模式,可选值为 history 或 hash // 路由模式,可选值为 history 或 hash
routerMode: "hash", routerMode: 'hash',
//不经过token校验的路由 //不经过token校验的路由
routesWhiteList: ["/login", "/register", "/404", "/401"], routesWhiteList: ['/login', '/register', '/404', '/401'],
//加载时显示文字 //加载时显示文字
loadingText: "正在加载中...", loadingText: '正在加载中...',
//token名称 //token名称
tokenName: "accessToken", tokenName: 'accessToken',
//token在localStorage、sessionStorage存储的key的名称 //token在localStorage、sessionStorage存储的key的名称
tokenTableName: "vue-admin-beautiful", tokenTableName: 'vue-admin-beautiful',
//token存储位置localStorage sessionStorage //token存储位置localStorage sessionStorage
storage: "localStorage", storage: 'localStorage',
//token失效回退到登录页时是否记录本次的路由 //token失效回退到登录页时是否记录本次的路由
recordRoute: true, recordRoute: true,
//是否显示logo不显示时设置false显示时请填写remixIcon图标名称暂时只支持设置remixIcon //是否显示logo不显示时设置false显示时请填写remixIcon图标名称暂时只支持设置remixIcon
logo: "vuejs-fill", logo: 'vuejs-fill',
//是否显示在页面高亮错误 //是否显示在页面高亮错误
errorLog: ["development"], errorLog: ['development'],
//是否开启登录拦截 //是否开启登录拦截
loginInterception: true, loginInterception: true,
//是否开启登录RSA加密 //是否开启登录RSA加密
loginRSA: false, loginRSA: false,
//intelligence和all两种方式前者后端权限只控制permissions不控制view文件的import前后端配合减轻后端工作量all方式完全交给后端前端只负责加载 //intelligence和all两种方式前者后端权限只控制permissions不控制view文件的import前后端配合减轻后端工作量all方式完全交给后端前端只负责加载
authentication: "intelligence", authentication: 'intelligence',
//vertical布局时是否只保持一个子菜单的展开 //vertical布局时是否只保持一个子菜单的展开
uniqueOpened: true, uniqueOpened: true,
//vertical布局时默认展开的菜单path使用逗号隔开建议只展开一个 //vertical布局时默认展开的菜单path使用逗号隔开建议只展开一个
defaultOopeneds: ["/vab"], defaultOopeneds: ['/vab'],
//需要加loading层的请求防止重复提交 //需要加loading层的请求防止重复提交
debounce: ["doEdit"], debounce: ['doEdit'],
//需要自动注入并加载的模块 //需要自动注入并加载的模块
providePlugin: { maptalks: "maptalks", "window.maptalks": "maptalks" }, providePlugin: { maptalks: 'maptalks', 'window.maptalks': 'maptalks' },
//npm run build时是否自动生成7z压缩包 //npm run build时是否自动生成7z压缩包
build7z: false, build7z: false,
//代码生成机生成在view下的文件夹名称 //代码生成机生成在view下的文件夹名称
templateFolder: "project", templateFolder: 'project',
//是否显示终端donation打印 //是否显示终端donation打印
donation: true, donation: true,
}; }
module.exports = setting; module.exports = setting

View File

@ -3,12 +3,12 @@
*/ */
const theme = { const theme = {
//是否国定头部 固定fixed 不固定noFixed //是否国定头部 固定fixed 不固定noFixed
header: "fixed", header: 'fixed',
//横纵布局 horizontal vertical //横纵布局 horizontal vertical
layout: "vertical", layout: 'vertical',
//是否开启主题配置按钮 //是否开启主题配置按钮
themeBar: true, themeBar: true,
//是否显示多标签页 //是否显示多标签页
tabsBar: true, tabsBar: true,
}; }
module.exports = theme; module.exports = theme

View File

@ -2,84 +2,81 @@
* @author chuzhixin 1204505056@qq.com 不想保留author可删除 * @author chuzhixin 1204505056@qq.com 不想保留author可删除
* @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,
progressBar, progressBar,
recordRoute, recordRoute,
routesWhiteList, routesWhiteList,
} from "./settings"; } from './settings'
VabProgress.configure({ VabProgress.configure({
easing: "ease", easing: 'ease',
speed: 500, speed: 500,
trickleSpeed: 200, trickleSpeed: 200,
showSpinner: false, showSpinner: false,
}); })
router.beforeResolve(async (to, from, next) => { router.beforeResolve(async (to, from, next) => {
if (progressBar) VabProgress.start(); if (progressBar) VabProgress.start()
let hasToken = store.getters["user/accessToken"]; let hasToken = store.getters['user/accessToken']
if (!loginInterception) hasToken = true; if (!loginInterception) hasToken = true
if (hasToken) { if (hasToken) {
if (to.path === "/login") { if (to.path === '/login') {
next({ path: "/" }); next({ path: '/' })
if (progressBar) VabProgress.done(); if (progressBar) VabProgress.done()
} else { } else {
const hasPermissions = const hasPermissions =
store.getters["user/permissions"] && store.getters['user/permissions'] &&
store.getters["user/permissions"].length > 0; store.getters['user/permissions'].length > 0
if (hasPermissions) { if (hasPermissions) {
next(); next()
} else { } else {
try { try {
let permissions; let permissions
if (!loginInterception) { if (!loginInterception) {
//settings.js loginInterception为false时创建虚拟权限 //settings.js loginInterception为false时创建虚拟权限
await store.dispatch("user/setPermissions", ["admin"]); await store.dispatch('user/setPermissions', ['admin'])
permissions = ["admin"]; permissions = ['admin']
} else { } else {
permissions = await store.dispatch("user/getUserInfo"); permissions = await store.dispatch('user/getUserInfo')
} }
let accessRoutes = []; let accessRoutes = []
if (authentication === "intelligence") { if (authentication === 'intelligence') {
accessRoutes = await store.dispatch( accessRoutes = await store.dispatch('routes/setRoutes', permissions)
"routes/setRoutes", } else if (authentication === 'all') {
permissions accessRoutes = await store.dispatch('routes/setAllRoutes')
);
} else if (authentication === "all") {
accessRoutes = await store.dispatch("routes/setAllRoutes");
} }
router.addRoutes(accessRoutes); router.addRoutes(accessRoutes)
next({ ...to, replace: true }); next({ ...to, replace: true })
} catch { } catch {
await store.dispatch("user/resetAccessToken"); await store.dispatch('user/resetAccessToken')
if (progressBar) VabProgress.done(); if (progressBar) VabProgress.done()
} }
} }
} }
} else { } else {
if (routesWhiteList.indexOf(to.path) !== -1) { if (routesWhiteList.indexOf(to.path) !== -1) {
next(); next()
} else { } else {
if (recordRoute) { if (recordRoute) {
next(`/login?redirect=${to.path}`); next(`/login?redirect=${to.path}`)
} else { } else {
next("/login"); next('/login')
} }
if (progressBar) VabProgress.done(); if (progressBar) VabProgress.done()
} }
} }
document.title = getPageTitle(to.meta.title); document.title = getPageTitle(to.meta.title)
}); })
router.afterEach(() => { router.afterEach(() => {
if (progressBar) VabProgress.done(); if (progressBar) VabProgress.done()
}); })

View File

@ -2,8 +2,8 @@
* @description 3个子配置通用配置|主题配置|网络配置建议在当前目录下修改config.js修改配置会覆盖默认配置也可以直接修改默认配置 * @description 3个子配置通用配置|主题配置|网络配置建议在当前目录下修改config.js修改配置会覆盖默认配置也可以直接修改默认配置
*/ */
//默认配置 //默认配置
const { setting, theme, network } = require("./default"); const { setting, theme, network } = require('./default')
//自定义配置 //自定义配置
const config = require("./config"); const config = require('./config')
//导出配置(以自定义配置为主) //导出配置(以自定义配置为主)
module.exports = Object.assign({}, setting, theme, network, config); module.exports = Object.assign({}, setting, theme, network, config)

View File

@ -16,24 +16,24 @@
</div> </div>
</template> </template>
<script> <script>
import { getList } from "@/api/ad"; import { getList } from '@/api/ad'
export default { export default {
data() { data() {
return { return {
nodeEnv: process.env.NODE_ENV, nodeEnv: process.env.NODE_ENV,
adList: [], adList: [],
}; }
}, },
created() { created() {
this.fetchData(); this.fetchData()
}, },
methods: { methods: {
async fetchData() { async fetchData() {
const { data } = await getList(); const { data } = await getList()
this.adList = data; this.adList = data
}, },
}, },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.vab-ad { .vab-ad {

View File

@ -14,16 +14,16 @@
</template> </template>
<script> <script>
import { mapActions, mapGetters } from "vuex"; import { mapActions, mapGetters } from 'vuex'
import { import {
copyright, copyright,
footerCopyright, footerCopyright,
keepAliveMaxNum, keepAliveMaxNum,
title, title,
} from "@/config/settings"; } from '@/config/settings'
export default { export default {
name: "AppMain", name: 'AppMain',
data() { data() {
return { return {
show: false, show: false,
@ -33,50 +33,50 @@
keepAliveMaxNum, keepAliveMaxNum,
routerView: true, routerView: true,
footerCopyright, footerCopyright,
}; }
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
visitedRoutes: "tabsBar/visitedRoutes", visitedRoutes: 'tabsBar/visitedRoutes',
device: "settings/device", device: 'settings/device',
}), }),
cachedRoutes() { cachedRoutes() {
const cachedRoutesArr = []; const cachedRoutesArr = []
this.visitedRoutes.forEach((item) => { this.visitedRoutes.forEach((item) => {
if (!item.meta.noKeepAlive) { if (!item.meta.noKeepAlive) {
cachedRoutesArr.push(item.name); cachedRoutesArr.push(item.name)
} }
}); })
return cachedRoutesArr; return cachedRoutesArr
}, },
key() { key() {
return this.$route.path; return this.$route.path
}, },
}, },
watch: { watch: {
$route: { $route: {
handler(route) { handler(route) {
if ("mobile" === this.device) this.foldSideBar(); if ('mobile' === this.device) this.foldSideBar()
}, },
immediate: true, immediate: true,
}, },
}, },
created() { created() {
// //
this.$baseEventBus.$on("reload-routerview", () => { this.$baseEventBus.$on('reload-routerview', () => {
this.routerView = false; this.routerView = false
this.$nextTick(() => { this.$nextTick(() => {
this.routerView = true; this.routerView = true
}); })
}); })
}, },
mounted() {}, mounted() {},
methods: { methods: {
...mapActions({ ...mapActions({
foldSideBar: "settings/foldSideBar", foldSideBar: 'settings/foldSideBar',
}), }),
}, },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -18,54 +18,54 @@
</template> </template>
<script> <script>
import { mapGetters } from "vuex"; import { mapGetters } from 'vuex'
import { recordRoute } from "@/config/settings"; import { recordRoute } from '@/config/settings'
export default { export default {
name: "Avatar", name: 'Avatar',
computed: { computed: {
...mapGetters({ ...mapGetters({
avatar: "user/avatar", avatar: 'user/avatar',
username: "user/username", username: 'user/username',
}), }),
}, },
methods: { methods: {
handleCommand(command) { handleCommand(command) {
switch (command) { switch (command) {
case "logout": case 'logout':
this.logout(); this.logout()
break; break
case "personalCenter": case 'personalCenter':
this.personalCenter(); this.personalCenter()
break; break
case "github": case 'github':
window.open("https://github.com/chuzhixin/vue-admin-beautiful"); window.open('https://github.com/chuzhixin/vue-admin-beautiful')
break; break
case "gitee": case 'gitee':
window.open("https://gitee.com/chu1204505056/vue-admin-beautiful"); window.open('https://gitee.com/chu1204505056/vue-admin-beautiful')
break; break
} }
}, },
personalCenter() { personalCenter() {
this.$router.push("/personalCenter/personalCenter"); this.$router.push('/personalCenter/personalCenter')
}, },
logout() { logout() {
this.$baseConfirm( this.$baseConfirm(
"您确定要退出" + this.$baseTitle + "吗?", '您确定要退出' + this.$baseTitle + '吗?',
null, null,
async () => { async () => {
await this.$store.dispatch("user/logout"); await this.$store.dispatch('user/logout')
if (recordRoute) { if (recordRoute) {
const fullPath = this.$route.fullPath; const fullPath = this.$route.fullPath
this.$router.push(`/login?redirect=${fullPath}`); this.$router.push(`/login?redirect=${fullPath}`)
} else { } else {
this.$router.push("/login"); this.$router.push('/login')
} }
} }
); )
}, },
}, },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.avatar-dropdown { .avatar-dropdown {

View File

@ -8,25 +8,25 @@
<script> <script>
export default { export default {
name: "Breadcrumb", name: 'Breadcrumb',
data() { data() {
return { return {
list: this.getBreadcrumb(), list: this.getBreadcrumb(),
}; }
}, },
watch: { watch: {
$route() { $route() {
this.list = this.getBreadcrumb(); this.list = this.getBreadcrumb()
}, },
}, },
methods: { methods: {
getBreadcrumb() { getBreadcrumb() {
return this.$route.matched.filter( return this.$route.matched.filter(
(item) => item.name && item.meta.title (item) => item.name && item.meta.title
); )
}, },
}, },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -14,23 +14,23 @@
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from "vuex"; import { mapGetters } from 'vuex'
import { logo } from "@/config/settings"; import { logo } from '@/config/settings'
export default { export default {
name: "Logo", name: 'Logo',
data() { data() {
return { return {
title: this.$baseTitle, title: this.$baseTitle,
}; }
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
logo: "settings/logo", logo: 'settings/logo',
layout: "settings/layout", layout: 'settings/layout',
}), }),
}, },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@mixin container { @mixin container {

View File

@ -36,7 +36,7 @@
</template> </template>
<script> <script>
import { mapActions, mapGetters } from "vuex"; import { mapActions, mapGetters } from 'vuex'
import { import {
Avatar, Avatar,
@ -44,10 +44,10 @@
ErrorLog, ErrorLog,
FullScreenBar, FullScreenBar,
ThemeBar, ThemeBar,
} from "@/layouts/components"; } from '@/layouts/components'
export default { export default {
name: "NavBar", name: 'NavBar',
components: { components: {
Avatar, Avatar,
Breadcrumb, Breadcrumb,
@ -58,32 +58,32 @@
data() { data() {
return { return {
pulse: false, pulse: false,
}; }
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
collapse: "settings/collapse", collapse: 'settings/collapse',
visitedRoutes: "tabsBar/visitedRoutes", visitedRoutes: 'tabsBar/visitedRoutes',
device: "settings/device", device: 'settings/device',
routes: "routes/routes", routes: 'routes/routes',
}), }),
}, },
methods: { methods: {
...mapActions({ ...mapActions({
changeCollapse: "settings/changeCollapse", changeCollapse: 'settings/changeCollapse',
}), }),
handleCollapse() { handleCollapse() {
this.changeCollapse(); this.changeCollapse()
}, },
async refreshRoute() { async refreshRoute() {
this.$baseEventBus.$emit("reload-routerview"); this.$baseEventBus.$emit('reload-routerview')
this.pulse = true; this.pulse = true
setTimeout(() => { setTimeout(() => {
this.pulse = false; this.pulse = false
}, 1000); }, 1000)
}, },
}, },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -66,119 +66,119 @@
</template> </template>
<script> <script>
import variables from "@/styles/variables.scss"; import variables from '@/styles/variables.scss'
import { mapActions, mapGetters } from "vuex"; import { mapActions, mapGetters } from 'vuex'
import { layout as defaultLayout } from "@/config/settings"; import { layout as defaultLayout } from '@/config/settings'
export default { export default {
name: "ThemeBar", name: 'ThemeBar',
data() { data() {
return { return {
drawerVisible: false, drawerVisible: false,
theme: { theme: {
name: "default", name: 'default',
layout: "", layout: '',
header: "", header: '',
tabsBar: "", tabsBar: '',
}, },
}; }
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
layout: "settings/layout", layout: 'settings/layout',
header: "settings/header", header: 'settings/header',
tabsBar: "settings/tabsBar", tabsBar: 'settings/tabsBar',
themeBar: "settings/themeBar", themeBar: 'settings/themeBar',
}), }),
}, },
created() { created() {
this.$baseEventBus.$on("theme", () => { this.$baseEventBus.$on('theme', () => {
this.handleOpenThemeBar(); this.handleOpenThemeBar()
}); })
const theme = localStorage.getItem("vue-admin-beautiful-theme"); const theme = localStorage.getItem('vue-admin-beautiful-theme')
if (null !== theme) { if (null !== theme) {
this.theme = JSON.parse(theme); this.theme = JSON.parse(theme)
this.handleSetTheme(); this.handleSetTheme()
} else { } else {
this.theme.layout = this.layout; this.theme.layout = this.layout
this.theme.header = this.header; this.theme.header = this.header
this.theme.tabsBar = this.tabsBar; this.theme.tabsBar = this.tabsBar
} }
}, },
methods: { methods: {
...mapActions({ ...mapActions({
changeLayout: "settings/changeLayout", changeLayout: 'settings/changeLayout',
changeHeader: "settings/changeHeader", changeHeader: 'settings/changeHeader',
changeTabsBar: "settings/changeTabsBar", changeTabsBar: 'settings/changeTabsBar',
}), }),
handleIsMobile() { handleIsMobile() {
return document.body.getBoundingClientRect().width - 1 < 992; return document.body.getBoundingClientRect().width - 1 < 992
}, },
handleOpenThemeBar() { handleOpenThemeBar() {
this.drawerVisible = true; this.drawerVisible = true
}, },
handleSetTheme() { handleSetTheme() {
let { name, layout, header, tabsBar } = this.theme; let { name, layout, header, tabsBar } = this.theme
localStorage.setItem( localStorage.setItem(
"vue-admin-beautiful-theme", 'vue-admin-beautiful-theme',
`{ `{
"name":"${name}", "name":"${name}",
"layout":"${layout}", "layout":"${layout}",
"header":"${header}", "header":"${header}",
"tabsBar":"${tabsBar}" "tabsBar":"${tabsBar}"
}` }`
); )
if (!this.handleIsMobile()) this.changeLayout(layout); if (!this.handleIsMobile()) this.changeLayout(layout)
this.changeHeader(header); this.changeHeader(header)
this.changeTabsBar(tabsBar); this.changeTabsBar(tabsBar)
document.getElementsByTagName( document.getElementsByTagName(
"body" 'body'
)[0].className = `vue-admin-beautiful-theme-${name}`; )[0].className = `vue-admin-beautiful-theme-${name}`
this.drawerVisible = false; this.drawerVisible = false
}, },
handleSaveTheme() { handleSaveTheme() {
this.handleSetTheme(); this.handleSetTheme()
}, },
handleSetDfaultTheme() { handleSetDfaultTheme() {
let { name } = this.theme; let { name } = this.theme
document document
.getElementsByTagName("body")[0] .getElementsByTagName('body')[0]
.classList.remove(`vue-admin-beautiful-theme-${name}`); .classList.remove(`vue-admin-beautiful-theme-${name}`)
localStorage.removeItem("vue-admin-beautiful-theme"); localStorage.removeItem('vue-admin-beautiful-theme')
this.$refs["form"].resetFields(); this.$refs['form'].resetFields()
Object.assign(this.$data, this.$options.data()); Object.assign(this.$data, this.$options.data())
this.changeHeader(defaultLayout); this.changeHeader(defaultLayout)
this.theme.name = "default"; this.theme.name = 'default'
this.theme.layout = this.layout; this.theme.layout = this.layout
this.theme.header = this.header; this.theme.header = this.header
this.theme.tabsBar = this.tabsBar; this.theme.tabsBar = this.tabsBar
this.drawerVisible = false; this.drawerVisible = false
}, },
handleGetCode() { handleGetCode() {
const url = const url =
"https://github.com/chuzhixin/vue-admin-beautiful/tree/master/src/views"; 'https://github.com/chuzhixin/vue-admin-beautiful/tree/master/src/views'
let path = this.$route.path + "/index.vue"; let path = this.$route.path + '/index.vue'
if (path === "/vab/menu1/menu1-1/menu1-1-1/index.vue") { if (path === '/vab/menu1/menu1-1/menu1-1-1/index.vue') {
path = "/vab/nested/menu1/menu1-1/menu1-1-1/index.vue"; path = '/vab/nested/menu1/menu1-1/menu1-1-1/index.vue'
} }
if (path === "/vab/icon/awesomeIcon/index.vue") { if (path === '/vab/icon/awesomeIcon/index.vue') {
path = "/vab/icon/index.vue"; path = '/vab/icon/index.vue'
} }
if (path === "/vab/icon/remixIcon/index.vue") { if (path === '/vab/icon/remixIcon/index.vue') {
path = "/vab/icon/remixIcon.vue"; path = '/vab/icon/remixIcon.vue'
} }
if (path === "/vab/icon/colorfulIcon/index.vue") { if (path === '/vab/icon/colorfulIcon/index.vue') {
path = "/vab/icon/colorfulIcon.vue"; path = '/vab/icon/colorfulIcon.vue'
} }
if (path === "/vab/table/comprehensiveTable/index.vue") { if (path === '/vab/table/comprehensiveTable/index.vue') {
path = "/vab/table/index.vue"; path = '/vab/table/index.vue'
} }
if (path === "/vab/table/inlineEditTable/index.vue") { if (path === '/vab/table/inlineEditTable/index.vue') {
path = "/vab/table/inlineEditTable.vue"; path = '/vab/table/inlineEditTable.vue'
} }
window.open(url + path); window.open(url + path)
}, },
}, },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -4,27 +4,27 @@
* 当然也存在一定的弊端给开发者自定义增加了一定的困难 * 当然也存在一定的弊端给开发者自定义增加了一定的困难
* 如果您一定要进行高度自定义请仔细阅读讨论群文档layouts本地化篇 * 如果您一定要进行高度自定义请仔细阅读讨论群文档layouts本地化篇
*/ */
export { default as ColorfullIcon } from "zx-layouts/ColorfullIcon"; export { default as ColorfullIcon } from 'zx-layouts/ColorfullIcon'
export { default as RemixIcon } from "zx-layouts/RemixIcon"; export { default as RemixIcon } from 'zx-layouts/RemixIcon'
export { default as VabDrag } from "zx-layouts/Drag"; export { default as VabDrag } from 'zx-layouts/Drag'
export { default as VabPermissions } from "zx-layouts/Permissions"; export { default as VabPermissions } from 'zx-layouts/Permissions'
export { default as VabQueryForm } from "zx-layouts/VabQueryForm/export"; export { default as VabQueryForm } from 'zx-layouts/VabQueryForm/export'
//本地化logo、默认使用svg如需变更为png更改logo源码即可 //本地化logo、默认使用svg如需变更为png更改logo源码即可
export { default as Logo } from "./Logo"; export { default as Logo } from './Logo'
//本地化头像组件 //本地化头像组件
export { default as Avatar } from "./Avatar"; export { default as Avatar } from './Avatar'
//本地化广告组件如不需要全局搜索ad组件删掉即可 //本地化广告组件如不需要全局搜索ad组件删掉即可
export { default as Ad } from "./Ad"; export { default as Ad } from './Ad'
//本地化AppMain组件 //本地化AppMain组件
export { default as AppMain } from "./AppMain"; export { default as AppMain } from './AppMain'
export { default as TabsBar } from "zx-layouts/TabsBar"; export { default as TabsBar } from 'zx-layouts/TabsBar'
export { default as SideBar } from "zx-layouts/SideBar"; export { default as SideBar } from 'zx-layouts/SideBar'
//本地化Breadcrumb组件 //本地化Breadcrumb组件
export { default as Breadcrumb } from "./Breadcrumb"; export { default as Breadcrumb } from './Breadcrumb'
export { default as FullScreenBar } from "zx-layouts/FullScreenBar"; export { default as FullScreenBar } from 'zx-layouts/FullScreenBar'
export { default as ErrorLog } from "zx-layouts/ErrorLog"; export { default as ErrorLog } from 'zx-layouts/ErrorLog'
//本地化ThemeBar组件 //本地化ThemeBar组件
export { default as ThemeBar } from "./ThemeBar"; export { default as ThemeBar } from './ThemeBar'
export { default as TopBar } from "zx-layouts/TopBar"; export { default as TopBar } from 'zx-layouts/TopBar'
//本地化NavBar组件 //本地化NavBar组件
export { default as NavBar } from "./NavBar"; export { default as NavBar } from './NavBar'

View File

@ -52,11 +52,11 @@
</template> </template>
<script> <script>
import { Ad, AppMain, NavBar, SideBar, TabsBar, TopBar } from "./components"; import { Ad, AppMain, NavBar, SideBar, TabsBar, TopBar } from './components'
import { mapActions, mapGetters } from "vuex"; import { mapActions, mapGetters } from 'vuex'
import { tokenName } from "@/config/settings"; import { tokenName } from '@/config/settings'
export default { export default {
name: "Layout", name: 'Layout',
components: { components: {
Ad, Ad,
TopBar, TopBar,
@ -66,88 +66,88 @@
TabsBar, TabsBar,
}, },
data() { data() {
return { oldLayout: "" }; return { oldLayout: '' }
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
layout: "settings/layout", layout: 'settings/layout',
tabsBar: "settings/tabsBar", tabsBar: 'settings/tabsBar',
collapse: "settings/collapse", collapse: 'settings/collapse',
header: "settings/header", header: 'settings/header',
device: "settings/device", device: 'settings/device',
}), }),
classObj() { classObj() {
return { return {
mobile: this.device === "mobile", mobile: this.device === 'mobile',
}; }
}, },
}, },
beforeMount() { beforeMount() {
window.addEventListener("resize", this.handleResize); window.addEventListener('resize', this.handleResize)
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener("resize", this.handleResize); window.removeEventListener('resize', this.handleResize)
}, },
mounted() { mounted() {
this.oldLayout = this.layout; this.oldLayout = this.layout
const userAgent = navigator.userAgent; const userAgent = navigator.userAgent
if (userAgent.includes("Juejin")) { if (userAgent.includes('Juejin')) {
this.$baseAlert( this.$baseAlert(
"vue-admin-beautiful不支持在掘金内置浏览器演示请手动复制以下地址到浏览器中查看http://mpfhrd48.sanxing.uz7.cn/vue-admin-beautiful" 'vue-admin-beautiful不支持在掘金内置浏览器演示请手动复制以下地址到浏览器中查看http://mpfhrd48.sanxing.uz7.cn/vue-admin-beautiful'
); )
} }
const isMobile = this.handleIsMobile(); const isMobile = this.handleIsMobile()
if (isMobile) { if (isMobile) {
if (isMobile) { if (isMobile) {
//访 //访
this.$store.dispatch("settings/changeLayout", "vertical"); this.$store.dispatch('settings/changeLayout', 'vertical')
} else { } else {
this.$store.dispatch("settings/changeLayout", this.oldLayout); this.$store.dispatch('settings/changeLayout', this.oldLayout)
} }
this.$store.dispatch("settings/toggleDevice", "mobile"); this.$store.dispatch('settings/toggleDevice', 'mobile')
setTimeout(() => { setTimeout(() => {
this.$store.dispatch("settings/foldSideBar"); this.$store.dispatch('settings/foldSideBar')
}, 2000); }, 2000)
} else { } else {
this.$store.dispatch("settings/openSideBar"); this.$store.dispatch('settings/openSideBar')
} }
this.$nextTick(() => { this.$nextTick(() => {
window.addEventListener( window.addEventListener(
"storage", 'storage',
(e) => { (e) => {
if (e.key === tokenName || e.key === null) window.location.reload(); if (e.key === tokenName || e.key === null) window.location.reload()
if (e.key === tokenName && e.value === null) if (e.key === tokenName && e.value === null)
window.location.reload(); window.location.reload()
}, },
false false
); )
}); })
}, },
methods: { methods: {
...mapActions({ ...mapActions({
handleFoldSideBar: "settings/foldSideBar", handleFoldSideBar: 'settings/foldSideBar',
}), }),
handleIsMobile() { handleIsMobile() {
return document.body.getBoundingClientRect().width - 1 < 992; return document.body.getBoundingClientRect().width - 1 < 992
}, },
handleResize() { handleResize() {
if (!document.hidden) { if (!document.hidden) {
const isMobile = this.handleIsMobile(); const isMobile = this.handleIsMobile()
if (isMobile) { if (isMobile) {
//访 //访
this.$store.dispatch("settings/changeLayout", "vertical"); this.$store.dispatch('settings/changeLayout', 'vertical')
} else { } else {
this.$store.dispatch("settings/changeLayout", this.oldLayout); this.$store.dispatch('settings/changeLayout', this.oldLayout)
} }
this.$store.dispatch( this.$store.dispatch(
"settings/toggleDevice", 'settings/toggleDevice',
isMobile ? "mobile" : "desktop" isMobile ? 'mobile' : 'desktop'
); )
} }
}, },
}, },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -1,23 +1,23 @@
import Vue from "vue"; import Vue from 'vue'
import App from "./App"; import App from './App'
import store from "./store"; import store from './store'
import router from "./router"; import router from './router'
import "./plugins"; import './plugins'
/** /**
* @author chuzhixin 1204505056@qq.com 不想保留author可删除 * @author chuzhixin 1204505056@qq.com 不想保留author可删除
* @description 生产环境默认都使用mock如果正式用于生产环境时记得去掉 * @description 生产环境默认都使用mock如果正式用于生产环境时记得去掉
*/ */
if (process.env.NODE_ENV === "production") { if (process.env.NODE_ENV === 'production') {
const { mockXHR } = require("@/utils/static"); const { mockXHR } = require('@/utils/static')
mockXHR(); mockXHR()
} }
Vue.config.productionTip = false; Vue.config.productionTip = false
new Vue({ new Vue({
el: "#vue-admin-beautiful", el: '#vue-admin-beautiful',
router, router,
store, store,
render: (h) => h(App), render: (h) => h(App),
}); })

View File

@ -1,11 +1,11 @@
import "echarts"; import 'echarts'
import "echarts/map/js/china"; import 'echarts/map/js/china'
import "echarts/map/js/world"; import 'echarts/map/js/world'
import "echarts-wordcloud"; import 'echarts-wordcloud'
import VabChart from "vue-echarts"; import VabChart from 'vue-echarts'
import theme from "./vab-echarts-theme.json"; import theme from './vab-echarts-theme.json'
VabChart.registerTheme("vab-echarts-theme", theme); VabChart.registerTheme('vab-echarts-theme', theme)
export default VabChart; export default VabChart

View File

@ -1,9 +1,9 @@
import Vue from "vue"; import Vue from 'vue'
import ElementUI from "element-ui"; import ElementUI from 'element-ui'
import "element-ui/lib/theme-chalk/display.css"; import 'element-ui/lib/theme-chalk/display.css'
import "@/styles/element-variables.scss"; import '@/styles/element-variables.scss'
Vue.use(ElementUI, { Vue.use(ElementUI, {
size: "small", size: 'small',
}); })

View File

@ -1,20 +1,20 @@
/* 公共引入,勿随意修改,修改时需经过确认 */ /* 公共引入,勿随意修改,修改时需经过确认 */
import Vue from "vue"; import Vue from 'vue'
import "./element"; import './element'
import "./support"; import './support'
import "@/styles/vab.scss"; import '@/styles/vab.scss'
import "@/remixIcon"; import '@/remixIcon'
import "@/colorfulIcon"; import '@/colorfulIcon'
import "@/config/permission"; import '@/config/permission'
import "@/utils/errorLog"; import '@/utils/errorLog'
import "./vabIcon"; import './vabIcon'
import Vab from "@/utils/vab"; import Vab from '@/utils/vab'
import { VabDrag, VabPermissions, VabQueryForm } from "@/layouts/components"; import { VabDrag, VabPermissions, VabQueryForm } from '@/layouts/components'
import VabCount from "zx-count"; import VabCount from 'zx-count'
Vue.use(Vab); Vue.use(Vab)
Vue.use(VabPermissions); Vue.use(VabPermissions)
Vue.use(VabDrag); Vue.use(VabDrag)
Vue.use(VabQueryForm); Vue.use(VabQueryForm)
Vue.use(VabCount); Vue.use(VabCount)

View File

@ -1,21 +1,21 @@
import { MessageBox } from "element-ui"; import { MessageBox } from 'element-ui'
import { donation } from "@/config/settings"; import { donation } from '@/config/settings'
import { dependencies, repository } from "../../package.json"; import { dependencies, repository } from '../../package.json'
if (!!window.ActiveXObject || "ActiveXObject" in window) { if (!!window.ActiveXObject || 'ActiveXObject' in window) {
MessageBox({ MessageBox({
title: "温馨提示", title: '温馨提示',
message: message:
'自2015年3月起微软已宣布弃用IE且不再对IE提供任何更新维护请<a target="_blank" style="color:blue" href="https://www.microsoft.com/zh-cn/edge/">点击此处</a>访问微软官网更新浏览器,如果您使用的是双核浏览器,请您切换浏览器内核为极速模式', '自2015年3月起微软已宣布弃用IE且不再对IE提供任何更新维护请<a target="_blank" style="color:blue" href="https://www.microsoft.com/zh-cn/edge/">点击此处</a>访问微软官网更新浏览器,如果您使用的是双核浏览器,请您切换浏览器内核为极速模式',
type: "warning", type: 'warning',
showClose: false, showClose: false,
showConfirmButton: false, showConfirmButton: false,
closeOnClickModal: false, closeOnClickModal: false,
closeOnPressEscape: false, closeOnPressEscape: false,
closeOnHashChange: false, closeOnHashChange: false,
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
}); })
} }
if (!dependencies["zx-icon"] || !dependencies["zx-layouts"]) { if (!dependencies['zx-icon'] || !dependencies['zx-layouts']) {
document.body.innerHTML = ""; document.body.innerHTML = ''
} }

View File

@ -1,3 +1,3 @@
import VabComparison from "zx-comparison"; import VabComparison from 'zx-comparison'
export default VabComparison; export default VabComparison

View File

@ -1,4 +1,4 @@
import Vue from "vue"; import Vue from 'vue'
import VabIcon from "zx-icon"; import VabIcon from 'zx-icon'
Vue.component("VabIcon", VabIcon); Vue.component('VabIcon', VabIcon)

View File

@ -1,3 +1,3 @@
import VabMagnifier from "zx-magnifie"; import VabMagnifier from 'zx-magnifie'
export default VabMagnifier; export default VabMagnifier

View File

@ -1,5 +1,5 @@
import ZxMarkdownEditor from "zx-markdown-editor"; import ZxMarkdownEditor from 'zx-markdown-editor'
import "zx-markdown-editor/dist/zx-markdown-editor.css"; import 'zx-markdown-editor/dist/zx-markdown-editor.css'
const VabMarkdownEditor = ZxMarkdownEditor; const VabMarkdownEditor = ZxMarkdownEditor
export default VabMarkdownEditor; export default VabMarkdownEditor

View File

@ -1,7 +1,7 @@
import { Custom, Flv, Hls, Mp4 } from "zx-player"; import { Custom, Flv, Hls, Mp4 } from 'zx-player'
const VabPlayerMp4 = Mp4; const VabPlayerMp4 = Mp4
const VabPlayerHls = Hls; const VabPlayerHls = Hls
const VabPlayerFlv = Flv; const VabPlayerFlv = Flv
const VabPlayerCustom = Custom; const VabPlayerCustom = Custom
export { VabPlayerMp4, VabPlayerHls, VabPlayerFlv, VabPlayerCustom }; export { VabPlayerMp4, VabPlayerHls, VabPlayerFlv, VabPlayerCustom }

View File

@ -1,4 +1,4 @@
import "zx-quill/dist/zx-quill.css"; import 'zx-quill/dist/zx-quill.css'
import VabQuill from "zx-quill"; import VabQuill from 'zx-quill'
export default VabQuill; export default VabQuill

View File

@ -1,4 +1,4 @@
import VabVerify from "zx-verify"; import VabVerify from 'zx-verify'
import "zx-verify/dist/zx-verify.css"; import 'zx-verify/dist/zx-verify.css'
export default VabVerify; export default VabVerify

View File

@ -1,8 +1,8 @@
import Vue from "vue"; import Vue from 'vue'
import { RemixIcon } from "@/layouts/components"; import { RemixIcon } from '@/layouts/components'
Vue.component("VabRemixIcon", RemixIcon); Vue.component('VabRemixIcon', RemixIcon)
const req = require.context("./svg", false, /\.svg$/), const req = require.context('./svg', false, /\.svg$/),
requireAll = (requireContext) => { requireAll = (requireContext) => {
/*let a = requireContext.keys().map(requireContext); /*let a = requireContext.keys().map(requireContext);
let arr = []; let arr = [];
@ -12,6 +12,6 @@ const req = require.context("./svg", false, /\.svg$/),
arr.push(icon); arr.push(icon);
} }
console.log(JSON.stringify(arr));*/ console.log(JSON.stringify(arr));*/
return requireContext.keys().map(requireContext); return requireContext.keys().map(requireContext)
}; }
requireAll(req); requireAll(req)

View File

@ -3,51 +3,51 @@
* @description router全局配置如有必要可分文件抽离其中asyncRoutes只有在intelligence模式下才会用到vip文档中已提供路由的基础图标与小清新图标的配置方案请仔细阅读 * @description router全局配置如有必要可分文件抽离其中asyncRoutes只有在intelligence模式下才会用到vip文档中已提供路由的基础图标与小清新图标的配置方案请仔细阅读
*/ */
import Vue from "vue"; import Vue from 'vue'
import VueRouter from "vue-router"; import VueRouter from 'vue-router'
import Layout from "@/layouts"; import Layout from '@/layouts'
import EmptyLayout from "@/layouts/EmptyLayout"; import EmptyLayout from '@/layouts/EmptyLayout'
import { publicPath, routerMode } from "@/config/settings"; import { publicPath, routerMode } from '@/config/settings'
Vue.use(VueRouter); Vue.use(VueRouter)
export const constantRoutes = [ export const constantRoutes = [
{ {
path: "/login", path: '/login',
component: () => import("@/views/login/index"), component: () => import('@/views/login/index'),
hidden: true, hidden: true,
}, },
{ {
path: "/register", path: '/register',
component: () => import("@/views/register/index"), component: () => import('@/views/register/index'),
hidden: true, hidden: true,
}, },
{ {
path: "/401", path: '/401',
name: "401", name: '401',
component: () => import("@/views/401"), component: () => import('@/views/401'),
hidden: true, hidden: true,
}, },
{ {
path: "/404", path: '/404',
name: "404", name: '404',
component: () => import("@/views/404"), component: () => import('@/views/404'),
hidden: true, hidden: true,
}, },
]; ]
export const asyncRoutes = [ export const asyncRoutes = [
{ {
path: "/", path: '/',
component: Layout, component: Layout,
redirect: "index", redirect: 'index',
children: [ children: [
{ {
path: "index", path: 'index',
name: "Index", name: 'Index',
component: () => import("@/views/index/index"), component: () => import('@/views/index/index'),
meta: { meta: {
title: "首页", title: '首页',
icon: "home", icon: 'home',
affix: true, affix: true,
}, },
}, },
@ -72,322 +72,322 @@ export const asyncRoutes = [
}, */ }, */
{ {
path: "/vab", path: '/vab',
component: Layout, component: Layout,
redirect: "noRedirect", redirect: 'noRedirect',
name: "Vab", name: 'Vab',
alwaysShow: true, alwaysShow: true,
meta: { title: "组件", icon: "box-open" }, meta: { title: '组件', icon: 'box-open' },
children: [ children: [
{ {
path: "permissions", path: 'permissions',
name: "Permission", name: 'Permission',
component: () => import("@/views/vab/permissions/index"), component: () => import('@/views/vab/permissions/index'),
meta: { meta: {
title: "角色权限", title: '角色权限',
permissions: ["admin", "editor"], permissions: ['admin', 'editor'],
}, },
}, },
{ {
path: "icon", path: 'icon',
component: EmptyLayout, component: EmptyLayout,
redirect: "noRedirect", redirect: 'noRedirect',
name: "Icon", name: 'Icon',
meta: { meta: {
title: "图标", title: '图标',
permissions: ["admin"], permissions: ['admin'],
}, },
children: [ children: [
{ {
path: "awesomeIcon", path: 'awesomeIcon',
name: "AwesomeIcon", name: 'AwesomeIcon',
component: () => import("@/views/vab/icon/index"), component: () => import('@/views/vab/icon/index'),
meta: { title: "常规图标" }, meta: { title: '常规图标' },
}, },
{ {
path: "remixIcon", path: 'remixIcon',
name: "RemixIcon", name: 'RemixIcon',
component: () => import("@/views/vab/icon/remixIcon"), component: () => import('@/views/vab/icon/remixIcon'),
meta: { title: "小清新图标" }, meta: { title: '小清新图标' },
}, },
{ {
path: "colorfulIcon", path: 'colorfulIcon',
name: "ColorfulIcon", name: 'ColorfulIcon',
component: () => import("@/views/vab/icon/colorfulIcon"), component: () => import('@/views/vab/icon/colorfulIcon'),
meta: { title: "多彩图标" }, meta: { title: '多彩图标' },
}, },
], ],
}, },
{ {
path: "table", path: 'table',
component: () => import("@/views/vab/table/index"), component: () => import('@/views/vab/table/index'),
name: "Table", name: 'Table',
meta: { meta: {
title: "表格", title: '表格',
permissions: ["admin"], permissions: ['admin'],
}, },
}, },
{ {
path: "map", path: 'map',
component: () => import("@/views/vab/map/index"), component: () => import('@/views/vab/map/index'),
name: "Map", name: 'Map',
meta: { meta: {
title: "地图", title: '地图',
permissions: ["admin"], permissions: ['admin'],
}, },
}, },
{ {
path: "webSocket", path: 'webSocket',
name: "WebSocket", name: 'WebSocket',
component: () => import("@/views/vab/webSocket/index"), component: () => import('@/views/vab/webSocket/index'),
meta: { title: "webSocket", permissions: ["admin"] }, meta: { title: 'webSocket', permissions: ['admin'] },
}, },
{ {
path: "form", path: 'form',
name: "Form", name: 'Form',
component: () => import("@/views/vab/form/index"), component: () => import('@/views/vab/form/index'),
meta: { title: "表单", permissions: ["admin"] }, meta: { title: '表单', permissions: ['admin'] },
}, },
{ {
path: "element", path: 'element',
name: "Element", name: 'Element',
component: () => import("@/views/vab/element/index"), component: () => import('@/views/vab/element/index'),
meta: { title: "常用组件", permissions: ["admin"] }, meta: { title: '常用组件', permissions: ['admin'] },
}, },
{ {
path: "tree", path: 'tree',
name: "Tree", name: 'Tree',
component: () => import("@/views/vab/tree/index"), component: () => import('@/views/vab/tree/index'),
meta: { title: "树", permissions: ["admin"] }, meta: { title: '树', permissions: ['admin'] },
}, },
{ {
path: "card", path: 'card',
name: "Card", name: 'Card',
component: () => import("@/views/vab/card/index"), component: () => import('@/views/vab/card/index'),
meta: { title: "卡片", permissions: ["admin"] }, meta: { title: '卡片', permissions: ['admin'] },
}, },
{ {
path: "verify", path: 'verify',
name: "Verify", name: 'Verify',
component: () => import("@/views/vab/verify/index"), component: () => import('@/views/vab/verify/index'),
meta: { title: "验证码", permissions: ["admin"] }, meta: { title: '验证码', permissions: ['admin'] },
}, },
{ {
path: "menu1", path: 'menu1',
component: () => import("@/views/vab/nested/menu1/index"), component: () => import('@/views/vab/nested/menu1/index'),
name: "Menu1", name: 'Menu1',
alwaysShow: true, alwaysShow: true,
meta: { meta: {
title: "嵌套路由 1", title: '嵌套路由 1',
permissions: ["admin"], permissions: ['admin'],
}, },
children: [ children: [
{ {
path: "menu1-1", path: 'menu1-1',
name: "Menu1-1", name: 'Menu1-1',
alwaysShow: true, alwaysShow: true,
meta: { title: "嵌套路由 1-1" }, meta: { title: '嵌套路由 1-1' },
component: () => import("@/views/vab/nested/menu1/menu1-1/index"), component: () => import('@/views/vab/nested/menu1/menu1-1/index'),
children: [ children: [
{ {
path: "menu1-1-1", path: 'menu1-1-1',
name: "Menu1-1-1", name: 'Menu1-1-1',
meta: { title: "嵌套路由 1-1-1" }, meta: { title: '嵌套路由 1-1-1' },
component: () => component: () =>
import("@/views/vab/nested/menu1/menu1-1/menu1-1-1/index"), import('@/views/vab/nested/menu1/menu1-1/menu1-1-1/index'),
}, },
], ],
}, },
], ],
}, },
{ {
path: "magnifier", path: 'magnifier',
name: "Magnifier", name: 'Magnifier',
component: () => import("@/views/vab/magnifier/index"), component: () => import('@/views/vab/magnifier/index'),
meta: { title: "放大镜", permissions: ["admin"] }, meta: { title: '放大镜', permissions: ['admin'] },
}, },
{ {
path: "echarts", path: 'echarts',
name: "Echarts", name: 'Echarts',
component: () => import("@/views/vab/echarts/index"), component: () => import('@/views/vab/echarts/index'),
meta: { title: "图表", permissions: ["admin"] }, meta: { title: '图表', permissions: ['admin'] },
}, },
{ {
path: "loading", path: 'loading',
name: "Loading", name: 'Loading',
component: () => import("@/views/vab/loading/index"), component: () => import('@/views/vab/loading/index'),
meta: { title: "loading", permissions: ["admin"] }, meta: { title: 'loading', permissions: ['admin'] },
}, },
{ {
path: "player", path: 'player',
name: "Player", name: 'Player',
component: () => import("@/views/vab/player/index"), component: () => import('@/views/vab/player/index'),
meta: { title: "视频播放器", permissions: ["admin"] }, meta: { title: '视频播放器', permissions: ['admin'] },
}, },
{ {
path: "markdownEditor", path: 'markdownEditor',
name: "MarkdownEditor", name: 'MarkdownEditor',
component: () => import("@/views/vab/markdownEditor/index"), component: () => import('@/views/vab/markdownEditor/index'),
meta: { title: "markdown编辑器", permissions: ["admin"] }, meta: { title: 'markdown编辑器', permissions: ['admin'] },
}, },
{ {
path: "editor", path: 'editor',
name: "Editor", name: 'Editor',
component: () => import("@/views/vab/editor/index"), component: () => import('@/views/vab/editor/index'),
meta: { meta: {
title: "富文本编辑器", title: '富文本编辑器',
permissions: ["admin"], permissions: ['admin'],
badge: "New", badge: 'New',
}, },
}, },
{ {
path: "backToTop", path: 'backToTop',
name: "BackToTop", name: 'BackToTop',
component: () => import("@/views/vab/backToTop/index"), component: () => import('@/views/vab/backToTop/index'),
meta: { title: "返回顶部", permissions: ["admin"] }, meta: { title: '返回顶部', permissions: ['admin'] },
}, },
{ {
path: "lodash", path: 'lodash',
name: "Lodash", name: 'Lodash',
component: () => import("@/views/vab/lodash/index"), component: () => import('@/views/vab/lodash/index'),
meta: { title: "lodash", permissions: ["admin"] }, meta: { title: 'lodash', permissions: ['admin'] },
}, },
{ {
path: "imgComparison", path: 'imgComparison',
name: "ImgComparison", name: 'ImgComparison',
component: () => import("@/views/vab/imgComparison/index"), component: () => import('@/views/vab/imgComparison/index'),
meta: { title: "图像拖拽比对", permissions: ["admin"] }, meta: { title: '图像拖拽比对', permissions: ['admin'] },
}, },
{ {
path: "smallComponents", path: 'smallComponents',
name: "SmallComponents", name: 'SmallComponents',
component: () => import("@/views/vab/smallComponents/index"), component: () => import('@/views/vab/smallComponents/index'),
meta: { title: "小组件", permissions: ["admin"] }, meta: { title: '小组件', permissions: ['admin'] },
}, },
{ {
path: "upload", path: 'upload',
name: "Upload", name: 'Upload',
component: () => import("@/views/vab/upload/index"), component: () => import('@/views/vab/upload/index'),
meta: { title: "上传", permissions: ["admin"] }, meta: { title: '上传', permissions: ['admin'] },
}, },
{ {
path: "log", path: 'log',
name: "Log", name: 'Log',
component: () => import("@/views/vab/errorLog/index"), component: () => import('@/views/vab/errorLog/index'),
meta: { title: "错误日志模拟", permissions: ["admin"] }, meta: { title: '错误日志模拟', permissions: ['admin'] },
}, },
{ {
path: path:
"https://github.com/chuzhixin/vue-admin-beautiful?utm_source=gold_browser_extension", 'https://github.com/chuzhixin/vue-admin-beautiful?utm_source=gold_browser_extension',
name: "ExternalLink", name: 'ExternalLink',
meta: { meta: {
title: "外链", title: '外链',
target: "_blank", target: '_blank',
permissions: ["admin", "editor"], permissions: ['admin', 'editor'],
badge: "New", badge: 'New',
}, },
}, },
{ {
path: "more", path: 'more',
name: "More", name: 'More',
component: () => import("@/views/vab/more/index"), component: () => import('@/views/vab/more/index'),
meta: { title: "关于", permissions: ["admin"] }, meta: { title: '关于', permissions: ['admin'] },
}, },
], ],
}, },
{ {
path: "/personnelManagement", path: '/personnelManagement',
component: Layout, component: Layout,
redirect: "noRedirect", redirect: 'noRedirect',
name: "PersonnelManagement", name: 'PersonnelManagement',
meta: { title: "配置", icon: "users-cog", permissions: ["admin"] }, meta: { title: '配置', icon: 'users-cog', permissions: ['admin'] },
children: [ children: [
{ {
path: "userManagement", path: 'userManagement',
name: "UserManagement", name: 'UserManagement',
component: () => component: () =>
import("@/views/personnelManagement/userManagement/index"), import('@/views/personnelManagement/userManagement/index'),
meta: { title: "用户管理" }, meta: { title: '用户管理' },
}, },
{ {
path: "roleManagement", path: 'roleManagement',
name: "RoleManagement", name: 'RoleManagement',
component: () => component: () =>
import("@/views/personnelManagement/roleManagement/index"), import('@/views/personnelManagement/roleManagement/index'),
meta: { title: "角色管理" }, meta: { title: '角色管理' },
}, },
{ {
path: "menuManagement", path: 'menuManagement',
name: "MenuManagement", name: 'MenuManagement',
component: () => component: () =>
import("@/views/personnelManagement/menuManagement/index"), import('@/views/personnelManagement/menuManagement/index'),
meta: { title: "菜单管理", badge: "New" }, meta: { title: '菜单管理', badge: 'New' },
}, },
], ],
}, },
{ {
path: "/mall", path: '/mall',
component: Layout, component: Layout,
redirect: "noRedirect", redirect: 'noRedirect',
name: "Mall", name: 'Mall',
meta: { meta: {
title: "商城", title: '商城',
icon: "shopping-cart", icon: 'shopping-cart',
permissions: ["admin"], permissions: ['admin'],
}, },
children: [ children: [
{ {
path: "pay", path: 'pay',
name: "Pay", name: 'Pay',
component: () => import("@/views/mall/pay/index"), component: () => import('@/views/mall/pay/index'),
meta: { meta: {
title: "支付", title: '支付',
noKeepAlive: true, noKeepAlive: true,
}, },
children: null, children: null,
}, },
{ {
path: "goodsList", path: 'goodsList',
name: "GoodsList", name: 'GoodsList',
component: () => import("@/views/mall/goodsList/index"), component: () => import('@/views/mall/goodsList/index'),
meta: { meta: {
title: "商品列表", title: '商品列表',
}, },
}, },
], ],
}, },
{ {
path: "/error", path: '/error',
component: EmptyLayout, component: EmptyLayout,
redirect: "noRedirect", redirect: 'noRedirect',
name: "Error", name: 'Error',
meta: { title: "错误页", icon: "bug" }, meta: { title: '错误页', icon: 'bug' },
children: [ children: [
{ {
path: "401", path: '401',
name: "Error401", name: 'Error401',
component: () => import("@/views/401"), component: () => import('@/views/401'),
meta: { title: "401" }, meta: { title: '401' },
}, },
{ {
path: "404", path: '404',
name: "Error404", name: 'Error404',
component: () => import("@/views/404"), component: () => import('@/views/404'),
meta: { title: "404" }, meta: { title: '404' },
}, },
], ],
}, },
{ {
path: "*", path: '*',
redirect: "/404", redirect: '/404',
hidden: true, hidden: true,
}, },
]; ]
const router = new VueRouter({ const router = new VueRouter({
base: publicPath, base: publicPath,
@ -396,14 +396,14 @@ const router = new VueRouter({
y: 0, y: 0,
}), }),
routes: constantRoutes, routes: constantRoutes,
}); })
//注释的地方是允许路由重复点击,如果你觉得框架路由跳转规范太过严格可选择放开 //注释的地方是允许路由重复点击,如果你觉得框架路由跳转规范太过严格可选择放开
const originalPush = VueRouter.prototype.push; const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) { VueRouter.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) if (onResolve || onReject)
return originalPush.call(this, location, onResolve, onReject); return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch((err) => err); return originalPush.call(this, location).catch((err) => err)
}; }
export function resetRouter() { export function resetRouter() {
router.matcher = new VueRouter({ router.matcher = new VueRouter({
@ -413,7 +413,7 @@ export function resetRouter() {
y: 0, y: 0,
}), }),
routes: constantRoutes, routes: constantRoutes,
}).matcher; }).matcher
} }
export default router; export default router

View File

@ -3,20 +3,20 @@
* @description 导入所有 vuex 模块自动加入namespaced:true用于解决vuex命名冲突请勿修改 * @description 导入所有 vuex 模块自动加入namespaced:true用于解决vuex命名冲突请勿修改
*/ */
import Vue from "vue"; import Vue from 'vue'
import Vuex from "vuex"; import Vuex from 'vuex'
Vue.use(Vuex); Vue.use(Vuex)
const files = require.context("./modules", false, /\.js$/); const files = require.context('./modules', false, /\.js$/)
const modules = {}; const modules = {}
files.keys().forEach((key) => { files.keys().forEach((key) => {
modules[key.replace(/(\.\/|\.js)/g, "")] = files(key).default; modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default
}); })
Object.keys(modules).forEach((key) => { Object.keys(modules).forEach((key) => {
modules[key]["namespaced"] = true; modules[key]['namespaced'] = true
}); })
const store = new Vuex.Store({ const store = new Vuex.Store({
modules, modules,
}); })
export default store; export default store

View File

@ -3,24 +3,24 @@
* @description 异常捕获的状态拦截请勿修改 * @description 异常捕获的状态拦截请勿修改
*/ */
const state = { errorLogs: [] }; const state = { errorLogs: [] }
const getters = { const getters = {
errorLogs: (state) => state.errorLogs, errorLogs: (state) => state.errorLogs,
}; }
const mutations = { const mutations = {
addErrorLog(state, errorLog) { addErrorLog(state, errorLog) {
state.errorLogs.push(errorLog); state.errorLogs.push(errorLog)
}, },
clearErrorLog: (state) => { clearErrorLog: (state) => {
state.errorLogs.splice(0); state.errorLogs.splice(0)
}, },
}; }
const actions = { const actions = {
addErrorLog({ commit }, errorLog) { addErrorLog({ commit }, errorLog) {
commit("addErrorLog", errorLog); commit('addErrorLog', errorLog)
}, },
clearErrorLog({ commit }) { clearErrorLog({ commit }) {
commit("clearErrorLog"); commit('clearErrorLog')
}, },
}; }
export default { state, getters, mutations, actions }; export default { state, getters, mutations, actions }

View File

@ -2,46 +2,46 @@
* @author chuzhixin 1204505056@qq.com 不想保留author可删除 * @author chuzhixin 1204505056@qq.com 不想保留author可删除
* @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, filterAsyncRoutes } from "@/utils/handleRoutes"; import { convertRouter, filterAsyncRoutes } from '@/utils/handleRoutes'
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 = constantRoutes.concat(routes); state.routes = constantRoutes.concat(routes)
}, },
setAllRoutes(state, routes) { setAllRoutes(state, routes) {
state.routes = constantRoutes.concat(routes); state.routes = constantRoutes.concat(routes)
}, },
setPartialRoutes(state, routes) { setPartialRoutes(state, routes) {
state.partialRoutes = constantRoutes.concat(routes); state.partialRoutes = constantRoutes.concat(routes)
}, },
}; }
const actions = { const actions = {
async setRoutes({ commit }, permissions) { async setRoutes({ commit }, permissions) {
//开源版只过滤动态路由permissionsadmin不再默认拥有全部权限 //开源版只过滤动态路由permissionsadmin不再默认拥有全部权限
const finallyAsyncRoutes = await filterAsyncRoutes( const finallyAsyncRoutes = await filterAsyncRoutes(
[...asyncRoutes], [...asyncRoutes],
permissions permissions
); )
commit("setRoutes", finallyAsyncRoutes); commit('setRoutes', finallyAsyncRoutes)
return finallyAsyncRoutes; return finallyAsyncRoutes
}, },
async setAllRoutes({ commit }) { async setAllRoutes({ commit }) {
let { data } = await getRouterList(); let { data } = await getRouterList()
data.push({ path: "*", redirect: "/404", hidden: true }); data.push({ path: '*', redirect: '/404', hidden: true })
let accessRoutes = convertRouter(data); let accessRoutes = convertRouter(data)
commit("setAllRoutes", accessRoutes); commit('setAllRoutes', accessRoutes)
return accessRoutes; return accessRoutes
}, },
setPartialRoutes({ commit }, accessRoutes) { setPartialRoutes({ commit }, accessRoutes) {
commit("setPartialRoutes", accessRoutes); commit('setPartialRoutes', accessRoutes)
return accessRoutes; return accessRoutes
}, },
}; }
export default { state, getters, mutations, actions }; export default { state, getters, mutations, actions }

View File

@ -3,20 +3,20 @@
* @description 所有全局配置的状态管理如无必要请勿修改 * @description 所有全局配置的状态管理如无必要请勿修改
*/ */
import defaultSettings from "@/config/settings"; import defaultSettings from '@/config/settings'
const { tabsBar, logo, layout, header, themeBar } = defaultSettings; const { tabsBar, logo, layout, header, themeBar } = defaultSettings
const theme = const theme =
JSON.parse(localStorage.getItem("vue-admin-beautiful-theme")) || ""; JSON.parse(localStorage.getItem('vue-admin-beautiful-theme')) || ''
const state = { const state = {
tabsBar: theme.tabsBar || tabsBar, tabsBar: theme.tabsBar || tabsBar,
logo, logo,
collapse: false, collapse: false,
layout: theme.layout || layout, layout: theme.layout || layout,
header: theme.header || header, header: theme.header || header,
device: "desktop", device: 'desktop',
themeBar, themeBar,
}; }
const getters = { const getters = {
collapse: (state) => state.collapse, collapse: (state) => state.collapse,
device: (state) => state.device, device: (state) => state.device,
@ -25,51 +25,51 @@ const getters = {
logo: (state) => state.logo, logo: (state) => state.logo,
tabsBar: (state) => state.tabsBar, tabsBar: (state) => state.tabsBar,
themeBar: (state) => state.themeBar, themeBar: (state) => state.themeBar,
}; }
const mutations = { const mutations = {
changeLayout: (state, layout) => { changeLayout: (state, layout) => {
if (layout) state.layout = layout; if (layout) state.layout = layout
}, },
changeHeader: (state, header) => { changeHeader: (state, header) => {
if (header) state.header = header; if (header) state.header = header
}, },
changeTabsBar: (state, tabsBar) => { changeTabsBar: (state, tabsBar) => {
if (tabsBar) state.tabsBar = tabsBar; if (tabsBar) state.tabsBar = tabsBar
}, },
changeCollapse: (state) => { changeCollapse: (state) => {
state.collapse = !state.collapse; state.collapse = !state.collapse
}, },
foldSideBar: (state) => { foldSideBar: (state) => {
state.collapse = true; state.collapse = true
}, },
openSideBar: (state) => { openSideBar: (state) => {
state.collapse = false; state.collapse = false
}, },
toggleDevice: (state, device) => { toggleDevice: (state, device) => {
state.device = device; state.device = device
}, },
}; }
const actions = { const actions = {
changeLayout({ commit }, layout) { changeLayout({ commit }, layout) {
commit("changeLayout", layout); commit('changeLayout', layout)
}, },
changeHeader({ commit }, header) { changeHeader({ commit }, header) {
commit("changeHeader", header); commit('changeHeader', header)
}, },
changeTabsBar({ commit }, tabsBar) { changeTabsBar({ commit }, tabsBar) {
commit("changeTabsBar", tabsBar); commit('changeTabsBar', tabsBar)
}, },
changeCollapse({ commit }) { changeCollapse({ commit }) {
commit("changeCollapse"); commit('changeCollapse')
}, },
foldSideBar({ commit }) { foldSideBar({ commit }) {
commit("foldSideBar"); commit('foldSideBar')
}, },
openSideBar({ commit }) { openSideBar({ commit }) {
commit("openSideBar"); commit('openSideBar')
}, },
toggleDevice({ commit }, device) { toggleDevice({ commit }, device) {
commit("toggleDevice", device); commit('toggleDevice', device)
}, },
}; }
export default { state, getters, mutations, actions }; export default { state, getters, mutations, actions }

View File

@ -3,19 +3,19 @@
* @description 代码生成机状态管理 * @description 代码生成机状态管理
*/ */
const state = { srcCode: "" }; const state = { srcCode: '' }
const getters = { const getters = {
srcTableCode: (state) => state.srcCode, srcTableCode: (state) => state.srcCode,
}; }
const mutations = { const mutations = {
setTableCode(state, srcCode) { setTableCode(state, srcCode) {
state.srcCode = srcCode; state.srcCode = srcCode
}, },
}; }
const actions = { const actions = {
setTableCode({ commit }, srcCode) { setTableCode({ commit }, srcCode) {
commit("setTableCode", srcCode); commit('setTableCode', srcCode)
}, },
}; }
export default { state, getters, mutations, actions }; export default { state, getters, mutations, actions }

View File

@ -5,108 +5,108 @@
const state = { const state = {
visitedRoutes: [], visitedRoutes: [],
}; }
const getters = { const getters = {
visitedRoutes: (state) => state.visitedRoutes, visitedRoutes: (state) => state.visitedRoutes,
}; }
const mutations = { const mutations = {
addVisitedRoute(state, route) { addVisitedRoute(state, route) {
let target = state.visitedRoutes.find((item) => item.path === route.path); let target = state.visitedRoutes.find((item) => item.path === route.path)
if (target) { if (target) {
if (route.fullPath !== target.fullPath) Object.assign(target, route); if (route.fullPath !== target.fullPath) Object.assign(target, route)
return; return
} }
state.visitedRoutes.push(Object.assign({}, route)); state.visitedRoutes.push(Object.assign({}, route))
}, },
delVisitedRoute(state, route) { delVisitedRoute(state, route) {
state.visitedRoutes.forEach((item, index) => { state.visitedRoutes.forEach((item, index) => {
if (item.path === route.path) state.visitedRoutes.splice(index, 1); if (item.path === route.path) state.visitedRoutes.splice(index, 1)
}); })
}, },
delOthersVisitedRoute(state, route) { delOthersVisitedRoute(state, route) {
state.visitedRoutes = state.visitedRoutes.filter( state.visitedRoutes = state.visitedRoutes.filter(
(item) => item.meta.affix || item.path === route.path (item) => item.meta.affix || item.path === route.path
); )
}, },
delLeftVisitedRoute(state, route) { delLeftVisitedRoute(state, route) {
let index = state.visitedRoutes.length; let index = state.visitedRoutes.length
state.visitedRoutes = state.visitedRoutes.filter((item) => { state.visitedRoutes = state.visitedRoutes.filter((item) => {
if (item.name === route.name) index = state.visitedRoutes.indexOf(item); if (item.name === route.name) index = state.visitedRoutes.indexOf(item)
return item.meta.affix || index <= state.visitedRoutes.indexOf(item); return item.meta.affix || index <= state.visitedRoutes.indexOf(item)
}); })
}, },
delRightVisitedRoute(state, route) { delRightVisitedRoute(state, route) {
let index = state.visitedRoutes.length; let index = state.visitedRoutes.length
state.visitedRoutes = state.visitedRoutes.filter((item) => { state.visitedRoutes = state.visitedRoutes.filter((item) => {
if (item.name === route.name) index = state.visitedRoutes.indexOf(item); if (item.name === route.name) index = state.visitedRoutes.indexOf(item)
return item.meta.affix || index >= state.visitedRoutes.indexOf(item); return item.meta.affix || index >= state.visitedRoutes.indexOf(item)
}); })
}, },
delAllVisitedRoutes(state) { delAllVisitedRoutes(state) {
state.visitedRoutes = state.visitedRoutes.filter((item) => item.meta.affix); state.visitedRoutes = state.visitedRoutes.filter((item) => item.meta.affix)
}, },
updateVisitedRoute(state, route) { updateVisitedRoute(state, route) {
state.visitedRoutes.forEach((item) => { state.visitedRoutes.forEach((item) => {
if (item.path === route.path) item = Object.assign(item, route); if (item.path === route.path) item = Object.assign(item, route)
}); })
}, },
}; }
const actions = { const actions = {
addVisitedRoute({ commit }, route) { addVisitedRoute({ commit }, route) {
commit("addVisitedRoute", route); commit('addVisitedRoute', route)
}, },
async delRoute({ dispatch, state }, route) { async delRoute({ dispatch, state }, route) {
await dispatch("delVisitedRoute", route); await dispatch('delVisitedRoute', route)
return { return {
visitedRoutes: [...state.visitedRoutes], visitedRoutes: [...state.visitedRoutes],
}; }
}, },
delVisitedRoute({ commit, state }, route) { delVisitedRoute({ commit, state }, route) {
commit("delVisitedRoute", route); commit('delVisitedRoute', route)
return [...state.visitedRoutes]; return [...state.visitedRoutes]
}, },
async delOthersRoutes({ dispatch, state }, route) { async delOthersRoutes({ dispatch, state }, route) {
await dispatch("delOthersVisitedRoute", route); await dispatch('delOthersVisitedRoute', route)
return { return {
visitedRoutes: [...state.visitedRoutes], visitedRoutes: [...state.visitedRoutes],
}; }
}, },
async delLeftRoutes({ dispatch, state }, route) { async delLeftRoutes({ dispatch, state }, route) {
await dispatch("delLeftVisitedRoute", route); await dispatch('delLeftVisitedRoute', route)
return { return {
visitedRoutes: [...state.visitedRoutes], visitedRoutes: [...state.visitedRoutes],
}; }
}, },
async delRightRoutes({ dispatch, state }, route) { async delRightRoutes({ dispatch, state }, route) {
await dispatch("delRightVisitedRoute", route); await dispatch('delRightVisitedRoute', route)
return { return {
visitedRoutes: [...state.visitedRoutes], visitedRoutes: [...state.visitedRoutes],
}; }
}, },
delOthersVisitedRoute({ commit, state }, route) { delOthersVisitedRoute({ commit, state }, route) {
commit("delOthersVisitedRoute", route); commit('delOthersVisitedRoute', route)
return [...state.visitedRoutes]; return [...state.visitedRoutes]
}, },
delLeftVisitedRoute({ commit, state }, route) { delLeftVisitedRoute({ commit, state }, route) {
commit("delLeftVisitedRoute", route); commit('delLeftVisitedRoute', route)
return [...state.visitedRoutes]; return [...state.visitedRoutes]
}, },
delRightVisitedRoute({ commit, state }, route) { delRightVisitedRoute({ commit, state }, route) {
commit("delRightVisitedRoute", route); commit('delRightVisitedRoute', route)
return [...state.visitedRoutes]; return [...state.visitedRoutes]
}, },
async delAllRoutes({ dispatch, state }, route) { async delAllRoutes({ dispatch, state }, route) {
await dispatch("delAllVisitedRoutes", route); await dispatch('delAllVisitedRoutes', route)
return { return {
visitedRoutes: [...state.visitedRoutes], visitedRoutes: [...state.visitedRoutes],
}; }
}, },
delAllVisitedRoutes({ commit, state }) { delAllVisitedRoutes({ commit, state }) {
commit("delAllVisitedRoutes"); commit('delAllVisitedRoutes')
return [...state.visitedRoutes]; return [...state.visitedRoutes]
}, },
updateVisitedRoute({ commit }, route) { updateVisitedRoute({ commit }, route) {
commit("updateVisitedRoute", route); commit('updateVisitedRoute', route)
}, },
}; }
export default { state, getters, mutations, actions }; export default { state, getters, mutations, actions }

View File

@ -3,97 +3,97 @@
* @description 登录获取用户信息退出登录清除accessToken逻辑不建议修改 * @description 登录获取用户信息退出登录清除accessToken逻辑不建议修改
*/ */
import Vue from "vue"; import Vue from 'vue'
import { getUserInfo, login, logout } from "@/api/user"; import { getUserInfo, login, logout } from '@/api/user'
import { import {
getAccessToken, getAccessToken,
removeAccessToken, removeAccessToken,
setAccessToken, setAccessToken,
} from "@/utils/accessToken"; } from '@/utils/accessToken'
import { resetRouter } from "@/router"; import { resetRouter } from '@/router'
import { title, tokenName } from "@/config/settings"; import { title, tokenName } from '@/config/settings'
const state = { const state = {
accessToken: getAccessToken(), accessToken: getAccessToken(),
username: "", username: '',
avatar: "", avatar: '',
permissions: [], permissions: [],
}; }
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,
permissions: (state) => state.permissions, permissions: (state) => state.permissions,
}; }
const mutations = { const mutations = {
setAccessToken(state, accessToken) { setAccessToken(state, accessToken) {
state.accessToken = accessToken; state.accessToken = accessToken
setAccessToken(accessToken); setAccessToken(accessToken)
}, },
setUsername(state, username) { setUsername(state, username) {
state.username = username; state.username = username
}, },
setAvatar(state, avatar) { setAvatar(state, avatar) {
state.avatar = avatar; state.avatar = avatar
}, },
setPermissions(state, permissions) { setPermissions(state, permissions) {
state.permissions = permissions; state.permissions = permissions
}, },
}; }
const actions = { const actions = {
setPermissions({ commit }, permissions) { setPermissions({ commit }, permissions) {
commit("setPermissions", permissions); commit('setPermissions', permissions)
}, },
async login({ commit }, userInfo) { async login({ commit }, userInfo) {
const { data } = await login(userInfo); const { data } = await login(userInfo)
const accessToken = data[tokenName]; const accessToken = data[tokenName]
if (accessToken) { if (accessToken) {
commit("setAccessToken", accessToken); commit('setAccessToken', accessToken)
const hour = new Date().getHours(); const hour = new Date().getHours()
const thisTime = const thisTime =
hour < 8 hour < 8
? "早上好" ? '早上好'
: hour <= 11 : hour <= 11
? "上午好" ? '上午好'
: hour <= 13 : hour <= 13
? "中午好" ? '中午好'
: hour < 18 : hour < 18
? "下午好" ? '下午好'
: "晚上好"; : '晚上好'
Vue.prototype.$baseNotify(`欢迎登录${title}`, `${thisTime}`); Vue.prototype.$baseNotify(`欢迎登录${title}`, `${thisTime}`)
} else { } else {
Vue.prototype.$baseMessage( Vue.prototype.$baseMessage(
`登录接口异常,未正确返回${tokenName}...`, `登录接口异常,未正确返回${tokenName}...`,
"error" 'error'
); )
} }
}, },
async getUserInfo({ commit, state }) { async getUserInfo({ commit, state }) {
const { data } = await getUserInfo(state.accessToken); const { data } = await getUserInfo(state.accessToken)
if (!data) { if (!data) {
Vue.prototype.$baseMessage("验证失败,请重新登录...", "error"); Vue.prototype.$baseMessage('验证失败,请重新登录...', 'error')
return false; return false
} }
let { permissions, username, avatar } = data; let { permissions, username, avatar } = data
if (permissions && username && Array.isArray(permissions)) { if (permissions && username && Array.isArray(permissions)) {
commit("setPermissions", permissions); commit('setPermissions', permissions)
commit("setUsername", username); commit('setUsername', username)
commit("setAvatar", avatar); commit('setAvatar', avatar)
return permissions; return permissions
} else { } else {
Vue.prototype.$baseMessage("用户信息接口异常", "error"); Vue.prototype.$baseMessage('用户信息接口异常', 'error')
return false; return false
} }
}, },
async logout({ dispatch }) { async logout({ dispatch }) {
await logout(state.accessToken); await logout(state.accessToken)
await dispatch("resetAccessToken"); await dispatch('resetAccessToken')
await resetRouter(); await resetRouter()
}, },
resetAccessToken({ commit }) { resetAccessToken({ commit }) {
commit("setPermissions", []); commit('setPermissions', [])
commit("setAccessToken", ""); commit('setAccessToken', '')
removeAccessToken(); removeAccessToken()
}, },
}; }
export default { state, getters, mutations, actions }; export default { state, getters, mutations, actions }

View File

@ -1,4 +1,4 @@
import { storage, tokenTableName } from "@/config/settings"; import { storage, tokenTableName } from '@/config/settings'
/** /**
* @author chuzhixin 1204505056@qq.com 不想保留author可删除 * @author chuzhixin 1204505056@qq.com 不想保留author可删除
@ -7,15 +7,15 @@ import { storage, tokenTableName } from "@/config/settings";
*/ */
export function getAccessToken() { export function getAccessToken() {
if (storage) { if (storage) {
if ("localStorage" === storage) { if ('localStorage' === storage) {
return localStorage.getItem(tokenTableName); return localStorage.getItem(tokenTableName)
} else if ("sessionStorage" === storage) { } else if ('sessionStorage' === storage) {
return sessionStorage.getItem(tokenTableName); return sessionStorage.getItem(tokenTableName)
} else { } else {
return localStorage.getItem(tokenTableName); return localStorage.getItem(tokenTableName)
} }
} else { } else {
return localStorage.getItem(tokenTableName); return localStorage.getItem(tokenTableName)
} }
} }
@ -27,15 +27,15 @@ export function getAccessToken() {
*/ */
export function setAccessToken(accessToken) { export function setAccessToken(accessToken) {
if (storage) { if (storage) {
if ("localStorage" === storage) { if ('localStorage' === storage) {
return localStorage.setItem(tokenTableName, accessToken); return localStorage.setItem(tokenTableName, accessToken)
} else if ("sessionStorage" === storage) { } else if ('sessionStorage' === storage) {
return sessionStorage.setItem(tokenTableName, accessToken); return sessionStorage.setItem(tokenTableName, accessToken)
} else { } else {
return localStorage.setItem(tokenTableName, accessToken); return localStorage.setItem(tokenTableName, accessToken)
} }
} else { } else {
return localStorage.setItem(tokenTableName, accessToken); return localStorage.setItem(tokenTableName, accessToken)
} }
} }
@ -46,14 +46,14 @@ export function setAccessToken(accessToken) {
*/ */
export function removeAccessToken() { export function removeAccessToken() {
if (storage) { if (storage) {
if ("localStorage" === storage) { if ('localStorage' === storage) {
return localStorage.removeItem(tokenTableName); return localStorage.removeItem(tokenTableName)
} else if ("sessionStorage" === storage) { } else if ('sessionStorage' === storage) {
return sessionStorage.clear(); return sessionStorage.clear()
} else { } else {
return localStorage.removeItem(tokenTableName); return localStorage.removeItem(tokenTableName)
} }
} else { } else {
return localStorage.removeItem(tokenTableName); return localStorage.removeItem(tokenTableName)
} }
} }

View File

@ -1,12 +1,12 @@
import Vue from "vue"; import Vue from 'vue'
import Clipboard from "clipboard"; import Clipboard from 'clipboard'
function clipboardSuccess() { function clipboardSuccess() {
Vue.prototype.$baseMessage("复制成功", "success"); Vue.prototype.$baseMessage('复制成功', 'success')
} }
function clipboardError() { function clipboardError() {
Vue.prototype.$baseMessage("复制失败", "error"); Vue.prototype.$baseMessage('复制失败', 'error')
} }
/** /**
@ -18,14 +18,14 @@ function clipboardError() {
export default function handleClipboard(text, event) { export default function handleClipboard(text, event) {
const clipboard = new Clipboard(event.target, { const clipboard = new Clipboard(event.target, {
text: () => text, text: () => text,
}); })
clipboard.on("success", () => { clipboard.on('success', () => {
clipboardSuccess(); clipboardSuccess()
clipboard.destroy(); clipboard.destroy()
}); })
clipboard.on("error", () => { clipboard.on('error', () => {
clipboardError(); clipboardError()
clipboard.destroy(); clipboard.destroy()
}); })
clipboard.onClick(event); clipboard.onClick(event)
} }

View File

@ -1,8 +1,8 @@
import { JSEncrypt } from "jsencrypt"; import { JSEncrypt } from 'jsencrypt'
import { getPublicKey } from "@/api/publicKey"; import { getPublicKey } from '@/api/publicKey'
const privateKey = const privateKey =
"MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMFPa+v52FkSUXvcUnrGI/XzW3EpZRI0s9BCWJ3oNQmEYA5luWW5p8h0uadTIoTyYweFPdH4hveyxlwmS7oefvbIdiP+o+QIYW/R4Wjsb4Yl8MhR4PJqUE3RCy6IT9fM8ckG4kN9ECs6Ja8fQFc6/mSl5dJczzJO3k1rWMBhKJD/AgMBAAECgYEAucMakH9dWeryhrYoRHcXo4giPVJsH9ypVt4KzmOQY/7jV7KFQK3x//27UoHfUCak51sxFw9ek7UmTPM4HjikA9LkYeE7S381b4QRvFuf3L6IbMP3ywJnJ8pPr2l5SqQ00W+oKv+w/VmEsyUHr+k4Z+4ik+FheTkVWp566WbqFsECQQDjYaMcaKw3j2Zecl8T6eUe7fdaRMIzp/gcpPMfT/9rDzIQk+7ORvm1NI9AUmFv/FAlfpuAMrdL2n7p9uznWb7RAkEA2aP934kbXg5bdV0R313MrL+7WTK/qdcYxATUbMsMuWWQBoS5irrt80WCZbG48hpocJavLNjbtrjmUX3CuJBmzwJAOJg8uP10n/+ZQzjEYXh+BszEHDuw+pp8LuT/fnOy5zrJA0dO0RjpXijO3vuiNPVgHXT9z1LQPJkNrb5ACPVVgQJBALPeb4uV0bNrJDUb5RB4ghZnIxv18CcaqNIft7vuGCcFBAIPIRTBprR+RuVq+xHDt3sNXdsvom4h49+Hky1b0ksCQBBwUtVaqH6ztCtwUF1j2c/Zcrt5P/uN7IHAd44K0gIJc1+Csr3qPG+G2yoqRM8KVqLI8Z2ZYn9c+AvEE+L9OQY="; 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMFPa+v52FkSUXvcUnrGI/XzW3EpZRI0s9BCWJ3oNQmEYA5luWW5p8h0uadTIoTyYweFPdH4hveyxlwmS7oefvbIdiP+o+QIYW/R4Wjsb4Yl8MhR4PJqUE3RCy6IT9fM8ckG4kN9ECs6Ja8fQFc6/mSl5dJczzJO3k1rWMBhKJD/AgMBAAECgYEAucMakH9dWeryhrYoRHcXo4giPVJsH9ypVt4KzmOQY/7jV7KFQK3x//27UoHfUCak51sxFw9ek7UmTPM4HjikA9LkYeE7S381b4QRvFuf3L6IbMP3ywJnJ8pPr2l5SqQ00W+oKv+w/VmEsyUHr+k4Z+4ik+FheTkVWp566WbqFsECQQDjYaMcaKw3j2Zecl8T6eUe7fdaRMIzp/gcpPMfT/9rDzIQk+7ORvm1NI9AUmFv/FAlfpuAMrdL2n7p9uznWb7RAkEA2aP934kbXg5bdV0R313MrL+7WTK/qdcYxATUbMsMuWWQBoS5irrt80WCZbG48hpocJavLNjbtrjmUX3CuJBmzwJAOJg8uP10n/+ZQzjEYXh+BszEHDuw+pp8LuT/fnOy5zrJA0dO0RjpXijO3vuiNPVgHXT9z1LQPJkNrb5ACPVVgQJBALPeb4uV0bNrJDUb5RB4ghZnIxv18CcaqNIft7vuGCcFBAIPIRTBprR+RuVq+xHDt3sNXdsvom4h49+Hky1b0ksCQBBwUtVaqH6ztCtwUF1j2c/Zcrt5P/uN7IHAd44K0gIJc1+Csr3qPG+G2yoqRM8KVqLI8Z2ZYn9c+AvEE+L9OQY='
/** /**
* @author chuzhixin 1204505056@qq.com 不想保留author可删除 * @author chuzhixin 1204505056@qq.com 不想保留author可删除
@ -11,23 +11,23 @@ const privateKey =
* @returns {Promise<{param: PromiseLike<ArrayBuffer>}|*>} * @returns {Promise<{param: PromiseLike<ArrayBuffer>}|*>}
*/ */
export async function encryptedData(data) { export async function encryptedData(data) {
let publicKey = ""; let publicKey = ''
const res = await getPublicKey(); const res = await getPublicKey()
publicKey = res.data.publicKey; publicKey = res.data.publicKey
if (res.data.mockServer) { if (res.data.mockServer) {
publicKey = ""; publicKey = ''
} }
if (publicKey == "") { if (publicKey == '') {
return data; return data
} }
const encrypt = new JSEncrypt(); const encrypt = new JSEncrypt()
encrypt.setPublicKey( encrypt.setPublicKey(
`-----BEGIN PUBLIC KEY-----${publicKey}-----END PUBLIC KEY-----` `-----BEGIN PUBLIC KEY-----${publicKey}-----END PUBLIC KEY-----`
); )
data = encrypt.encrypt(JSON.stringify(data)); data = encrypt.encrypt(JSON.stringify(data))
return { return {
param: data, param: data,
}; }
} }
/** /**
@ -37,10 +37,10 @@ export async function encryptedData(data) {
* @returns {PromiseLike<ArrayBuffer>} * @returns {PromiseLike<ArrayBuffer>}
*/ */
export function decryptedData(data) { export function decryptedData(data) {
const decrypt = new JSEncrypt(); const decrypt = new JSEncrypt()
decrypt.setPrivateKey( decrypt.setPrivateKey(
`-----BEGIN RSA PRIVATE KEY-----${privateKey}-----END RSA PRIVATE KEY-----` `-----BEGIN RSA PRIVATE KEY-----${privateKey}-----END RSA PRIVATE KEY-----`
); )
data = decrypt.decrypt(JSON.stringify(data)); data = decrypt.decrypt(JSON.stringify(data))
return data; return data
} }

View File

@ -1,25 +1,25 @@
import Vue from "vue"; import Vue from 'vue'
import store from "@/store"; import store from '@/store'
import { isArray, isString } from "@/utils/validate"; import { isArray, isString } from '@/utils/validate'
import { errorLog } from "@/config/settings"; import { errorLog } from '@/config/settings'
const needErrorLog = errorLog; const needErrorLog = errorLog
const checkNeed = () => { const checkNeed = () => {
const env = process.env.NODE_ENV; const env = process.env.NODE_ENV
if (isString(needErrorLog)) { if (isString(needErrorLog)) {
return env === needErrorLog; return env === needErrorLog
} }
if (isArray(needErrorLog)) { if (isArray(needErrorLog)) {
return needErrorLog.includes(env); return needErrorLog.includes(env)
} }
return false; return false
}; }
if (checkNeed()) { if (checkNeed()) {
Vue.config.errorHandler = (err, vm, info) => { Vue.config.errorHandler = (err, vm, info) => {
console.error("vue-admin-beautiful错误拦截:", err, vm, info); console.error('vue-admin-beautiful错误拦截:', err, vm, info)
const url = window.location.href; const url = window.location.href
Vue.nextTick(() => { Vue.nextTick(() => {
store.dispatch("errorLog/addErrorLog", { err, vm, info, url }); store.dispatch('errorLog/addErrorLog', { err, vm, info, url })
}); })
}; }
} }

View File

@ -7,23 +7,23 @@
export function convertRouter(asyncRoutes) { export function convertRouter(asyncRoutes) {
return asyncRoutes.map((route) => { return asyncRoutes.map((route) => {
if (route.component) { if (route.component) {
if (route.component === "Layout") { if (route.component === 'Layout') {
route.component = (resolve) => require(["@/layouts"], resolve); route.component = (resolve) => require(['@/layouts'], resolve)
} else if (route.component === "EmptyLayout") { } else if (route.component === 'EmptyLayout') {
route.component = (resolve) => route.component = (resolve) =>
require(["@/layouts/EmptyLayout"], resolve); require(['@/layouts/EmptyLayout'], resolve)
} else { } else {
const index = route.component.indexOf("views"); const index = route.component.indexOf('views')
const path = const path =
index > 0 ? route.component.slice(index) : `views/${route.component}`; index > 0 ? route.component.slice(index) : `views/${route.component}`
route.component = (resolve) => require([`@/${path}`], resolve); route.component = (resolve) => require([`@/${path}`], resolve)
} }
} }
if (route.children && route.children.length) if (route.children && route.children.length)
route.children = convertRouter(route.children); route.children = convertRouter(route.children)
if (route.children && route.children.length === 0) delete route.children; if (route.children && route.children.length === 0) delete route.children
return route; return route
}); })
} }
/** /**
@ -35,9 +35,9 @@ export function convertRouter(asyncRoutes) {
*/ */
function hasPermission(permissions, route) { function hasPermission(permissions, route) {
if (route.meta && route.meta.permissions) { if (route.meta && route.meta.permissions) {
return permissions.some((role) => route.meta.permissions.includes(role)); return permissions.some((role) => route.meta.permissions.includes(role))
} else { } else {
return true; return true
} }
} }
@ -49,15 +49,15 @@ function hasPermission(permissions, route) {
* @returns {[]} * @returns {[]}
*/ */
export function filterAsyncRoutes(routes, permissions) { export function filterAsyncRoutes(routes, permissions) {
const finallyRoutes = []; const finallyRoutes = []
routes.forEach((route) => { routes.forEach((route) => {
const item = { ...route }; const item = { ...route }
if (hasPermission(permissions, item)) { if (hasPermission(permissions, item)) {
if (item.children) { if (item.children) {
item.children = filterAsyncRoutes(item.children, permissions); item.children = filterAsyncRoutes(item.children, permissions)
} }
finallyRoutes.push(item); finallyRoutes.push(item)
} }
}); })
return finallyRoutes; return finallyRoutes
} }

View File

@ -7,20 +7,20 @@
*/ */
export function parseTime(time, cFormat) { export function parseTime(time, cFormat) {
if (arguments.length === 0) { if (arguments.length === 0) {
return null; return null
} }
const format = cFormat || "{y}-{m}-{d} {h}:{i}:{s}"; const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date; let date
if (typeof time === "object") { if (typeof time === 'object') {
date = time; date = time
} else { } else {
if (typeof time === "string" && /^[0-9]+$/.test(time)) { if (typeof time === 'string' && /^[0-9]+$/.test(time)) {
time = parseInt(time); time = parseInt(time)
} }
if (typeof time === "number" && time.toString().length === 10) { if (typeof time === 'number' && time.toString().length === 10) {
time = time * 1000; time = time * 1000
} }
date = new Date(time); date = new Date(time)
} }
const formatObj = { const formatObj = {
y: date.getFullYear(), y: date.getFullYear(),
@ -30,18 +30,18 @@ export function parseTime(time, cFormat) {
i: date.getMinutes(), i: date.getMinutes(),
s: date.getSeconds(), s: date.getSeconds(),
a: date.getDay(), a: date.getDay(),
}; }
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]; let value = formatObj[key]
if (key === "a") { if (key === 'a') {
return ["日", "一", "二", "三", "四", "五", "六"][value]; return ['日', '一', '二', '三', '四', '五', '六'][value]
} }
if (result.length > 0 && value < 10) { if (result.length > 0 && value < 10) {
value = "0" + value; value = '0' + value
} }
return value || 0; return value || 0
}); })
return time_str; return time_str
} }
/** /**
@ -52,40 +52,40 @@ export function parseTime(time, cFormat) {
* @returns {string} * @returns {string}
*/ */
export function formatTime(time, option) { export function formatTime(time, option) {
if (("" + time).length === 10) { if (('' + time).length === 10) {
time = parseInt(time) * 1000; time = parseInt(time) * 1000
} else { } else {
time = +time; time = +time
} }
const d = new Date(time); const d = new Date(time)
const now = Date.now(); const now = Date.now()
const diff = (now - d) / 1000; const diff = (now - d) / 1000
if (diff < 30) { if (diff < 30) {
return "刚刚"; return '刚刚'
} else if (diff < 3600) { } else if (diff < 3600) {
// less 1 hour // less 1 hour
return Math.ceil(diff / 60) + "分钟前"; return Math.ceil(diff / 60) + '分钟前'
} else if (diff < 3600 * 24) { } else if (diff < 3600 * 24) {
return Math.ceil(diff / 3600) + "小时前"; return Math.ceil(diff / 3600) + '小时前'
} else if (diff < 3600 * 24 * 2) { } else if (diff < 3600 * 24 * 2) {
return "1天前"; return '1天前'
} }
if (option) { if (option) {
return parseTime(time, option); return parseTime(time, option)
} else { } else {
return ( return (
d.getMonth() + d.getMonth() +
1 + 1 +
"月" + '月' +
d.getDate() + d.getDate() +
"日" + '日' +
d.getHours() + d.getHours() +
"时" + '时' +
d.getMinutes() + d.getMinutes() +
"分" '分'
); )
} }
} }
@ -96,9 +96,9 @@ export function formatTime(time, option) {
* @returns {{}|any} * @returns {{}|any}
*/ */
export function paramObj(url) { export function paramObj(url) {
const search = url.split("?")[1]; const search = url.split('?')[1]
if (!search) { if (!search) {
return {}; return {}
} }
return JSON.parse( return JSON.parse(
'{"' + '{"' +
@ -106,9 +106,9 @@ export function paramObj(url) {
.replace(/"/g, '\\"') .replace(/"/g, '\\"')
.replace(/&/g, '","') .replace(/&/g, '","')
.replace(/=/g, '":"') .replace(/=/g, '":"')
.replace(/\+/g, " ") + .replace(/\+/g, ' ') +
'"}' '"}'
); )
} }
/** /**
@ -119,27 +119,27 @@ export function paramObj(url) {
*/ */
export function translateDataToTree(data) { export function translateDataToTree(data) {
const parent = data.filter( const parent = data.filter(
(value) => value.parentId === "undefined" || value.parentId == null (value) => value.parentId === 'undefined' || value.parentId == null
); )
const children = data.filter( const children = data.filter(
(value) => value.parentId !== "undefined" && value.parentId != null (value) => value.parentId !== 'undefined' && value.parentId != null
); )
const translator = (parent, children) => { const translator = (parent, children) => {
parent.forEach((parent) => { parent.forEach((parent) => {
children.forEach((current, index) => { children.forEach((current, index) => {
if (current.parentId === parent.id) { if (current.parentId === parent.id) {
const temp = JSON.parse(JSON.stringify(children)); const temp = JSON.parse(JSON.stringify(children))
temp.splice(index, 1); temp.splice(index, 1)
translator([current], temp); translator([current], temp)
typeof parent.children !== "undefined" typeof parent.children !== 'undefined'
? parent.children.push(current) ? parent.children.push(current)
: (parent.children = [current]); : (parent.children = [current])
} }
}); })
}); })
}; }
translator(parent, children); translator(parent, children)
return parent; return parent
} }
/** /**
@ -149,24 +149,24 @@ export function translateDataToTree(data) {
* @returns {[]} * @returns {[]}
*/ */
export function translateTreeToData(data) { export function translateTreeToData(data) {
const result = []; const result = []
data.forEach((item) => { data.forEach((item) => {
const loop = (data) => { const loop = (data) => {
result.push({ result.push({
id: data.id, id: data.id,
name: data.name, name: data.name,
parentId: data.parentId, parentId: data.parentId,
}); })
const child = data.children; const child = data.children
if (child) { if (child) {
for (let i = 0; i < child.length; i++) { for (let i = 0; i < child.length; i++) {
loop(child[i]); loop(child[i])
} }
} }
}; }
loop(item); loop(item)
}); })
return result; return result
} }
/** /**
@ -176,19 +176,19 @@ export function translateTreeToData(data) {
* @returns {string} * @returns {string}
*/ */
export function tenBitTimestamp(time) { export function tenBitTimestamp(time) {
const date = new Date(time * 1000); const date = new Date(time * 1000)
const y = date.getFullYear(); const y = date.getFullYear()
let m = date.getMonth() + 1; let m = date.getMonth() + 1
m = m < 10 ? "" + m : m; m = m < 10 ? '' + m : m
let d = date.getDate(); let d = date.getDate()
d = d < 10 ? "" + d : d; d = d < 10 ? '' + d : d
let h = date.getHours(); let h = date.getHours()
h = h < 10 ? "0" + h : h; h = h < 10 ? '0' + h : h
let minute = date.getMinutes(); let minute = date.getMinutes()
let second = date.getSeconds(); let second = date.getSeconds()
minute = minute < 10 ? "0" + minute : minute; minute = minute < 10 ? '0' + minute : minute
second = second < 10 ? "0" + second : second; second = second < 10 ? '0' + second : second
return y + "年" + m + "月" + d + "日 " + h + ":" + minute + ":" + second; //组合 return y + '年' + m + '月' + d + '日 ' + h + ':' + minute + ':' + second //组合
} }
/** /**
@ -198,19 +198,19 @@ export function tenBitTimestamp(time) {
* @returns {string} * @returns {string}
*/ */
export function thirteenBitTimestamp(time) { export function thirteenBitTimestamp(time) {
const date = new Date(time / 1); const date = new Date(time / 1)
const y = date.getFullYear(); const y = date.getFullYear()
let m = date.getMonth() + 1; let m = date.getMonth() + 1
m = m < 10 ? "" + m : m; m = m < 10 ? '' + m : m
let d = date.getDate(); let d = date.getDate()
d = d < 10 ? "" + d : d; d = d < 10 ? '' + d : d
let h = date.getHours(); let h = date.getHours()
h = h < 10 ? "0" + h : h; h = h < 10 ? '0' + h : h
let minute = date.getMinutes(); let minute = date.getMinutes()
let second = date.getSeconds(); let second = date.getSeconds()
minute = minute < 10 ? "0" + minute : minute; minute = minute < 10 ? '0' + minute : minute
second = second < 10 ? "0" + second : second; second = second < 10 ? '0' + second : second
return y + "年" + m + "月" + d + "日 " + h + ":" + minute + ":" + second; //组合 return y + '年' + m + '月' + d + '日 ' + h + ':' + minute + ':' + second //组合
} }
/** /**
@ -220,12 +220,12 @@ export function thirteenBitTimestamp(time) {
* @returns {string} * @returns {string}
*/ */
export function uuid(length = 32) { export function uuid(length = 32) {
const num = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; const num = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
let str = ""; let str = ''
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
str += num.charAt(Math.floor(Math.random() * num.length)); str += num.charAt(Math.floor(Math.random() * num.length))
} }
return str; return str
} }
/** /**
@ -236,7 +236,7 @@ export function uuid(length = 32) {
* @returns {number} * @returns {number}
*/ */
export function random(m, n) { export function random(m, n) {
return Math.floor(Math.random() * (m - n) + n); return Math.floor(Math.random() * (m - n) + n)
} }
/** /**
@ -247,10 +247,10 @@ export function random(m, n) {
export const on = (function () { export const on = (function () {
return function (element, event, handler, useCapture = false) { return function (element, event, handler, useCapture = false) {
if (element && event && handler) { if (element && event && handler) {
element.addEventListener(event, handler, useCapture); element.addEventListener(event, handler, useCapture)
} }
}; }
})(); })()
/** /**
* @author chuzhixin 1204505056@qq.com 不想保留author可删除 * @author chuzhixin 1204505056@qq.com 不想保留author可删除
@ -260,7 +260,7 @@ export const on = (function () {
export const off = (function () { export const off = (function () {
return function (element, event, handler, useCapture = false) { return function (element, event, handler, useCapture = false) {
if (element && event) { if (element && event) {
element.removeEventListener(event, handler, useCapture); element.removeEventListener(event, handler, useCapture)
} }
}; }
})(); })()

View File

@ -1,4 +1,4 @@
import { title } from "@/config/settings"; import { title } from '@/config/settings'
/** /**
* @author chuzhixin 1204505056@qq.com 不想保留author可删除 * @author chuzhixin 1204505056@qq.com 不想保留author可删除
@ -8,7 +8,7 @@ import { title } from "@/config/settings";
*/ */
export default function getPageTitle(pageTitle) { export default function getPageTitle(pageTitle) {
if (pageTitle) { if (pageTitle) {
return `${pageTitle}-${title}`; return `${pageTitle}-${title}`
} }
return `${title}`; return `${title}`
} }

View File

@ -1,4 +1,4 @@
import store from "@/store"; import store from '@/store'
/** /**
* @author chuzhixin 1204505056@qq.com 不想保留author可删除 * @author chuzhixin 1204505056@qq.com 不想保留author可删除
@ -8,13 +8,13 @@ import store from "@/store";
*/ */
export default function checkPermission(value) { export default function checkPermission(value) {
if (value && value instanceof Array && value.length > 0) { if (value && value instanceof Array && value.length > 0) {
const permissions = store.getters["user/permissions"]; const permissions = store.getters['user/permissions']
const permissionPermissions = value; const permissionPermissions = value
return permissions.some((role) => { return permissions.some((role) => {
return permissionPermissions.includes(role); return permissionPermissions.includes(role)
}); })
} else { } else {
return false; return false
} }
} }

View File

@ -1,5 +1,5 @@
import Vue from "vue"; import Vue from 'vue'
import axios from "axios"; import axios from 'axios'
import { import {
baseURL, baseURL,
contentType, contentType,
@ -10,13 +10,13 @@ import {
successCode, successCode,
tokenName, tokenName,
loginInterception, loginInterception,
} from "@/config/settings"; } from '@/config/settings'
import store from "@/store"; import store from '@/store'
import qs from "qs"; import qs from 'qs'
import router from "@/router"; import router from '@/router'
import { isArray } from "@/utils/validate"; import { isArray } from '@/utils/validate'
let loadingInstance; let loadingInstance
/** /**
* @author chuzhixin 1204505056@qq.com 不想保留author可删除 * @author chuzhixin 1204505056@qq.com 不想保留author可删除
@ -27,99 +27,99 @@ let loadingInstance;
const handleCode = (code, msg) => { const handleCode = (code, msg) => {
switch (code) { switch (code) {
case invalidCode: case invalidCode:
Vue.prototype.$baseMessage(msg || `后端接口${code}异常`, "error"); Vue.prototype.$baseMessage(msg || `后端接口${code}异常`, 'error')
store.dispatch("user/resetAccessToken").catch(() => {}); store.dispatch('user/resetAccessToken').catch(() => {})
if (loginInterception) { if (loginInterception) {
location.reload(); location.reload()
} }
break; break
case noPermissionCode: case noPermissionCode:
router.push({ path: "/401" }).catch(() => {}); router.push({ path: '/401' }).catch(() => {})
break; break
default: default:
Vue.prototype.$baseMessage(msg || `后端接口${code}异常`, "error"); Vue.prototype.$baseMessage(msg || `后端接口${code}异常`, 'error')
break; break
} }
}; }
const instance = axios.create({ const instance = axios.create({
baseURL, baseURL,
timeout: requestTimeout, timeout: requestTimeout,
headers: { headers: {
"Content-Type": contentType, 'Content-Type': contentType,
}, },
}); })
instance.interceptors.request.use( instance.interceptors.request.use(
(config) => { (config) => {
if (store.getters["user/accessToken"]) { if (store.getters['user/accessToken']) {
config.headers[tokenName] = store.getters["user/accessToken"]; config.headers[tokenName] = store.getters['user/accessToken']
} }
//这里会过滤所有为空、0、false的key如果不需要请自行注释 //这里会过滤所有为空、0、false的key如果不需要请自行注释
if (config.data) if (config.data)
config.data = Vue.prototype.$baseLodash.pickBy( config.data = Vue.prototype.$baseLodash.pickBy(
config.data, config.data,
Vue.prototype.$baseLodash.identity Vue.prototype.$baseLodash.identity
); )
if ( if (
config.data && config.data &&
config.headers["Content-Type"] === config.headers['Content-Type'] ===
"application/x-www-form-urlencoded;charset=UTF-8" 'application/x-www-form-urlencoded;charset=UTF-8'
) )
config.data = qs.stringify(config.data); config.data = qs.stringify(config.data)
if (debounce.some((item) => config.url.includes(item))) if (debounce.some((item) => config.url.includes(item)))
loadingInstance = Vue.prototype.$baseLoading(); loadingInstance = Vue.prototype.$baseLoading()
return config; return config
}, },
(error) => { (error) => {
return Promise.reject(error); return Promise.reject(error)
} }
); )
instance.interceptors.response.use( instance.interceptors.response.use(
(response) => { (response) => {
if (loadingInstance) loadingInstance.close(); if (loadingInstance) loadingInstance.close()
const { data, config } = response; const { data, config } = response
const { code, msg } = data; const { code, msg } = data
// 操作正常Code数组 // 操作正常Code数组
const codeVerificationArray = isArray(successCode) const codeVerificationArray = isArray(successCode)
? [...successCode] ? [...successCode]
: [...[successCode]]; : [...[successCode]]
// 是否操作正常 // 是否操作正常
if (codeVerificationArray.includes(code)) { if (codeVerificationArray.includes(code)) {
return data; return data
} else { } else {
handleCode(code, msg); handleCode(code, msg)
return Promise.reject( return Promise.reject(
"vue-admin-beautiful请求异常拦截:" + 'vue-admin-beautiful请求异常拦截:' +
JSON.stringify({ url: config.url, code, msg }) || "Error" JSON.stringify({ url: config.url, code, msg }) || 'Error'
); )
} }
}, },
(error) => { (error) => {
if (loadingInstance) loadingInstance.close(); if (loadingInstance) loadingInstance.close()
const { response, message } = error; const { response, message } = error
if (error.response && error.response.data) { if (error.response && error.response.data) {
const { status, data } = response; const { status, data } = response
handleCode(status, data.msg || message); handleCode(status, data.msg || message)
return Promise.reject(error); return Promise.reject(error)
} else { } else {
let { message } = error; let { message } = error
if (message === "Network Error") { if (message === 'Network Error') {
message = "后端接口连接异常"; message = '后端接口连接异常'
} }
if (message.includes("timeout")) { if (message.includes('timeout')) {
message = "后端接口请求超时"; message = '后端接口请求超时'
} }
if (message.includes("Request failed with status code")) { if (message.includes('Request failed with status code')) {
const code = message.substr(message.length - 3); const code = message.substr(message.length - 3)
message = "后端接口" + code + "异常"; message = '后端接口' + code + '异常'
} }
Vue.prototype.$baseMessage(message || `后端接口未知异常`, "error"); Vue.prototype.$baseMessage(message || `后端接口未知异常`, 'error')
return Promise.reject(error); return Promise.reject(error)
} }
} }
); )
export default instance; export default instance

View File

@ -2,51 +2,51 @@
* @author chuzhixin 1204505056@qq.com * @author chuzhixin 1204505056@qq.com
* @description 导入所有 controller 模块浏览器环境中自动输出controller文件夹下Mock接口请勿修改 * @description 导入所有 controller 模块浏览器环境中自动输出controller文件夹下Mock接口请勿修改
*/ */
import Mock from "mockjs"; import Mock from 'mockjs'
import { paramObj } from "@/utils/index"; import { paramObj } from '@/utils/index'
const mocks = []; const mocks = []
const files = require.context("../../mock/controller", false, /\.js$/); const files = require.context('../../mock/controller', false, /\.js$/)
files.keys().forEach((key) => { files.keys().forEach((key) => {
mocks.push(...files(key)); mocks.push(...files(key))
}); })
export function mockXHR() { export function mockXHR() {
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send; Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function () { Mock.XHR.prototype.send = function () {
if (this.custom.xhr) { if (this.custom.xhr) {
this.custom.xhr.withCredentials = this.withCredentials || false; this.custom.xhr.withCredentials = this.withCredentials || false
if (this.responseType) { if (this.responseType) {
this.custom.xhr.responseType = this.responseType; this.custom.xhr.responseType = this.responseType
} }
} }
this.proxy_send(...arguments); this.proxy_send(...arguments)
}; }
function XHRHttpRequst(respond) { function XHRHttpRequst(respond) {
return function (options) { return function (options) {
let result; let result
if (respond instanceof Function) { if (respond instanceof Function) {
const { body, type, url } = options; const { body, type, url } = options
result = respond({ result = respond({
method: type, method: type,
body: JSON.parse(body), body: JSON.parse(body),
query: paramObj(url), query: paramObj(url),
}); })
} else { } else {
result = respond; result = respond
} }
return Mock.mock(result); return Mock.mock(result)
}; }
} }
mocks.forEach((item) => { mocks.forEach((item) => {
Mock.mock( Mock.mock(
new RegExp(item.url), new RegExp(item.url),
item.type || "get", item.type || 'get',
XHRHttpRequst(item.response) XHRHttpRequst(item.response)
); )
}); })
} }

View File

@ -1,74 +1,74 @@
import { loadingText, messageDuration, title } from "@/config/settings"; import { loadingText, messageDuration, title } from '@/config/settings'
import * as lodash from "lodash"; import * as lodash from 'lodash'
import { Loading, Message, MessageBox, Notification } from "element-ui"; import { Loading, Message, MessageBox, Notification } from 'element-ui'
import store from "@/store"; import store from '@/store'
import { getAccessToken } from "@/utils/accessToken"; import { getAccessToken } from '@/utils/accessToken'
const accessToken = store.getters["user/accessToken"]; const accessToken = store.getters['user/accessToken']
const layout = store.getters["settings/layout"]; const layout = store.getters['settings/layout']
const install = (Vue, opts = {}) => { const install = (Vue, opts = {}) => {
/* 全局accessToken */ /* 全局accessToken */
Vue.prototype.$baseAccessToken = () => { Vue.prototype.$baseAccessToken = () => {
return accessToken || getAccessToken(); return accessToken || getAccessToken()
}; }
/* 全局标题 */ /* 全局标题 */
Vue.prototype.$baseTitle = (() => { Vue.prototype.$baseTitle = (() => {
return title; return title
})(); })()
/* 全局加载层 */ /* 全局加载层 */
Vue.prototype.$baseLoading = (index, text) => { Vue.prototype.$baseLoading = (index, text) => {
let loading; let loading
if (!index) { if (!index) {
loading = Loading.service({ loading = Loading.service({
lock: true, lock: true,
text: text || loadingText, text: text || loadingText,
background: "hsla(0,0%,100%,.8)", background: 'hsla(0,0%,100%,.8)',
}); })
} else { } else {
loading = Loading.service({ loading = Loading.service({
lock: true, lock: true,
text: text || loadingText, text: text || loadingText,
spinner: "vab-loading-type" + index, spinner: 'vab-loading-type' + index,
background: "hsla(0,0%,100%,.8)", background: 'hsla(0,0%,100%,.8)',
}); })
} }
return loading; return loading
}; }
/* 全局多彩加载层 */ /* 全局多彩加载层 */
Vue.prototype.$baseColorfullLoading = (index, text) => { Vue.prototype.$baseColorfullLoading = (index, text) => {
let loading; let loading
if (!index) { if (!index) {
loading = Loading.service({ loading = Loading.service({
lock: true, lock: true,
text: text || loadingText, text: text || loadingText,
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'
break; break
case 2: case 2:
index = "gauge"; index = 'gauge'
break; break
case 3: case 3:
index = "inner-circles"; index = 'inner-circles'
break; break
case 4: case 4:
index = "plus"; index = 'plus'
break; break
} }
loading = Loading.service({ loading = Loading.service({
lock: true, lock: true,
text: text || loadingText, text: text || loadingText,
spinner: index + "-loader", spinner: index + '-loader',
background: "hsla(0,0%,100%,.8)", background: 'hsla(0,0%,100%,.8)',
}); })
} }
return loading; return loading
}; }
/* 全局Message */ /* 全局Message */
Vue.prototype.$baseMessage = (message, type) => { Vue.prototype.$baseMessage = (message, type) => {
Message({ Message({
@ -78,103 +78,103 @@ const install = (Vue, opts = {}) => {
type: type, type: type,
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
duration: messageDuration, duration: messageDuration,
}); })
}; }
/* 全局Alert */ /* 全局Alert */
Vue.prototype.$baseAlert = (content, title, callback) => { Vue.prototype.$baseAlert = (content, title, callback) => {
MessageBox.alert(content, title || "温馨提示", { MessageBox.alert(content, title || '温馨提示', {
confirmButtonText: "确定", confirmButtonText: '确定',
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
callback: (action) => { callback: (action) => {
if (callback) { if (callback) {
callback(); callback()
} }
}, },
}); })
}; }
/* 全局Confirm */ /* 全局Confirm */
Vue.prototype.$baseConfirm = (content, title, callback1, callback2) => { Vue.prototype.$baseConfirm = (content, title, callback1, callback2) => {
MessageBox.confirm(content, title || "温馨提示", { MessageBox.confirm(content, title || '温馨提示', {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
closeOnClickModal: false, closeOnClickModal: false,
type: "warning", type: 'warning',
}) })
.then(() => { .then(() => {
if (callback1) { if (callback1) {
callback1(); callback1()
} }
}) })
.catch(() => { .catch(() => {
if (callback2) { if (callback2) {
callback2(); callback2()
} }
}); })
}; }
/* 全局Notification */ /* 全局Notification */
Vue.prototype.$baseNotify = (message, title, type, position) => { Vue.prototype.$baseNotify = (message, title, type, position) => {
Notification({ Notification({
title: title, title: title,
message: message, message: message,
position: position || "top-right", position: position || 'top-right',
type: type || "success", type: type || 'success',
duration: messageDuration, duration: messageDuration,
}); })
}; }
/* 全局TableHeight */ /* 全局TableHeight */
Vue.prototype.$baseTableHeight = (formType) => { Vue.prototype.$baseTableHeight = (formType) => {
let height = window.innerHeight; let height = window.innerHeight
let paddingHeight = 400; let paddingHeight = 400
const formHeight = 50; const formHeight = 50
if (layout === "vertical") { if (layout === 'vertical') {
paddingHeight = 340; paddingHeight = 340
} }
if ("number" == typeof formType) { if ('number' == typeof formType) {
height = height - paddingHeight - formHeight * formType; height = height - paddingHeight - formHeight * formType
} else { } else {
height = height - paddingHeight; height = height - paddingHeight
} }
return height; return height
}; }
/* 全局map图层 */ /* 全局map图层 */
Vue.prototype.$baseMap = () => { Vue.prototype.$baseMap = () => {
return new maptalks.Map("map", { return new maptalks.Map('map', {
center: [116.41348403785, 39.910843952376], center: [116.41348403785, 39.910843952376],
zoom: 12, zoom: 12,
minZoom: 1, minZoom: 1,
maxZoom: 19, maxZoom: 19,
spatialReference: { spatialReference: {
projection: "baidu", projection: 'baidu',
}, },
attribution: { attribution: {
content: "&copy; vue-admin-beautiful", content: '&copy; vue-admin-beautiful',
}, },
baseLayer: new maptalks.TileLayer("base", { baseLayer: new maptalks.TileLayer('base', {
cssFilter: "sepia(100%) invert(90%)", cssFilter: 'sepia(100%) invert(90%)',
urlTemplate: urlTemplate:
"http://online{s}.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles=pl&scaler=1&p=1", 'http://online{s}.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles=pl&scaler=1&p=1',
subdomains: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], subdomains: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
attribution: attribution:
'&copy; <a target="_blank" href="http://map.baidu.com">Baidu</a>', '&copy; <a target="_blank" href="http://map.baidu.com">Baidu</a>',
}), }),
}); })
}; }
/* 全局lodash */ /* 全局lodash */
Vue.prototype.$baseLodash = lodash; Vue.prototype.$baseLodash = lodash
/* 全局事件总线 */ /* 全局事件总线 */
Vue.prototype.$baseEventBus = new Vue(); Vue.prototype.$baseEventBus = new Vue()
};
if (typeof window !== "undefined" && window.Vue) {
install(window.Vue);
} }
export default install; if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
}
export default install

View File

@ -5,7 +5,7 @@
* @returns {boolean} * @returns {boolean}
*/ */
export function isExternal(path) { export function isExternal(path) {
return /^(https?:|mailto:|tel:)/.test(path); return /^(https?:|mailto:|tel:)/.test(path)
} }
/** /**
@ -15,7 +15,7 @@ export function isExternal(path) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isPassword(str) { export function isPassword(str) {
return str.length >= 6; return str.length >= 6
} }
/** /**
@ -25,8 +25,8 @@ export function isPassword(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isNumber(value) { export function isNumber(value) {
const reg = /^[0-9]*$/; const reg = /^[0-9]*$/
return reg.test(value); return reg.test(value)
} }
/** /**
@ -36,8 +36,8 @@ export function isNumber(value) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isName(value) { export function isName(value) {
const reg = /^[\u4e00-\u9fa5a-zA-Z0-9]+$/; const reg = /^[\u4e00-\u9fa5a-zA-Z0-9]+$/
return reg.test(value); return reg.test(value)
} }
/** /**
@ -47,8 +47,8 @@ export function isName(value) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isIP(ip) { export function isIP(ip) {
const reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; const reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
return reg.test(ip); return reg.test(ip)
} }
/** /**
@ -58,8 +58,8 @@ export function isIP(ip) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isUrl(url) { export function isUrl(url) {
const reg = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/; const reg = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
return reg.test(url); return reg.test(url)
} }
/** /**
@ -69,8 +69,8 @@ export function isUrl(url) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isLowerCase(str) { export function isLowerCase(str) {
const reg = /^[a-z]+$/; const reg = /^[a-z]+$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -80,8 +80,8 @@ export function isLowerCase(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isUpperCase(str) { export function isUpperCase(str) {
const reg = /^[A-Z]+$/; const reg = /^[A-Z]+$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -91,8 +91,8 @@ export function isUpperCase(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isAlphabets(str) { export function isAlphabets(str) {
const reg = /^[A-Za-z]+$/; const reg = /^[A-Za-z]+$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -102,7 +102,7 @@ export function isAlphabets(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isString(str) { export function isString(str) {
return typeof str === "string" || str instanceof String; return typeof str === 'string' || str instanceof String
} }
/** /**
@ -112,10 +112,10 @@ export function isString(str) {
* @returns {arg is any[]|boolean} * @returns {arg is any[]|boolean}
*/ */
export function isArray(arg) { export function isArray(arg) {
if (typeof Array.isArray === "undefined") { if (typeof Array.isArray === 'undefined') {
return Object.prototype.toString.call(arg) === "[object Array]"; return Object.prototype.toString.call(arg) === '[object Array]'
} }
return Array.isArray(arg); return Array.isArray(arg)
} }
/** /**
@ -125,8 +125,8 @@ export function isArray(arg) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isPort(str) { export function isPort(str) {
const reg = /^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/; const reg = /^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -136,8 +136,8 @@ export function isPort(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isPhone(str) { export function isPhone(str) {
const reg = /^1\d{10}$/; const reg = /^1\d{10}$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -147,8 +147,8 @@ export function isPhone(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isIdCard(str) { export function isIdCard(str) {
const reg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/; const reg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -158,8 +158,8 @@ export function isIdCard(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isEmail(str) { export function isEmail(str) {
const reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; const reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -169,8 +169,8 @@ export function isEmail(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isChina(str) { export function isChina(str) {
const reg = /^[\u4E00-\u9FA5]{2,4}$/; const reg = /^[\u4E00-\u9FA5]{2,4}$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -183,10 +183,10 @@ export function isBlank(str) {
return ( return (
str == null || str == null ||
false || false ||
str === "" || str === '' ||
str.trim() === "" || str.trim() === '' ||
str.toLocaleLowerCase().trim() === "null" str.toLocaleLowerCase().trim() === 'null'
); )
} }
/** /**
@ -196,8 +196,8 @@ export function isBlank(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isTel(str) { export function isTel(str) {
const reg = /^(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |转)*([0-9]{1,4}))?$/; const reg = /^(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |转)*([0-9]{1,4}))?$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -207,8 +207,8 @@ export function isTel(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isNum(str) { export function isNum(str) {
const reg = /^\d+(\.\d{1,2})?$/; const reg = /^\d+(\.\d{1,2})?$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -218,8 +218,8 @@ export function isNum(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isLongitude(str) { export function isLongitude(str) {
const reg = /^[-|+]?(0?\d{1,2}\.\d{1,5}|1[0-7]?\d{1}\.\d{1,5}|180\.0{1,5})$/; const reg = /^[-|+]?(0?\d{1,2}\.\d{1,5}|1[0-7]?\d{1}\.\d{1,5}|180\.0{1,5})$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -229,8 +229,8 @@ export function isLongitude(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isLatitude(str) { export function isLatitude(str) {
const reg = /^[-|+]?([0-8]?\d{1}\.\d{1,5}|90\.0{1,5})$/; const reg = /^[-|+]?([0-8]?\d{1}\.\d{1,5}|90\.0{1,5})$/
return reg.test(str); return reg.test(str)
} }
/** /**
@ -240,8 +240,8 @@ export function isLatitude(str) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isRTSP(str) { export function isRTSP(str) {
const reg = /^rtsp:\/\/([a-z]{0,10}:.{0,10}@)?(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; const reg = /^rtsp:\/\/([a-z]{0,10}:.{0,10}@)?(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
const reg1 = /^rtsp:\/\/([a-z]{0,10}:.{0,10}@)?(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]):[0-9]{1,5}/; const reg1 = /^rtsp:\/\/([a-z]{0,10}:.{0,10}@)?(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]):[0-9]{1,5}/
const reg2 = /^rtsp:\/\/([a-z]{0,10}:.{0,10}@)?(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\//; const reg2 = /^rtsp:\/\/([a-z]{0,10}:.{0,10}@)?(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\//
return reg.test(str) || reg1.test(str) || reg2.test(str); return reg.test(str) || reg1.test(str) || reg2.test(str)
} }

Some files were not shown because too many files have changed in this diff Show More