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.
......@@ -6,6 +6,16 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<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>
</head>
......
......@@ -2,41 +2,41 @@
<div class="app-wrapper">
<router-view v-slot="{ Component }">
<keep-alive v-if="$route.meta.keepAlive">
<component :is="Component"> </component>
<component :is="Component"></component>
</keep-alive>
<component :is="Component" v-if="!$route.meta.keepAlive"> </component>
<component :is="Component" v-if="!$route.meta.keepAlive"></component>
</router-view>
</div>
</template>
<script>
import { getCookie, redirectToLogin } from "@/utils/util";
import { fetchCurrentUser } from "./service/user";
import { getCookie, redirectToLogin } from '@/utils/util';
import { fetchCurrentUser } from './service/user';
export default {
export default {
async mounted() {
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('请先登录');
return redirectToLogin();
}
if (!this.$store.state.permissions) {
const { status, user } = await fetchCurrentUser();
if (status === "success") {
this.$store.commit("updateUserInfo", user);
await this.$store.dispatch("updateUserPermission", { email: user.email });
this.$store.dispatch("fetchPermission", {
appId: "merchant-op-auditing",
if (status === 'success') {
this.$store.commit('updateUserInfo', user);
await this.$store.dispatch('updateUserPermission', { email: user.email });
this.$store.dispatch('fetchPermission', {
appId: 'merchant-op-auditing'
});
}
}
},
};
}
};
</script>
<style lang="less" src="./global.less"></style>
<style lang="less" scoped>
.app-wrapper {
.app-wrapper {
height: 100%;
}
}
</style>
......@@ -62,8 +62,7 @@ export default {
}
this.userInfo.email = email.indexOf("@") === -1 ? email + "@yidian-inc.com" : email;
const res = await this.userLogin({ payload: this.userInfo });
res && await this.fentchUser()
redirectPage()
res && (await this.fentchUser(), redirectPage())
},
async fentchUser() {
if (!this.$store.state.permissions) {
......
/* eslint-disable */
import { yd_login, j_login } from "@/service/user";
import { isYdUser, setCookie, delCookie,redirectToLogin, getCookie } from "@/utils/util";
import { ElMessage } from "element-plus";
// import Cookies from 'js-cookie'
export default {
state: {},
......
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 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 = {
outputDir: isDev ? "./dist" : path.resolve("./public/dist/"),
publicPath: isDev ? "/" : "/dist",
indexPath: './index.html',
lintOnSave: false,
configureWebpack: {
devServer: {
proxy: "http://127.0.0.1:8055", //http://localhost:8055
......@@ -17,6 +62,8 @@ module.exports = {
'@': path.join(__dirname, 'src') // 使用@别名简写src目录所在的绝对路径
},
},
externals: externalObj,
plugins,
},
chainWebpack: config => {
// 默认不开启 c
......@@ -28,7 +75,15 @@ module.exports = {
// 修改页面 title
config.plugin("html").tap(args => {
args[0].title = "运营管理系统";
if (isProduction) {
args[0].cdn = cdn.build
}
// if (!isProduction) {
// args[0].cdn = cdn.dev
// }
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