diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ea6e20f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..ee9f76f --- /dev/null +++ b/.env.development @@ -0,0 +1,7 @@ +ENV = 'development' + +# 上下文 +VUE_APP_CONTEXT_PATH = '/' + +# 接口地址 +VUE_APP_BASE_API = 'http://localhost:7330' diff --git a/.gitignore b/.gitignore index b9a5fa8..65e6414 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ package-lock.json /public/ /.idea/ +/dist/ diff --git a/package.json b/package.json index efec2a6..f146115 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,9 @@ "element-ui": "^2.15.6", "js-cookie": "^2.2.0", "nprogress": "^0.2.0", + "sass-loader": "^10.0.5", + "node-sass": "^7.0.3", + "normalize.css": "7.0.0", "vue": "^2.6.11", "vue-router": "^3.5.2", "vuex": "^3.6.2" @@ -24,7 +27,8 @@ "babel-eslint": "^10.1.0", "eslint": "^6.7.2", "eslint-plugin-vue": "^6.2.2", - "vue-template-compiler": "^2.6.11" + "vue-template-compiler": "^2.6.11", + "path-to-regexp": "^6.2.0" }, "eslintConfig": { "root": true, diff --git a/src/App.vue b/src/App.vue index 7470183..986874c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,6 @@ @@ -13,12 +13,14 @@ export default { diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue new file mode 100644 index 0000000..5b91be1 --- /dev/null +++ b/src/layout/components/AppMain.vue @@ -0,0 +1,18 @@ + + + diff --git a/src/layout/components/background/index.vue b/src/layout/components/background/index.vue new file mode 100644 index 0000000..20d478d --- /dev/null +++ b/src/layout/components/background/index.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/src/layout/components/footer.vue b/src/layout/components/footer.vue new file mode 100644 index 0000000..196c888 --- /dev/null +++ b/src/layout/components/footer.vue @@ -0,0 +1,33 @@ + + + + + diff --git a/src/layout/components/navbar/index.vue b/src/layout/components/navbar/index.vue new file mode 100644 index 0000000..23913b5 --- /dev/null +++ b/src/layout/components/navbar/index.vue @@ -0,0 +1,131 @@ + + + + + diff --git a/src/layout/index.vue b/src/layout/index.vue new file mode 100644 index 0000000..424c925 --- /dev/null +++ b/src/layout/index.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/src/main.js b/src/main.js index a64b5ac..25d81ea 100644 --- a/src/main.js +++ b/src/main.js @@ -1,12 +1,17 @@ import Vue from 'vue' import App from './App.vue' import store from "@/store"; +import ElementUI from 'element-ui' +import 'element-ui/lib/theme-chalk/index.css' +import router from './router' +import '@/style/index.scss' // 全局样式 +import '@/router/beforce' -Vue.config.productionTip = false - +Vue.use(ElementUI) new Vue({ - el: '#app', - render: h => h(App), - store -}).$mount('#app') + el: '#app', + render: h => h(App), + router, + store +}) diff --git a/src/router/beforce.js b/src/router/beforce.js new file mode 100644 index 0000000..a26526e --- /dev/null +++ b/src/router/beforce.js @@ -0,0 +1,19 @@ +import router from './index' +import NProgress from 'nprogress' // progress bar +import 'nprogress/nprogress.css' // progress bar style +import getPageTitle from '@/utils/get-page-title' + + +router.beforeEach(async (to, from, next) => { + // start progress bar + NProgress.start() + + // set page title + document.title = getPageTitle(to.meta.title) + next() +}) + +router.afterEach(() => { + // finish progress bar + NProgress.done() +}) diff --git a/src/router/index.js b/src/router/index.js new file mode 100644 index 0000000..7e6f6cd --- /dev/null +++ b/src/router/index.js @@ -0,0 +1,73 @@ +import Vue from "vue"; +import VueRouter from "vue-router"; +import Layout from "@/layout"; + +Vue.use(VueRouter) + +export const routes = [ + { + path: '', + component: Layout, + children: [{ + path: '/', + name: 'Home', + component: () => import('@/views/home/index'), + meta: {title: '首页', icon: 'dashboard'} + }] + }, + { + path: '', + component: Layout, + children: [{ + path: '/soui', + name: 'SoUI', + component: () => import('@/views/soui/index'), + meta: {title: 'SoUI', icon: 'dashboard'} + }] + }, + { + path: '', + component: Layout, + children: [{ + path: '/demo', + name: 'SoDemo', + component: () => import('@/views/sodemo/index'), + meta: {title: '灵魂演示', icon: 'dashboard'} + }] + }, + // { + // path: '', + // component: Layout, + // meta: {title: '多菜单测试', icon: 'dashboard'}, + // children: [{ + // path: '/a', + // name: 'a', + // component: () => import('@/views/sodemo/index'), + // meta: {title: '菜单1', icon: 'dashboard'} + // },{ + // path: '/b', + // name: 'b', + // component: () => import('@/views/sodemo/index'), + // meta: {title: '菜单2', icon: 'dashboard'} + // }] + // }, +] + +const createRouter = () => new VueRouter({ + base: process.env.VUE_APP_CONTEXT_PATH || '/', + mode: 'history', // require service support + scrollBehavior: () => ({y: 0}), + routes: routes +}) + +const router = createRouter() + +// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 +export function resetRouter() { + const newRouter = createRouter() + router.matcher = newRouter.matcher // reset router +} + +export default router + + diff --git a/src/settings.js b/src/settings.js new file mode 100644 index 0000000..a4cb981 --- /dev/null +++ b/src/settings.js @@ -0,0 +1,8 @@ +module.exports = { + + title: 'soul2', + + // 启动时自动打开url + autoOpenBrowser: false + +} diff --git a/src/store/getters.js b/src/store/getters.js index 1bde25e..01c12b8 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -1,5 +1,5 @@ const getters = { - routes: state => state.routes + routes: state => state.menu.routes } export default getters diff --git a/src/store/index.js b/src/store/index.js index aaabb2f..10a1375 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,12 +1,15 @@ import Vue from 'vue' import Vuex from 'vuex' import getters from "@/store/getters"; +import menu from "@/store/modules/menu" Vue.use(Vuex) const store = new Vuex.Store({ - modules: {}, - getters + modules: { + menu + }, + getters }) export default store diff --git a/src/store/modules/menu.js b/src/store/modules/menu.js new file mode 100644 index 0000000..44cdc49 --- /dev/null +++ b/src/store/modules/menu.js @@ -0,0 +1,16 @@ +import {routes} from '@/router' + +const state = { + routes +} + +const mutations = {} + +const actions = {} + +export default { + namespaced: true, + state, + mutations, + actions +} diff --git a/src/style/index.scss b/src/style/index.scss new file mode 100644 index 0000000..8a51b70 --- /dev/null +++ b/src/style/index.scss @@ -0,0 +1,80 @@ +@import "./transition.scss"; + +* { + margin: 0; + padding: 0; +} + +body { + height: 100%; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + text-rendering: optimizeLegibility; + font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, + Microsoft YaHei, Arial, sans-serif; + box-sizing: border-box; + margin: 0; +} + +html { + height: 100%; + box-sizing: border-box; +} + +#app { + height: 100%; + text-align: center; + box-sizing: border-box; +} + +// main-container global css +.app-container { + position: relative; + padding: 20px; +} + +// table-operate-container global css +.table-operate-container { + margin-top: 20px; +} + +// table-container global css +.table-container { + margin-top: 20px; +} + +// webkit内核滚动条优化(Chrome 和 Safari 浏览器) +*:hover::-webkit-scrollbar { + display: block; +} + +::-webkit-scrollbar { + display: none; + /*滚动条整体样式*/ + width: 10px; /*高宽分别对应横竖滚动条的尺寸*/ + height: 10px; +} + +::-webkit-scrollbar-thumb { + /*滚动条里面小方块*/ + border-radius: 8px; + background-color: rgba(144, 147, 153, 0.5); + -webkit-transition: 0.3s background-color; + transition: 0.3s background-color; +} + +::-webkit-scrollbar-track { + /*滚动条里面轨道*/ + /* -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); + border-radius: 6px; + background-color: rgba(144,147,153,.3); */ +} + +/* 火狐美化滚动条 */ +* { + + scrollbar-color: #c8d2e0 #f3f4f9; + /* 滑块颜色 滚动条背景颜色 */ + scrollbar-width: thin; + /* 滚动条宽度有三种:thin、auto、none */ +} diff --git a/src/style/layout/footer.scss b/src/style/layout/footer.scss new file mode 100644 index 0000000..ee36940 --- /dev/null +++ b/src/style/layout/footer.scss @@ -0,0 +1,3 @@ +//color +//备案号 +$recordNumberHover: #b79500 diff --git a/src/style/layout/variables.scss b/src/style/layout/variables.scss new file mode 100644 index 0000000..9c495e2 --- /dev/null +++ b/src/style/layout/variables.scss @@ -0,0 +1,23 @@ +// navbar +$menuText: #fff; +$menuActiveText: #ffd04b; +$subMenuActiveText: #ffd04b; + +$menuBg: #545c64; +$menuHover: #ffd04b; + +$subMenuBg: #545c64; +$subMenuHover: #ffd04b; + + +// the :export directive is the magic sauce for webpack +// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass +:export { + menuText: $menuText; + menuActiveText: $menuActiveText; + subMenuActiveText: $subMenuActiveText; + menuBg: $menuBg; + menuHover: $menuHover; + subMenuBg: $subMenuBg; + subMenuHover: $subMenuHover; +} diff --git a/src/style/transition.scss b/src/style/transition.scss new file mode 100644 index 0000000..4cb27cc --- /dev/null +++ b/src/style/transition.scss @@ -0,0 +1,48 @@ +// global transition css + +/* fade */ +.fade-enter-active, +.fade-leave-active { + transition: opacity 0.28s; +} + +.fade-enter, +.fade-leave-active { + opacity: 0; +} + +/* fade-transform */ +.fade-transform-leave-active, +.fade-transform-enter-active { + transition: all .5s; +} + +.fade-transform-enter { + opacity: 0; + transform: translateX(-30px); +} + +.fade-transform-leave-to { + opacity: 0; + transform: translateX(30px); +} + +/* breadcrumb transition */ +.breadcrumb-enter-active, +.breadcrumb-leave-active { + transition: all .5s; +} + +.breadcrumb-enter, +.breadcrumb-leave-active { + opacity: 0; + transform: translateX(20px); +} + +.breadcrumb-move { + transition: all .5s; +} + +.breadcrumb-leave-active { + position: absolute; +} diff --git a/src/utils/get-page-title.js b/src/utils/get-page-title.js new file mode 100644 index 0000000..a6de99d --- /dev/null +++ b/src/utils/get-page-title.js @@ -0,0 +1,10 @@ +import defaultSettings from '@/settings' + +const title = defaultSettings.title || 'Vue Admin Template' + +export default function getPageTitle(pageTitle) { + if (pageTitle) { + return `${pageTitle} - ${title}` + } + return `${title}` +} diff --git a/src/views/home/index.vue b/src/views/home/index.vue new file mode 100644 index 0000000..e905615 --- /dev/null +++ b/src/views/home/index.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/src/views/sodemo/index.vue b/src/views/sodemo/index.vue new file mode 100644 index 0000000..8b043ec --- /dev/null +++ b/src/views/sodemo/index.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/src/views/soui/index.vue b/src/views/soui/index.vue new file mode 100644 index 0000000..c1bb98c --- /dev/null +++ b/src/views/soui/index.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/vue.config.js b/vue.config.js new file mode 100644 index 0000000..15d6b03 --- /dev/null +++ b/vue.config.js @@ -0,0 +1,46 @@ +'use strict' +const path = require('path') +const defaultSettings = require('./src/settings.js') + +function resolve(dir) { + return path.join(__dirname, dir) +} + +const name = defaultSettings.title || '未命名标题' +const autoOpenBrowser = defaultSettings.autoOpenBrowser || false +const port = process.env.port || process.env.npm_config_port || 6810 // dev port + +module.exports = { + /** + * You will need to set publicPath if you plan to deploy your site under a sub path, + * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/, + * then publicPath should be set to "/bar/". + * In most cases please use '/' !!! + * Detail: https://cli.vuejs.org/config/#publicpath + */ + publicPath: process.env.VUE_APP_CONTEXT_PATH || '/', + outputDir: 'dist', + assetsDir: 'static', + lintOnSave: process.env.NODE_ENV === 'development', + productionSourceMap: false, + devServer: { + // disableHostCheck: true, + port: port, + open: autoOpenBrowser, + overlay: { + warnings: false, + errors: true + } + // before: require('./mock/mock-server.js') + }, + configureWebpack: { + // provide the app's title in webpack's name field, so that + // it can be accessed in index.html to inject the correct title. + name: name, + resolve: { + alias: { + '@': resolve('src') + } + } + }, +}