Commit 1cbcda01 authored by liwenhong's avatar liwenhong

Merge branch 'cmsLogin'

parents e34702b9 f694cf14
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
"dayjs": "^1.10.6", "dayjs": "^1.10.6",
"element-plus": "^1.0.2-beta.44", "element-plus": "^1.0.2-beta.44",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"js-cookie": "^3.0.0",
"json-bigint": "^1.0.0", "json-bigint": "^1.0.0",
"koa": "^2.13.1", "koa": "^2.13.1",
"koa-body": "^4.2.0", "koa-body": "^4.2.0",
...@@ -30,6 +29,7 @@ ...@@ -30,6 +29,7 @@
"koa-views": "^7.0.1", "koa-views": "^7.0.1",
"moment": "^2.29.1", "moment": "^2.29.1",
"request": "^2.88.2", "request": "^2.88.2",
"uglifyjs-webpack-plugin": "^2.2.0",
"uuid": "^8.3.2", "uuid": "^8.3.2",
"vue": "3.0.11", "vue": "3.0.11",
"vue-router": "^4.0.0-beta.12", "vue-router": "^4.0.0-beta.12",
......
...@@ -6,6 +6,16 @@ ...@@ -6,6 +6,16 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="https://static.yidianzixun.com/img/faviconred.ico"> <link rel="icon" href="https://static.yidianzixun.com/img/faviconred.ico">
<!-- 使用CDN的CSS文件 -->
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %>
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style" />
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
<% } %>
<!-- 使用CDN的JS文件 -->
<% for (let i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.js) { %>
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
<% } %>
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
</head> </head>
......
...@@ -2,41 +2,41 @@ ...@@ -2,41 +2,41 @@
<div class="app-wrapper"> <div class="app-wrapper">
<router-view v-slot="{ Component }"> <router-view v-slot="{ Component }">
<keep-alive v-if="$route.meta.keepAlive"> <keep-alive v-if="$route.meta.keepAlive">
<component :is="Component"> </component> <component :is="Component"></component>
</keep-alive> </keep-alive>
<component :is="Component" v-if="!$route.meta.keepAlive"> </component> <component :is="Component" v-if="!$route.meta.keepAlive"></component>
</router-view> </router-view>
</div> </div>
</template> </template>
<script> <script>
import { getCookie, redirectToLogin } from "@/utils/util"; import { getCookie, redirectToLogin } from '@/utils/util';
import { fetchCurrentUser } from "./service/user"; import { fetchCurrentUser } from './service/user';
export default { export default {
async mounted() { async mounted() {
if (this.$store.state.permissions && this.$store.state.userInfo) return; if (this.$store.state.permissions && this.$store.state.userInfo) return;
if(!getCookie('username') && window.location.pathname != '/op/login') { if (!getCookie('username') && window.location.pathname != '/op/login') {
this.$message('请先登录'); this.$message('请先登录');
return redirectToLogin(); return redirectToLogin();
} }
if (!this.$store.state.permissions) { if (!this.$store.state.permissions) {
const { status, user } = await fetchCurrentUser(); const { status, user } = await fetchCurrentUser();
if (status === "success") { if (status === 'success') {
this.$store.commit("updateUserInfo", user); this.$store.commit('updateUserInfo', user);
await this.$store.dispatch("updateUserPermission", { email: user.email }); await this.$store.dispatch('updateUserPermission', { email: user.email });
this.$store.dispatch("fetchPermission", { this.$store.dispatch('fetchPermission', {
appId: "merchant-op-auditing", appId: 'merchant-op-auditing'
}); });
} }
} }
}, }
}; };
</script> </script>
<style lang="less" src="./global.less"></style> <style lang="less" src="./global.less"></style>
<style lang="less" scoped> <style lang="less" scoped>
.app-wrapper { .app-wrapper {
height: 100%; height: 100%;
} }
</style> </style>
...@@ -62,8 +62,7 @@ export default { ...@@ -62,8 +62,7 @@ export default {
} }
this.userInfo.email = email.indexOf("@") === -1 ? email + "@yidian-inc.com" : email; this.userInfo.email = email.indexOf("@") === -1 ? email + "@yidian-inc.com" : email;
const res = await this.userLogin({ payload: this.userInfo }); const res = await this.userLogin({ payload: this.userInfo });
res && await this.fentchUser() res && (await this.fentchUser(), redirectPage())
redirectPage()
}, },
async fentchUser() { async fentchUser() {
if (!this.$store.state.permissions) { if (!this.$store.state.permissions) {
......
/* eslint-disable */
import { yd_login, j_login } from "@/service/user"; import { yd_login, j_login } from "@/service/user";
import { isYdUser, setCookie, delCookie,redirectToLogin, getCookie } from "@/utils/util"; import { isYdUser, setCookie, delCookie,redirectToLogin, getCookie } from "@/utils/util";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
// import Cookies from 'js-cookie'
export default { export default {
state: {}, state: {},
......
const path = require("path"); const path = require("path");
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production';
const isDev = process.env.NODE_ENV === "development"; const isDev = process.env.NODE_ENV === "development";
const plugins = [];
let externalObj = {};
if(isProduction) {
externalObj = {
'element-plus': 'ElementPlus',
vue: "Vue",
"vue-router": "VueRouter",
vuex: "Vuex",
axios: "axios"
}
}
if (process.env.NODE_ENV === 'production') {
plugins.push(new UglifyJsPlugin({
uglifyOptions: {
warnings: false
},
sourceMap: false,
parallel: true,
}));
}
const cdn = {
// 开发环境
dev: {
css: [],
js: []
},
// 生产环境
build: {
css: [
"https://unpkg.com/element-plus/lib/theme-chalk/index.css"
],
js: [
'/nodepackage/vue/dist/vue.min.js',
'/nodepackage/vue-router/dist/vue-router.min.js',
'https://cdn.bootcdn.net/ajax/libs/vuex/4.0.0/vuex.global.js',,
'/nodepackage/axios/dist/axios.min.js',
'https://cdn.bootcdn.net/ajax/libs/element-plus/1.0.2-beta.44/index.full.js',
'https://cdn.bootcdn.net/ajax/libs/element-plus/1.0.2-beta.44/umd/locale/zh-cn.js',
'https://unpkg.com/dayjs/locale/zh-cn.js'
]
}
}
module.exports = { module.exports = {
outputDir: isDev ? "./dist" : path.resolve("./public/dist/"), outputDir: isDev ? "./dist" : path.resolve("./public/dist/"),
publicPath: isDev ? "/" : "/dist", publicPath: isDev ? "/" : "/dist",
indexPath: './index.html',
lintOnSave: false,
configureWebpack: { configureWebpack: {
devServer: { devServer: {
proxy: "http://127.0.0.1:8055", //http://localhost:8055 proxy: "http://127.0.0.1:8055", //http://localhost:8055
...@@ -17,6 +62,8 @@ module.exports = { ...@@ -17,6 +62,8 @@ module.exports = {
'@': path.join(__dirname, 'src') // 使用@别名简写src目录所在的绝对路径 '@': path.join(__dirname, 'src') // 使用@别名简写src目录所在的绝对路径
}, },
}, },
externals: externalObj,
plugins,
}, },
chainWebpack: config => { chainWebpack: config => {
// 默认不开启 c // 默认不开启 c
...@@ -28,7 +75,15 @@ module.exports = { ...@@ -28,7 +75,15 @@ module.exports = {
// 修改页面 title // 修改页面 title
config.plugin("html").tap(args => { config.plugin("html").tap(args => {
args[0].title = "运营管理系统"; args[0].title = "运营管理系统";
if (isProduction) {
args[0].cdn = cdn.build
}
// if (!isProduction) {
// args[0].cdn = cdn.dev
// }
return args; return args;
}); });
} },
productionSourceMap: false,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment