update to 1.8.4

This commit is contained in:
FairyEver
2020-04-19 22:20:38 +08:00
parent a56eab8486
commit d84f11ad95
29 changed files with 3873 additions and 19088 deletions
-13
View File
@@ -1,13 +0,0 @@
# 构建预览页面
# 指定构建模式
NODE_ENV=production
# 标记当前构建方式
VUE_APP_BUILD_MODE=PREVIEW
# 显示源码按钮
VUE_APP_SCOURCE_LINK=TRUE
# 部署路径
VUE_APP_PUBLIC_PATH=/d2-admin-start-kit/
-13
View File
@@ -1,13 +0,0 @@
# 构建预览页面
# 指定构建模式
NODE_ENV=production
# 标记当前构建方式
VUE_APP_BUILD_MODE=PREVIEW
# 显示源码按钮
VUE_APP_SCOURCE_LINK=TRUE
# 部署路径
VUE_APP_PUBLIC_PATH=/
+1 -1
View File
@@ -10,4 +10,4 @@ VUE_APP_BUILD_MODE=PREVIEW
VUE_APP_SCOURCE_LINK=TRUE VUE_APP_SCOURCE_LINK=TRUE
# 部署路径 # 部署路径
VUE_APP_PUBLIC_PATH=/d2-admin-start-kit/preview/ VUE_APP_PUBLIC_PATH=/
-50
View File
@@ -1,50 +0,0 @@
name: Deploy https://cdn.d2.pub
on:
push:
branches:
- master
env:
SITE: https://cdn.d2.pub/
QINIU_BUCKET: d2-cdn
DIST_FOLDER: /dist
PATH_SUFFIX: /preview
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Download qshell
run: |
wget http://devtools.qiniu.com/qshell-linux-x86-v2.4.0.zip
unzip qshell-linux-x86-v2.4.0.zip
mv qshell-linux-x86-v2.4.0 qshell
- name: Install packages
run: npm i
- name: Build
run: npm run build:preview
- name: CDN login
run: ./qshell account ${{ secrets.AK }} ${{ secrets.SK }} GITHUB_ACTION
- name: CDN upload
run: |
REPO=${GITHUB_REPOSITORY//*\//}
echo $SITE > cdnrefresh.txt
./qshell qupload2 \
--src-dir=$GITHUB_WORKSPACE$DIST_FOLDER \
--bucket=$QINIU_BUCKET \
--key-prefix=$REPO$PATH_SUFFIX/ \
--overwrite=true \
--check-exists=true \
--check-hash=true \
--check-size=true \
--rescan-local=true \
--thread-count=32
- name: CDN refresh
run: ./qshell cdnrefresh --dirs -i ./cdnrefresh.txt
-30
View File
@@ -1,30 +0,0 @@
name: Deploy https://d2.pub
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Build
run: |
npm install
npm run build:preview
- name: Deploy
uses: SamKirkland/FTP-Deploy-Action@2.0.0
env:
FTP_SERVER: ${{ secrets.FTP_SERVER }}
FTP_USERNAME: ${{ secrets.FTP_USERNAME }}
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
METHOD: sftp
PORT: ${{ secrets.FTP_PORT }}
LOCAL_DIR: dist
REMOTE_DIR: /www/d2-admin-start-kit/preview
ARGS: --delete --verbose --parallel=100
-21
View File
@@ -1,21 +0,0 @@
name: Deploy Github
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build and Deploy
uses: JamesIves/github-pages-deploy-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: dist
BUILD_SCRIPT: npm install && npm run build:github
CLEAN: true
+107
View File
@@ -0,0 +1,107 @@
name: Deploy preview
on:
push:
branches:
- master
jobs:
cdn:
name: CDN
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: bahmutov/npm-install@v1
- name: Set vue cli env
shell: bash
run: |
echo -e "\
VUE_APP_PUBLIC_PATH=/d2-admin-start-kit/preview/\
" > .env.preview.local
cat .env.preview.local | while read line
do
echo $line
done
- name: Build
run: yarn build:preview --report
- name: CDN download qshell
run: |
wget http://devtools.qiniu.com/qshell-linux-x86-v2.4.0.zip
unzip qshell-linux-x86-v2.4.0.zip
mv qshell-linux-x86-v2.4.0 qshell
- name: CDN login
run: ./qshell account ${{ secrets.AK }} ${{ secrets.SK }} GITHUB_ACTION
- name: CDN upload
run: |
./qshell qupload2 \
--src-dir=$GITHUB_WORKSPACE/dist \
--bucket=d2-cdn \
--key-prefix=${GITHUB_REPOSITORY//*\//}/preview/ \
--overwrite=true \
--check-exists=true \
--check-hash=true \
--check-size=true \
--rescan-local=true \
--thread-count=32
- name: CDN refresh
run: |
echo "https://cdn.d2.pub/${GITHUB_REPOSITORY//*\//}/preview/" > cdnrefresh.txt
./qshell cdnrefresh --dirs -i ./cdnrefresh.txt
ftp:
name: FTP
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: bahmutov/npm-install@v1
- name: Set vue cli env
shell: bash
run: |
echo -e "\
VUE_APP_PUBLIC_PATH=/d2-admin-start-kit/preview/\
" > .env.preview.local
cat .env.preview.local | while read line
do
echo $line
done
- name: Build
run: yarn build:preview --report
- name: Deploy
uses: SamKirkland/FTP-Deploy-Action@2.0.0
env:
FTP_SERVER: ${{ secrets.FTP_SERVER }}
FTP_USERNAME: ${{ secrets.FTP_USERNAME }}
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
METHOD: sftp
PORT: ${{ secrets.FTP_PORT }}
LOCAL_DIR: dist
REMOTE_DIR: /www/d2-admin-start-kit/preview
ARGS: --delete --verbose --parallel=100
gh-pages:
name: Github Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: bahmutov/npm-install@v1
- name: Set vue cli env
shell: bash
run: |
echo -e "\
VUE_APP_PUBLIC_PATH=/d2-admin-start-kit/\
" > .env.preview.local
cat .env.preview.local | while read line
do
echo $line
done
- name: Build
run: yarn build:preview --report
- name: Deploy
uses: peaceiris/actions-gh-pages@v2
env:
PERSONAL_TOKEN: ${{ secrets.ACCESS_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./dist
with:
forceOrphan: true
+22
View File
@@ -0,0 +1,22 @@
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'
]
}
]
]
}
-15036
View File
File diff suppressed because it is too large Load Diff
+5 -6
View File
@@ -1,6 +1,6 @@
{ {
"name": "d2-admin", "name": "d2-admin-start-kit",
"version": "1.8.0", "version": "1.8.4",
"scripts": { "scripts": {
"serve": "vue-cli-service serve --open", "serve": "vue-cli-service serve --open",
"start": "npm run serve", "start": "npm run serve",
@@ -8,12 +8,11 @@
"build": "vue-cli-service build", "build": "vue-cli-service build",
"build:nomock": "vue-cli-service build --mode nomock", "build:nomock": "vue-cli-service build --mode nomock",
"build:preview": "NODE_OPTIONS=--max_old_space_size=4096 vue-cli-service build --mode preview", "build:preview": "NODE_OPTIONS=--max_old_space_size=4096 vue-cli-service build --mode preview",
"build:github": "NODE_OPTIONS=--max_old_space_size=4096 vue-cli-service build --mode github",
"build:netlify": "NODE_OPTIONS=--max_old_space_size=4096 vue-cli-service build --mode netlify",
"lint": "vue-cli-service lint --fix", "lint": "vue-cli-service lint --fix",
"test:unit": "vue-cli-service test:unit", "test:unit": "vue-cli-service test:unit",
"i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'", "i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'",
"analyz": "npm_config_report=true npm run build" "analyz": "npm_config_report=true npm run build",
"commit": "git-cz"
}, },
"dependencies": { "dependencies": {
"axios": "^0.19.0", "axios": "^0.19.0",
@@ -30,7 +29,7 @@
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"qs": "^6.9.1", "qs": "^6.9.1",
"screenfull": "^5.0.0", "screenfull": "^5.0.2",
"sortablejs": "^1.10.1", "sortablejs": "^1.10.1",
"ua-parser-js": "^0.7.20", "ua-parser-js": "^0.7.20",
"vue": "^2.6.11", "vue": "^2.6.11",
@@ -1,19 +1,8 @@
<template> <template>
<div <div class="d2-contentmenu-list" @click="rowClick">
class="d2-contentmenu-list" <div v-for="item in menulist" :key="item.value" :data-value="item.value" class="d2-contentmenu-item" flex="cross:center main:center">
@click="rowClick"> <d2-icon v-if="item.icon" :name="item.icon"/>
<div <div class="d2-contentmenu-item-title" flex-box="1">
v-for="item in menulist"
:key="item.value"
:data-value="item.value"
class="d2-contentmenu-item"
flex="cross:center main:center">
<d2-icon
v-if="item.icon"
:name="item.icon"/>
<div
class="d2-contentmenu-item-title"
flex-box="1">
{{item.title}} {{item.title}}
</div> </div>
</div> </div>
@@ -1,8 +1,5 @@
<template> <template>
<div <div class="d2-contextmenu" v-show="flag" :style="style">
class="d2-contextmenu"
v-show="flag"
:style="style">
<slot/> <slot/>
</div> </div>
</template> </template>
@@ -1,8 +1,5 @@
<template> <template>
<el-tooltip <el-tooltip effect="dark" :content="active ? '退出全屏' : '全屏'" placement="bottom">
effect="dark"
:content="active ? '退出全屏' : '全屏'"
placement="bottom">
<el-button class="d2-mr btn-text can-hover" type="text" @click="toggle"> <el-button class="d2-mr btn-text can-hover" type="text" @click="toggle">
<d2-icon v-if="active" name="compress"/> <d2-icon v-if="active" name="compress"/>
<d2-icon v-else name="arrows-alt" style="font-size: 16px"/> <d2-icon v-else name="arrows-alt" style="font-size: 16px"/>
@@ -1,8 +1,5 @@
<template> <template>
<el-dropdown <el-dropdown placement="bottom" size="small" @command="onChangeLocale">
placement="bottom"
size="small"
@command="onChangeLocale">
<el-button class="d2-mr btn-text can-hover" type="text"> <el-button class="d2-mr btn-text can-hover" type="text">
<d2-icon name="language" style="font-size: 16px;"/> <d2-icon name="language" style="font-size: 16px;"/>
</el-button> </el-button>
@@ -1,25 +1,10 @@
<template> <template>
<el-tooltip <el-tooltip effect="dark" :content="tooltipContent" placement="bottom">
effect="dark" <el-button class="d2-ml-0 d2-mr btn-text can-hover" type="text" @click="handleClick">
:content="tooltipContent" <el-badge v-if="logLength > 0" :max="99" :value="logLengthError" :is-dot="logLengthError === 0">
placement="bottom"> <d2-icon :name="logLengthError === 0 ? 'dot-circle-o' : 'bug'" style="font-size: 20px"/>
<el-button
class="d2-ml-0 d2-mr btn-text can-hover"
type="text"
@click="handleClick">
<el-badge
v-if="logLength > 0"
:max="99"
:value="logLengthError"
:is-dot="logLengthError === 0">
<d2-icon
:name="logLengthError === 0 ? 'dot-circle-o' : 'bug'"
style="font-size: 20px"/>
</el-badge> </el-badge>
<d2-icon <d2-icon v-else name="dot-circle-o" style="font-size: 20px"/>
v-else
name="dot-circle-o"
style="font-size: 20px"/>
</el-button> </el-button>
</el-tooltip> </el-tooltip>
</template> </template>
@@ -1,39 +1,13 @@
<template> <template>
<el-table <el-table :data="list" v-bind="table">
:data="list" <el-table-column prop="title" align="center" width="160"/>
v-bind="table"> <el-table-column label="预览" width="120">
<el-table-column <div slot-scope="scope" class="theme-preview" :style="{ backgroundImage: `url(${$baseUrl}${scope.row.preview})` }"/>
prop="title"
align="center"
width="160"/>
<el-table-column
label="预览"
width="120">
<div
slot-scope="scope"
class="theme-preview"
:style="{
backgroundImage: `url(${$baseUrl}${scope.row.preview})`
}">
</div>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="address" align="center">
prop="address"
align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button v-if="activeName === scope.row.name" type="success" icon="el-icon-check" round>已激活</el-button>
v-if="activeName === scope.row.name" <el-button v-else round @click="handleSelectTheme(scope.row.name)">使用</el-button>
type="success"
icon="el-icon-check"
round>
已激活
</el-button>
<el-button
v-else
round
@click="handleSelectTheme(scope.row.name)">
使用
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@@ -1,6 +1,6 @@
// 创建 el-menu-item // 创建 el-menu-item
export function elMenuItem (createElement, menu) { export function elMenuItem (createElement, menu) {
return createElement('el-menu-item', { props: { index: menu.path } }, [ return createElement('el-menu-item', { key: menu.path, props: { index: menu.path } }, [
...menu.icon ? [ ...menu.icon ? [
createElement('i', { attrs: { class: `fa fa-${menu.icon}` } }) createElement('i', { attrs: { class: `fa fa-${menu.icon}` } })
] : [], ] : [],
@@ -16,7 +16,7 @@ export function elMenuItem (createElement, menu) {
// 创建 el-submenu // 创建 el-submenu
export function elSubmenu (createElement, menu) { export function elSubmenu (createElement, menu) {
return createElement('el-submenu', { props: { index: menu.path } }, [ return createElement('el-submenu', { key: menu.path, props: { index: menu.path } }, [
...menu.icon ? [ ...menu.icon ? [
createElement('i', { slot: 'title', attrs: { class: `fa fa-${menu.icon}` } }) createElement('i', { slot: 'title', attrs: { class: `fa fa-${menu.icon}` } })
] : [], ] : [],
@@ -11,7 +11,7 @@ export default {
render (createElement) { render (createElement) {
return createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-side' } }, [ return createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-side' } }, [
createElement('el-menu', { createElement('el-menu', {
props: { collapse: this.asideCollapse, uniqueOpened: true, defaultActive: this.active }, props: { collapse: this.asideCollapse, uniqueOpened: true, defaultActive: this.$route.fullPath },
ref: 'menu', ref: 'menu',
on: { select: this.handleMenuSelect } on: { select: this.handleMenuSelect }
}, this.aside.map(menu => (menu.children === undefined ? elMenuItem : elSubmenu).call(this, createElement, menu))), }, this.aside.map(menu => (menu.children === undefined ? elMenuItem : elSubmenu).call(this, createElement, menu))),
@@ -25,7 +25,6 @@ export default {
}, },
data () { data () {
return { return {
active: '',
asideHeight: 300, asideHeight: 300,
BS: null BS: null
} }
@@ -43,13 +42,6 @@ export default {
setTimeout(() => { setTimeout(() => {
this.scrollInit() this.scrollInit()
}, 500) }, 500)
},
// 监听路由 控制侧边栏激活状态
'$route.fullPath': {
handler (value) {
this.active = value
},
immediate: true
} }
}, },
mounted () { mounted () {
@@ -1,15 +1,7 @@
<template> <template>
<div <div class="panel-search" flex="dir:top">
class="panel-search" <div class="panel-search__input-group" flex-box="0" flex="dir:top main:center cross:center" @click.self="handlePanelClick">
flex="dir:top"> <d2-icon-svg class="panel-search__logo" name="d2-admin-text"/>
<div
class="panel-search__input-group"
flex-box="0"
flex="dir:top main:center cross:center"
@click.self="handlePanelClick">
<d2-icon-svg
class="panel-search__logo"
name="d2-admin-text"/>
<el-autocomplete <el-autocomplete
class="panel-search__input" class="panel-search__input"
ref="input" ref="input"
@@ -21,9 +13,7 @@
:clearable="true" :clearable="true"
@keydown.esc.native="handleEsc" @keydown.esc.native="handleEsc"
@select="handleSelect"> @select="handleSelect">
<d2-panel-search-item <d2-panel-search-item slot-scope="{ item }" :item="item"/>
slot-scope="{ item }"
:item="item"/>
</el-autocomplete> </el-autocomplete>
<div class="panel-search__tip"> <div class="panel-search__tip">
您可以使用快捷键 您可以使用快捷键
@@ -33,10 +23,7 @@
关闭 关闭
</div> </div>
</div> </div>
<div <div v-if="resultsList.length > 0" class="panel-search__results-group" flex-box="1">
v-if="resultsList.length > 0"
class="panel-search__results-group"
flex-box="1">
<el-card> <el-card>
<div class="panel-search__results-group-inner"> <div class="panel-search__results-group-inner">
<d2-panel-search-item <d2-panel-search-item
@@ -2,13 +2,8 @@
<div class="d2-multiple-page-control-group" flex> <div class="d2-multiple-page-control-group" flex>
<div class="d2-multiple-page-control-content" flex-box="1"> <div class="d2-multiple-page-control-content" flex-box="1">
<div class="d2-multiple-page-control-content-inner"> <div class="d2-multiple-page-control-content-inner">
<d2-contextmenu <d2-contextmenu :visible.sync="contextmenuFlag" :x="contentmenuX" :y="contentmenuY">
:visible.sync="contextmenuFlag" <d2-contextmenu-list :menulist="tagName === '/index' ? contextmenuListIndex : contextmenuList" @rowClick="contextmenuClick"/>
:x="contentmenuX"
:y="contentmenuY">
<d2-contextmenu-list
:menulist="tagName === '/index' ? contextmenuListIndex : contextmenuList"
@rowClick="contextmenuClick"/>
</d2-contextmenu> </d2-contextmenu>
<el-tabs <el-tabs
class="d2-multiple-page-control d2-multiple-page-sort" class="d2-multiple-page-control d2-multiple-page-sort"
@@ -18,22 +13,12 @@
@tab-click="handleClick" @tab-click="handleClick"
@edit="handleTabsEdit" @edit="handleTabsEdit"
@contextmenu.native="handleContextmenu"> @contextmenu.native="handleContextmenu">
<el-tab-pane <el-tab-pane v-for="page in opened" :key="page.fullPath" :label="page.meta.title || '未命名'" :name="page.fullPath"/>
v-for="page in opened"
:key="page.fullPath"
:label="page.meta.title || '未命名'"
:name="page.fullPath"/>
</el-tabs> </el-tabs>
</div> </div>
</div> </div>
<div <div class="d2-multiple-page-control-btn" flex-box="0">
class="d2-multiple-page-control-btn" <el-dropdown size="default" split-button @click="closeAll" @command="command => handleControlItemClick(command)">
flex-box="0">
<el-dropdown
size="default"
split-button
@click="closeAll"
@command="command => handleControlItemClick(command)">
<d2-icon name="times-circle"/> <d2-icon name="times-circle"/>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="left"> <el-dropdown-item command="left">
+7 -27
View File
@@ -1,20 +1,11 @@
<template> <template>
<div <div class="d2-layout-header-aside-group" :style="styleLayoutMainGroup" :class="{grayMode: grayActive}">
class="d2-layout-header-aside-group"
:style="styleLayoutMainGroup"
:class="{grayMode: grayActive}">
<!-- 半透明遮罩 --> <!-- 半透明遮罩 -->
<div class="d2-layout-header-aside-mask"></div> <div class="d2-layout-header-aside-mask"></div>
<!-- 主体内容 --> <!-- 主体内容 -->
<div class="d2-layout-header-aside-content" flex="dir:top"> <div class="d2-layout-header-aside-content" flex="dir:top">
<!-- 顶栏 --> <!-- 顶栏 -->
<div <div class="d2-theme-header" :style="{ opacity: this.searchActive ? 0.5 : 1 }" flex-box="0" flex>
class="d2-theme-header"
:style="{
opacity: this.searchActive ? 0.5 : 1
}"
flex-box="0"
flex>
<router-link to="/index" class="logo-group" :style="{width: asideCollapse ? asideWidthCollapse : asideWidth}" flex-box="0"> <router-link to="/index" class="logo-group" :style="{width: asideCollapse ? asideWidthCollapse : asideWidth}" flex-box="0">
<img v-if="asideCollapse" :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/icon-only.png`"> <img v-if="asideCollapse" :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/icon-only.png`">
<img v-else :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/all.png`"> <img v-else :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/all.png`">
@@ -39,14 +30,7 @@
<!-- 下面 主体 --> <!-- 下面 主体 -->
<div class="d2-theme-container" flex-box="1" flex> <div class="d2-theme-container" flex-box="1" flex>
<!-- 主体 侧边栏 --> <!-- 主体 侧边栏 -->
<div <div flex-box="0" ref="aside" class="d2-theme-container-aside" :style="{ width: asideCollapse ? asideWidthCollapse : asideWidth, opacity: this.searchActive ? 0.5 : 1 }">
flex-box="0"
ref="aside"
class="d2-theme-container-aside"
:style="{
width: asideCollapse ? asideWidthCollapse : asideWidth,
opacity: this.searchActive ? 0.5 : 1
}">
<d2-menu-side/> <d2-menu-side/>
</div> </div>
<!-- 主体 --> <!-- 主体 -->
@@ -54,9 +38,7 @@
<!-- 搜索 --> <!-- 搜索 -->
<transition name="fade-scale"> <transition name="fade-scale">
<div v-if="searchActive" class="d2-theme-container-main-layer" flex> <div v-if="searchActive" class="d2-theme-container-main-layer" flex>
<d2-panel-search <d2-panel-search ref="panelSearch" @close="searchPanelClose"/>
ref="panelSearch"
@close="searchPanelClose"/>
</div> </div>
</transition> </transition>
<!-- 内容 --> <!-- 内容 -->
@@ -136,11 +118,9 @@ export default {
* @description 最外层容器的背景图片样式 * @description 最外层容器的背景图片样式
*/ */
styleLayoutMainGroup () { styleLayoutMainGroup () {
return { return this.themeActiveSetting.backgroundImage
...this.themeActiveSetting.backgroundImage ? { ? { backgroundImage: `url('${this.$baseUrl}${this.themeActiveSetting.backgroundImage}')` }
backgroundImage: `url('${this.$baseUrl}${this.themeActiveSetting.backgroundImage}')` : {}
} : {}
}
} }
}, },
methods: { methods: {
+1 -2
View File
@@ -9,8 +9,7 @@ import store from '@/store/index'
// 菜单和路由设置 // 菜单和路由设置
import router from './router' import router from './router'
import menuHeader from '@/menu/header' import { menuHeader, menuAside } from '@/menu'
import menuAside from '@/menu/aside'
import { frameInRoutes } from '@/router/routes' import { frameInRoutes } from '@/router/routes'
// 核心插件 // 核心插件
-13
View File
@@ -1,13 +0,0 @@
// 菜单 侧边栏
export default [
{ path: '/index', title: '首页', icon: 'home' },
{
title: '页面',
icon: 'folder-o',
children: [
{ path: '/page1', title: '页面 1' },
{ path: '/page2', title: '页面 2' },
{ path: '/page3', title: '页面 3' }
]
}
]
-13
View File
@@ -1,13 +0,0 @@
// 菜单 顶栏
export default [
{ path: '/index', title: '首页', icon: 'home' },
{
title: '页面',
icon: 'folder-o',
children: [
{ path: '/page1', title: '页面 1' },
{ path: '/page2', title: '页面 2' },
{ path: '/page3', title: '页面 3' }
]
}
]
+42
View File
@@ -0,0 +1,42 @@
import { uniqueId } from 'lodash'
/**
* @description 给菜单数据补充上 path 字段
* @description https://github.com/d2-projects/d2-admin/issues/209
* @param {Array} menu 原始的菜单数据
*/
function supplementPath (menu) {
return menu.map(e => ({
...e,
path: e.path || uniqueId('d2-menu-empty-'),
...e.children ? {
children: supplementPath(e.children)
} : {}
}))
}
export const menuHeader = supplementPath([
{ path: '/index', title: '首页', icon: 'home' },
{
title: '页面',
icon: 'folder-o',
children: [
{ path: '/page1', title: '页面 1' },
{ path: '/page2', title: '页面 2' },
{ path: '/page3', title: '页面 3' }
]
}
])
export const menuAside = supplementPath([
{ path: '/index', title: '首页', icon: 'home' },
{
title: '页面',
icon: 'folder-o',
children: [
{ path: '/page1', title: '页面 1' },
{ path: '/page2', title: '页面 2' },
{ path: '/page3', title: '页面 3' }
]
}
])
+4 -1
View File
@@ -4,7 +4,10 @@ export default function (Mock) {
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
this.custom.xhr.responseType = this.responseType // https://github.com/d2-projects/d2-admin/issues/254
if (!this.custom.async) {
this.custom.xhr.responseType = this.responseType
}
} }
this.__send.apply(this, arguments) this.__send.apply(this, arguments)
} }
@@ -12,18 +12,11 @@ export default {
* @param {Object} context * @param {Object} context
*/ */
listen ({ commit }) { listen ({ commit }) {
return new Promise(resolve => { if (screenfull.isEnabled) {
if (screenfull.enabled) { screenfull.on('change', () => {
screenfull.on('change', () => { if (!screenfull.isFullscreen) commit('set', false)
console.log('1') })
if (!screenfull.isFullscreen) { }
commit('set', false)
}
})
}
// end
resolve()
})
}, },
/** /**
* @description 切换全屏 * @description 切换全屏
+27 -19
View File
@@ -3,6 +3,7 @@ const VueFilenameInjector = require('@d2-projects/vue-filename-injector')
const ThemeColorReplacer = require('webpack-theme-color-replacer') const ThemeColorReplacer = require('webpack-theme-color-replacer')
const forElementUI = require('webpack-theme-color-replacer/forElementUI') const forElementUI = require('webpack-theme-color-replacer/forElementUI')
const cdnDependencies = require('./dependencies-cdn') const cdnDependencies = require('./dependencies-cdn')
const { chain, set, each, keys } = require('lodash')
// 拼接路径 // 拼接路径
const resolve = dir => require('path').join(__dirname, dir) const resolve = dir => require('path').join(__dirname, dir)
@@ -16,7 +17,7 @@ let publicPath = process.env.VUE_APP_PUBLIC_PATH || '/'
// 设置不参与构建的库 // 设置不参与构建的库
let externals = {} let externals = {}
cdnDependencies.forEach(package => { externals[package.name] = package.library }) cdnDependencies.forEach(pkg => { externals[pkg.name] = pkg.library })
// 引入文件的 cdn 链接 // 引入文件的 cdn 链接
const cdn = { const cdn = {
@@ -24,12 +25,20 @@ const cdn = {
js: cdnDependencies.map(e => e.js).filter(e => e) js: cdnDependencies.map(e => e.js).filter(e => e)
} }
// 多页配置,默认未开启,如需要请参考 https://cli.vuejs.org/zh/config/#pages
const pages = undefined
// const pages = {
// index: './src/main.js',
// subpage: './src/subpage.js'
// }
module.exports = { module.exports = {
// 根据你的实际情况更改这里 // 根据你的实际情况更改这里
publicPath, publicPath,
lintOnSave: true, lintOnSave: true,
devServer: { devServer: {
publicPath // 和 publicPath 保持一致 publicPath, // 和 publicPath 保持一致
disableHostCheck: process.env.NODE_ENV === 'development' // 关闭 host check,方便使用 ngrok 之类的内网转发工具
}, },
css: { css: {
loaderOptions: { loaderOptions: {
@@ -39,6 +48,7 @@ module.exports = {
} }
} }
}, },
pages,
configureWebpack: config => { configureWebpack: config => {
const configNew = {} const configNew = {}
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
@@ -54,27 +64,23 @@ module.exports = {
}) })
] ]
} }
if (process.env.NODE_ENV === 'development') {
// 关闭 host check,方便使用 ngrok 之类的内网转发工具
configNew.devServer = {
disableHostCheck: true
}
}
return configNew return configNew
}, },
// 默认设置: https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-service/lib/config/base.js // 默认设置: https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-service/lib/config/base.js
chainWebpack: config => { chainWebpack: config => {
/** /**
* 添加 CDN 参数到 htmlWebpackPlugin 配置中 * 添加 CDN 参数到 htmlWebpackPlugin 配置中
* 已适配多页
*/ */
config.plugin('html').tap(args => { const htmlPluginNames = chain(pages).keys().map(page => 'html-' + page).value()
if (process.env.NODE_ENV === 'production') { const targetHtmlPluginNames = htmlPluginNames.length ? htmlPluginNames : ['html']
args[0].cdn = cdn each(targetHtmlPluginNames, name => {
} else { config.plugin(name).tap(options => {
args[0].cdn = [] set(options, '[0].cdn', process.env.NODE_ENV === 'production' ? cdn : [])
} return options
return args })
}) })
/** /**
* 删除懒加载模块的 prefetch preload,降低带宽压力 * 删除懒加载模块的 prefetch preload,降低带宽压力
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#prefetch * https://cli.vuejs.org/zh/guide/html-and-static-assets.html#prefetch
@@ -140,11 +146,13 @@ module.exports = {
config.resolve.alias config.resolve.alias
.set('@api', resolve('src/api')) .set('@api', resolve('src/api'))
// 判断环境加入模拟数据 // 判断环境加入模拟数据
const entry = config.entry('app') // 已适配多页
if (process.env.VUE_APP_BUILD_MODE !== 'NOMOCK') { if (process.env.VUE_APP_BUILD_MODE !== 'NOMOCK') {
entry const multiEntry = keys(pages || {})
.add('@/mock') const entrys = multiEntry.length ? multiEntry : ['app']
.end() each(entrys, entry => {
config.entry(entry).add('@/mock').end()
})
} }
// 分析工具 // 分析工具
if (process.env.npm_config_report) { if (process.env.npm_config_report) {
+3620 -3702
View File
File diff suppressed because it is too large Load Diff