From e563d9317a376911c610135b959a9b51bf4e3a69 Mon Sep 17 00:00:00 2001
From: liyang <1711467488@qq.com>
Date: Fri, 14 Dec 2018 11:16:10 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=8E=AF=E5=A2=83=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Former-commit-id: 4dae4bb78d76f7f938f96cb7e8d70ae3e0f3ff9a [formerly 4dae4bb78d76f7f938f96cb7e8d70ae3e0f3ff9a [formerly 4dae4bb78d76f7f938f96cb7e8d70ae3e0f3ff9a [formerly 4dae4bb78d76f7f938f96cb7e8d70ae3e0f3ff9a [formerly 5e20e47a6957a82b94b57af913a9a45a58fa5281 [formerly 7b63f06f2da85d10f4df205ef81a25e2fa8a7933]]]]]
Former-commit-id: c9fce450c6afe4885d7105af2145fd597e2b7142
Former-commit-id: 837a71bd1de9152b2f22c7d2b310e6ab690cf563
Former-commit-id: e801081f67155ea604b9fbcfa8fb5f935d44189c [formerly d46bd2dfc6214d15783c2c9d1cf31e2ba8326ea7]
Former-commit-id: 43308d8ac292147918a94fcc23c20f992cf3f4f6
Former-commit-id: 5c2e21a21d6dbc1628f0aedd2366f6a96184c428
Former-commit-id: 8ac1d58beb3d54e8674e900cf0c9b15110eb8ed5
Former-commit-id: 9fee2dfe7f53f06b403f7a6a9a9d6585517d9518
Former-commit-id: d1971ac9f64902e97f4173008c87882e5a026496
---
src/components/d2-page-cover/index.vue | 35 ++++++++-----------
src/libs/db.js | 3 +-
src/libs/util.cookies.js | 7 ++--
src/pages/index/page.vue | 12 ++-----
src/plugin/d2admin/index.js | 7 +++-
src/setting.js | 6 ----
src/store/modules/d2admin/modules/releases.js | 9 ++---
vue.config.js | 4 +++
8 files changed, 33 insertions(+), 50 deletions(-)
diff --git a/src/components/d2-page-cover/index.vue b/src/components/d2-page-cover/index.vue
index 63540c64..1045ef35 100644
--- a/src/components/d2-page-cover/index.vue
+++ b/src/components/d2-page-cover/index.vue
@@ -3,8 +3,9 @@
- {{title}}
- {{subTitle}}
+ D2 Admin {{$version}}
+ 优雅的中后台集成方案
+ FINAL BUILD TIME {{$buildTime}}
-
-
diff --git a/src/libs/db.js b/src/libs/db.js
index 0df33761..be8fe965 100644
--- a/src/libs/db.js
+++ b/src/libs/db.js
@@ -1,8 +1,7 @@
import low from 'lowdb'
import LocalStorage from 'lowdb/adapters/LocalStorage'
-import setting from '@/setting.js'
-const adapter = new LocalStorage(`d2admin-${setting.releases.version}`)
+const adapter = new LocalStorage(`d2admin-${process.env.VUE_APP_VERSION}`)
const db = low(adapter)
db
diff --git a/src/libs/util.cookies.js b/src/libs/util.cookies.js
index 24e922ed..22a30a3a 100644
--- a/src/libs/util.cookies.js
+++ b/src/libs/util.cookies.js
@@ -1,5 +1,4 @@
import Cookies from 'js-cookie'
-import setting from '@/setting.js'
const cookies = {}
@@ -14,7 +13,7 @@ cookies.set = function (name = 'default', value = '', cookieSetting = {}) {
expires: 1
}
Object.assign(currentCookieSetting, cookieSetting)
- Cookies.set(`d2admin-${setting.releases.version}-${name}`, value, currentCookieSetting)
+ Cookies.set(`d2admin-${process.env.VUE_APP_VERSION}-${name}`, value, currentCookieSetting)
}
/**
@@ -22,7 +21,7 @@ cookies.set = function (name = 'default', value = '', cookieSetting = {}) {
* @param {String} name cookie name
*/
cookies.get = function (name = 'default') {
- return Cookies.get(`d2admin-${setting.releases.version}-${name}`)
+ return Cookies.get(`d2admin-${process.env.VUE_APP_VERSION}-${name}`)
}
/**
@@ -37,7 +36,7 @@ cookies.getAll = function () {
* @param {String} name cookie name
*/
cookies.remove = function (name = 'default') {
- return Cookies.remove(`d2admin-${setting.releases.version}-${name}`)
+ return Cookies.remove(`d2admin-${process.env.VUE_APP_VERSION}-${name}`)
}
export default cookies
diff --git a/src/pages/index/page.vue b/src/pages/index/page.vue
index d20a3d1c..c24d7c04 100644
--- a/src/pages/index/page.vue
+++ b/src/pages/index/page.vue
@@ -1,8 +1,6 @@
-
+
@@ -35,7 +33,6 @@
@@ -64,7 +56,7 @@ export default {
.page__btn-group {
color: $color-text-placehoder;
font-size: 12px;
- margin-top: -10px;
+ margin-top: 0px;
margin-bottom: 20px;
span {
color: $color-text-sub;
diff --git a/src/plugin/d2admin/index.js b/src/plugin/d2admin/index.js
index 33620967..d7a9e5c2 100644
--- a/src/plugin/d2admin/index.js
+++ b/src/plugin/d2admin/index.js
@@ -16,12 +16,17 @@ import pluginOpen from '@/plugin/open'
export default {
async install (Vue, options) {
- // 设置为 false 以阻止 vue 在启动时生成生产提示。https://cn.vuejs.org/v2/api/#productionTip
+ // 设置为 false 以阻止 vue 在启动时生成生产提示
+ // https://cn.vuejs.org/v2/api/#productionTip
Vue.config.productionTip = false
// 当前环境
Vue.prototype.$env = process.env.NODE_ENV
// 当前的 baseUrl
Vue.prototype.$baseUrl = process.env.BASE_URL
+ // 当前版本
+ Vue.prototype.$version = process.env.VUE_APP_VERSION
+ // 构建时间
+ Vue.prototype.$buildTime = process.env.VUE_APP_BUILD_TIME
// Element
Vue.use(ElementUI)
// 插件
diff --git a/src/setting.js b/src/setting.js
index e7f8b6aa..4e5a3534 100644
--- a/src/setting.js
+++ b/src/setting.js
@@ -1,5 +1,3 @@
-import { version } from '../package'
-
export default {
// 快捷键
// 支持快捷键 例如 ctrl+shift+s
@@ -26,10 +24,6 @@ export default {
}
]
},
- // 版本
- releases: {
- version
- },
// 菜单搜索
search: {
enable: true
diff --git a/src/store/modules/d2admin/modules/releases.js b/src/store/modules/d2admin/modules/releases.js
index 305c6a3d..698ea876 100644
--- a/src/store/modules/d2admin/modules/releases.js
+++ b/src/store/modules/d2admin/modules/releases.js
@@ -1,19 +1,14 @@
import util from '@/libs/util.js'
-import setting from '@/setting.js'
export default {
namespaced: true,
- state: {
- // D2Admin 版本
- version: setting.releases.version
- },
mutations: {
/**
* @description 显示版本信息
* @param {Object} state vuex state
*/
- versionShow (state) {
- util.log.capsule('D2Admin', `v${state.version}`)
+ versionShow () {
+ util.log.capsule('D2Admin', `v${process.env.VUE_APP_VERSION}`)
console.log('Github https://github.com/d2-projects/d2-admin')
console.log('Doc https://doc.d2admin.fairyever.com/zh/')
console.log('请不要吝啬您的 star,谢谢 ~')
diff --git a/vue.config.js b/vue.config.js
index 4706d5a2..16e0f411 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -3,6 +3,10 @@ const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
// 拼接路径
const resolve = dir => require('path').join(__dirname, dir)
+// 增加环境变量
+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 baseUrl = '/'