diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..64b2c57 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,17 @@ +module.exports = { + root: true, + env: { + node: true + }, + 'extends': [ + 'plugin:vue/essential', + // 'eslint:recommended' + ], + rules: { + 'no-console': process.env.NODE_ENV === 'production' ? 'off' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'off' : 'off' + }, + parserOptions: { + parser: 'babel-eslint' + } +} diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..c40365d --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target":"es6", + "baseUrl": ".", + "allowSyntheticDefaultImports": true, + "paths": { + "@/*": ["./src/*"] , + "com/*":["./src/components/*"] + } + }, + // "exclude": ["node_modules"] +} \ No newline at end of file diff --git a/package.json b/package.json index 7511c0c..2a8048e 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,11 @@ "lint": "vue-cli-service lint" }, "dependencies": { + "ant-design-vue": "^1.7.0", "core-js": "^3.6.5", - "vue": "^2.6.11" + "vue": "^2.6.11", + "vue-router": "^3.4.8", + "vuex": "^3.5.1" }, "devDependencies": { "@vue/cli-plugin-babel": "~4.5.0", diff --git a/src/App.vue b/src/App.vue index 55df315..3368af0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,19 +1,11 @@ diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue deleted file mode 100644 index 879051a..0000000 --- a/src/components/HelloWorld.vue +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - diff --git a/src/components/Login.vue b/src/components/Login.vue new file mode 100644 index 0000000..17bcab3 --- /dev/null +++ b/src/components/Login.vue @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/src/components/Main.vue b/src/components/Main.vue new file mode 100644 index 0000000..6f5aac1 --- /dev/null +++ b/src/components/Main.vue @@ -0,0 +1,33 @@ + + + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 63eb05f..11a9c22 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,16 @@ import Vue from 'vue' import App from './App.vue' +import store from './utils/store' +import router from './utils/router' +import Antd from 'ant-design-vue'; +import 'ant-design-vue/dist/antd.css'; + +Vue.use(Antd) Vue.config.productionTip = false +Vue.prototype.$store = store new Vue({ + router, render: h => h(App), }).$mount('#app') diff --git a/src/utils/http.js b/src/utils/http.js new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/router.js b/src/utils/router.js new file mode 100644 index 0000000..d5ddbc5 --- /dev/null +++ b/src/utils/router.js @@ -0,0 +1,45 @@ +import Vue from 'vue' +import Router from 'vue-router' +import Index from '@/components/Main' + +Vue.use(Router) + +const routes = [ + { + path: '/', + redirect: '/index', + }, + { + path: '/index', + name: 'index', + component: Index, + meta: { + requireAuth: false + } + } +] + +const router = new Router({ + base: process.env.BASE_URL, + routes +}) + +router.beforeEach((to, from, next) => { + if (to.meta.requireAuth) { + // console.log(to.fullPath); + if (store.state.login && ((new Date()).getTime() - store.state.loginTime) < store.state.second * 1000) { + next() + } else { + next({ + path: '/login', query: { + redirect: to.fullPath + } + }) + } + } + else { + next() + } +}) + +export default router \ No newline at end of file diff --git a/src/utils/store.js b/src/utils/store.js new file mode 100644 index 0000000..6fb29b1 --- /dev/null +++ b/src/utils/store.js @@ -0,0 +1,12 @@ +import Vue from 'vue' +import Vuex from 'vuex' + +Vue.use(Vuex) + +const store = new Vuex.Store({ + state: { + + } +}) + +export default store \ No newline at end of file diff --git a/src/utils/utils.js b/src/utils/utils.js new file mode 100644 index 0000000..e69de29 diff --git a/vue.config.js b/vue.config.js new file mode 100644 index 0000000..b316a0d --- /dev/null +++ b/vue.config.js @@ -0,0 +1,31 @@ +const path = require('path') + +module.exports = { + publicPath: '/water/', + + devServer: { + host: '127.0.0.1', + port: 8090, + + proxy: { + '/backend': { + // target: 'http://223.75.53.208:8081', + target: 'http://127.0.0.1:8000', + } + } + }, + productionSourceMap: false, + + configureWebpack: { + resolve: { + alias: { + '@': path.resolve(__dirname, 'src'), + 'com': path.resolve(__dirname, 'src', 'components') + } + }, + + module: { + + } + } +} \ No newline at end of file