feat: update 1.11.0

This commit is contained in:
FairyEver
2020-05-08 10:41:10 +08:00
parent 9e8e3345f1
commit f9f0607430
41 changed files with 17240 additions and 825 deletions
-7
View File
@@ -1,7 +0,0 @@
# No Mock 构建
# 指定构建模式
NODE_ENV=production
# 标记当前是 No Mock 构建
VUE_APP_BUILD_MODE=NOMOCK
-22
View File
@@ -1,22 +0,0 @@
module.exports = {
branch: 'master',
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
[
'@semantic-release/npm',
{
npmPublish: false
}
],
'@semantic-release/github',
[
'@semantic-release/git',
{
assets: [
'package.json'
]
}
]
]
}
+3 -3
View File
@@ -5,18 +5,18 @@ module.exports = [
{ name: 'vuex', library: 'Vuex', js: 'https://cdn.jsdelivr.net/npm/vuex@3.1.2/dist/vuex.min.js', css: '' },
{ name: 'axios', library: 'axios', js: 'https://cdn.jsdelivr.net/npm/axios@0.19.0/dist/axios.min.js', css: '' },
{ name: 'better-scroll', library: 'BScroll', js: 'https://cdn.jsdelivr.net/npm/better-scroll@1.15.2/dist/bscroll.min.js', css: '' },
{ name: 'axios-mock-adapter', library: 'AxiosMockAdapter', js: 'https://cdn.jsdelivr.net/npm/axios-mock-adapter@1.18.1/dist/axios-mock-adapter.min.js', css: '' },
{ name: 'element-ui', library: 'ELEMENT', js: 'https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/index.js', css: 'https://cdn.jsdelivr.net/npm/element-ui@2.13.0/lib/theme-chalk/index.css' },
{ name: 'mockjs', library: 'Mock', js: 'https://cdn.jsdelivr.net/npm/mockjs@1.1.0/dist/mock.min.js', css: '' },
{ name: 'lodash', library: '_', js: 'https://cdn.jsdelivr.net/npm/lodash@4.17.15/lodash.min.js', css: '' },
{ name: 'ua-parser-js', library: 'UAParser', js: 'https://cdn.jsdelivr.net/npm/ua-parser-js@0.7.20/dist/ua-parser.min.js', css: '' },
{ name: 'js-cookie', library: 'Cookies', js: 'https://cdn.jsdelivr.net/npm/js-cookie@2.2.1/src/js.cookie.min.js', css: '' },
{ name: 'nprogress', library: 'NProgress', js: 'https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js', css: 'https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.css' },
{ name: 'dayjs', library: 'dayjs', js: 'https://cdn.jsdelivr.net/npm/dayjs@1.8.17/dayjs.min.js', css: '' },
{ name: 'fuse.js', library: 'Fuse', js: 'https://cdn.jsdelivr.net/npm/fuse.js@3.4.6/dist/fuse.min.js', css: '' },
{ name: 'fuse.js', library: 'Fuse', js: 'https://cdn.jsdelivr.net/npm/fuse.js@5.2.3/dist/fuse.min.js', css: '' },
{ name: 'hotkeys-js', library: 'hotkeys', js: 'https://cdn.jsdelivr.net/npm/hotkeys-js@3.7.3/dist/hotkeys.min.js', css: '' },
{ name: 'qs', library: 'Qs', js: 'https://cdn.jsdelivr.net/npm/qs@6.9.1/dist/qs.js', css: '' },
{ name: 'lowdb', library: 'low', js: 'https://cdn.jsdelivr.net/npm/lowdb@1.0.0/dist/low.min.js', css: '' },
{ name: 'lowdb/adapters/LocalStorage', library: 'LocalStorage', js: 'https://cdn.jsdelivr.net/npm/lowdb@1.0.0/dist/LocalStorage.min.js', css: '' },
{ name: 'screenfull', library: 'screenfull', js: 'https://cdn.jsdelivr.net/npm/screenfull@5.0.2/dist/screenfull.min.js', css: '' },
{ name: 'sortablejs', library: 'Sortable', js: 'https://cdn.jsdelivr.net/npm/sortablejs@1.10.1/Sortable.min.js', css: '' },
{ name: 'sortablejs', library: 'Sortable', js: 'https://cdn.jsdelivr.net/npm/sortablejs@1.10.1/Sortable.min.js', css: '' }
]
+16335
View File
File diff suppressed because it is too large Load Diff
+22 -18
View File
@@ -1,34 +1,30 @@
{
"name": "d2-admin-start-kit",
"version": "1.10.0",
"name": "d2-admin",
"version": "1.11.0",
"scripts": {
"serve": "vue-cli-service serve --open",
"start": "npm run serve",
"dev": "npm run serve",
"build": "vue-cli-service build",
"build:nomock": "vue-cli-service build --mode nomock",
"build:preview": "NODE_OPTIONS=--max_old_space_size=4096 vue-cli-service build --mode preview",
"lint": "vue-cli-service lint --fix",
"test:unit": "vue-cli-service test:unit",
"i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'",
"analyz": "npm_config_report=true npm run build",
"commit": "git-cz"
"test:unit": "vue-cli-service test:unit"
},
"dependencies": {
"axios": "^0.19.0",
"axios-mock-adapter": "^1.18.1",
"better-scroll": "^1.15.2",
"core-js": "^3.4.3",
"dayjs": "^1.8.17",
"element-ui": "^2.13.0",
"element-ui": "^2.13.1",
"faker": "^4.1.0",
"flex.css": "^1.1.7",
"fuse.js": "^3.4.6",
"fuse.js": "^5.2.3",
"hotkeys-js": "^3.7.3",
"js-cookie": "^2.2.1",
"lodash": "^4.17.15",
"lowdb": "^1.0.0",
"mockjs": "^1.1.0",
"nprogress": "^0.2.0",
"qs": "^6.9.1",
"screenfull": "^5.0.2",
"sortablejs": "^1.10.1",
"ua-parser-js": "^0.7.20",
@@ -39,25 +35,29 @@
},
"devDependencies": {
"@d2-projects/vue-filename-injector": "^1.1.0",
"@kazupon/vue-i18n-loader": "^0.4.1",
"@kazupon/vue-i18n-loader": "^0.5.0",
"@vue/cli-plugin-babel": "^4.1.0",
"@vue/cli-plugin-eslint": "^4.1.0",
"@vue/cli-plugin-router": "^4.1.0",
"@vue/cli-plugin-unit-jest": "^4.1.0",
"@vue/cli-plugin-vuex": "^4.1.0",
"@vue/cli-service": "^4.1.0",
"@vue/eslint-config-standard": "^4.0.0",
"@vue/test-utils": "1.0.0-beta.29",
"@vue/eslint-config-standard": "^5.1.2",
"@vue/test-utils": "^1.0.2",
"babel-eslint": "^10.0.3",
"compression-webpack-plugin": "^3.0.1",
"cz-conventional-changelog": "3.1.0",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"cz-conventional-changelog": "^3.2.0",
"eslint": "^6.8.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-vue": "^6.2.2",
"sass": "^1.23.7",
"sass-loader": "^8.0.0",
"svg-sprite-loader": "^4.1.6",
"text-loader": "^0.0.1",
"vue-cli-plugin-i18n": "^0.6.0",
"vue-cli-plugin-i18n": "^1.0.1",
"vue-template-compiler": "^2.6.10",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-theme-color-replacer": "^1.3.3"
@@ -66,5 +66,9 @@
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"repository": {
"type": "git",
"url": "https://github.com/d2-projects/d2-admin.git"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

+14
View File
@@ -0,0 +1,14 @@
import { assign, map } from 'lodash'
import faker from 'faker/locale/zh_CN'
import { request, mock } from './service'
import * as tools from './tools'
const files = require.context('./modules', false, /\.js$/)
const generators = files.keys().map(key => files(key).default)
export default assign({}, ...map(generators, generator => generator({
request,
faker,
mock,
tools
})))
+31
View File
@@ -0,0 +1,31 @@
import { find, assign } from 'lodash'
const users = [
{ username: 'admin', password: 'admin', uuid: 'admin-uuid', name: 'Admin' },
{ username: 'editor', password: 'editor', uuid: 'editor-uuid', name: 'Editor' },
{ username: 'user1', password: 'user1', uuid: 'user1-uuid', name: 'User1' }
]
export default ({ request, faker, mock, tools }) => ({
/**
* @description 登录
* @param {Object} data 登录携带的信息
*/
SYS_USER_LOGIN (data = {}) {
// 模拟数据
mock
.onAny('/login')
.reply(config => {
const user = find(users, tools.parse(config.data))
return user
? tools.responseSuccess(assign({}, user, { token: faker.random.uuid() }))
: tools.responseError({}, '账号或密码不正确')
})
// 接口请求
return request({
url: '/login',
method: 'post',
data
})
}
})
@@ -1,7 +1,9 @@
import store from '@/store'
import axios from 'axios'
import Adapter from 'axios-mock-adapter'
import { Message } from 'element-ui'
import { get } from 'lodash'
import util from '@/libs/util'
import store from '@/store'
// 创建一个错误
function errorCreate (msg) {
@@ -34,20 +36,11 @@ function errorLog (error) {
}
// 创建一个 axios 实例
const service = axios.create({
baseURL: process.env.VUE_APP_API,
timeout: 5000 // 请求超时时间
})
const service = axios.create()
// 请求拦截器
service.interceptors.request.use(
config => {
// 在请求发送之前做一些处理
const token = util.cookies.get('token')
// 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改
config.headers['X-Token'] = token
return config
},
config => config,
error => {
// 发送失败
console.log(error)
@@ -105,4 +98,18 @@ service.interceptors.response.use(
}
)
export default service
export const mock = new Adapter(service)
export function request (config) {
const token = util.cookies.get('token')
const configDefault = {
headers: {
Authorization: token,
'Content-Type': get(config, 'headers.Content-Type', 'application/json')
},
timeout: 5000,
baseURL: process.env.VUE_APP_API,
data: {}
}
return service(Object.assign(configDefault, config))
}
-9
View File
@@ -1,9 +0,0 @@
import request from '@/plugin/axios'
export function accountLogin (data) {
return request({
url: '/login',
method: 'post',
data
})
}
+46
View File
@@ -0,0 +1,46 @@
/**
* @description 安全地解析 json 字符串
* @param {String} jsonString 需要解析的 json 字符串
* @param {String} defaultValue 默认值
*/
export function parse (jsonString = '{}', defaultValue = {}) {
let result = defaultValue
try {
result = JSON.parse(jsonString)
} catch (error) {
console.log(error)
}
return result
}
/**
* @description 接口请求返回
* @param {Any} data 返回值
* @param {String} msg 状态信息
* @param {Number} code 状态码
*/
export function response (data = {}, msg = '', code = 0) {
return [
200,
{ code, msg, data }
]
}
/**
* @description 接口请求返回 正确返回
* @param {Any} data 返回值
* @param {String} msg 状态信息
*/
export function responseSuccess (data = {}, msg = '成功') {
return response(data, msg)
}
/**
* @description 接口请求返回 错误返回
* @param {Any} data 返回值
* @param {String} msg 状态信息
* @param {Number} code 状态码
*/
export function responseError (data = {}, msg = '请求失败', code = 500) {
return response(data, msg, code)
}
+9
View File
@@ -0,0 +1,9 @@
// markdown 样式补丁
.markdown-body {
ul {
list-style: disc;
}
h1, h2 {
border-bottom: none;
}
}
+5
View File
@@ -0,0 +1,5 @@
.tree-view-wrapper.tree-view-small {
.tree-view-item {
font-size: 10px;
}
}
@@ -0,0 +1,9 @@
// vue-splitpane 样式补丁
.vue-grid-item {
&.vue-grid-placeholder {
border: 1px solid $color-border-1;
background-color: rgba(#FFF, .3);
opacity: 1;
border-radius: 4px;
}
}
@@ -0,0 +1,5 @@
// vue-splitpane 样式补丁
.splitter-pane-resizer {
background-color: $color-border-1 !important;
opacity: 1 !important;
}
+10
View File
@@ -4,6 +4,16 @@
@import '~@/assets/style/fixed/base.scss';
// 补丁 element
@import '~@/assets/style/fixed/element.scss';
// 补丁 markdown
@import '~@/assets/style/fixed/markdown.scss';
// 补丁 n-progress
@import '~@/assets/style/fixed/n-progress.scss';
// 补丁 vue-splitpane
@import '~@/assets/style/fixed/vue-splitpane.scss';
// 补丁 vue-grid-layout
@import '~@/assets/style/fixed/vue-grid-layout.scss';
// 补丁 tree-view
@import '~@/assets/style/fixed/tree-view.scss';
// 动画
@import '~@/assets/style/animate/vue-transition.scss';
@@ -0,0 +1,2 @@
@import './setting.scss';
@import '../theme.scss';
@@ -0,0 +1,64 @@
// 主题名称
$theme-name: 'element';
// 主题背景颜色
$theme-bg-color: #314255;
// 主题背景图片遮罩
$theme-bg-mask: rgba(#000, 0);
// 消息提示
$theme-message-info-background-color: #FFFFFF;
$theme-message-info-text-color: #202D3D;
$theme-message-info-border-color: #202D3D;
// container组件
$theme-container-background-color: rgba(#FFF, 1);
$theme-container-header-footer-background-color: #FFF;
$theme-container-border-inner: 1px solid #CFD7E5;
$theme-container-border-outer: 1px solid #011527;
$theme-multiple-page-control-color: #BFCBD9;
$theme-multiple-page-control-color-active: #46A0FC;
$theme-multiple-page-control-nav-prev-color: #BFCBD9;
$theme-multiple-page-control-nav-next-color: #BFCBD9;
$theme-multiple-page-control-border-color: #011527;
$theme-multiple-page-control-border-color-active: #FFFFFF;
$theme-multiple-page-control-background-color: #212D3D;
$theme-multiple-page-control-background-color-active: #FFFFFF;
// 顶栏和侧边栏中展开的菜单 hover 状态下
$theme-menu-item-color-hover: #BFCBD9;
$theme-menu-item-background-color-hover: #011527;
// 顶栏上的文字颜色
$theme-header-item-color: #BFCBD9;
$theme-header-item-background-color: transparent;
// 顶栏上的项目在 hover 时
$theme-header-item-color-hover: #BFCBD9;
$theme-header-item-background-color-hover: #011527;
// 顶栏上的项目在 focus 时
$theme-header-item-color-focus: #BFCBD9;
$theme-header-item-background-color-focus: #202D3D;
// 顶栏上的项目在 active 时
$theme-header-item-color-active: #46A0FC;
$theme-header-item-background-color-active: #202D3D;
// 侧边栏上的文字颜色
$theme-aside-item-color: #BFCBD9;
$theme-aside-item-background-color: transparent;
// 侧边栏上的项目在 hover 时
$theme-aside-item-color-hover: #BFCBD9;
$theme-aside-item-background-color-hover: #011527;
// 侧边栏上的项目在 focus 时
$theme-aside-item-color-focus: #BFCBD9;
$theme-aside-item-background-color-focus: #202D3D;
// 侧边栏上的项目在 active 时
$theme-aside-item-color-active: #46A0FC;
$theme-aside-item-background-color-active: #202D3D;
// 侧边栏菜单为空的时候显示的元素
$theme-aside-menu-empty-icon-color: #BFCBD9;
$theme-aside-menu-empty-text-color: #BFCBD9;
$theme-aside-menu-empty-background-color: #202D3D;
$theme-aside-menu-empty-icon-color-hover: #46A0FC;
$theme-aside-menu-empty-text-color-hover: #46A0FC;
$theme-aside-menu-empty-background-color-hover: #202D3D;
+1
View File
@@ -2,6 +2,7 @@
@import '~@/assets/style/theme/d2/index.scss';
@import '~@/assets/style/theme/chester/index.scss';
@import '~@/assets/style/theme/element/index.scss';
@import '~@/assets/style/theme/line/index.scss';
@import '~@/assets/style/theme/star/index.scss';
@import '~@/assets/style/theme/tomorrow-night-blue/index.scss';
@@ -66,25 +66,10 @@ export default {
value: e.fullTitle,
...e
})) : this.results
}
},
methods: {
/**
* @description 过滤选项 这个方法在每次输入框的值发生变化时会触发
*/
querySearch (queryString, callback) {
var pool = this.pool
const results = this.query(queryString ? pool : [], queryString)
this.results = results
callback(results)
},
/**
* @description 指定的数据源中根据指定的查询字符串过滤数据
* @param {Object} pool 需要过滤的数据
* @param {String} queryString 查询字符串
*/
query (pool, queryString) {
return new Fuse(pool, {
// 根据 pool 更新 fuse 实例
fuse () {
return new Fuse(this.pool, {
shouldSort: true,
tokenize: true,
threshold: 0.6,
@@ -97,11 +82,16 @@ export default {
'path'
]
})
.search(queryString)
.map(e => ({
value: e.fullTitle,
...e
}))
}
},
methods: {
/**
* @description 过滤选项 这个方法在每次输入框的值发生变化时会触发
*/
querySearch (queryString, callback) {
const results = this.fuse.search(queryString).map(e => e.item)
this.results = results
callback(results)
},
/**
* @description 聚焦输入框
+1 -1
View File
@@ -9,7 +9,7 @@ const cookies = {}
* @param {Object} setting cookie setting
*/
cookies.set = function (name = 'default', value = '', cookieSetting = {}) {
let currentCookieSetting = {
const currentCookieSetting = {
expires: 1
}
Object.assign(currentCookieSetting, cookieSetting)
+2 -2
View File
@@ -6,8 +6,8 @@ export default {
if (process.env.VUE_APP_BUILD_MODE === 'PREVIEW') {
message = [
`当前语言:${this.$t('_name')} [ ${this.$i18n.locale} ]`,
`仅提供切换功能,没有配置具体的语言数据 `,
`文档参考:<a class="el-link el-link--primary is-underline" target="_blank" href="https://d2.pub/zh/doc/d2-admin/locales">《国际化 | D2Admin》</a>`
'仅提供切换功能,没有配置具体的语言数据 ',
'文档参考:<a class="el-link el-link--primary is-underline" target="_blank" href="https://d2.pub/zh/doc/d2-admin/locales">《国际化 | D2Admin》</a>'
].join('<br/>')
}
this.$notify({
-31
View File
@@ -1,31 +0,0 @@
const userDB = [
{ username: 'admin', password: 'admin', uuid: 'admin-uuid', name: 'Admin' },
{ username: 'editor', password: 'editor', uuid: 'editor-uuid', name: 'Editor' },
{ username: 'user1', password: 'user1', uuid: 'user1-uuid', name: 'User1' }
]
export default [
{
path: '/api/login',
method: 'post',
handle ({ body }) {
const user = userDB.find(e => e.username === body.username && e.password === body.password)
if (user) {
return {
code: 0,
msg: '登录成功',
data: {
...user,
token: '8dfhassad0asdjwoeiruty'
}
}
} else {
return {
code: 401,
msg: '用户名或密码错误',
data: {}
}
}
}
}
]
-73
View File
@@ -1,73 +0,0 @@
import Mock from 'mockjs'
import qs from 'qs'
import withCredentials from './patch/withCredentials'
/* 补丁 */
withCredentials(Mock)
/* Mock 默认配置 */
Mock.setup({ timeout: '200-300' })
/* 扩展 [生成器] */
const Generator = (prop, template) => {
const obj = {}
obj[prop] = [template]
return Mock.mock(obj)
}
/* 扩展 [循环] */
const Repeat = (num, itemTemplate) => Generator(`data|${num}`, itemTemplate).data
const CustomExtends = {
Generator,
Repeat,
Mock,
Random: Mock.Random
}
const extend = (prop, value) => {
CustomExtends[prop] = value
}
/* 装配配置组 */
const wired = ({ url, type, body }) => ({
method: type,
params: qs.parse(url.split('?').length > 1 ? url.split('?')[1] : ''),
body: JSON.parse(body),
url: qs.parse(url.split('?')[0]),
...CustomExtends
})
const setup = (path, method, handle) => {
Mock.mock(
RegExp(path),
method,
typeof handle === 'function' ? o => handle(wired(o)) : handle
)
}
const load = (collection) => {
collection.map(({ path, method, handle }) => {
if (method === '*') {
method = [
'get',
'head',
'post',
'put',
'delete',
'connect',
'options',
'trace',
'patch'
]
}
if (typeof method === 'string' && method.indexOf('|') > -1) method = method.split('|')
if (method instanceof Array) {
method.map(item => setup(path, item, handle))
} else {
setup(path, method, handle)
}
})
}
export default { setup, load, extend }
-14
View File
@@ -1,14 +0,0 @@
export default function (Mock) {
// http://cnine.me/note/FrontEnd/mock-lose-cookies-dbg.html
Mock.XHR.prototype.__send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function () {
if (this.custom.xhr) {
this.custom.xhr.withCredentials = this.withCredentials || false
// https://github.com/d2-projects/d2-admin/issues/254
if (!this.custom.async) {
this.custom.xhr.responseType = this.responseType
}
}
this.__send.apply(this, arguments)
}
}
-10
View File
@@ -1,10 +0,0 @@
import d2Mock from './d2-mock'
const req = context => context.keys().map(context)
const options = req(require.context('./api/', true, /\.js$/))
.filter(e => e.default)
.map(e => e.default)
options.forEach(option => {
d2Mock.load(option)
})
+7
View File
@@ -0,0 +1,7 @@
import api from '@/api'
export default {
install (Vue) {
Vue.prototype.$api = api
}
}
+2
View File
@@ -11,6 +11,7 @@ import '@/assets/svg-icons'
import i18n from '@/i18n.js'
// 功能插件
import pluginApi from '@/plugin/api'
import pluginError from '@/plugin/error'
import pluginLog from '@/plugin/log'
import pluginOpen from '@/plugin/open'
@@ -33,6 +34,7 @@ export default {
i18n: (key, value) => i18n.t(key, value)
})
// 插件
Vue.use(pluginApi)
Vue.use(pluginError)
Vue.use(pluginLog)
Vue.use(pluginOpen)
+35 -9
View File
@@ -1,28 +1,54 @@
import { get, isObject } from 'lodash'
import store from '@/store'
import util from '@/libs/util'
export default {
install (Vue, options) {
Vue.config.errorHandler = function (error, instance, info) {
function writeLog (logType) {
return (error, vm, info = '') => {
Vue.nextTick(() => {
// store 追加 log
store.dispatch('d2admin/log/push', {
message: `${info}: ${error.message}`,
type: 'danger',
message: `${info}: ${isObject(error) ? error.message : error}`,
type: logType,
meta: {
error,
instance
vm
}
})
// 只在开发模式下打印 log
if (process.env.NODE_ENV === 'development') {
util.log.capsule('D2Admin', 'ErrorHandler', 'danger')
if (process.env.NODE_ENV !== 'development') return
util.log.capsule('D2Admin', 'ErrorHandler', logType)
util.log.danger('>>>>>> 错误信息 >>>>>>')
console.log(info)
util.log.danger('>>>>>> Vue 实例 >>>>>>')
console.log(instance)
console.log(vm)
util.log.danger('>>>>>> Error >>>>>>')
console.log(error)
})
}
}
if (process.env.NODE_ENV === 'development') {
Vue.config.warnHandler = writeLog('warning')
}
Vue.config.errorHandler = writeLog('danger')
window.onunhandledrejection = error => {
store.dispatch('d2admin/log/push', {
message: get(error, 'reason.message', 'Unknown error'),
type: 'danger',
meta: {
error: get(error, 'reason'),
trace: get(error, 'reason.stack')
}
})
}
window.onerror = (event, source, lineno, colno, error) => {
store.dispatch('d2admin/log/push', {
message: get(error, 'message', 'Unknown error'),
type: 'danger',
meta: {
error,
trace: get(error, 'stack'),
source: `${source}@${lineno}:${colno}`,
event: event
}
})
}
+5
View File
@@ -42,6 +42,11 @@ export default {
name: 'chester',
preview: 'image/theme/chester/preview@2x.png'
},
{
title: 'Element',
name: 'element',
preview: 'image/theme/element/preview@2x.png'
},
{
title: '紫罗兰',
name: 'violet',
+2 -2
View File
@@ -1,7 +1,7 @@
import { Message, MessageBox } from 'element-ui'
import util from '@/libs/util.js'
import router from '@/router'
import { accountLogin } from '@api/sys.login'
import api from '@/api'
export default {
namespaced: true,
@@ -17,7 +17,7 @@ export default {
username = '',
password = ''
} = {}) {
const res = await accountLogin({ username, password })
const res = await api.SYS_USER_LOGIN({ username, password })
// 设置 cookie 一定要存 uuid 和 token 两个 cookie
// 整个系统依赖这两个数据进行校验和存储
// uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
+7 -7
View File
@@ -93,7 +93,7 @@ export default {
*/
async openedUpdate ({ state, commit, dispatch }, { index, params, query, fullPath }) {
// 更新页面列表某一项
let page = state.opened[index]
const page = state.opened[index]
page.params = params || page.params
page.query = query || page.query
page.fullPath = fullPath || page.fullPath
@@ -109,7 +109,7 @@ export default {
*/
async openedSort ({ state, commit, dispatch }, { oldIndex, newIndex }) {
// 重排页面列表某一项
let page = state.opened[oldIndex]
const page = state.opened[oldIndex]
state.opened.splice(oldIndex, 1)
state.opened.splice(newIndex, 0, page)
// 持久化
@@ -123,7 +123,7 @@ export default {
*/
async add ({ state, commit, dispatch }, { tag, params, query, fullPath }) {
// 设置新的 tag 在新打开一个以前没打开过的页面时使用
let newTag = tag
const newTag = tag
newTag.params = params || newTag.params
newTag.query = query || newTag.query
newTag.fullPath = fullPath || newTag.fullPath
@@ -142,7 +142,7 @@ export default {
*/
async open ({ state, commit, dispatch }, { name, params, query, fullPath, meta }) {
// 已经打开的页面
let opened = state.opened
const opened = state.opened
// 判断此页面是否已经打开 并且记录位置
let pageOpendIndex = 0
const pageOpend = opened.find((page, index) => {
@@ -160,7 +160,7 @@ export default {
})
} else {
// 页面以前没有打开过
let page = state.pool.find(t => t.name === name)
const page = state.pool.find(t => t.name === name)
// 如果这里没有找到 page 代表这个路由虽然在框架内 但是不参与标签页显示
if (page) {
await dispatch('add', {
@@ -189,7 +189,7 @@ export default {
// 如果关闭的页面就是当前显示的页面
if (isCurrent) {
// 去找一个新的页面
let len = state.opened.length
const len = state.opened.length
for (let i = 0; i < len; i++) {
if (state.opened[i].fullPath === tagName) {
newPage = i < len - 1 ? state.opened[i + 1] : state.opened[i - 1]
@@ -210,7 +210,7 @@ export default {
// 决定最后停留的页面
if (isCurrent) {
const { name = 'index', params = {}, query = {} } = newPage
let routerObj = { name, params, query }
const routerObj = { name, params, query }
await router.push(routerObj)
}
},
+1 -1
View File
@@ -41,7 +41,7 @@ export default {
*/
async load ({ state, commit, dispatch }) {
// store 赋值
let activeName = await dispatch('d2admin/db/get', {
const activeName = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'theme.activeName',
defaultValue: state.list[0].name,
@@ -24,10 +24,10 @@ export default {
{ img: 'https://img.shields.io/github/last-commit/d2-projects/d2-admin.svg', link: linkD2Admin }
],
[
{ img: 'https://github.com/d2-projects/d2-admin-start-kit/workflows/Deploy%20https%3A%2F%2Fd2.pub/badge.svg', link: `${linkD2Admin}/actions?query=workflow%3A%22Deploy+https%3A%2F%2Fd2.pub%22` },
{ img: 'https://github.com/d2-projects/d2-admin-start-kit/workflows/Deploy%20https%3A%2F%2Fcdn.d2.pub/badge.svg', link: `${linkD2Admin}/actions?query=workflow%3A%22Deploy+https%3A%2F%2Fcdn.d2.pub%22` },
{ img: 'https://github.com/d2-projects/d2-admin-start-kit/workflows/Deploy%20Github/badge.svg', link: `${linkD2Admin}/actions?query=workflow%3A%22Deploy+Github%22` },
{ img: 'https://api.netlify.com/api/v1/badges/08ff8c93-f0a8-497a-a081-440b31fb3aa4/deploy-status', link: 'https://app.netlify.com/sites/d2-admin-start-kit/deploys' }
{ img: 'https://github.com/d2-projects/d2-admin/workflows/Deploy%20https%3A%2F%2Fd2.pub/badge.svg', link: `${linkD2Admin}/actions?query=workflow%3A%22Deploy+https%3A%2F%2Fd2.pub%22` },
{ img: 'https://github.com/d2-projects/d2-admin/workflows/Deploy%20https%3A%2F%2Fcdn.d2.pub/badge.svg', link: `${linkD2Admin}/actions?query=workflow%3A%22Deploy+https%3A%2F%2Fcdn.d2.pub%22` },
{ img: 'https://github.com/d2-projects/d2-admin/workflows/Deploy%20Github/badge.svg', link: `${linkD2Admin}/actions?query=workflow%3A%22Deploy+Github%22` },
{ img: 'https://api.netlify.com/api/v1/badges/a5dd4bbd-da3f-4145-98a9-8012577bdcf5/deploy-status', link: 'https://app.netlify.com/sites/d2-admin/deploys' }
],
[
{ img: 'https://visitor-count-badge.herokuapp.com/today.svg?repo_id=d2-projects.d2-admin', link: linkD2Admin },
-5
View File
@@ -36,11 +36,6 @@ export default {
D2Badge,
D2Help,
D2PageCover
},
data () {
return {
filename: __filename
}
}
}
</script>
+4 -13
View File
@@ -3,7 +3,7 @@ const VueFilenameInjector = require('@d2-projects/vue-filename-injector')
const ThemeColorReplacer = require('webpack-theme-color-replacer')
const forElementUI = require('webpack-theme-color-replacer/forElementUI')
const cdnDependencies = require('./dependencies-cdn')
const { chain, set, each, keys } = require('lodash')
const { chain, set, each } = require('lodash')
// 拼接路径
const resolve = dir => require('path').join(__dirname, dir)
@@ -13,10 +13,10 @@ process.env.VUE_APP_VERSION = require('./package.json').version
process.env.VUE_APP_BUILD_TIME = require('dayjs')().format('YYYY-M-D HH:mm:ss')
// 基础路径 注意发布之前要先修改这里
let publicPath = process.env.VUE_APP_PUBLIC_PATH || '/'
const publicPath = process.env.VUE_APP_PUBLIC_PATH || '/'
// 设置不参与构建的库
let externals = {}
const externals = {}
cdnDependencies.forEach(pkg => { externals[pkg.name] = pkg.library })
// 引入文件的 cdn 链接
@@ -44,7 +44,7 @@ module.exports = {
loaderOptions: {
// 设置 scss 公用变量文件
sass: {
prependData: `@import '~@/assets/style/public.scss';`
prependData: '@import \'~@/assets/style/public.scss\';'
}
}
},
@@ -145,15 +145,6 @@ module.exports = {
// 重新设置 alias
config.resolve.alias
.set('@api', resolve('src/api'))
// 判断环境加入模拟数据
// 已适配多页
if (process.env.VUE_APP_BUILD_MODE !== 'NOMOCK') {
const multiEntry = keys(pages || {})
const entries = multiEntry.length ? multiEntry : ['app']
each(entries, entry => {
config.entry(entry).add('@/mock').end()
})
}
// 分析工具
if (process.env.npm_config_report) {
config
+569 -546
View File
File diff suppressed because it is too large Load Diff