调整前端代码格式符合ESLint规范

This commit is contained in:
zer0Black
2023-02-28 22:43:03 +08:00
parent f5e5990a3b
commit 77b1ca8f0d
48 changed files with 3199 additions and 3179 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
export default {
PUBLIC_KEY: `MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDKwvimHNGEiyV5L73llAeTv8O/3c9KLZLjNDpzNVOvzowk1MJySdSh6BiZPFXGLJ49Rrp/0U1L68ZCvC2Zv07YYTrr7Bd8o8lKB9HlUqcJo/seIHrLCLl2ePuLn+NYtIM4xxbbvAOdy5Ep/QbK4aWz8G7vsx8pctijLksYKNBQyQIDAQAB`,
PUBLIC_KEY: 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDKwvimHNGEiyV5L73llAeTv8O/3c9KLZLjNDpzNVOvzowk1MJySdSh6BiZPFXGLJ49Rrp/0U1L68ZCvC2Zv07YYTrr7Bd8o8lKB9HlUqcJo/seIHrLCLl2ePuLn+NYtIM4xxbbvAOdy5Ep/QbK4aWz8G7vsx8pctijLksYKNBQyQIDAQAB'
}
+27 -27
View File
@@ -4,31 +4,31 @@
* @param fmt
* @returns {*}
*/
export function formatDate(value, fmt) {
let regPos = /^\d+(\.\d+)?$/
if (regPos.test(value)) {
//如果是数字
let getDate = new Date(value)
let o = {
'M+': getDate.getMonth() + 1,
'd+': getDate.getDate(),
'h+': getDate.getHours(),
'm+': getDate.getMinutes(),
's+': getDate.getSeconds(),
'q+': Math.floor((getDate.getMonth() + 3) / 3),
'S': getDate.getMilliseconds()
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (getDate.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (let k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
}
}
return fmt
} else {
value = value.trim()
return value.substr(0, fmt.length)
}
export function formatDate (value, fmt) {
const regPos = /^\d+(\.\d+)?$/
if (regPos.test(value)) {
// 如果是数字
const getDate = new Date(value)
const o = {
'M+': getDate.getMonth() + 1,
'd+': getDate.getDate(),
'h+': getDate.getHours(),
'm+': getDate.getMinutes(),
's+': getDate.getSeconds(),
'q+': Math.floor((getDate.getMonth() + 3) / 3),
S: getDate.getMilliseconds()
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (getDate.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (const k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
}
}
return fmt
} else {
value = value.trim()
return value.substr(0, fmt.length)
}
}
+10 -10
View File
@@ -1,13 +1,13 @@
import {fileType} from "./fileType";
import { fileType } from './fileType'
export const downloadFile = (res) => {
let file_name = decodeURI(res.headers["content-disposition"]).split('=').pop();
let file_type = file_name.split('.').pop();
let blobData = new Blob([res.data], {type: fileType[file_type]});
let downloadUrl = window.URL.createObjectURL(blobData);
let anchor = document.createElement("a");
anchor.href = downloadUrl;
anchor.download = file_name;
anchor.click();
window.URL.revokeObjectURL(blobData);
const file_name = decodeURI(res.headers['content-disposition']).split('=').pop()
const file_type = file_name.split('.').pop()
const blobData = new Blob([res.data], { type: fileType[file_type] })
const downloadUrl = window.URL.createObjectURL(blobData)
const anchor = document.createElement('a')
anchor.href = downloadUrl
anchor.download = file_name
anchor.click()
window.URL.revokeObjectURL(blobData)
}
+11 -11
View File
@@ -1,13 +1,13 @@
export const fileType = {
pdf: 'application/pdf',
xls: 'application/vnd.ms-excel',
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
doc: 'application/msword',
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
ppt: 'application/vnd.ms-powerpoint',
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
png: 'image/png',
jpg: 'image/jpeg',
rar: 'application/x-rar',
zip: 'application/zip',
pdf: 'application/pdf',
xls: 'application/vnd.ms-excel',
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
doc: 'application/msword',
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
ppt: 'application/vnd.ms-powerpoint',
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
png: 'image/png',
jpg: 'image/jpeg',
rar: 'application/x-rar',
zip: 'application/zip'
}
+10 -10
View File
@@ -1,15 +1,15 @@
export const BASE_URL = {
// LOGIN_URL : "http://192.168.144.29:9090/cas/login?service=http://192.168.144.22:9966/login?loginType=1",
// LOGOUT_URL : "http://192.168.144.29:9090/cas/logout?service=http://192.168.144.22:9966/login?loginType=1",
// LOGIN_URL : "http://192.168.144.29:9090/cas/login?service=http://192.168.144.22:9966/login?loginType=1",
// LOGOUT_URL : "http://192.168.144.29:9090/cas/logout?service=http://192.168.144.22:9966/login?loginType=1",
//内部测试
// BASE_CHANGAN:'http://192.168.144.29:9090/cas',
BASE_LOCAL:'http://127.0.0.1:8080',
BASE_LOCAL_IMG:'http://127.0.0.1:8080',
// 内部测试
// BASE_CHANGAN:'http://192.168.144.29:9090/cas',
BASE_LOCAL: 'http://127.0.0.1:8080',
BASE_LOCAL_IMG: 'http://127.0.0.1:8080'
// //企业测试
// BASE_CHANGAN:'https://caddmuat.changan.com.cn/cas',
// BASE_LOCAL:'https://caddmuat.changan.com.cn/mi',
// BASE_LOCAL_IMG:'https://caddmuat.changan.com.cn',
// //企业测试
// BASE_CHANGAN:'https://caddmuat.changan.com.cn/cas',
// BASE_LOCAL:'https://caddmuat.changan.com.cn/mi',
// BASE_LOCAL_IMG:'https://caddmuat.changan.com.cn',
}
+7 -7
View File
@@ -1,13 +1,13 @@
import Quill from "quill";
import Quill from 'quill'
let Parchment = Quill.import("parchment");
const Parchment = Quill.import('parchment')
class lineHeightAttributor extends Parchment.Attributor.Style {
}
const lineHeightStyle = new lineHeightAttributor("lineHeight", "line-height", {
scope: Parchment.Scope.INLINE,
whitelist: ["initial", "1", "1.5", "1.75", "2", "3", "4"]
});
const lineHeightStyle = new lineHeightAttributor('lineHeight', 'line-height', {
scope: Parchment.Scope.INLINE,
whitelist: ['initial', '1', '1.5', '1.75', '2', '3', '4']
})
export {lineHeightStyle};
export { lineHeightStyle }
+87 -88
View File
@@ -1,104 +1,103 @@
import axios from 'axios';
import {Message, Loading} from 'element-ui';
import store from '../store';
import router from "../router";
import {BASE_URL} from "../utils/http";
import axios from 'axios'
import { Message, Loading } from 'element-ui'
import store from '../store'
import router from '../router'
import { BASE_URL } from '../utils/http'
// 记录请求个数、加载
let count = 0, loading = null;
let count = 0; let loading = null
// axios实例化
const instance = axios.create({
baseURL: '/library',
// timeout: 60000,
headers: {
'Cache-Control': 'no-cache',
'Pragma': 'no-cache'
}
});
baseURL: '/library',
// timeout: 60000,
headers: {
'Cache-Control': 'no-cache',
Pragma: 'no-cache'
}
})
// 添加请求拦截器
instance.interceptors.request.use(function (config) {
// 在发送请求之前做些什么
loading = Loading.service(null);
count++;
store.commit('saveIsLoading', true);
return config;
// 在发送请求之前做些什么
loading = Loading.service(null)
count++
store.commit('saveIsLoading', true)
return config
}, function (error) {
// 对请求错误做些什么
count--;
if (count < 1) {
loading.close();
store.commit('saveIsLoading', false);
}
Message.error(error);
return Promise.reject(error);
});
// 对请求错误做些什么
count--
if (count < 1) {
loading.close()
store.commit('saveIsLoading', false)
}
Message.error(error)
return Promise.reject(error)
})
// 添加响应拦截器
instance.interceptors.response.use(function (response) {
// 对响应数据做点什么
count--;
if (count < 1) {
loading.close();
store.commit('saveIsLoading', false);
}
// 对响应数据做点什么
count--
if (count < 1) {
loading.close()
store.commit('saveIsLoading', false)
}
// 登录超时
if (response.data.respCode === '401') {
store.commit('saveUserInfo', null);
router.push('/login');
Message.error('登录超时过期');
// var url = 'http://192.168.144.22:9966/login?loginType=1'
// // var url = 'http://10.64.23.30:7766/home'
//
// return window.open('http://192.168.144.29:9090/cas/login?service='+url, '_self');
// return window.open('https://caddmuat.changan.com.cn/cas/login?service='+url, '_self');
// window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self');
}
// 登录超时
if (response.data.respCode === '401') {
store.commit('saveUserInfo', null)
router.push('/login')
Message.error('登录超时过期')
// var url = 'http://192.168.144.22:9966/login?loginType=1'
// // var url = 'http://10.64.23.30:7766/home'
//
// return window.open('http://192.168.144.29:9090/cas/login?service='+url, '_self');
// return window.open('https://caddmuat.changan.com.cn/cas/login?service='+url, '_self');
// window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self');
}
// 请求成功
if (response.status === 200) {
if (response.data.respCode === "0") {
return response.data;
} else if (response.data.respCode === "-1") {
Message.error(response.data.message);
return Promise.reject(response);
} else {
return response;
}
} else { // 请求失败
Message.error(response.data.message);
return Promise.reject(response);
}
}, function (error) {
// 对响应错误做点什么
count--;
if (count < 1) {
loading.close();
store.commit('saveIsLoading', false);
}
// 登录过期
if (error.response.status === 401) {
store.commit('saveUserInfo', null);
router.push('/login');
Message.error('登录超时过期');
// window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self');
// var url = 'http://192.168.144.22:9966/login?loginType=1'
// // var url = 'http://10.64.23.30:7766/home'
//
// return window.open('http://192.168.144.29:9090/cas/login?service='+url, '_self');
// // return window.open('https://caddmuat.changan.com.cn/cas/login?service='+url, '_self');
}
// 判断超时
if (error.code === "ECONNABORTED" && error.message.indexOf('timeout') !== -1 && !error.config._retry) {
Message.error(error.message);
// 请求成功
if (response.status === 200) {
if (response.data.respCode === '0') {
return response.data
} else if (response.data.respCode === '-1') {
Message.error(response.data.message)
return Promise.reject(response)
} else {
Message.error(error.message);
return response
}
return Promise.reject(error);
});
} else { // 请求失败
Message.error(response.data.message)
return Promise.reject(response)
}
}, function (error) {
// 对响应错误做点什么
count--
if (count < 1) {
loading.close()
store.commit('saveIsLoading', false)
}
export {instance, loading};
// 登录过期
if (error.response.status === 401) {
store.commit('saveUserInfo', null)
router.push('/login')
Message.error('登录超时过期')
// window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self');
// var url = 'http://192.168.144.22:9966/login?loginType=1'
// // var url = 'http://10.64.23.30:7766/home'
//
// return window.open('http://192.168.144.29:9090/cas/login?service='+url, '_self');
// // return window.open('https://caddmuat.changan.com.cn/cas/login?service='+url, '_self');
}
// 判断超时
if (error.code === 'ECONNABORTED' && error.message.indexOf('timeout') !== -1 && !error.config._retry) {
Message.error(error.message)
} else {
Message.error(error.message)
}
return Promise.reject(error)
})
export { instance, loading }
+5 -5
View File
@@ -7,20 +7,20 @@ import Vue from 'vue'
* v-watermark="{text: '水印名称', textColor: 'rgba(100, 100, 100, 0.6)'}"
*/
Vue.directive('watermark', {
bind: function(el, binding){
bind: function (el, binding) {
// 水印文字,父元素,画布宽度,画布高度,字体,文字颜色,画布横坐标,是否铺满全页
function addWaterMarker(str, parentNode, width, height, font, textColor, fillTextX = '10'){
function addWaterMarker (str, parentNode, width, height, font, textColor, fillTextX = '10') {
// 检查父元素是否包含子元素
const elementContains = (parent, child) => parent !== child && parent.contains(child)
const flag = elementContains(parentNode, document.querySelector('canvas'))
// 防止重复创建
if (!flag) {
let can = document.createElement('canvas')
const can = document.createElement('canvas')
parentNode.appendChild(can)
can.width = width || 300
can.height = height || 140
can.style.display = 'none'
let cans = can.getContext('2d')
const cans = can.getContext('2d')
cans.rotate(-20 * Math.PI / 180)
cans.font = font || '13px Microsoft Yahei'
cans.fillStyle = textColor || 'rgba(100, 100, 100, 0.2)'
@@ -31,7 +31,7 @@ Vue.directive('watermark', {
// parentNode.style.backgroundImage = "url(" + can.toDataURL("image/png") + ")";
// 创建div 定位覆盖(某个元素,如图片添加水印建议使用此方法)
let div = document.createElement('div')
const div = document.createElement('div')
div.id = str
div.className = 'waterMark'
div.style.pointerEvents = 'none'