Commit 231f8753 by limin

init

0 parents
Showing 95 changed files with 3237 additions and 0 deletions
> 1%
last 2 versions
not dead
# 首次登录时默认跳转的微应用入口
VUE_APP_PORT = 6650
\ No newline at end of file
# 首次登录时默认跳转的微应用入口
VUE_APP_PORT = 6650
\ No newline at end of file
module.exports = {
root: true,
env: {
node: true
},
extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'],
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
}
}
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
{
"printWidth": 800,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "none",
"semi": false,
"wrap_line_length": 820,
"wrap_attributes": "auto",
"proseWrap": "always",
"arrowParens": "avoid",
"bracketSpacing": true,
"htmlWhitespaceSensitivity": "ignore",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"jsxBracketSameLine": true,
"files.insertFinalNewline": true,
"prettier.ignorePath": ".prettierignore",
"useTabs": false,
"eslintIntegration": false,
"overrides": [
{
"files": ".prettierrc",
"options": {
"parser": "json"
}
}
],
"endOfLine": "auto"
}
# main
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
module.exports = {
presets: ['@vue/cli-plugin-babel/preset']
}
This diff could not be displayed because it is too large.
{
"name": "main",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "vue-cli-service serve",
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"element-ui": "^2.15.6",
"glsx-common": "^1.4.4",
"nprogress": "^0.2.0",
"qiankun": "^2.5.0",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-prettier": "^6.0.0",
"autoprefixer": "^10.2.5",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^6.2.2",
"lint-staged": "^9.5.0",
"node-sass": "^4.12.0",
"postcss": "^8.2.8",
"prettier": "^2.2.1",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11",
"webpack-spritesmith": "^1.1.0"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.{js,jsx,vue}": [
"vue-cli-service lint",
"git add"
]
}
}
No preview for this file type
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>
<%= htmlWebpackPlugin.options.title %>
</title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
Please enable it to continue.</strong>
</noscript>
<div id="main"></div>
<!-- built files will be auto injected -->
</body>
</html>
\ No newline at end of file
[
{
"moduleTitle": "子应用1",
"moduleName": "sub01",
"icon": "子应用1",
"menuList": [
{
"title": "应用管理",
"moduleName": "sub01",
"name": "sub01home",
"path": "/sub01/home",
"component": "/home",
"icon": "home",
"meta": { "isTabs": true, "isSide": true },
"children": [
{
"title": "应用跳转",
"moduleName": "sub01",
"name": "sub01home",
"path": "/sub01/home",
"component": "/home",
"children": [],
"icon": "home",
"meta": { "isTabs": true, "isSide": true }
},
{
"title": "数据修改",
"moduleName": "sub01",
"name": "sub01changeData",
"path": "/sub01/changeData",
"component": "/changeData",
"children": [],
"icon": "home",
"meta": { "isTabs": true, "isSide": true }
}
]
},
{
"title": "关于子应用",
"moduleName": "sub01",
"name": "sub01about",
"path": "/sub01/about",
"component": "/about",
"children": [],
"icon": "home",
"meta": { "isTabs": true, "isSide": true }
}
]
},
{
"moduleTitle": "子应用2",
"moduleName": "sub02",
"icon": "子应用2",
"menuList": [
{
"title": "全局数据展示",
"moduleName": "sub02",
"name": "sub02home",
"path": "/sub02/home",
"component": "/home",
"children": [],
"icon": "home",
"meta": { "isTabs": true, "isSide": true }
},
{
"title": "页面展示",
"moduleName": "sub02",
"name": "sub02about",
"path": "/sub02/about",
"component": "/about",
"children": [],
"icon": "home",
"meta": { "isTabs": true, "isSide": true }
}
]
}
]
var express = require('express')
var history = require('connect-history-api-fallback')
var cors = require('cors')
var app = express()
app.use(history())
app.use(cors())
app.use(express.static('./dist'))
app.get('/', function (req, res) {
res.send('Hello jq')
})
const port = 6650
app.listen(port)
console.log(`服务已运行:\r\n http://127.0.0.1:${port}`)
<template>
<div id="main">
<!-- {{ app.isLoading }} -->
<router-view></router-view>
<!-- <div class="el-loading-mask scrm-base-app-loading" v-if="app.isLoading" style="background-color: rgba(0, 0, 0, 0)">
<div class="el-loading-spinner">
<i class="el-icon-loading"></i>
<p class="el-loading-text">拼命加载中</p>
</div>
</div> -->
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
computed: {
...mapGetters(['app'])
}
}
</script>
<style lang="scss">
@import '~@/assets/style/variables.scss';
html {
margin: 0;
padding: 0;
font-size: 625%;
-webkit-text-size-adjust: 100%; // 4
-ms-text-size-adjust: 100%; // 4
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); // 6
height: 100%;
max-height: 100%;
}
body {
margin: 0;
padding: 0;
height: 100%;
max-height: 100%;
font-size: 14px;
font-family: 'Microsoft YaHei', '微软雅黑', 'MicrosoftJhengHei', 'STHeiti', 'MingLiu';
}
#main {
height: 100%;
// font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: $main-background-color;
}
</style>
/*
所有模块都定义在 modules
|-modules
|----demo.js
|----demo1.js
|----...
|-index.js ---动态对外暴露所有模块 无须手动添加
参考demo.js 用法 : this.$apis.demo.GETLISTDEVICEFILEUNSTOCK(...)
*/
const modulesFiles = require.context('./modules', true, /\.js$/)
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
const value = modulesFiles(modulePath)
modules[moduleName] = value.default
return modules
}, {})
export default modules
import { http } from '@/main'
const login = data => {
data.method = 'scrm.api.sso.user.loginCode'
return http({ data, returnAll: true })
}
const permission = data => {
data.method = 'scrm.api.sso.user.permission.get'
return http({ data })
}
const code = data => {
data.method = 'scrm.api.sso.user.login.getVerifyCode'
return http({ data })
}
const logout = data => {
data.method = 'scrm.api.sso.user.logout'
return http({ data })
}
export default {
login,
logout,
permission,
code
}
.i { display: inline-block; vertical-align: middle; background-image: url(./sprite.png) }
.i-conversion-active { width: 14px; height: 16px; background-position: -52px -82px; }
.i-conversion { width: 14px; height: 16px; background-position: -76px -82px; }
.i-custom-active { width: 16px; height: 16px; background-position: 0px -30px; }
.i-custom { width: 16px; height: 16px; background-position: -26px -30px; }
.i-dataview-active { width: 16px; height: 14px; background-position: -112px 0px; }
.i-dataview { width: 16px; height: 14px; background-position: -112px -24px; }
.i-finance-active { width: 16px; height: 16px; background-position: -60px 0px; }
.i-finance { width: 16px; height: 16px; background-position: -60px -26px; }
.i-home-active { width: 16px; height: 16px; background-position: 0px -56px; }
.i-home { width: 16px; height: 16px; background-position: -26px -56px; }
.i-increase-active { width: 16px; height: 16px; background-position: -52px -56px; }
.i-increase { width: 16px; height: 16px; background-position: -86px 0px; }
.i-password { width: 20px; height: 20px; background-position: 0px 0px; }
.i-settings-active { width: 16px; height: 16px; background-position: -86px -26px; }
.i-settings { width: 16px; height: 16px; background-position: -86px -52px; }
.i-tactics-active { width: 16px; height: 16px; background-position: 0px -82px; }
.i-tactics { width: 16px; height: 16px; background-position: -26px -82px; }
.i-user { width: 20px; height: 20px; background-position: -30px 0px; }
\ No newline at end of file
# 让 scss 变量能够当做 js 变量来使用
当前我们使用 scss 变量有两个痛点:
1. 需要手动导入
2. 无法与 js 建立联系或者很难,后续不能在此基础上做一些骚操作为了解决这两个问题,我们以创建 js 文件以 json 格式定义 scss 变量,然后通过配置 webpack 的解析规则来达到即能像普通 scss 一样使用,又能作为 js 变量使用的目的。
## scss 变量使用规范
### 变量创建
所有 scss 变量在`style/variables.scss.js`编写,格式要求为:
1. 只允许使用小写字母
2. 单词间以下划线"\_"连接
3. 命名应简洁易懂,以一个大的模块或高级别的单词开头\_后面跟功能描述单词结尾
```例
const variables = {
'header_height': '60px',
'header_background': `#ededed`
}
module.exports = variables;
```
注意:命名以下划线连接是为了在 js 文件中能够单个 import, 使用中已经在 webpack 进行转换,必须按照此格式!
在 scss 变量中使用是正常的 scss 变量:`$header-height`
在 js 中使用是定义时的变量格式:`import { header_height } from "@/style/variables.scss.js";`
### 变量使用
配置 webpack 中 sass 解析方式,一般来说项目构建者已经处理完毕,项目成员无需关心。
使用时无需引入,直接在样式文件中正常使用即可。
> scss 中使用示例
```style lang=sass
.the-nav{
height: $header-height;
}
```
> js 中使用示例
```
import { header_height } from "@/style/variables.scss.js";
...
data(){
return {
header_height: header_height
}
}
...
```
配置讲解
> vue.config.js 中 cuecli3+
```vue.config.js
let scssVariables = require('./src/style/variables.scss.js'); module.exports = { css: { loaderOptions: { sass: { prependData: Object.keys(scssVariables) .map(k => `\$${k.replace('_', '-')}: ${scssVariables[k]};`) .join('\n') } } } };
```
注意:此处有个坑,新版本的 sass-loader 更换了 api 参数`prependData`但是似乎没有文档说明
> 老版本的 sass-loader vue.config.js 中 cuecli3+
```vue.config.js
let scssVariables = require('./src/style/variables.scss.js'); module.exports = { css: { loaderOptions: { sass: { data: Object.keys(scssVariables) .map(k => `\$${k.replace('_', '-')}: ${scssVariables[k]};`) .join('\n') } } } };
```
老版本`data` => 新版本 `prependData`
> webpack.config.js 中 vuecli2
```
let scssVariables = require('./src/style/variables.scss.js');
...
{
test: /\.scss$/,
use: [
'css-loader',
'postcss-loader',
{
loader: 'sass-loader',
options: {
data: Object.keys(scssVariables)
.map(k => `\$${k.replace('_', '-')}: ${scssVariables[k]};`)
.join('\n')
}
}
]
}
...
```
@import 'reset.css';
@import 'variables';
$prefix: paas !default;
html {
margin: 0;
padding: 0;
font-size: 625%;
-webkit-text-size-adjust: 100%; // 4
-ms-text-size-adjust: 100%; // 4
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); // 6
height: 100%;
max-height: 100%;
overflow-x: hidden;
overflow-y: auto;
}
body {
margin: 0;
padding: 0;
height: 100vh;
width: 100vw;
overflow: auto;
padding-left: calc(100vw - 100%);
font-size: 14px;
font-family: 'Microsoft YaHei', '微软雅黑', 'MicrosoftJhengHei', 'STHeiti', 'MingLiu';
color: #303133;
-ms-overflow-style: none;
scrollbar-width: none;
}
body::-webkit-scrollbar {
display: none;
}
a {
text-decoration: none;
color: #303133;
}
/* 宽度100% */
.width-abs {
width: 100% !important;
}
/* 高度100% */
.height-abs {
height: 100% !important;
}
@mixin flex-row {
display: -webkit-flex;
display: flex !important;
}
@mixin flex-col {
@include flex-row;
flex-direction: column;
}
/* flex布局 */
.flex-row {
@include flex-row;
}
.flex-col {
@include flex-row;
flex-direction: column;
}
// 分布两边
.flex-row-between {
@include flex-row;
justify-content: space-between;
}
// 居中
.flex-row-center {
@include flex-row;
justify-content: center;
}
// 左右等份
.flex-row-around {
@include flex-row;
justify-content: space-around;
}
// 上下两边分布
.flex-col-between {
@include flex-col;
justify-content: space-between;
}
// 上下等份
.flex-col-around {
@include flex-col;
justify-content: space-around;
}
// 元素上下居中
.flex-col-center {
@include flex-col;
justify-content: center;
}
/* flex布局子元素位置 */
.flex-items-start {
align-items: flex-start;
}
.flex-items-center {
align-items: center;
}
.flex-items-end {
align-items: flex-end;
}
/* 换行 || 等分 */
.flex-wrap {
flex-wrap: wrap;
}
.flex-1 {
flex: 1;
}
/* 定位布局 */
.position-relative {
position: relative;
}
.position-absolute {
position: absolute;
}
.position-fixed {
position: fixed;
}
/* 元素溢出处理 */
.overflow-hidden {
overflow: hidden;
}
.overflow-auto-x {
overflow-x: auto;
}
.overflow-auto-y {
overflow-y: auto;
}
/* 文本不换行 */
.overflow-nowrap {
white-space: nowrap;
}
/* 超出一行省略 */
.overflow-ellipsis {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
/* 元素转换处理 */
@each $var in (block, inline, inline-block) {
.box-#{$var} {
display: $var;
}
}
/* 鼠标点击效果 */
@each $var in (pointer, default, wait, no-drop) {
.cursor-#{$var} {
cursor: $var;
}
}
/* 文本对齐 */
@each $var in (left, center, right) {
.text-#{$var} {
text-align: $var;
}
}
/* 阴影处理 */
.shadow {
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.none-shadow {
box-shadow: none !important;
}
.none-border {
border: none !important;
}
@each $var in (left, top, right, bottom) {
.border-#{$var} {
border-#{$var}: solid 1px $base-border;
}
}
html,
body,
div,
span,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
abbr,
address,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
samp,
small,
strong,
sub,
sup,
var,
b,
i,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
body {
line-height: 1;
}
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
nav ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}
a {
margin: 0;
padding: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
/* change colours to suit your needs */
ins {
background-color: #ff9;
color: #000;
text-decoration: none;
}
/* change colours to suit your needs */
mark {
background-color: #ff9;
color: #000;
font-style: italic;
font-weight: bold;
}
del {
text-decoration: line-through;
}
abbr[title],
dfn[title] {
border-bottom: 1px dotted;
cursor: help;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/* change border colour to suit your needs */
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #cccccc;
margin: 1em 0;
padding: 0;
}
input,
select {
vertical-align: middle;
}
null
\ No newline at end of file
// 头部样式变量
$header-height: 60px;
$header-background: #a3b6c6;
$header-color: #fff;
$header-padding: 15px;
// 左侧菜单样式变量
$menu-background: #2a3f54;
$menu-color: #fff;
$menu-active-color: #fff;
// 主视图区样式变量
$main-background-color: #f4f5fa;
$main-color: #5f5efb;
$menu-width: 194px;
$base-border: #5f5efb;
module.exports = {
// 头部样式变量
header_height: '60px',
header_background: `#ededed`,
header_color: `#2a3f54`,
header_padding: `15px`,
// 左侧菜单样式变量
menu_background: `#4d6987`,
menu_color: `#fff`,
menu_active_color: `#ffd04b`,
// 主视图区样式变量
main_base_color: `#f2f3f3`,
main_body_padding: '8px',
space_n: '8px',
space_s: '10px',
space_m: '12px',
space_l: '15px',
border_color_eee: '#EBEEF5'
}
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-09-18 09:35:02
* @LastEditors: limin
* @LastEditTime: 2021-09-18 18:07:07
* @FilePath: \scrm\scrm-base\src\common\constants.js
*/
export default {
SCRM_BASE_CURRENTPAGE: 'SCRM_BASE_CURRENTPAGE',
SCRM_BASE_SESSIONINFO: 'SCRM_BASE_SESSIONINFO',
SCRM_BASE_MENULIST: 'SCRM_BASE_MENULIST'
}
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-09-18 09:35:59
* @LastEditors: limin
* @LastEditTime: 2021-09-18 09:37:02
* @FilePath: \scrm\scrm-base\src\common\index.js
*/
import constants from './constants'
export { constants }
import WlContainer from './index.vue'
WlContainer.install = function (Vue) {
Vue.component(WlContainer.name, WlContainer)
}
export default WlContainer
<template>
<div class="gl-container">
<el-scrollbar class="gl-container-scroll">
<slot></slot>
</el-scrollbar>
</div>
</template>
<script>
export default {
name: 'GLContainer'
}
</script>
<style>
.gl-container {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
flex-grow: 1;
flex-shrink: 1;
padding: 8px;
}
</style>
import WlContextmenu from './index.vue'
WlContextmenu.install = function (Vue) {
Vue.component(WlContextmenu.name, WlContextmenu)
}
export default WlContextmenu
<template>
<div class="gl-context-menu" v-if="flag" :style="style">
<ul class="menu-liet" v-if="useDefault">
<li class="menu-item" v-for="item of menuList" :key="item.value" @click="handleMenuItem(item)">
<i class="memu-item-icon" :class="item.icon"></i>
<span class="memu-item-title">{{ item.title }}</span>
</li>
<li class="menu-item" v-if="menuList.length === 0" @click="flag = false">
<span class="memu-item-title">暂无菜单</span>
</li>
</ul>
<slot />
</div>
</template>
<script>
export default {
name: 'GLContextmenu',
props: {
visible: {
type: Boolean,
default: false
}, // 是否打开上下文菜单
x: {
type: Number,
default: 0
}, // 菜单打开坐标x轴
y: {
type: Number,
default: 0
}, // 菜单打开坐标y轴
useDefault: {
type: Boolean,
default: true
}, // 是否使用内置菜单样式
menuList: {
type: Array,
default: () => []
} // 使用内置菜单样式是,菜单列表
},
computed: {
flag: {
get() {
if (this.visible) {
// 注册全局监听事件 [ 目前只考虑鼠标解除触发 ]
window.addEventListener('mousedown', this.watchContextmenu)
}
return this.visible
},
set(newVal) {
this.$emit('update:visible', newVal)
}
},
style() {
return {
lewl: this.x + 'px',
top: this.y + 'px',
display: this.visible ? 'block' : 'none '
}
}
},
methods: {
// 菜单点击事件
handleMenuItem(item) {
this.$emit('rowClick', item)
},
watchContextmenu(event) {
if (!this.$el.contains(event.target) || event.button !== 0) this.flag = false
window.removeEventListener('mousedown', this.watchContextmenu)
}
},
mounted() {
// 将菜单放置到body下
document.querySelector('body').appendChild(this.$el)
}
}
</script>
<style lang="scss">
.gl-context-menu {
position: absolute;
padding: 5px 0;
z-index: 2018;
background: #fff;
border: 1px solid #cfd7e5;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
.menu-item {
padding: 8px 20px 8px 15px;
margin: 0;
font-size: 14px;
color: #606266;
cursor: pointer;
&:hover {
background: #ecf5ff;
color: #66b1ff;
}
.memu-item-icon {
font-size: 16px;
font-weight: 600;
}
.memu-item-title {
margin-lewl: 10px;
}
}
}
</style>
import WlFadein from './index.vue'
WlFadein.install = function (Vue) {
Vue.component(WlFadein.name, WlFadein)
}
export default WlFadein
<template>
<transition name="gl-fade">
<div v-if="show" class="gl-fade-in">
<h3 class="gl-fade-in-header" v-if="$slots.header">
<slot name="header"></slot>
</h3>
<!-- 主体区 -->
<el-scrollbar class="gl-fade-in-scroll" v-if="useScroll">
<slot></slot>
</el-scrollbar>
<div v-else class="gl-fade-in-main" :class="ftBodyClass">
<slot></slot>
</div>
<!-- 主体内容区 - 底部 -->
<div class="gl-fade-in-footer" v-if="$slots.footer">
<slot name="footer"></slot>
</div>
</div>
</transition>
</template>
<script>
export default {
name: 'GLFadein',
props: {
// 是否显示
show: {
type: Boolean,
default: false
},
// 是否使用scroll组件
useScroll: {
type: Boolean,
default: true
},
// 自定义main的class
ftBodyClass: [String, Function]
}
}
</script>
<style lang="scss">
.gl-fade-in {
display: flex;
flex-direction: column;
flex-grow: 1;
flex-shrink: 1;
position: fixed;
top: $header_height + $main_body_padding;
bottom: $main_body_padding;
right: $main_body_padding;
z-index: 9;
width: 460px;
background: #fff;
border: 1px solid $border-color-eee;
box-shadow: -2px 0 5px rgba(136, 133, 133, 0.6);
> .gl-fade-in-header {
padding: $space-s $space-l;
line-height: 24px;
font-size: 16px;
font-weight: 600;
color: #333;
border-bottom: 1px solid $border-color-eee;
}
> .gl-fade-in-footer {
padding: $space-s $space-l;
}
> .gl-fade-in-scroll {
flex: 1;
flex-grow: 1;
flex-shrink: 1;
> .el-scrollbar__wrap {
overflow-x: hidden;
> .el-scrollbar__view {
padding: $space-s $space-l;
}
}
}
> .gl-fade-in-main {
position: relative;
flex: 1;
flex-grow: 1;
flex-shrink: 1;
overflow: hidden;
padding: $space-s $space-l;
}
}
.gl-fade-enter-active,
.gl-fade-leave-active {
transition: all 0.3s;
}
.gl-fade-enter, .gl-fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
transform: translateX(50%);
opacity: 0;
}
</style>
import GLScroll from './index.vue'
GLScroll.install = function (Vue) {
Vue.component(GLScroll.name, GLScroll)
}
export default GLScroll
<template>
<el-scrollbar class="gl-scroll">
<slot></slot>
</el-scrollbar>
</template>
<script>
export default {
name: 'GLScroll'
}
</script>
<style lang="scss">
.gl-scroll {
flex: 1;
> .el-scrollbar__wrap {
overflow-x: hidden;
}
}
</style>
import GLSvgIcon from './index.vue'
GLSvgIcon.install = function (Vue) {
Vue.component(GLSvgIcon.name, GLSvgIcon)
}
const req = require.context('@/asstes/images/icons/svg', false, /\.svg$/)
const requireAll = requireContext => requireContext.keys().map(requireContext)
requireAll(req)
export default GLSvgIcon
<template>
<svg :class="svgClass" aria-hidden="true">
<use :xlink:href="iconName" />
</svg>
</template>
<script>
export default {
name: 'GLSvgIcon',
props: {
iconClass: {
type: String,
required: true
},
className: {
type: String,
default: ''
}
},
computed: {
iconName() {
return `#icon-${this.iconClass}`
},
svgClass() {
if (this.className) {
return 'svg-icon ' + this.className
} else {
return 'svg-icon'
}
}
}
}
</script>
<style scoped>
.svg-icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
}
</style>
import Vue from 'vue'
import GLContainer from './GLContainer'
import GLContextmenu from './GLContextmenu'
import GLFadein from './GLFadein'
import GLScroll from './GLScroll'
const components = [GLContainer, GLContextmenu, GLFadein, GLScroll]
const install = function (Vue) {
components.forEach(component => {
Vue.component(component.name, component)
})
}
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
}
Vue.use({
install,
GLContainer,
GLContextmenu,
GLFadein,
GLScroll
})
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-08 16:55:43
*/
// 根据环境引入不同配置 process.env.VUE_APP_ENV
const environment = process.env.NODE_ENV || 'production'
let config = require('./env.' + environment)
module.exports = config
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-10-08 09:33:51
*/
// 本地环境配置
module.exports = {
title: 'scrm-base',
response: {
data_key: 'data',
message_key: 'message',
code_key: 'code',
code_success_value: '0',
code_message_map: {}
},
request: {
baseURL: 'http://192.168.2.59:8315/rop-scrm-sso/router',
// baseURL: 'https://oss-config.test.glsx.com.cn/mock/6136bea6ceeb5a5c2bec6950/base',
// 设置超时时间
timeout: 180000,
// 携带凭证
withCredentials: true,
// 返回数据类型
responseType: 'json'
},
sign: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
v: '1.0.0',
format: 'json',
source: 'scrm-base'
},
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b',
cdn: 'https://www.xxx.cn/static',
productCode: 'PC0001',
defaultPath: '/home/home/index'
}
module.exports = {
title: 'scrm-base',
response: {
data_key: 'data',
message_key: 'message',
code_key: 'code',
code_success_value: '0',
code_message_map: {}
},
request: {
baseURL: 'http://192.168.2.59:8315/rop-scrm-sso/router',
// 设置超时时间
timeout: 180000,
// 携带凭证
withCredentials: true,
// 返回数据类型
responseType: 'json'
},
sign: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
v: '1.0.0',
format: 'json',
source: ''
},
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b',
cdn: 'https://www.xxx.cn/static',
productCode: 'PC0001',
//默认打开页面
defaultPath: '/home/home/index'
}
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-10-06 09:27:23
*/
// 根据环境引入不同配置 process.env.VUE_APP_ENV
let cfg = require('./conf.js')
import { Http } from 'glsx-common'
let timeout = 30000 //超时时间
export const fetchConfig = (isEnv = true) => {
if (isEnv) {
let { request } = cfg
Object.assign(request, { timeout })
return Promise.resolve(cfg)
}
return new Http().get('https://oss-config.test.glsx.com.cn/mock/6136bea6ceeb5a5c2bec6950/base/config')
}
export const config = {
install(vue, cfg) {
vue.prototype.$config = cfg
}
}
export default cfg
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-08-13 14:12:11
* @LastEditors: limin
* @LastEditTime: 2021-08-25 14:46:12
* @FilePath: \scrm\scrm-base\src\util\childEmit.js
*/
/**
* des:主应用传递给子应用的 用于emit触发主应用事件的函数
*/
import store from '@/store'
function changeDataMsg(val) {
store.dispatch('send-data/changeMsg', val)
}
export { changeDataMsg }
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-08-25 14:52:15
* @LastEditors: limin
* @LastEditTime: 2021-10-13 11:22:37
* @FilePath: \scrm\scrm-base\src\global\history.js
*/
import store from '@/store'
import { utils } from 'glsx-common'
/**
* 跨应用路由跳转
* @param {String} href url地址
* @param {Object} stateObj 状态参数 可以通过history.state读取
* @param {String} title 标题 暂时没有用
*/
function push(menu) {
let stateObj, title, url, id
function val(to) {
if (to) {
stateObj = to.stateObj
title = to.title
id = to.id
url = to.path
if (id) {
store.dispatch('app/setCurrentPage', to)
}
}
}
if (typeof menu === 'string') {
url = menu
} else {
val(menu)
}
if (!url) {
throw new Error('history.push:必须传入URL')
}
const to = store.getters.app.flatten.find(mod => url === mod.path || '/' + url === mod.path)
to && val(to)
if (!url) {
throw new Error('跳转页面失败,请检查页面参数是否正确')
}
if (!utils.isEmptyObject(menu.params)) {
url = url + '?' + utils.genUrlParams(menu.params)
}
window.history.pushState(stateObj, title, url)
}
export {
push // 跨应用路由跳转
}
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-08-24 14:17:53
* @LastEditors: limin
* @LastEditTime: 2021-10-13 14:03:39
* @FilePath: \scrm\scrm-base\src\global\index.js
*/
import messenger from './messenger'
import * as emiter from './emiter'
import * as history from './history'
// import store from './store'
export { messenger, emiter, history }
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-08-13 14:12:11
* @LastEditors: limin
* @LastEditTime: 2021-09-23 21:22:21
* @FilePath: \scrm\scrm-base\src\global\messenger.js
*/
import { push } from './history'
import { Subject } from 'rxjs'
class Messenger extends Subject {
constructor() {
super()
}
send(msg) {
if (!msg) return
const { route } = msg
if (route) {
push(route)
}
this.next(msg)
}
}
const messenger = new Messenger()
messenger.subscribe(v => {
console.log(`监听到子应用${v.from}发来消息:`, v)
})
export default messenger
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-15 14:46:31
* @LastEditors: limin
* @LastEditTime: 2021-10-13 14:02:54
*/
// import store from 'storejs'
// export default {
// ...store,
// exp: {
// set: function (key, val, exp = 24 * 60 * 60 * 1000) {
// store.set(key, { val: val, exp: exp, time: new Date().getTime() })
// },
// get: function (key) {
// var info = store.get(key)
// if (!info) {
// return null
// }
// if (new Date().getTime() - info.time > info.exp) {
// store.remove(key)
// return null
// }
// return info.val
// }
// },
// consts: {
// SCRM_BASE_CURRENTPAGE: 'SCRM_BASE_CURRENTPAGE'
// }
// }
<template>
<el-breadcrumb separator="/">
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
<el-breadcrumb-item :to="{ path: item.path }" v-for="item in breadcrumbs" :key="item.id">{{ item.title }}</el-breadcrumb-item>
</el-breadcrumb>
</template>
<script>
import { Breadcrumb, BreadcrumbItem } from 'element-ui'
import { mapGetters } from 'vuex'
export default {
name: 'GLBreadcrumb',
components: {
[Breadcrumb.name]: Breadcrumb,
[BreadcrumbItem.name]: BreadcrumbItem
},
mounted() {
// console.log(111111111, this.app.currentPage, this.app.routers, this.app.menuList)
},
computed: {
breadcrumbs() {
const { currentPage, menuList: menus } = this.app
if (!currentPage || !menus || !menus.length) return []
const curId = this.app.currentPage.id
const [lv1, lv2] = curId.split('-')
const menu1 = menus.find(menu => menu.id == lv1)
const bc = [{ title: menu1.title }]
const menu2 = menu1.children && menu1.children.find(menu => menu.id == `${lv1}-${lv2}`)
if (menu2) {
bc.push({ title: menu2.title })
const menu3 = menu2.children && menu2.children.find(menu => menu.id == curId)
menu3 && bc.push({ title: menu3.title })
}
return bc
},
...mapGetters(['app'])
}
}
</script>
<style lang="scss" scoped>
/deep/.el-breadcrumb {
&__item {
.el-breadcrumb__inner {
color: #999 !important;
font-weight: 500;
}
&[aria-current='page'] {
.el-breadcrumb__inner {
font-weight: 700 !important;
color: #3a3a3a !important;
}
}
}
}
</style>
<!--
* @Author: lizhijie429
* @Date: 2021-08-19 11:16:08
* @LastEditors: limin
* @LastEditTime: 2021-09-29 10:09:54
* @Description:
-->
<template>
<div class="logo">
<el-image :src="require('@/assets/logo.png')"></el-image>
</div>
</template>
<script>
export default {
name: 'Logo'
}
</script>
<style lang="scss" scoped>
.logo {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
line-height: 64px;
background: #fff;
color: #333;
text-align: center;
font-size: 20px;
font-weight: 600;
overflow: hidden;
}
</style>
<template>
<div class="scrm-base-nav">
<div class="flex-row" style="height: 60px">
<div class="flex-1 none-border nav-left">
<GLBreadcrumb></GLBreadcrumb>
</div>
<div class="flex-row flex-items-center nav-right">
<div class="menu-icons">
<span class="menu-icon">
<el-badge is-dot class="item">
<i class="el-icon-bell icon" />
</el-badge>
</span>
<span class="nav-text">消息</span>
</div>
<div class="menu-icons">
<span class="menu-icon">
<el-badge class="item">
<i class="el-icon-phone-outline" />
</el-badge>
</span>
<span class="nav-text">
<a href="">联系我们</a>
|
<a>营销学院</a>
</span>
</div>
<el-dropdown @command="handleCommand">
<div class="flex-row flex-items-center cursor-pointer">
<el-avatar class="border" :src="avatarImg"></el-avatar>
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="logout">退出</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<span class="nav-text" style="padding-left: 8px">{{ user.userInfo && user.userInfo.name }}</span>
</div>
</div>
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
export default {
name: 'NavMenu',
data() {
return {
avatarImg: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png'
}
},
computed: {
...mapGetters(['user'])
},
methods: {
...mapActions('user', ['updateUserInfoItem']),
...mapActions('app', ['logout']),
handleCommand(command) {
if (command === 'logout') {
this.logout()
// this.$router.replace({ path: '/login' })
location.reload('/login')
return false
}
if (command === 'setting') {
this.updateUserInfoItem({ key: 'userInfo', value: { name: 'zhangsan' } })
// this.$actions.setGlobalState({ userInfo: { name: 'zhangsan' } })
return false
}
}
}
}
</script>
<style lang="scss" scoped>
.scrm-base-nav {
.nav-text,
.nav-text a {
font-size: 14px;
font-weight: 500;
color: #3b457f;
}
.nav-left {
display: flex;
align-items: center;
margin-left: 40px;
}
.nav-right {
margin-right: 20px;
}
.qiankun-font {
font-size: 22px;
padding-right: 20px;
line-height: 60px;
}
.menu-icons {
padding-right: 20px;
display: flex;
align-items: center;
.menu-icon {
padding: 0 12px;
cursor: pointer;
.icon {
display: inline-block;
font-size: 18px;
text-align: center;
}
}
}
}
</style>
<template>
<div class="side-bar">
<div class="logo">
<Logo></Logo>
</div>
<div class="side-bar-menu">
<div class="side-bar-menu-left">
<el-menu class="flex-1 none-border" background-color="#fff" @open="open" @close="close" active-text-color="#409EFF" text-color="#999" :default-openeds="openeds" :default-active="active" :unique-opened="true">
<SubMenu :subMenu="app.menuList" ref="sub"></SubMenu>
</el-menu>
</div>
</div>
</div>
</template>
<script>
import { mapActions, mapGetters } from 'vuex'
export default {
name: 'SideMenu',
computed: {
...mapGetters(['app']),
active() {
if (this.app.currentNav2) {
return this.app.currentNav2.id
}
return '0'
},
openeds() {
if (this.app.currentApp) {
return [this.app.currentApp.id]
}
return []
}
},
methods: {
...mapActions('app', ['setCurrentApp']),
...mapActions('menu', ['setOpenId', 'setHoverId']),
open(index) {
this.setOpenId(index)
},
close() {
this.setOpenId('')
this.setHoverId('')
}
}
}
</script>
<style lang="scss" scoped>
$logo-height: 140px;
.side-bar {
height: 100%;
display: flex;
flex-direction: column;
/deep/ .collapse-transition {
transition: 0.2s height ease-in-out, 0.2s padding-top ease-in-out, 0.2s padding-bottom ease-in-out;
}
.logo {
flex: 0 0 $logo-height;
}
.side-bar-menu {
flex: 1;
user-select: none;
&-left {
height: 100%;
.el-menu {
height: 100%;
}
}
}
}
</style>
<template>
<div class="scrm-base-submenu">
<template v-for="item in subMenu">
<el-submenu v-if="isNotLv3(item)" :key="item.id" :index="item.id">
<template slot="title">
<div @mouseenter="hover(item)" @mouseleave="mouseleave">
<i class="i" :class="genClass(item)" v-if="item.icon"></i>
<span slot="title">{{ item.title }}</span>
</div>
</template>
<sub-menu :subMenu="item.children"></sub-menu>
</el-submenu>
<el-menu-item v-else :key="item.id" :index="item.id" @click="handleSelect(item)">
<span slot="title">{{ item.title }}</span>
</el-menu-item>
</template>
</div>
</template>
<script>
import { mapActions, mapGetters } from 'vuex'
export default {
name: 'SubMenu',
props: {
subMenu: {
type: Array,
required: true
}
},
data() {
return {
activeId: '',
hoverId: '',
openId: ''
}
},
computed: {
...mapGetters(['app', 'menu']),
active() {
if (this.app.currentApp) {
return this.app.currentApp.id
}
return '0'
}
},
mounted() {},
methods: {
handleSelect(item) {
if (item.path) {
this.$router.push(item.path)
}
this.setCurrentNav2(item)
},
genClass(item) {
const active = this.active == item.id || this.menu.hoverId == item.id || this.menu.openId == item.id
return `i-${active ? `${item.icon}-active` : item.icon}`
},
hover(item) {
this.setHoverId(item.id)
},
mouseleave() {
this.setHoverId('')
},
isNotLv3(item) {
// 3级菜单不在左侧menu渲染
return item.children && item.children.length > 0 && item.children[0].id.split('-').length <= 2
},
...mapActions('app', ['setCurrentNav2']),
...mapActions('menu', ['setHoverId'])
}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/variables.scss';
$active-background-color: rgba(235, 234, 255, 1) !important;
.scrm-base-submenu {
/deep/.el-submenu {
&__title {
height: 40px;
line-height: 40px;
padding: 0 0 0 10px !important;
border-radius: 4px;
margin: 0 20px;
&:hover {
background-color: $active-background-color;
span {
color: $main-color !important;
}
}
span {
font-size: 14px;
color: #999;
letter-spacing: 0;
font-weight: 600;
margin-left: 10.8px;
}
.el-submenu__icon-arrow {
display: none;
}
}
&.is-opened {
.el-submenu__title {
background-color: $active-background-color;
span {
color: $main-color !important;
}
}
}
}
.el-menu-item {
min-width: $menu-width;
padding-left: 60px !important;
&:hover,
&.is-active {
outline: 0 !important;
color: $main-color !important;
background-color: #fff !important;
border-bottom: none;
}
&:hover {
background-color: transparent !important;
}
}
}
</style>
<template>
<div class="scrm-base-sub-nav">
<el-tabs v-model="activeName" @tab-click="handleClick()">
<el-tab-pane :label="item.title" :name="item.path" v-for="item in subNavs" :key="item.id"></el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'SubNav',
data() {
return {
activeName: '',
subNavs: []
}
},
mounted() {},
methods: {
handleClick() {}
},
computed: {
...mapGetters(['app'])
},
watch: {
activeName(n) {
if (n.startsWith('/')) {
this.$router.push(n)
}
},
'app.currentNav2': {
handler(v) {
if (!v) return
const sub = v.children
if (sub && sub.length) {
this.subNavs = sub.filter(item => !item.hidden)
}
const curPage = this.app.currentPage
if (curPage) {
const nav2 = this.app.currentNav2
if (nav2 && curPage.id.startsWith(nav2.id)) {
this.activeName = curPage.path
return
}
}
if (this.subNavs && this.subNavs.length) {
this.activeName = this.subNavs[0].path
}
},
immediate: true
}
}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/variables.scss';
.scrm-base-sub-nav {
/deep/.el-tabs {
&__nav-wrap {
&::after {
opacity: 0;
}
}
&__item {
&.is-active,
&:hover {
color: $main-color;
}
font-weight: 400;
color: #717171;
height: 36px;
line-height: 36px;
}
&__active-bar {
background-color: $main-color;
}
}
}
</style>
<template>
<div class="tabs-box flex-row flex-items-center">
<div class="tabs-item paas-flex-cc" v-for="item in tabsList" :key="item.id" :class="item.path === currentPage ? 'tabs-item-hover' : 'null'">
<span>
<span class="cursor-pointer fs-14 tabs-item-text" @click="handleClick(item)">{{ item.title }}</span>
<i class="el-icon-close tabs-remove-icon cursor-pointer" @click="removeTab(item)"></i>
</span>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'Tabs',
computed: {
...mapState({
menuList: state => state.app.menuList,
currentPage: state => state.app.currentPage,
tabsList: state => state.tabs.tabsList
})
},
methods: {
// 获取元素数组下标
getArrayIndex(arr, id) {
for (let index = 0; index < arr.length; index++) {
const item = arr[index]
if (item.id === id) {
return index
}
}
return -1
},
// 跳转tabs标签
handleClick(item) {
if (this.currentPage.id === item.id) return false
// 设置左侧菜单数据
if (item.path !== '/home') {
const menu = this.menuList.filter(element => {
return element.id === item.id.split('-')[0]
})
this.$store.commit('app/UPDATE_SUB_MENU', menu[0].menuList)
this.$router.push({ path: item.path })
} else {
this.$store.commit('app/UPDATE_SUB_MENU', true)
this.$router.push({ path: item.path })
}
},
// 删除tabs标签
removeTab(item) {
let tabsListLength = this.tabsList.length - 1
// 获取当前要删除的tabs的位置
let indexOf = this.getArrayIndex(this.tabsList, item.id)
if (tabsListLength === indexOf) {
// 删除最后一个
this.$store.dispatch('tabs/REMOVE_LAST_TAB', item)
} else {
// 删除除了第一个跟最后一个
this.$store.dispatch('tabs/REMOVE_ANY_TAB', {
indexOf,
tabsItem: item
})
}
}
}
}
</script>
<style lang="scss" scoped>
.tabs-box {
height: 0.32rem;
padding: 0.1rem;
.tabs-item {
height: 100%;
padding: 0 0.12rem;
margin-right: 0.1rem;
background-color: #fff;
border-radius: 0.04rem;
color: #333;
font-size: 0.14rem;
line-height: 0.32rem;
white-space: nowrap;
.tabs-item-text {
&:hover {
color: #23b7e5;
}
}
.tabs-remove-icon {
margin-left: 0.02rem;
padding: 0.02rem;
font-size: 0.04px;
cursor: pointer;
}
.tabs-remove-icon:hover {
border-radius: 50%;
color: #fff;
background-color: #23b7e5;
}
}
.tabs-item:last-child {
border-right: none !important;
}
}
.tabs-item-hover {
color: #23b7e5 !important;
}
</style>
// export { default as NavMenu } from "./NavMenu.vue";
// export { default as SideMenu } from "./SideMenu.vue";
// export { default as Tabs } from "./Tabs.vue";
import Vue from 'vue'
const componentsFiles = require.context(`./`, true, /.vue$/)
componentsFiles.keys().forEach(path => {
const component = componentsFiles(path).default
Vue.component(component.name, component)
})
<template>
<el-container class="base-container">
<el-aside class="base-container-aside">
<SideMenu></SideMenu>
</el-aside>
<el-container class="base-container-right">
<el-header>
<NavMenu></NavMenu>
</el-header>
<SubNav></SubNav>
<!-- <Tabs></Tabs> -->
<el-main v-loading="app.isLoading" element-loading-spinner="el-icon-loading">
<GLScroll class="el-main-scroll">
<slot></slot>
</GLScroll>
</el-main>
</el-container>
</el-container>
</template>
<script>
import './subscriber'
import './components'
import { mapGetters } from 'vuex'
export default {
name: 'Layout',
computed: {
...mapGetters(['app'])
}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/variables.scss';
.base-container {
height: 100%;
display: flex;
&-aside {
flex: 0 0 $menu-width;
text-align: left;
}
&-right {
flex: 1;
height: 100%;
// padding: 0 20px 20px 40px;
/deep/.el-loading-spinner {
i,
.el-loading-text {
color: $main-color;
font-size: 26px;
}
}
.el-header {
padding: 0;
color: #333;
text-align: center;
}
.el-main {
height: calc(100% - 80px) !important;
-ms-overflow-style: none;
scrollbar-width: none;
padding: 0;
// background-color: #fff;
&::-webkit-scrollbar {
display: none;
}
&-scroll {
height: 100%;
/deep/.el-scrollbar__thumb {
background-color: rgba(144, 147, 153, 0.1);
}
}
}
}
}
</style>
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-09-17 09:35:30
* @LastEditors: limin
* @LastEditTime: 2021-09-17 09:35:31
* @FilePath: \scrm\scrm-base\src\layout\MessageSubscribe.js
*/
import { messenger } from '@/global'
import store from '../store'
messenger.subscribe(({ userInfo }) => {
if (userInfo) {
store.dispatch('user/updateUserInfo', userInfo)
}
})
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import { Http, utils } from 'glsx-common'
import { fetchConfig, config } from '@/config/index'
// import 'glsx-common/src/style/index.scss'
import '@/assets/style/index.scss'
import '@/assets/images/sprite/sprite.css'
import 'glsx-common/src/iconfont/iconfont.css'
import 'element-ui/lib/theme-chalk/index.css'
import './components'
import { Message } from './plugins/element.js'
Vue.config.productionTip = false
Vue.prototype.$utils = utils
Vue.prototype.$event = new Vue()
var instance = null
async function render() {
const cfg = await fetchConfig(false)
const { response, request, sign, secret } = cfg
Vue.use(config, cfg)
const http = new Http({ response, request, sign, secret, alert: Message.error })
Vue.prototype.$http = http
instance = new Vue({
router,
store,
render: h => h(App)
}).$mount('#main')
}
export const http = params => Vue.prototype.$http(params)
export const KoI = key => instance[key]
render()
import Vue from 'vue'
import { Message, Button, ButtonGroup, Container, Aside, Menu, MenuItem, Submenu, MenuItemGroup, Header, Main, Footer, Avatar, Badge, Dropdown, DropdownMenu, DropdownItem, Scrollbar, Carousel, CarouselItem, Form, FormItem, Input, Image, Tabs, TabPane, Loading } from 'element-ui'
Vue.use(Button)
Vue.use(ButtonGroup)
Vue.use(Container)
Vue.use(Aside)
Vue.use(Menu)
Vue.use(MenuItem)
Vue.use(Submenu)
Vue.use(MenuItemGroup)
Vue.use(Header)
Vue.use(Main)
Vue.use(Footer)
Vue.use(Avatar)
Vue.use(Badge)
Vue.use(Dropdown)
Vue.use(DropdownMenu)
Vue.use(DropdownItem)
Vue.use(Scrollbar)
Vue.use(Carousel)
Vue.use(CarouselItem)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Input)
Vue.use(Image)
Vue.use(Tabs)
Vue.use(TabPane)
Vue.use(Loading)
export { Message }
// import store from '../store/index'
import { initGlobalState } from 'qiankun'
// 定义全局下发的数据
export const initialState = {
// 当前登录用户
userInfo: null,
// 全局配置
globalConfig: null,
// 路由数据
routers: null
}
const globalActions = initGlobalState(initialState)
globalActions.onGlobalStateChange((value, prev) => {
console.log(`[主应用接收到值变化 - ${actions}]:`, value, prev)
})
export function setGlobalState(state) {
globalActions.setGlobalState(state)
}
// 初始化全局下发的数据
export const actions = globalActions
import { registerMicroApps, start, addGlobalUncaughtErrorHandler } from 'qiankun'
import { filterApps, microConfig } from './registerApp'
// import { setGlobalState } from './globalState'
import { Message } from 'element-ui'
import store from '@/store'
// 微应用注册
export const registerApps = microApps => {
const _apps = filterApps(microApps)
registerMicroApps(_apps, microConfig)
// setGlobalState({ userInfo: 111 })
start({
prefetch: true, // 可选,是否开启预加载,默认为 true。
sandbox: true, // 可选,是否开启沙箱,默认为 true。// 从而确保微应用的样式不会对全局造成影响。
singular: true // 可选,是否为单实例场景,单实例指的是同一时间只会渲染一个微应用。默认为 true。
})
addGlobalUncaughtErrorHandler(event => {
if (event.message == 'Script error.') {
Message.error('加载失败,请检查服务是否开启')
}
store.dispatch('app/setLoading', false)
})
}
import { Http, utils } from 'glsx-common'
import { messenger, history } from '@/global'
import store from '@/store'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
// import { actions } from './globalState'
/* 重构apps */
export const filterApps = microApps => {
microApps.forEach(item => {
// 必选,微应用的容器节点的选择器或者 Element 实例。
item.container = '#subapp-viewport'
item.loader = loading => {
store.dispatch('app/setLoading', loading)
}
// 可选,主应用需要传递给微应用的数据。
item.props = {
routerBase: item.activeRule, // 下发基础路由
globalState: { routers: filter(item.activeRule), session: store.getters.auth.session }, // 下发全局数据方法
common: { Http, utils },
messenger,
history
}
item.activeRule = `#${item.activeRule}`
})
return microApps
}
function filter(routerBase) {
const routers = store.getters.app.routers.reduce((collect, route) => {
if (route.path.startsWith(routerBase)) {
route.compath = route.path.slice(routerBase.length)
collect.push(route)
}
return collect
}, [])
return routers
}
/* qiankun全局声明周期钩子 */
export const microConfig = {
beforeLoad: app => {
console.log('%c before load', 'background:#3a5ab0 ; padding: 1px; border-radius: 3px; color: #fff', app)
}, // 挂载前回调
beforeMount: app => {
NProgress.start()
console.log('%c before mount', 'background:#7d9553 ; padding: 1px; border-radius: 3px; color: #fff', app)
}, // 挂载钱回调
afterMount: app => {
NProgress.done()
console.log('%c after mount', 'background:#d2525c ; padding: 1px; border-radius: 3px; color: #fff', app)
}, // 卸载后回调
afterUnmount: app => {
console.log('%c after unload', 'background:#d2525c ; padding: 1px; border-radius: 3px; color: #fff', app)
}
// 卸载后回调
}
import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '@/store'
import Login from '@/views/Login'
// import { utils } from 'glsx-common'
// import { constants } from '@/common'
// import Home from '@/views/Home'
import E404 from '@/views/404'
// import Layout from '@/views/Layout'
Vue.use(VueRouter)
const Path = Object.freeze({
LOGIN: '/login',
E404: '/404'
})
// 路由
let constantRoutes = [
{
path: Path.LOGIN,
name: 'login',
component: Login,
meta: { isBase: true, title: '登录' }
},
{
path: Path.E404,
name: '404',
component: E404,
meta: { isBase: true, title: '404' }
},
{
path: '/',
redirect: Path.LOGIN // 默认加载的路由
},
{ path: '*', redirect: Path.E404 }
]
const createRouter = () => {
return new VueRouter({
mode: 'hash',
routes: constantRoutes,
scrollBehavior(to, from, savedPosition = { x: 0, y: 0 }) {
return savedPosition
}
})
}
// 处理重复点击同一个路由报错的问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
//判断路由是否存在
VueRouter.prototype.hasRoute = function (path) {
return this.getRoutes().some(route => route.path === path)
}
VueRouter.prototype.constantRoutes = constantRoutes
/**
* 重置注册的路由导航map
*/
VueRouter.prototype.reset = function () {
const newRouter = createRouter()
this.matcher = newRouter.matcher
}
const router = createRouter()
router.beforeEach(async (to, from, next) => {
const session = store.getters.auth.session
if (from.path !== '/' && session === null) {
next(Path.LOGIN)
return
}
store.dispatch('app/setCurrentPage', to.meta)
if (from.name === null && to.path === Path.E404 && to.redirectedFrom && session === null) {
// 页面刷新 动态路由会失效 初始化路由与左侧菜单栏
await store.dispatch('init/init')
if (router.hasRoute(to.redirectedFrom)) {
next(to.redirectedFrom)
} else {
next(Path.LOGIN)
}
} else {
if (session) {
next()
} else {
if (to.path === Path.LOGIN) {
next()
} else {
next(Path.LOGIN)
}
}
}
})
export default router
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const modulesFiles = require.context('./modules', true, /\.js$/)
const modules = modulesFiles.keys().reduce(
(result, modulePath) => {
const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
const value = modulesFiles(modulePath)
result.getters[moduleName] = state => state[moduleName]
result.modules[moduleName] = value.default
return result
},
{ modules: {}, getters: {} }
)
export default new Vuex.Store(modules)
import { utils } from 'glsx-common'
import Layout from '@/views/Layout'
import { constants } from '@/common'
import router from '@/router'
const app = {
namespaced: true,
state: () => ({
routers: null,
menuList: [],
currentPage: null,
currentApp: null,
microApps: [],
isBase: true,
isLoading: false,
flatten: [],
currentNav2: {}
}),
mutations: {
SET_CURRENT_PAGE(state, page) {
const { id, isBase } = page
state.isBase = !!isBase
if (!id) return
const [lv1, lv2] = id.split('-')
state.currentApp = state.flatten.find(mod => mod.id == lv1)
state.currentNav2 = state.flatten.find(item => item.id == `${lv1}-${lv2}`)
utils.storage.setSession(constants.SCRM_BASE_CURRENTPAGE, page)
state.currentPage = page
},
SET_MENU_LIST(state, list) {
state.menuList = list
state.flatten = utils.array.flattenDeep(list)
utils.storage.setSession(constants.SCRM_BASE_MENULIST, list)
},
SET_MICROAPPS(state, payload) {
state.microApps = payload
},
SET_ROUTES(state, payload) {
state.routers = router.constantRoutes.concat(payload)
},
SET_CURRENT_APP(state, payload) {
state.currentApp = payload
},
SET_CURRENT_NAV2(state, nav2) {
state.currentNav2 = nav2
},
SET_LOADING(state, isLoading) {
state.isLoading = isLoading
},
CLEAR(state) {
state.menuList = []
state.flatten = []
state.microApps = []
state.currentApp = null
state.currentNav2 = {}
state.currentPage = null
state.isLoading = false
utils.storage.removeSession(constants.SCRM_BASE_MENULIST)
utils.storage.removeSession(constants.SCRM_BASE_CURRENTPAGE)
}
},
actions: {
async login({ dispatch }, form) {
// 向后端请求路由数据
router.reset()
const { code, message, menus } = await dispatch('auth/login', form, { root: true })
if (menus) {
const menuFormat = formatData(menus, '')
await dispatch('persisted', { data: menuFormat, isWithModuleName: true })
}
return { code, message }
},
async logout({ dispatch }) {
await dispatch('auth/logout', null, { root: true })
await dispatch('init/reset', null, { root: true })
},
clear({ commit }) {
commit('CLEAR')
},
setCurrentPage({ commit, dispatch }, page) {
dispatch('menu/clear', null, { root: true })
commit('SET_CURRENT_PAGE', page)
},
setCurrentApp({ commit }, payload) {
commit('SET_CURRENT_APP', payload)
},
setCurrentNav2({ commit }, nav2) {
commit('SET_CURRENT_NAV2', nav2)
},
setLoading({ commit }, isLoading) {
commit('SET_LOADING', isLoading)
},
async persisted({ commit }, { data, isWithModuleName }) {
const { routes, apps } = data.reduce(
({ routes, apps }, module) => {
let { entry, name, id, children } = module
apps.push({ name, entry, activeRule: `/${name}`, id })
if (children && children.length) {
const route = getMenuItem(isWithModuleName ? name : '', children)
routes = routes.concat(route)
}
return { routes, apps }
},
{ routes: [], apps: [] }
)
await commit('SET_MENU_LIST', data)
await commit('SET_MICROAPPS', apps)
await commit('SET_ROUTES', routes)
return routes
}
}
}
/**
* 解析后台返回数据,format 系统所需要的格式
* @param {*} menus
* @returns
*/
function formatData(menus, concatId) {
const formatMenus = []
for (let i = 0; i < menus.length; i++) {
if (!menus[i]) continue
const menu = {}
let { menuUrl: path, id, label: title, url, children, logo: icon, name } = menus[i]
if (!concatId) {
if (!name) {
if (!path.includes('@')) continue
const [entry, name] = path.split('@')
menu.entry = entry
menu.name = name
menu.icon = name
} else {
menu.name = name
menu.entry = path
menu.icon = name
}
icon
// menu.icon = icon
menu.id = `${id}`
} else {
menu.id = `${concatId}-${id}`
if (path.includes('@')) {
const [p, u] = path.split('@')
path = p
url = u
}
}
if (title.startsWith('*')) {
title = title.slice(1)
menu.hidden = true
}
menu.title = title
menu.path = path
menu.url = url
if (children) {
menu.children = formatData(children, menu.id)
}
formatMenus.push(menu)
}
return formatMenus
}
// 组装路由数据
function getMenuItem(moduleName, menus) {
let routers = []
const flattenMenus = utils.array.flattenDeep(menus)
for (let index = 0; index < flattenMenus.length; index++) {
const menu = flattenMenus[index]
const route = __gen(moduleName, menu)
router.addRoute(route)
routers.push(route)
}
return routers
}
function __gen(moduleName, menu) {
const { path, meta = {}, id, title, url } = menu
const [, m, n] = path.split('/')
const name = `${m}${n ? `-${n}` : ''}_${id}`
const _path = `${moduleName ? `/${moduleName}` : ''}${path.startsWith('/') ? path : `/${path}`}`
menu.path = _path
const route = {
path: _path,
component: Layout,
name,
meta: { ...meta, id, title, name, url, path: _path }
}
return route
}
export default app
import { utils } from 'glsx-common'
import { constants } from '@/common'
import api from '@/api'
import { KoI } from '@/main'
const auth = {
namespaced: true,
state: () => ({
session: null
}),
mutations: {
SET_SESSION_INFO(state, session) {
state.session = session
utils.storage.setSession(constants.SCRM_BASE_SESSIONINFO, session)
},
async LOGOUT(state) {
await api.app.logout({ sessionId: state.session.token })
},
CLEAR(state) {
state.session = null
utils.storage.removeSession(constants.SCRM_BASE_SESSIONINFO)
}
},
actions: {
async setSessionInfo({ commit, dispatch }, info) {
dispatch('user/updateUserInfo', info ? info.userInfo : null, { root: true })
commit('SET_SESSION_INFO', info)
},
async login({ dispatch }, form) {
const { code, data, message } = await api.app.login(form)
const { productCode, response } = KoI('$config')
var menus = null
if (code == response.code_success_value) {
const sessionId = data.sessionId
const [account] = await api.app.permission({ productCode, sessionId })
menus = account.products[0].merchantProTreeResponses
// menus = await api.app.permission({ productCode, sessionId })
const userInfo = { name: form.userName }
dispatch('setSessionInfo', { userInfo, ...data, token: sessionId })
} else {
return { code, message }
}
return { code, message, menus }
},
async logout({ commit }) {
await commit('LOGOUT')
},
clear({ commit }) {
commit('CLEAR')
}
}
}
export default auth
import { utils } from 'glsx-common'
import { constants } from '@/common'
const modulesFiles = require.context('.', true, /\.js$/).keys()
const init = {
namespaced: true,
actions: {
async init({ dispatch }) {
// 获取页面持久化数据
const currentPage = utils.storage.getSession(constants.SCRM_BASE_CURRENTPAGE)
currentPage && (await dispatch('app/setCurrentPage', currentPage, { root: true }))
const sessionInfo = utils.storage.getSession(constants.SCRM_BASE_SESSIONINFO)
sessionInfo && (await dispatch('auth/setSessionInfo', sessionInfo, { root: true }))
const menuList = utils.storage.getSession(constants.SCRM_BASE_MENULIST)
menuList && (await dispatch('app/persisted', { data: menuList, isWithModuleName: false }, { root: true }))
},
reset({ dispatch }) {
modulesFiles.forEach(modulePath => {
const module = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
module !== 'init' && dispatch(`${module}/clear`, null, { root: true })
})
}
}
}
export default init
const menu = {
namespaced: true,
state: () => ({
hoverId: '',
openId: ''
}),
mutations: {
SET_HOVER_ID(state, id) {
state.hoverId = id
},
SET_OPEN_ID(state, id) {
state.openId = id
},
CLEAR(state) {
state.openId = ''
state.hoverId = ''
}
},
actions: {
setHoverId({ commit }, id) {
commit('SET_HOVER_ID', id)
},
setOpenId({ commit }, id) {
commit('SET_OPEN_ID', id)
},
clear({ commit }) {
commit('CLEAR')
}
}
}
export default menu
const user = {
namespaced: true,
state: () => ({
userInfo: null,
globalConfig: null
}),
mutations: {
UPDATE_USER_INFO_ITEM(state, payload) {
state[payload.key] = payload.value
},
UPDATE_GLOBAL_CONFIG_ITEM(state, payload) {
state[payload.key] = payload.value
},
UPDATE_USER_INFO(state, payload) {
state.userInfo = payload
},
UPDATE_GLOBAL_CONFIG(state, payload) {
state.globalConfig = payload
},
CLEAR(state) {
state.globalConfig = null
state.userInfo = null
}
},
actions: {
updateUserInfoItem({ commit }, payload) {
commit('UPDATE_USER_INFO_ITEM', payload)
},
updateGlobalConfigItem({ commit }, payload) {
commit('UPDATE_GLOBAL_CONFIG_ITEM', payload)
},
updateUserInfo({ commit }, payload) {
commit('UPDATE_USER_INFO', payload)
},
updateGlobalConfig({ commit }, payload) {
commit('UPDATE_GLOBAL_CONFIG', payload)
},
clear({ commit }) {
commit('CLEAR')
}
}
}
export default user
<template>
<div class="about">
<h1>404</h1>
</div>
</template>
<script>
export default {
name: 'error404'
}
</script>
<template>
<div class="scrm-base-layout">
<router-view v-show="app.isBase" class="height-abs"></router-view>
<layout v-show="!app.isBase">
<div id="subapp-viewport" class="app-view-box"></div>
</layout>
<!-- <div class="el-loading-mask scrm-base-app-loading" v-if="isLoading" style="background-color: rgba(0, 0, 0, 0)">
<div class="el-loading-spinner">
<i class="el-icon-loading"></i>
<p class="el-loading-text">拼命加载中</p>
</div>
</div> -->
</div>
</template>
<script>
import Layout from '@/layout/index.vue'
import { registerApps } from '@/qiankun'
import { mapGetters } from 'vuex'
export default {
components: {
Layout
},
mounted() {
if (!window.qiankunStarted) {
window.qiankunStarted = true
registerApps(this.app.microApps)
}
},
computed: {
...mapGetters(['app'])
}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/variables.scss';
.scrm-base-layout {
height: 100%;
}
.scrm-base-app-loading {
position: absolute;
z-index: 111;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
height: 100%;
width: 100%;
background: rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
color: $main-color;
}
.scrm-base-app-loading {
.el-loading-spinner {
i,
.el-loading-text {
color: $main-color;
}
}
}
</style>
<template>
<div class="scrm-base-home">
<div class="login-header">
<el-image :src="require(`@/assets/images/login/logo.png`)"></el-image>
<h2>专注汽车行业数字化+智能营销解决方案——帮您的流量变销量</h2>
</div>
<div class="login-form">
<div class="left">
<el-carousel height="500px" :autoplay="true" arrow="never">
<el-carousel-item v-for="item in 3" :key="item">
<el-image :src="require(`@/assets/images/login/banner1.png`)"></el-image>
</el-carousel-item>
</el-carousel>
</div>
<div class="right">
<div class="error-tip" v-show="errMsg" :class="errMsg ? 'shake' : ''">
<i class="el-icon-error"></i>
{{ errMsg }}
<i class="el-icon-close" @click="errMsg = ''"></i>
</div>
<span class="welcome">欢迎登录</span>
<el-form :model="loginForm" @keyup.enter.native="submitForm" :rules="rules" ref="loginForm" class="form">
<el-form-item prop="userName">
<el-input clearable v-model="loginForm.userName" placeholder="请输入手机号/用户名" @keyup.enter.native="submitForm">
<!-- <div class="input-prefix" slot="prefix"> -->
<!-- <i class="i i-user"></i> -->
<!-- <span>手机号/用户名:</span> -->
<!-- </div> -->
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input type="password" clearable v-model="loginForm.password" placeholder="请输入密码" @keyup.enter.native="submitForm">
<!-- <div class="input-prefix" slot="prefix"> -->
<!-- <i class="i i-password"></i> -->
<!-- <span>密码:</span> -->
<!-- </div> -->
</el-input>
</el-form-item>
<el-form-item prop="code">
<el-input type="code" v-model="loginForm.code" maxlength="36" placeholder="请输入验证码" @keyup.enter.native="submitForm">
<div class="code-suffix" slot="suffix" @click="getCode">
<el-image :src="code64"></el-image>
</div>
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm()" :disabled="disabled" :style="isLogin ? '' : 'letter-spacing: 1em;'">登录{{ isLogin ? '中...' : '' }}</el-button>
</el-form-item>
<div class="privacy">
登录即表明您同意
<a>&lt;&lt;营销车隐私声明&gt;&gt;</a>
及
<a>&lt;&lt;用户协议&gt;&gt;</a>
</div>
</el-form>
</div>
</div>
</div>
</template>
<script>
import { mapActions } from 'vuex'
import { utils } from 'glsx-common'
import api from '@/api'
export default {
name: 'Login',
mounted() {
this.getCode()
},
data() {
return {
loginForm: {
userName: 'glsadmin',
password: '123456',
codeToken: '',
code: ''
},
code64: '',
errMsg: '',
isLogin: false,
showTip: false,
rules: {
userName: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
code: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
}
}
},
computed: {
disabled() {
return !this.loginForm.userName || !this.loginForm.password || !this.loginForm.codeToken || !this.loginForm.code
}
},
methods: {
submitForm: utils.debounce(function () {
this.errMsg = ''
this.$refs['loginForm'].validate(async valid => {
if (valid) {
this.isLogin = true
const { code, message } = await this.login(this.loginForm)
const { response, defaultPath } = this.$config
this.isLogin = false
if (code == response.code_success_value) {
this.$router.push(defaultPath)
} else {
this.errMsg = message
this.getCode()
}
}
})
}, 500),
resetForm(formName) {
this.$refs[formName].resetFields()
},
getCode() {
api.app.code({}).then(({ data, token }) => {
this.code64 = data
this.loginForm.codeToken = token
})
},
...mapActions('app', ['login', 'setLoading'])
}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/variables.scss';
@keyframes shake {
0% {
transform: rotate(2deg);
}
50% {
transform: rotate(-3deg);
}
70% {
transform: rotate(3deg);
}
100% {
transform: rotate(0deg);
}
}
.shake {
animation: shake 0.3s ease-in-out forwards;
}
.scrm-base-home {
height: 100%;
display: flex;
align-items: center;
padding-top: 87px;
background-color: $main-color;
background: url('~@/assets/images/login/bg.png') no-repeat;
background-size: 100% 100%;
flex-direction: column;
.login-header {
text-align: center;
margin-bottom: 44px;
h2 {
margin-top: 15px;
font-size: 14px;
font-weight: 500;
color: #666666;
line-height: 20px;
letter-spacing: 1px;
}
}
.login-form {
width: 984px;
height: 500px;
display: flex;
box-shadow: 15px 18px 64px 0px rgba(210, 210, 210, 0.13);
border-radius: 20px;
overflow: hidden;
.left {
flex: 0 0 492px;
/deep/.el-carousel {
.el-carousel__button {
width: 12px;
height: 12px;
border-radius: 12px;
background-color: #fff;
opacity: 0.8;
}
.el-carousel__indicator {
&.is-active {
.el-carousel__button {
background-color: #fe911a;
opacity: 1;
}
}
padding: 17px 4px;
}
}
}
.right {
flex: 0 0 492px;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
position: relative;
.error-tip {
width: 341px;
height: 32px;
line-height: 32px;
background: #fff1f0;
border-radius: 4px;
border: 1px solid #eb4e4e;
font-size: 14px;
font-weight: 400;
color: rgba(0, 0, 0, 0.65);
padding-left: 16px;
top: 20px;
position: absolute;
box-sizing: border-box;
i.el-icon-error {
color: #eb4e4e;
}
i.el-icon-close {
color: #000;
// position: absolute;
// right: 16px;
// top: 13px;
margin-left: 200px;
cursor: pointer;
}
}
/deep/.el-form {
width: 342px;
.el-form-item__content {
margin-top: 10px;
.el-input__inner {
&:focus {
border-color: $main-color;
}
}
.el-input__suffix-inner {
.code-suffix {
.el-image {
cursor: pointer;
line-height: 28px;
vertical-align: middle;
}
}
}
.el-button--primary {
width: 341px;
height: 42px;
background: $main-color;
border-radius: 4px;
font-size: 18px;
text-indent: 1em;
border: 2px solid rgba(254, 145, 26, 0.1);
&.is-disabled,
&.is-disabled:hover {
background: #e9e9e9;
border-color: #e9e9e9;
color: #999;
}
&:hover,
&:focus {
border-color: #7777f3;
background-color: #7777f3;
}
span {
position: relative;
top: -3px;
}
}
}
}
.welcome {
width: 101px;
height: 33px;
font-size: 24px;
font-weight: 500;
color: #333;
line-height: 33px;
letter-spacing: 1px;
margin-bottom: 30px;
}
}
.privacy {
margin-top: -8px;
font-size: 12px;
font-weight: 600;
color: #999;
line-height: 20px;
a {
color: #5850ff;
font-weight: 600;
}
}
}
}
</style>
const path = require('path')
let styleVariables = require('./src/assets/style/variables.scss.js')
const resolve = dir => path.join(__dirname, dir)
const SpritesmithPlugin = require('webpack-spritesmith')
module.exports = {
// publicPath: './',
devServer: {
// host: '0.0.0.0',
hot: true,
disableHostCheck: true,
port: process.env.VUE_APP_PORT,
overlay: {
warnings: false,
errors: true
},
headers: {
'Access-Control-Allow-Origin': '*'
}
// proxy: {
// '/api': {
// target: 'http://scrm.test.glsx.com.cn/rop-scrm-sso', //对应自己的接口
// changeOrigin: true,
// ws: true,
// pathRewrite: {
// '^/api': '/router'
// }
// }
// }
},
css: {
loaderOptions: {
sass: {
prependData: Object.keys(styleVariables)
.map(k => `\$${k.replace('_', '-')}: ${styleVariables[k]};`)
.join('\n')
}
}
},
chainWebpack: config => {
config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test
// 别名 alias
config.resolve.alias.set('@', resolve('src'))
config.plugin('webpack-spritesmith').use(SpritesmithPlugin, [
{
src: {
cwd: './src/assets/images/icons/',
glob: '*.png'
},
target: {
image: './src/assets/images/sprite/sprite.png',
css: [
[
path.resolve(__dirname, './src/assets/images/sprite/sprite.css'),
{
// 引用自己的模板
format: 'function_based_template'
}
]
]
},
apiOptions: {
cssImageRef: './sprite.png'
},
customTemplates: {
function_based_template: templateFunction
},
spritesmithOptions: {
algorithm: 'binary-tree',
padding: 10
}
}
])
}
}
const templateFunction = function (data) {
var shared = '.i { display: inline-block; vertical-align: middle; background-image: url(I) }'.replace('I', data.sprites[0].image)
var perSprite = data.sprites
.map(function (sprite) {
return '.i-N { width: Wpx; height: Hpx; background-position: Xpx Ypx; }'.replace('N', sprite.name).replace('W', sprite.width).replace('H', sprite.height).replace('X', sprite.offset_x).replace('Y', sprite.offset_y)
})
.join('\n')
return shared + '\n' + perSprite
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!