Skip to content

Commit ebafd83

Browse files
committed
结构优化
1 parent deeefcd commit ebafd83

File tree

17 files changed

+357
-350
lines changed

17 files changed

+357
-350
lines changed

src/assets/css/themes.scss

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,29 @@
11
$t1-base-color: #409EFF;
2-
$t1-boxShadow-color: #2d77c0;
32
$t2-base-color: #fe7c01;
4-
$t2-boxShadow-color: #a94f00;
53
$t3-base-color: #6e7786;
6-
$t3-boxShadow-color: #3f444d;
4+
75

86

97
.theme1 {
10-
box-shadow: 0px 1px 10px 1px $t1-boxShadow-color;
11-
width: 94%;
8+
width: 92%;
129
background: #fff;
1310
border-radius: 8px;
14-
margin: 0 3% 20px 3%;
15-
padding-bottom: 20px;
16-
overflow: hidden;
11+
margin: 0 auto 20px auto;
12+
padding: 10px 0;
1713
}
1814

1915
.theme2 {
20-
box-shadow: 0px 1px 10px 1px $t2-boxShadow-color;
21-
width: 94%;
16+
width: 92%;
2217
background: #fff;
2318
border-radius: 8px;
24-
margin: 0 3% 20px 3%;
25-
padding-bottom: 20px;
26-
overflow: hidden;
19+
margin: 0 auto 20px auto;
20+
padding: 10px 0;
2721
}
2822

2923
.theme3 {
30-
box-shadow: 0px 1px 10px 1px $t3-boxShadow-color;
31-
width: 94%;
24+
width: 92%;
3225
background: #fff;
3326
border-radius: 8px;
34-
margin: 0 3% 20px 3%;
35-
padding-bottom: 20px;
36-
overflow: hidden;
27+
margin: 0 auto 20px auto;
28+
padding: 10px 0;
3729
}

src/assets/css/widget.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ $primary-background-color: #d8e8fa;
2121

