Commit 118e75d3 by xinlaa

素材接口,客户接口调试,配置更改等

1 parent df8c99af
# 开发环境配置 # 开发环境配置
ENV = 'development' ENV = 'development'
# 若依管理系统/开发环境 # 塬微管理系统/开发环境
VUE_APP_BASE_API = '/dev-api' VUE_APP_BASE_API = 'http://106.13.201.219'
# VUE_APP_BASE_API = 'http://n3rpzt.natappfree.cc'
# 开发环境IP
VUE_APP_BASE_URL = 'http://192.168.0.101'
# 路由懒加载 # 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true VUE_CLI_BABEL_TRANSPILE_MODULES = true
# 生产环境配置 # 生产环境配置
ENV = 'production' ENV = 'production'
# 若依管理系统/生产环境 # 塬微管理系统/生产环境api
VUE_APP_BASE_API = '/prod-api' VUE_APP_BASE_API = 'http://106.13.201.219'
# 生产环境IP
VUE_APP_BASE_URL = 'http://106.13.201.219'
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build:prod": "vue-cli-service build", "build": "vue-cli-service build",
"preview": "node build/index.js --preview", "preview": "node build/index.js --preview",
"lint": "eslint --ext .js,.vue src", "lint": "eslint --ext .js,.vue src",
"test:unit": "jest --clearCache && vue-cli-service test:unit", "test:unit": "jest --clearCache && vue-cli-service test:unit",
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
], ],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://gitee.com/y_project/RuoYi-Vue.git" "url": "https://gitee.com/LinkWeChat/link-wechat.git"
}, },
"dependencies": { "dependencies": {
"@riophae/vue-treeselect": "0.4.0", "@riophae/vue-treeselect": "0.4.0",
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
"promise.prototype.finally": "^3.1.2", "promise.prototype.finally": "^3.1.2",
"screenfull": "4.2.0", "screenfull": "4.2.0",
"sortablejs": "1.8.4", "sortablejs": "1.8.4",
"video.js": "^7.10.2",
"vue": "2.6.10", "vue": "2.6.10",
"vue-count-to": "1.0.13", "vue-count-to": "1.0.13",
"vue-cropper": "0.4.9", "vue-cropper": "0.4.9",
...@@ -103,4 +104,4 @@ ...@@ -103,4 +104,4 @@
"> 1%", "> 1%",
"last 2 versions" "last 2 versions"
] ]
} }
\ No newline at end of file \ No newline at end of file
...@@ -95,3 +95,13 @@ export function exportCustomer(query) { ...@@ -95,3 +95,13 @@ export function exportCustomer(query) {
params: query, params: query,
}) })
} }
/**
*客户详情
* @param {*} externalUserid
*/
export function getDetail(externalUserid) {
return request({
url: service + '/getCustomersByUserId/' + externalUserid,
})
}
import request from '@/utils/request' import request from '@/utils/request'
const service = window.CONFIG.CONFIG.services.wecom + '/group' const service = window.CONFIG.services.wecom + '/group'
// 客户标签 // 客户标签
......
...@@ -72,7 +72,7 @@ type:0 图片(image)、1 语音(voice)、2 视频(video),3 普通 ...@@ -72,7 +72,7 @@ type:0 图片(image)、1 语音(voice)、2 视频(video),3 普通
*/ */
export function upload(data) { export function upload(data) {
return request({ return request({
url: window.CONFIG.services.wecom + '/upload', url: service + '/upload',
method: 'post', method: 'post',
data, data,
}) })
......
<script> <script>
import { upload } from '@/api/material' import { upload } from '@/api/material'
import Video from 'video.js'
export default { export default {
components: {}, components: {},
props: { props: {
...@@ -7,39 +8,49 @@ export default { ...@@ -7,39 +8,49 @@ export default {
type: String, type: String,
default: '', default: '',
}, },
fileName: {
type: String,
default: '',
},
// 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file) // 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file)
type: { type: {
type: String, type: String,
default: '0', default: '0',
}, },
beforeUpload: { // beforeUpload: {
type: Function, // type: Function,
default: () => () => {}, // default: function() {
}, // return function() {}
// },
// },
}, },
data() { data() {
return { return {
loading: false,
action: action:
process.env.VUE_APP_BASE_API + window.CONFIG.services.wecom + '/upload', process.env.VUE_APP_BASE_API +
window.CONFIG.services.wecom +
'/material/upload',
headers: window.CONFIG.headers, headers: window.CONFIG.headers,
} }
}, },
watch: {}, watch: {},
computed: { computed: {
accept() { accept() {
return ['image/*', 'audio/*', 'video/*', '*'][this.type] return ['image/*', '*', 'video/*', '*'][this.type]
}, },
}, },
created() { created() {},
upload()
},
mounted() {}, mounted() {},
methods: { methods: {
handleBeforeUpload(file) { handleBeforeUpload(file) {
this.loading = true
let isFormat = true,
isSize = true
if (this.type === '0') { if (this.type === '0') {
// 图片 // 图片
const isFormat = file.type === 'image/jpeg' isFormat = file.type === 'image/jpeg'
const isSize = file.size / 1024 / 1024 < 2 isSize = file.size / 1024 / 1024 < 2
if (!isFormat) { if (!isFormat) {
this.$message.error('上传文件只能是 JPG 格式!') this.$message.error('上传文件只能是 JPG 格式!')
...@@ -47,11 +58,10 @@ export default { ...@@ -47,11 +58,10 @@ export default {
if (!isSize) { if (!isSize) {
this.$message.error('上传文件大小不能超过 2MB!') this.$message.error('上传文件大小不能超过 2MB!')
} }
return isFormat && isSize
} else if (this.type === '1') { } else if (this.type === '1') {
// 语音 // 语音
const isFormat = file.type === 'audio/amr' isFormat = /.amr$/gi.test(file.name)
const isSize = file.size / 1024 / 1024 < 2 isSize = file.size / 1024 / 1024 < 2
if (!isFormat) { if (!isFormat) {
this.$message.error('上传文件只能是 amr 格式!') this.$message.error('上传文件只能是 amr 格式!')
...@@ -59,11 +69,10 @@ export default { ...@@ -59,11 +69,10 @@ export default {
if (!isSize) { if (!isSize) {
this.$message.error('上传文件大小不能超过 2MB!') this.$message.error('上传文件大小不能超过 2MB!')
} }
return isFormat && isSize
} else if (this.type === '2') { } else if (this.type === '2') {
// 视频 // 视频
const isFormat = file.type === 'video/mp4' isFormat = file.type === 'video/mp4'
const isSize = file.size / 1024 / 1024 < 10 isSize = file.size / 1024 / 1024 < 10
if (!isFormat) { if (!isFormat) {
this.$message.error('上传文件只能是 mp4 格式!') this.$message.error('上传文件只能是 mp4 格式!')
...@@ -71,20 +80,30 @@ export default { ...@@ -71,20 +80,30 @@ export default {
if (!isSize) { if (!isSize) {
this.$message.error('上传文件大小不能超过 10MB!') this.$message.error('上传文件大小不能超过 10MB!')
} }
return isFormat && isSize
} else if (this.type === '3') { } else if (this.type === '3') {
// 普通文件 // 普通文件
const isSize = file.size / 1024 / 1024 < 20 isSize = file.size / 1024 / 1024 < 20
if (!isSize) { if (!isSize) {
this.$message.error('上传文件大小不能超过 20MB!') this.$message.error('上传文件大小不能超过 20MB!')
} }
return isSize
} }
return beforeUpload(file) if (!isFormat || !isSize) {
this.loading = false
}
// if (beforeUpload) {
// return beforeUpload(file)
// }
return isFormat && isSize
}, },
onSuccess(res, file) { onSuccess(res, file) {
this.fileUrl = URL.createObjectURL(file.raw) if (res.code === 200) {
this.loading = false
this.$emit('update:fileUrl', res.data.materialUrl)
this.$emit('update:fileName', res.data.materialName)
// this.fileUrl = URL.createObjectURL(file.raw)
}
}, },
}, },
} }
...@@ -93,16 +112,35 @@ export default { ...@@ -93,16 +112,35 @@ export default {
<template> <template>
<div> <div>
<el-upload <el-upload
v-loading="loading"
class="uploader" class="uploader"
:accept="accept" :accept="accept"
:action="action" :action="action"
:headers="headers" :headers="headers"
:data="{ type: type }" :data="{ mediaType: type }"
:show-file-list="false" :show-file-list="false"
:on-success="onSuccess" :on-success="onSuccess"
:before-upload="handleBeforeUpload" :before-upload="handleBeforeUpload"
> >
<img v-if="fileUrl" :src="fileUrl" class="upload-img" /> <template v-if="fileUrl">
<img v-if="type === '0'" :src="fileUrl" class="upload-img" />
<div v-else-if="type === '2'">
<video
id="myVideo"
class="video-js vjs-default-skin
vjs-big-play-centered"
width="100%"
controls
webkit-playsinline="true"
playsinline="true"
autoplay="none"
preload="auto"
>
<source :src="fileUrl" type="video/mp4" />
</video>
</div>
<div v-else>{{ fileName }}</div>
</template>
<i v-else class="el-icon-plus uploader-icon"></i> <i v-else class="el-icon-plus uploader-icon"></i>
</el-upload> </el-upload>
<div class="tip"> <div class="tip">
...@@ -113,7 +151,6 @@ export default { ...@@ -113,7 +151,6 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
/deep/.uploader .el-upload { /deep/.uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px; border-radius: 6px;
cursor: pointer; cursor: pointer;
position: relative; position: relative;
...@@ -129,6 +166,8 @@ export default { ...@@ -129,6 +166,8 @@ export default {
height: 178px; height: 178px;
line-height: 178px; line-height: 178px;
text-align: center; text-align: center;
border-radius: 6px;
border: 1px dashed #d9d9d9;
} }
.upload-img { .upload-img {
width: 178px; width: 178px;
......
...@@ -14,6 +14,7 @@ Vue.use(Element, { ...@@ -14,6 +14,7 @@ Vue.use(Element, {
import '@/styles/common.scss' // common css import '@/styles/common.scss' // common css
import '@/styles/index.scss' // global css import '@/styles/index.scss' // global css
import 'video.js/dist/video-js.css'
import config from '@/config' import config from '@/config'
import App from './App' import App from './App'
......
...@@ -138,109 +138,142 @@ export const constantRoutes = [ ...@@ -138,109 +138,142 @@ export const constantRoutes = [
// { // {
// path: 'staff', // path: 'staff',
// name: 'CodeStaff', // name: 'CodeStaff',
// component: (resolve) => require(['@/views/drainageCode/staff/list'], resolve), // component: (resolve) =>
// meta: { title: '员工活码', icon: '' } // require(['@/views/drainageCode/staff/list'], resolve),
// meta: { title: '员工活码', icon: '' },
// }, // },
// { // {
// path: 'staffAdd', // path: 'staffAdd',
// hidden: true, // hidden: true,
// component: (resolve) => require(['@/views/drainageCode/staff/add'], resolve), // component: (resolve) =>
// meta: { title: '新建员工活码', icon: '', activeMenu: '/drainageCode/staff' } // require(['@/views/drainageCode/staff/add'], resolve),
// meta: {
// title: '新建员工活码',
// icon: '',
// activeMenu: '/drainageCode/staff',
// },
// }, // },
// { // {
// path: 'staffDetail', // path: 'staffDetail',
// hidden: true, // hidden: true,
// component: (resolve) => require(['@/views/drainageCode/staff/detail'], resolve), // component: (resolve) =>
// meta: { title: '员工活码详情', icon: '', activeMenu: '/drainageCode/staff' } // require(['@/views/drainageCode/staff/detail'], resolve),
// meta: {
// title: '员工活码详情',
// icon: '',
// activeMenu: '/drainageCode/staff',
// },
// }, // },
// { // {
// path: 'group', // path: 'group',
// name: 'CodeGroup', // name: 'CodeGroup',
// component: (resolve) => require(['@/views/drainageCode/group/list'], resolve), // component: (resolve) =>
// meta: { title: '客户群活码', icon: '' } // require(['@/views/drainageCode/group/list'], resolve),
// meta: { title: '客户群活码', icon: '' },
// }, // },
// { // {
// path: 'groupAdd', // path: 'groupAdd',
// hidden: true, // hidden: true,
// component: (resolve) => require(['@/views/drainageCode/group/add'], resolve), // component: (resolve) =>
// meta: { title: '新增客户群活码', icon: '', activeMenu: '/drainageCode/group' } // require(['@/views/drainageCode/group/add'], resolve),
// meta: {
// title: '新增客户群活码',
// icon: '',
// activeMenu: '/drainageCode/group',
// },
// }, // },
// { // {
// path: 'groupDetail', // path: 'groupDetail',
// hidden: true, // hidden: true,
// component: (resolve) => require(['@/views/drainageCode/group/detail'], resolve), // component: (resolve) =>
// meta: { title: '客户群活码信息', icon: '', activeMenu: '/drainageCode/group' } // require(['@/views/drainageCode/group/detail'], resolve),
// meta: {
// title: '客户群活码信息',
// icon: '',
// activeMenu: '/drainageCode/group',
// },
// }, // },
// { // {
// path: 'groupBaseInfo', // path: 'groupBaseInfo',
// hidden: true, // hidden: true,
// component: (resolve) => require(['@/views/drainageCode/group/baseInfo'], resolve), // component: (resolve) =>
// meta: { title: '客户群活码', icon: '', activeMenu: '/drainageCode/group' } // require(['@/views/drainageCode/group/baseInfo'], resolve),
// meta: {
// title: '客户群活码',
// icon: '',
// activeMenu: '/drainageCode/group',
// },
// }, // },
// { // {
// path: 'welcome', // path: 'welcome',
// name: 'Welcome', // name: 'Welcome',
// component: (resolve) => require(['@/views/drainageCode/welcome/list'], resolve), // component: (resolve) =>
// meta: { title: '欢迎语', icon: '' } // require(['@/views/drainageCode/welcome/list'], resolve),
// meta: { title: '欢迎语', icon: '' },
// }, // },
// { // {
// path: 'welcomeAdd', // path: 'welcomeAdd',
// hidden: true, // hidden: true,
// component: (resolve) => require(['@/views/drainageCode/welcome/add'], resolve), // component: (resolve) =>
// meta: { title: '新建欢迎语', icon: '', activeMenu: '/drainageCode/welcome' } // require(['@/views/drainageCode/welcome/add'], resolve),
// meta: {
// title: '新建欢迎语',
// icon: '',
// activeMenu: '/drainageCode/welcome',
// },
// }, // },
// ] // ],
// },
// {
// path: '/material',
// component: Layout,
// redirect: '/material/text',
// meta: { title: '素材中心', icon: 'material' },
// children: [
// {
// path: 'text',
// name: 'MaterialText',
// component: (resolve) => require(['@/views/material/text'], resolve),
// meta: { title: '文本', icon: '' },
// },
// {
// path: 'image',
// name: 'MaterialImage',
// component: (resolve) => require(['@/views/material/image'], resolve),
// meta: { title: '图片', icon: '' },
// },
// {
// path: 'web',
// name: 'MaterialWeb',
// component: (resolve) => require(['@/views/material/web'], resolve),
// meta: { title: '网页', icon: '' },
// },
// {
// path: 'audio',
// name: 'MaterialAudio',
// component: (resolve) => require(['@/views/material/audio'], resolve),
// meta: { title: '语音', icon: '' },
// },
// {
// path: 'video',
// name: 'MaterialVideo',
// component: (resolve) => require(['@/views/material/video'], resolve),
// meta: { title: '视频', icon: '' },
// },
// {
// path: 'file',
// name: 'MaterialFile',
// component: (resolve) => require(['@/views/material/file'], resolve),
// meta: { title: '文件', icon: '' },
// },
// {
// path: 'applet',
// name: 'MaterialApplet',
// component: (resolve) => require(['@/views/material/applet'], resolve),
// meta: { title: '小程序', icon: '' },
// },
// ],
// }, // },
{
path: '/material',
component: Layout,
redirect: '/material/text',
meta: { title: '素材中心', icon: 'material' },
children: [
{
path: 'text',
name: 'MaterialText',
component: (resolve) => require(['@/views/material/text'], resolve),
meta: { title: '文本', icon: '' },
},
{
path: 'image',
name: 'MaterialImage',
component: (resolve) => require(['@/views/material/image'], resolve),
meta: { title: '图片', icon: '' },
},
{
path: 'web',
name: 'MaterialWeb',
component: (resolve) => require(['@/views/material/web'], resolve),
meta: { title: '网页', icon: '' },
},
{
path: 'audio',
name: 'MaterialAudio',
component: (resolve) => require(['@/views/material/audio'], resolve),
meta: { title: '语音', icon: '' },
},
{
path: 'video',
name: 'MaterialVideo',
component: (resolve) => require(['@/views/material/video'], resolve),
meta: { title: '视频', icon: '' },
},
{
path: 'file',
name: 'MaterialFile',
component: (resolve) => require(['@/views/material/file'], resolve),
meta: { title: '文件', icon: '' },
},
{
path: 'applet',
name: 'MaterialApplet',
component: (resolve) => require(['@/views/material/applet'], resolve),
meta: { title: '小程序', icon: '' },
},
],
},
// { // {
// path: '/appTool', // path: '/appTool',
// component: Layout, // component: Layout,
......
<script> <script>
import * as api from "@/api/customer"; import { updateBirthday, getDetail } from '@/api/customer'
export default { export default {
name: "CustomerDetail", name: 'CustomerDetail',
data() { data() {
return { return {
datePickerVisible: false, datePickerVisible: false,
customer: { customer: {
weFlowerCustomerRels: [], weFlowerCustomerRels: [],
}, },
birthday: "", birthday: '',
}; }
}, },
created() { created() {
this.customer = this.$route.query; this.getDetail()
this.birthday = this.customer.birthday;
}, },
methods: { methods: {
updateBirthday() { updateBirthday() {
if (!this.birthday) { if (!this.birthday || this.birthday == this.customer.birthday) {
return; return
} }
let data = { let data = {
externalUserid: this.customer.externalUserid, externalUserid: this.customer.externalUserid,
birthday: this.birthday, birthday: this.birthday,
}; }
api.updateBirthday(data).then((response) => { updateBirthday(data).then((response) => {
this.msgSuccess("操作成功"); this.msgSuccess('操作成功')
// todo get info this.getDetail()
this.datePickerVisible = false; this.datePickerVisible = false
}); })
},
getDetail() {
getDetail(this.$route.query.id).then(({ data }) => {
this.customer = data[0]
this.birthday = this.customer.birthday
})
}, },
}, },
}; }
</script> </script>
<template> <template>
...@@ -42,14 +47,20 @@ export default { ...@@ -42,14 +47,20 @@ export default {
<el-avatar :size="100" :src="customer.avatar"></el-avatar> <el-avatar :size="100" :src="customer.avatar"></el-avatar>
<div class="info-wrap"> <div class="info-wrap">
<div class="mb10"> <div class="mb10">
{{customer.name}} {{ customer.name }}
<span <span
:style="{color: customer.type == 1 ? '#4bde03' : '#f9a90b'}" :style="{ color: customer.type == 1 ? '#4bde03' : '#f9a90b' }"
>{{ ({1: '@微信', 2: '@企业微信'})[customer.type] }}</span> >{{ { 1: '@微信', 2: '@企业微信' }[customer.type] }}</span
<i :class="['el-icon-s-custom', ({1: 'man', 2: 'woman'})[customer.gender]]"></i> >
<i
:class="[
'el-icon-s-custom',
{ 1: 'man', 2: 'woman' }[customer.gender],
]"
></i>
</div> </div>
<div class="info"> <div class="info">
出生日期:{{customer.birthday || '--'}} 出生日期:{{ customer.birthday || '--' }}
<div class="bfc-d ml20"> <div class="bfc-d ml20">
<el-date-picker <el-date-picker
v-if="datePickerVisible" v-if="datePickerVisible"
...@@ -60,46 +71,61 @@ export default { ...@@ -60,46 +71,61 @@ export default {
@blur="datePickerVisible = false" @blur="datePickerVisible = false"
@change="updateBirthday" @change="updateBirthday"
></el-date-picker> ></el-date-picker>
<i v-else class="el-icon-edit" @click="datePickerVisible = true"></i> <i
v-else
v-hasPermi="['customerManage:customer:edit']"
class="el-icon-edit"
@click="datePickerVisible = true"
></i>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<el-card shadow="never" :body-style="{width: '400px'}"> <el-card shadow="never" :body-style="{ width: '400px' }">
<div> <div>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="10">备注名:</el-col> <el-col :span="10">备注名:</el-col>
<el-col :span="12">{{customer.name}}</el-col> <el-col :span="12">{{ customer.name }}</el-col>
</el-row> </el-row>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="10">标签:</el-col> <el-col :span="10">标签:</el-col>
<el-col :span="12"> <el-col :span="12">
<div v-for="(item, index) in customer.weFlowerCustomerRels" :key="index"> <div
v-for="(item, index) in customer.weFlowerCustomerRels"
:key="index"
>
<el-tag <el-tag
type="info" type="info"
v-for="(unit, unique) in item.weFlowerCustomerTagRels" v-for="(unit, unique) in item.weFlowerCustomerTagRels"
:key="unique" :key="unique"
>{{unit.tagName}}</el-tag> >{{ unit.tagName }}</el-tag
>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="10">个人标签:</el-col> <el-col :span="10">个人标签:</el-col>
<el-col :span="12">{{"--"}}</el-col> <el-col :span="12">{{ '--' }}</el-col>
</el-row> </el-row>
<el-divider></el-divider> <el-divider></el-divider>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="10">添加人:</el-col> <el-col :span="10">添加人:</el-col>
<el-col :span="12">{{customer.weFlowerCustomerRels[0].userName}}</el-col> <el-col :span="12">{{
customer.weFlowerCustomerRels[0].userName
}}</el-col>
</el-row> </el-row>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="10">所在部门:</el-col> <el-col :span="10">所在部门:</el-col>
<el-col :span="12">{{customer.weFlowerCustomerRels[0].department}}</el-col> <el-col :span="12">{{
customer.weFlowerCustomerRels[0].department
}}</el-col>
</el-row> </el-row>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="10">添加时间:</el-col> <el-col :span="10">添加时间:</el-col>
<el-col :span="12">{{customer.weFlowerCustomerRels[0].createTime}}</el-col> <el-col :span="12">{{
customer.weFlowerCustomerRels[0].createTime
}}</el-col>
</el-row> </el-row>
</div> </div>
</el-card> </el-card>
...@@ -158,4 +184,4 @@ export default { ...@@ -158,4 +184,4 @@ export default {
color: #f753b2; color: #f753b2;
} }
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
<script> <script>
import * as api from "@/api/customer/group"; import * as api from '@/api/customer/group'
export default { export default {
name: "GroupDetail", name: 'GroupDetail',
data() { data() {
return { return {
// 遮罩层 // 遮罩层
...@@ -25,34 +25,34 @@ export default { ...@@ -25,34 +25,34 @@ export default {
memberName: undefined, memberName: undefined,
}, },
joinScene: { joinScene: {
1: "由成员邀请入群(直接邀请入群)", 1: '由成员邀请入群(直接邀请入群)',
2: "由成员邀请入群(通过邀请链接入群)", 2: '由成员邀请入群(通过邀请链接入群)',
3: "通过扫描群二维码入群", 3: '通过扫描群二维码入群',
}, },
}; }
}, },
created() { created() {
this.group = this.$route.query; this.group = this.$route.query
this.query.chatId = this.group.chatId; this.query.chatId = this.group.chatId
this.getList(); this.getList()
}, },
methods: { methods: {
getList(page) { getList(page) {
page && (this.query.pageNum = page); page && (this.query.pageNum = page)
this.loading = false; this.loading = false
api.getMembers(this.query).then((response) => { api.getMembers(this.query).then((response) => {
this.list = response.rows; this.list = response.rows
this.total = +response.total; this.total = +response.total
this.loading = false; this.loading = false
}); })
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map((item) => item.operId); this.ids = selection.map((item) => item.operId)
this.multiple = !selection.length; this.multiple = !selection.length
}, },
}, },
}; }
</script> </script>
<template> <template>
...@@ -64,16 +64,21 @@ export default { ...@@ -64,16 +64,21 @@ export default {
src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
></el-avatar> ></el-avatar>
<div class="info-wrap"> <div class="info-wrap">
<div style="margin-bottom: 20px;">{{group.groupName}}</div> <div style="margin-bottom: 20px;">{{ group.groupName }}</div>
<div <div class="info">
class="info" 群主:{{ group.groupLeaderName }} | 创建时间:{{ group.createTime }} |
>群主:{{group.groupLeaderName}} | 创建时间:{{group.createTime}} | 群公告:{{group.notice || '未设置'}}</div> 群公告:{{ group.notice || '未设置' }}
</div>
</div> </div>
</div> </div>
<el-input placeholder="请输入群成员" v-model="query.memberName" class> <el-input placeholder="请输入群成员" v-model="query.memberName" class>
<el-button slot="append" @click="getList(1)">查询</el-button> <el-button slot="append" @click="getList(1)">查询</el-button>
</el-input> </el-input>
<el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange"> <el-table
v-loading="loading"
:data="list"
@selection-change="handleSelectionChange"
>
<!-- <el-table-column type="selection" width="55" align="center" /> --> <!-- <el-table-column type="selection" width="55" align="center" /> -->
<el-table-column label="群成员" align="center" prop="memberName"> <el-table-column label="群成员" align="center" prop="memberName">
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -84,7 +89,12 @@ export default { ...@@ -84,7 +89,12 @@ export default {
<!-- <i :class="['el-icon-s-custom', ({1: 'man', 2: 'woman'})[scope.row.gender]]"></i> --> <!-- <i :class="['el-icon-s-custom', ({1: 'man', 2: 'woman'})[scope.row.gender]]"></i> -->
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="进群时间" align="center" prop="joinTime" width="180"></el-table-column> <el-table-column
label="进群时间"
align="center"
prop="joinTime"
width="180"
></el-table-column>
<el-table-column label="进群方式" align="center" prop="joinScene"> <el-table-column label="进群方式" align="center" prop="joinScene">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ joinScene[scope.row.joinScene] }}</span> <span>{{ joinScene[scope.row.joinScene] }}</span>
...@@ -93,7 +103,7 @@ export default { ...@@ -93,7 +103,7 @@ export default {
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total > 0"
:total="total" :total="total"
:page.sync="query.pageNum" :page.sync="query.pageNum"
:limit.sync="query.pageSize" :limit.sync="query.pageSize"
...@@ -133,4 +143,4 @@ export default { ...@@ -133,4 +143,4 @@ export default {
color: #aaa; color: #aaa;
} }
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -17,32 +17,24 @@ export default { ...@@ -17,32 +17,24 @@ export default {
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id) + '' this.ids = selection.map((item) => item.id)
}, },
}, },
} }
</script> </script>
<template> <template>
<MaPage ref="page" type="1" @listChange="listChange"> <MaPage ref="page" type="1" @listChange="listChange" :selected="ids">
<el-table :data="list" @selection-change="handleSelectionChange"> <el-table :data="list" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" /> <el-table-column type="selection" width="50" align="center" />
<el-table-column label="语音" align="center" prop="materialUrl" /> <el-table-column label="语音" align="center" prop="materialName" />
<el-table-column <el-table-column label="时长" align="center" prop="audioTime" />
label="时长"
align="center"
prop="userName"
:show-overflow-tooltip="true"
/>
<el-table-column <el-table-column
label="创建时间" label="创建时间"
align="center" align="center"
prop="createTime" prop="createTime"
width="160" width="160"
> >
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="操作" label="操作"
......
...@@ -62,14 +62,18 @@ export default { ...@@ -62,14 +62,18 @@ export default {
emitPath: false, emitPath: false,
}, },
typeTitle: ['图片', '语音', '视频', '普通文件', '文本'], typeTitle: ['图片', '语音', '视频', '文件', '文本'],
form: {}, // 素材表单 form: {}, // 素材表单
fileUrl: '',
dialogVisible: false, // 素材表格对话框显隐 dialogVisible: false, // 素材表格对话框显隐
// 表单校验 // 表单校验
rules: Object.freeze({ rules: Object.freeze({
categoryId: [
{ required: true, message: '不能为空', trigger: 'change' },
],
content: [{ required: true, message: '不能为空', trigger: 'blur' }], content: [{ required: true, message: '不能为空', trigger: 'blur' }],
materialUrl: [{ required: true, message: '不能为空', trigger: 'blur' }], materialUrl: [
{ required: true, message: '不能为空', trigger: 'change' },
],
materialName: [ materialName: [
{ required: true, message: '不能为空', trigger: 'blur' }, { required: true, message: '不能为空', trigger: 'blur' },
], ],
...@@ -162,6 +166,7 @@ export default { ...@@ -162,6 +166,7 @@ export default {
}, },
// 素材提交 // 素材提交
submit() { submit() {
// this.$refs['form'].validateField
this.$refs['form'].validate((valid) => { this.$refs['form'].validate((valid) => {
if (valid) { if (valid) {
let form = JSON.parse(JSON.stringify(this.form)) let form = JSON.parse(JSON.stringify(this.form))
...@@ -179,7 +184,7 @@ export default { ...@@ -179,7 +184,7 @@ export default {
}, },
// 素材删除 // 素材删除
remove(id) { remove(id) {
const Ids = id || this.selected const Ids = id || this.selected + ''
this.$confirm('是否确认删除吗?', '警告', { this.$confirm('是否确认删除吗?', '警告', {
type: 'warning', type: 'warning',
}) })
...@@ -191,13 +196,18 @@ export default { ...@@ -191,13 +196,18 @@ export default {
this.msgSuccess('删除成功') this.msgSuccess('删除成功')
}) })
}, },
// 移动分组
moveGroup() { moveGroup() {
moveGroup(this.group, this.selected).then(() => { moveGroup(this.group, this.selected + '').then(() => {
this.getList() this.getList()
this.msgSuccess('操作成功') this.msgSuccess('操作成功')
this.groupDialogVisible = false this.groupDialogVisible = false
}) })
}, },
// 下载
download(data) {
window.open(data.materialUrl)
},
}, },
} }
</script> </script>
...@@ -207,7 +217,11 @@ export default { ...@@ -207,7 +217,11 @@ export default {
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="6" :xs="24"> <el-col :span="6" :xs="24">
<div> <div>
<el-button slot="reference" type="primary" @click="treeEdit({}, 0)" <el-button
v-hasPermi="['material:addType']"
slot="reference"
type="primary"
@click="treeEdit({}, 0)"
>添加分类</el-button >添加分类</el-button
> >
</div> </div>
...@@ -226,20 +240,21 @@ export default { ...@@ -226,20 +240,21 @@ export default {
<span>{{ node.label }}</span> <span>{{ node.label }}</span>
<span class="fr"> <span class="fr">
<i <i
v-hasPermi="['material:editType']"
class="el-icon-edit" class="el-icon-edit"
title="编辑" title="编辑"
@click.stop="treeEdit(data, 1)" @click.stop="treeEdit(data, 1)"
></i> ></i>
<i <i
v-hasPermi="['material:addType']"
class="el-icon-plus" class="el-icon-plus"
title="添加子分类" title="添加子分类"
v-hasPermi="['contacts:organization:addDep']"
@click.stop="treeEdit(data, 0)" @click.stop="treeEdit(data, 0)"
></i> ></i>
<i <i
v-hasPermi="['material:removeType']"
class="el-icon-minus" class="el-icon-minus"
title="删除" title="删除"
v-hasPermi="['contacts:organization:removeDep']"
@click.stop="treeRemove(data.id)" @click.stop="treeRemove(data.id)"
></i> ></i>
</span> </span>
...@@ -264,7 +279,10 @@ export default { ...@@ -264,7 +279,10 @@ export default {
style="width: 300px;" style="width: 300px;"
/> />
<el-button class="ml10" @click="getList(1)">搜索</el-button> <el-button class="ml10" @click="getList(1)">搜索</el-button>
<el-button @click="remove" :disabled="selected.length === 0" <el-button
v-hasPermi="['material:remove']"
@click="remove"
:disabled="selected.length === 0"
>删除</el-button >删除</el-button
> >
<el-popover placement="top" width="260" v-model="groupDialogVisible"> <el-popover placement="top" width="260" v-model="groupDialogVisible">
...@@ -285,6 +303,7 @@ export default { ...@@ -285,6 +303,7 @@ export default {
> >
</div> </div>
<el-button <el-button
v-hasPermi="['material:edit']"
slot="reference" slot="reference"
class="ml10" class="ml10"
:disabled="selected.length === 0" :disabled="selected.length === 0"
...@@ -293,7 +312,10 @@ export default { ...@@ -293,7 +312,10 @@ export default {
</el-popover> </el-popover>
<div class="fr"> <div class="fr">
<el-button type="primary" @click="edit(1)" <el-button
v-hasPermi="['material:add']"
type="primary"
@click="edit(1)"
>添加{{ typeTitle[type] }}</el-button >添加{{ typeTitle[type] }}</el-button
> >
</div> </div>
...@@ -347,7 +369,7 @@ export default { ...@@ -347,7 +369,7 @@ export default {
append-to-body append-to-body
> >
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item :label="typeTitle[type] + '分类'"> <el-form-item label="分类" prop="categoryId">
<el-cascader <el-cascader
v-model="form.categoryId" v-model="form.categoryId"
:options="treeData" :options="treeData"
...@@ -364,32 +386,74 @@ export default { ...@@ -364,32 +386,74 @@ export default {
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="图片" prop="materialUrl" v-else-if="type === '0'"> <template v-else-if="type === '0'">
<upload :fileUrl.sync="form.fileUrl" :mediaType="type"> <el-form-item label="文案" prop="content">
<div slot="tip"> <el-input
支持JPG,PNG格式,图片大小不超过2M,建议上传宽高1:1的图片 v-model="form.content"
</div> type="textarea"
</upload> :autosize="{ minRows: 2, maxRows: 50 }"
</el-form-item> placeholder="请输入"
></el-input>
</el-form-item>
<el-form-item label="图片" prop="materialUrl">
<upload
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName"
:type="type"
>
<div slot="tip">
支持JPG,PNG格式,图片大小不超过2M,建议上传宽高1:1的图片
</div>
</upload>
</el-form-item>
<el-form-item label="名称" prop="materialName">
<el-input
v-model="form.materialName"
placeholder="请输入"
></el-input>
</el-form-item>
</template>
<el-form-item label="语音" prop="materialUrl" v-else-if="type === '1'"> <template v-else-if="type === '1'">
<upload :fileUrl.sync="form.fileUrl" :mediaType="type"> <el-form-item label="语音" prop="materialUrl">
<div slot="tip"> <upload
只能上传amr格式的语音文件。单个文件大小不超过2M,时长不超过1分钟 :fileUrl.sync="form.materialUrl"
</div> :fileName.sync="form.materialName"
</upload> :type="type"
</el-form-item> >
<div slot="tip">
只能上传amr格式的语音文件。单个文件大小不超过2M,时长不超过1分钟
</div>
</upload>
</el-form-item>
<el-form-item label="名称" prop="materialName">
<el-input
v-model="form.materialName"
placeholder="请输入"
></el-input>
</el-form-item>
</template>
<template v-else-if="type === '2'"> <template v-else-if="type === '2'">
<el-form-item label="视频" prop="materialUrl"> <el-form-item label="视频" prop="materialUrl">
<upload :fileUrl.sync="form.fileUrl" :mediaType="type"> <upload
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName"
:type="type"
>
<div slot="tip"> <div slot="tip">
不超过10M, 文件格式: mp4 不超过10M, 文件格式: mp4
</div> </div>
</upload> </upload>
</el-form-item> </el-form-item>
<el-form-item label="名称" prop="materialName">
<el-input
v-model="form.materialName"
placeholder="请输入"
></el-input>
</el-form-item>
<el-form-item label="封面"> <el-form-item label="封面">
<upload :fileUrl.sync="form.coverUrl" mediaType="0"> <upload :fileUrl.sync="form.coverUrl" type="0">
<div slot="tip"> <div slot="tip">
建议尺寸:1068*455 建议尺寸:1068*455
</div> </div>
...@@ -404,13 +468,25 @@ export default { ...@@ -404,13 +468,25 @@ export default {
</el-form-item> </el-form-item>
</template> </template>
<el-form-item label="文件" prop="materialUrl" v-else-if="type === '3'"> <template v-else-if="type === '3'">
<upload :fileUrl.sync="form.coverUrl" :mediaType="type"> <el-form-item label="文件" prop="materialUrl">
<div slot="tip"> <upload
单个文件大小不超过20M :fileUrl.sync="form.materialUrl"
</div> :fileName.sync="form.materialName"
</upload> :type="type"
</el-form-item> >
<div slot="tip">
单个文件大小不超过20M
</div>
</upload>
</el-form-item>
<el-form-item label="名称" prop="materialName">
<el-input
v-model="form.materialName"
placeholder="请输入"
></el-input>
</el-form-item>
</template>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit">确 定</el-button> <el-button type="primary" @click="submit">确 定</el-button>
......
...@@ -16,35 +16,25 @@ export default { ...@@ -16,35 +16,25 @@ export default {
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map((item) => item.userId) this.ids = selection.map((item) => item.id)
this.single = selection.length != 1
this.multiple = !selection.length
}, },
}, },
} }
</script> </script>
<template> <template>
<MaPage ref="page" type="4" @listChange="listChange"> <MaPage ref="page" type="3" @listChange="listChange" :selected="ids">
<el-table :data="userList" @selection-change="handleSelectionChange"> <el-table :data="list" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" /> <el-table-column type="selection" width="50" align="center" />
<el-table-column <el-table-column
label="文件名" label="文件名"
align="center" align="center"
prop="materialUrl" prop="materialName"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
/> />
<el-table-column label="大小" align="center" prop="userName" /> <el-table-column label="大小" align="center" prop="userName" />
<el-table-column <el-table-column label="创建时间" align="center" prop="createTime">
label="创建时间"
align="center"
prop="createTime"
width="160"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="操作" label="操作"
......
...@@ -19,16 +19,12 @@ export default { ...@@ -19,16 +19,12 @@ export default {
listChange(data) { listChange(data) {
this.list = data this.list = data
}, },
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.userId)
},
}, },
} }
</script> </script>
<template> <template>
<MaPage ref="page" type="0" @listChange="listChange"> <MaPage ref="page" type="0" @listChange="listChange" :selected="ids">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col <el-col
:span="6" :span="6"
...@@ -58,7 +54,9 @@ export default { ...@@ -58,7 +54,9 @@ export default {
</div> </div>
</div> </div>
<div style="padding: 14px;"> <div style="padding: 14px;">
<el-checkbox v-model="ids">{{ item.name }}</el-checkbox> <el-checkbox v-model="ids" :label="item.id">{{
item.materialName
}}</el-checkbox>
</div> </div>
</el-card> </el-card>
</el-col> </el-col>
......
...@@ -18,7 +18,7 @@ export default { ...@@ -18,7 +18,7 @@ export default {
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id) + '' this.ids = selection.map((item) => item.id)
}, },
}, },
} }
......
<script> <script>
import MaPage from '@/views/material/components/MaPage' import MaPage from '@/views/material/components/MaPage'
import Video from 'video.js'
export default { export default {
components: { components: {
...@@ -7,10 +8,6 @@ export default { ...@@ -7,10 +8,6 @@ export default {
}, },
data() { data() {
return { return {
srcList: [
'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg',
],
list: [], // 列表 list: [], // 列表
ids: [], // 选中数组 ids: [], // 选中数组
} }
...@@ -26,20 +23,29 @@ export default { ...@@ -26,20 +23,29 @@ export default {
</script> </script>
<template> <template>
<MaPage ref="page" type="2" @listChange="listChange"> <MaPage ref="page" type="2" @listChange="listChange" :selected="ids">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col <el-col
:span="6" :span="6"
style="margin-top: 24px;" style="margin-top: 24px;min-width: 280px;"
v-for="(item, index) in list" v-for="(item, index) in list"
:key="index" :key="index"
> >
<el-card shadow="hover" body-style="padding: 0px;"> <el-card shadow="hover" body-style="padding: 0px;">
<div class="img-wrap"> <div class="img-wrap">
<el-image <video
:src="item.coverUrl" id="video"
:preview-src-list="srcList" class="video-js vjs-default-skin
></el-image> vjs-big-play-centered"
controls
webkit-playsinline="true"
playsinline="true"
autoplay="none"
preload="auto"
:poster="item.coverUrl"
>
<source :src="item.materialUrl" type="video/mp4" />
</video>
<div class="el-upload-list__item-actions"> <div class="el-upload-list__item-actions">
<span <span
class="el-upload-list__item-preview" class="el-upload-list__item-preview"
...@@ -62,9 +68,11 @@ export default { ...@@ -62,9 +68,11 @@ export default {
</div> </div>
</div> </div>
<div style="padding: 14px;"> <div style="padding: 14px;">
<el-checkbox v-model="kl">{{ item.createTime }}</el-checkbox> <el-checkbox v-model="ids" :label="item.id">{{
<div>{{ item.digest }}</div> item.createTime
}}</el-checkbox>
<div>{{ item.digest }}</div> <div>{{ item.digest }}</div>
<!-- <div>{{ item.digest }}</div> -->
</div> </div>
</el-card> </el-card>
</el-col> </el-col>
...@@ -82,7 +90,7 @@ export default { ...@@ -82,7 +90,7 @@ export default {
.el-upload-list__item-actions { .el-upload-list__item-actions {
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 50px; height: 40px;
left: 0; left: 0;
top: 0; top: 0;
cursor: default; cursor: default;
...@@ -93,4 +101,8 @@ export default { ...@@ -93,4 +101,8 @@ export default {
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
transition: opacity 0.3s; transition: opacity 0.3s;
} }
#video {
width: 100%;
height: 100%;
}
</style> </style>
...@@ -6,7 +6,6 @@ function resolve(dir) { ...@@ -6,7 +6,6 @@ function resolve(dir) {
} }
process.env.VUE_APP_TITLE = require('./package.json').description process.env.VUE_APP_TITLE = require('./package.json').description
process.env.VUE_APP_BASE_API = process.env.NODE_ENV === 'development' ? 'http://127.0.0.1:8080' : 'http://127.0.0.1:8080'
// vue.config.js 配置说明 // vue.config.js 配置说明
//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions //官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
// 这里只列一部分,具体配置参考文档 // 这里只列一部分,具体配置参考文档
...@@ -14,7 +13,7 @@ module.exports = { ...@@ -14,7 +13,7 @@ module.exports = {
// 部署生产环境和开发环境下的URL。 // 部署生产环境和开发环境下的URL。
// 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.xx.cn/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.xx.cn/admin/,则设置 baseUrl 为 /admin/。 // 例如 https://www.xx.cn/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.xx.cn/admin/,则设置 baseUrl 为 /admin/。
publicPath: process.env.NODE_ENV === "production" ? "/" : "/", publicPath: process.env.NODE_ENV === 'production' ? '/' : '/',
// 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist) // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
outputDir: 'dist', outputDir: 'dist',
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
...@@ -31,34 +30,34 @@ module.exports = { ...@@ -31,34 +30,34 @@ module.exports = {
open: true, open: true,
proxy: { proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy // detail: https://cli.vuejs.org/config/#devserver-proxy
['/']: { ['http']: {
target: process.env.VUE_APP_BASE_API, target: process.env.VUE_APP_BASE_API,
changeOrigin: true, changeOrigin: true,
// pathRewrite: { // pathRewrite: {
// ['^' + process.env.VUE_APP_BASE_API]: '' // ['^' + process.env.VUE_APP_BASE_API]: ''
// } // }
} },
}, },
disableHostCheck: true disableHostCheck: true,
}, },
css: { css: {
loaderOptions: { loaderOptions: {
sass: { sass: {
//依次导入的公用的scss变量,公用的scss混入,共用的默认样式 //依次导入的公用的scss变量,公用的scss混入,共用的默认样式
prependData: `@import "./src/styles/variables.scss";` prependData: `@import "./src/styles/variables.scss";`,
} },
} },
}, },
configureWebpack: { configureWebpack: {
resolve: { resolve: {
alias: { alias: {
'@': resolve('src') '@': resolve('src'),
} },
} },
}, },
chainWebpack(config) { chainWebpack(config) {
// 修复HMR // 修复HMR
config.resolve.symlinks(true); config.resolve.symlinks(true)
// set svg-sprite-loader // set svg-sprite-loader
config.module config.module
.rule('svg') .rule('svg')
...@@ -72,51 +71,49 @@ module.exports = { ...@@ -72,51 +71,49 @@ module.exports = {
.use('svg-sprite-loader') .use('svg-sprite-loader')
.loader('svg-sprite-loader') .loader('svg-sprite-loader')
.options({ .options({
symbolId: 'icon-[name]' symbolId: 'icon-[name]',
}) })
.end() .end()
config config.when(process.env.NODE_ENV !== 'development', (config) => {
.when(process.env.NODE_ENV !== 'development', config
config => { .plugin('ScriptExtHtmlWebpackPlugin')
config .after('html')
.plugin('ScriptExtHtmlWebpackPlugin') .use('script-ext-html-webpack-plugin', [
.after('html')
.use('script-ext-html-webpack-plugin', [{
// `runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/
}])
.end()
config
.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial' // only package third parties that are initially dependent
},
elementUI: {
name: 'chunk-elementUI', // split elementUI into a single package
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true
}
}
})
config.optimization.runtimeChunk('single'),
{ {
from: path.resolve(__dirname, './public/robots.txt'),//防爬虫文件 // `runtime` must same as runtimeChunk name. default is `runtime`
to: './',//到根目录下 inline: /runtime\..*\.js$/,
} },
])
.end()
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial', // only package third parties that are initially dependent
},
elementUI: {
name: 'chunk-elementUI', // split elementUI into a single package
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true,
},
},
})
config.optimization.runtimeChunk('single'),
{
from: path.resolve(__dirname, './public/robots.txt'), //防爬虫文件
to: './', //到根目录下
} }
) })
} },
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!