diff --git a/src/components/d2-page-cover/index.vue b/src/components/d2-page-cover/index.vue index 63540c646..1045ef35b 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 0df33761d..be8fe9659 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 24e922ed5..22a30a3ad 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 d20a3d1c0..c24d7c040 100644 --- a/src/pages/index/page.vue +++ b/src/pages/index/page.vue @@ -1,8 +1,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 33620967d..d7a9e5c28 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 e7f8b6aa9..4e5a3534c 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 305c6a3db..698ea8765 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 4706d5a27..16e0f411b 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 = '/'