2222
.widget-form-list {
2323
min-height: 360px;
24-
padding-bottom: 25px;
2524

2625
.ghost {
2726
background: #fff;

src/assets/js/api.js

Lines changed: 3 additions & 240 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
import Vue from "vue";
2-
import Crypto from "./crypto";
1+
// import Vue from "vue";
2+
3+
// const vue = new Vue();
34

45
export default {
5-
install(Vue) {
6-
if (Vue) {
7-
Vue.prototype.$api = this;
8-
}
9-
},
10-
vue: new Vue(),
116
previewUrl: "http://192.168.218.113:3000",
127
env() {
138
if (process.env.NODE_ENV === "development") return "development";
@@ -19,237 +14,5 @@ export default {
1914
// if (this.env() === "development") return "http://192.168.218.185:8022/";
2015
// if (this.env() === 'test') return "http://test-api.junjue888.com/";
2116
// return "http://api.junjue888.com/";
22-
},
23-
getUrlParam(name) {
24-
var reg = new RegExp("(^|/?|&)" + name + "=([^&]*)(&|$)", "i");
25-
var l = window.location.href;
26-
var i = l.indexOf("?");
27-
if (i < 0) return null;
28-
var str = l.slice(i + 1, l.length);
29-
if (str) {
30-
var r = str.match(reg);
31-
if (r) {
32-
return unescape(r[2]);
33-
}
34-
}
35-
return null;
36-
},
37-
/**
38-
* 设置cookie
39-
* @param key key
40-
* @param value 值
41-
* @param time 保存时间(天)
42-
*/
43-
setCookie(key, value, time) {
44-
var cur = new Date();
45-
cur.setTime(cur.getTime() + time * 24 * 3600 * 1000);
46-
document.cookie = key + "=" + encodeURIComponent(value) + ";expires=" + (time ? cur.toGMTString() : "");
47-
},
48-
getCookie(key) {
49-
var data = document.cookie;
50-
var startIndex = data.indexOf(key + "=");
51-
if (startIndex > -1) {
52-
startIndex = startIndex + key.length + 1;
53-
var endIndex = data.indexOf(";", startIndex);
54-
endIndex = endIndex < 0 ? data.length : endIndex;
55-
return decodeURIComponent(data.substring(startIndex, endIndex));
56-
} else {
57-
return "";
58-
}
59-
},
60-
delCookie(key) {
61-
var data = this.getCookie(key);
62-
if (data !== false) this.setCookie(key, data, -1);
63-
},
64-
/**
65-
*
66-
* @param key key
67-
* @param value value
68-
* @param encode 是否加密存储
69-
*/
70-
setSStorage(key, value, encode) {
71-
let str = window.JSON.stringify(value);
72-
if (encode) {
73-
str = Crypto.encrypt(str);
74-
}
75-
window.sessionStorage.setItem(key, str);
76-
},
77-
getSStorage(key, decode) {
78-
var str = "";
79-
str = window.sessionStorage.getItem(key);
80-
if (!str) return "";
81-
if (decode) {
82-
str = Crypto.decrypt(str);
83-
}
84-
try {
85-
return window.JSON.parse(str);
86-
} catch (error) {
87-
window.sessionStorage.removeItem(key);
88-
window.location.reload();
89-
}
90-
},
91-
setLStorage(key, value, encode) {
92-
let str = window.JSON.stringify(value);
93-
if (encode) {
94-
str = Crypto.encrypt(str);
95-
}
96-
window.localStorage.setItem(key, str);
97-
},
98-
getLStorage(key, decode) {
99-
var str = "";
100-
str = window.localStorage.getItem(key);
101-
if (!str) return "";
102-
try {
103-
if (decode) str = Crypto.decrypt(str);
104-
return window.JSON.parse(str);
105-
} catch (error) {
106-
window.localStorage.removeItem(key);
107-
window.location.reload();
108-
}
109-
},
110-
checkMobile(nub) {
111-
return /^1[0-9]{10}$/.test(nub);
112-
},
113-
isNumber(val) {
114-
let pattern = /^[1-9]{1}\d*$/g;
115-
let isNumber = pattern.test(val);
116-
return isNumber;
117-
},
118-
/**
119-
* 四舍五入强制保留n位小数
120-
* @param x 操作数字
121-
* @param n 保留位数
122-
*/
123-
toDecimal(x, n) {
124-
var f = parseFloat(x);
125-
if (isNaN(f) && isNaN(n)) {
126-
return false;
127-
}
128-
if (n === 0) return Math.round(x);
129-
var num = Number("1E" + n);
130-
f = Math.round(x * num) / num;
131-
var s = f.toString();
132-
var rs = s.indexOf(".");
133-
if (rs < 0) {
134-
rs = s.length;
135-
s += ".";
136-
}
137-
while (s.length <= rs + n) {
138-
s += "0";
139-
}
140-
return s;
141-
},
142-
/**
143-
* 获取日期时间 默认格式 "yyyy-mm-dd hh:mm:ss"
144-
* @param {String} formatType 可选 格式类型
145-
* @param {Date} formatDate 可选 指定日期
146-
* @return {String} 所需格式的日期
147-
*/
148-
getFormatDate(formatType, formatDate) {
149-
let type = formatType || "yyyy-mm-dd hh:mm:ss";
150-
let date = Object.prototype.toString.call(formatDate) === "[object Date]" ? formatDate : new Date();
151-
let currentdate = "";
152-
let month = date.getMonth() + 1;
153-
let strDate = date.getDate();
154-
let minutes = date.getMinutes();
155-
let seconds = date.getSeconds();
156-
month >= 1 && month <= 9 ? (month = "0" + month) : "";
157-
strDate >= 0 && strDate <= 9 ? (strDate = "0" + strDate) : "";
158-
minutes >= 0 && minutes <= 9 ? (minutes = "0" + minutes) : "";
159-
seconds >= 0 && seconds <= 9 ? (seconds = "0" + seconds) : "";
160-
161-
switch (type.toLowerCase()) {
162-
case "yyyy-mm-dd hh:mm:ss":
163-
currentdate = date.getFullYear() + "-" + month + "-" + strDate + " " + date.getHours() + ":" + minutes + ":" + seconds;
164-
break;
165-
case "yyyy-mm-dd":
166-
currentdate = date.getFullYear() + "-" + month + "-" + strDate;
167-
break;
168-
case "yyyy-mm-dd hh:mm":
169-
currentdate = date.getFullYear() + "-" + month + "-" + strDate + " " + date.getHours() + ":" + minutes;
170-
break;
171-
case "yyyy-mm-dd hh":
172-
currentdate = date.getFullYear() + "-" + month + "-" + strDate + " " + date.getHours();
173-
break;
174-
case "yyyy-mm":
175-
currentdate = date.getFullYear() + "-" + month;
176-
break;
177-
case "yyyy":
178-
currentdate = date.getFullYear();
179-
break;
180-
default:
181-
currentdate = date.getFullYear() + "-" + month + "-" + strDate + " " + date.getHours() + ":" + minutes + ":" + seconds;
182-
break;
183-
}
184-
return currentdate;
185-
},
186-
/**
187-
* 数据导出
188-
* @param {String} url 导出路径
189-
* @param {Object} data 导出参数
190-
*/
191-
exportData(url, data) {
192-
if (typeof data !== "object") {
193-
console.warn("导出参数错误");
194-
return;
195-
}
196-
let queryData = "",
197-
downloadUrl = "";
198-
for (const [key, value] of Object.entries(data)) {
199-
if (key === "sessionId") break;
200-
queryData += `${key}=${value}&`;
201-
}
202-
downloadUrl = url + "?" + queryData.slice(0, -1);
203-
window.location.href = downloadUrl;
204-
},
205-
/**
206-
* 缓冲函数
207-
* @param {Object} dom 目标dom
208-
* @param {Number} destination 目标位置
209-
* @param {Number} rate 缓动率
210-
* 示例用法
211-
var dom = document.documentElement || document.body;
212-
this.$api.easeout(dom, 0, 5);
213-
*/
214-
easeout(dom, destination = 0, rate = 3) {
215-
let position = dom.scrollTop;
216-
if (position === destination || typeof destination !== "number" || rate === 0) {
217-
return false;
218-
}
219-
// 不存在原生`requestAnimationFrame`,用`setTimeout`模拟替代
220-
if (!window.requestAnimationFrame) {
221-
window.requestAnimationFrame = function(fn) {
222-
return setTimeout(fn, 17);
223-
};
224-
}
225-
let step = function() {
226-
position = position + (destination - position) / rate;
227-
if (Math.abs(destination - position) < 1) {
228-
//动画结束
229-
dom.scrollTop = destination;
230-
return;
231-
}
232-
dom.scrollTop = position;
233-
requestAnimationFrame(step);
234-
};
235-
step();
236-
},
237-
/**
238-
* 对象深拷贝
239-
* @param {Object} obj 初始对象
240-
* @return {Object} result 拷贝后对象
241-
*/
242-
deepClone(obj) {
243-
let result = Array.isArray(obj) ? [] : {};
244-
for (let key in obj) {
245-
if (obj.hasOwnProperty(key)) {
246-
if (typeof obj[key] === 'object') {
247-
result[key] = this.deepClone(obj[key]); //递归复制
248-
} else {
249-
result[key] = obj[key];
250-
}
251-
}
252-
}
253-
return result;
25417
}
25518
};

src/assets/js/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Vue from 'vue';
2+
import Api from './api';
3+
import Util from './util';
4+
5+
"use strict";
6+
7+
let MyPlugin = {}
8+
9+
MyPlugin.install = function(Vue) {
10+
if (Vue) {
11+
Vue.prototype.$api = Api;
12+
Vue.prototype.$util = Util;
13+
}
14+
};
15+
16+
Vue.use(MyPlugin)
17+
18+
export default MyPlugin;

0 commit comments

Comments
 (0)