guci-date 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+
2
+
3
+
4
+
5
+
6
+ export function handleContextmenu() {
7
+ document.addEventListener('contextmenu', (event) =>{
8
+ event.preventDefault()
9
+ alert('你点了右键,是想复制啥东西吗? 根本不可能~。')
10
+ })
11
+
12
+ }
13
+
14
+
15
+ export function handleMenu() {
16
+
17
+ var menu = document.getElementById('menu');
18
+ document.body.oncontextmenu = function (e) {
19
+ var e = e || window.event;
20
+ e.preventDefault();
21
+ let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
22
+ let scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
23
+ menu.style.display = 'block';
24
+ menu.style.left = e.clientX + scrollLeft + 'px';
25
+ menu.style.top = e.clientY + scrollTop + 'px';
26
+ }
27
+
28
+ handleContextmenu()
29
+
30
+ }
31
+
32
+
33
+
package/loading.js ADDED
@@ -0,0 +1,22 @@
1
+
2
+ import { Loading } from 'element-ui';
3
+
4
+
5
+ let loading = null;
6
+
7
+ let startLoading = () => {
8
+ loading = Loading.service({
9
+ lock: true,
10
+ text: '加载中........',
11
+ spinner: 'el-icon-loading',
12
+ background: 'rgba(0, 0, 0, 0.6)'
13
+ })
14
+ }
15
+ let endLoading = () => {
16
+ loading.close();
17
+ }
18
+
19
+ export default {
20
+ startLoading,
21
+ endLoading
22
+ }
package/loding.js ADDED
@@ -0,0 +1,112 @@
1
+ var $ = {};
2
+
3
+ $.Particle = function(opt) {
4
+ this.radius = 7;
5
+ this.x = opt.x;
6
+ this.y = opt.y;
7
+ this.angle = opt.angle;
8
+ this.speed = opt.speed;
9
+ this.accel = opt.accel;
10
+ this.decay = 0.01;
11
+ this.life = 1;
12
+ };
13
+
14
+ $.Particle.prototype.step = function(i) {
15
+ this.speed += this.accel;
16
+ this.x += Math.cos(this.angle) * this.speed;
17
+ this.y += Math.sin(this.angle) * this.speed;
18
+ this.angle += $.PI / 64;
19
+ this.accel *= 1.01;
20
+ this.life -= this.decay;
21
+
22
+ if (this.life <= 0) {
23
+ $.particles.splice(i, 1);
24
+ }
25
+ };
26
+
27
+ $.Particle.prototype.draw = function(i) {
28
+ $.ctx.fillStyle = $.ctx.strokeStyle =
29
+ "hsla(" + ($.tick + this.life * 120) + ", 100%, 60%, " + this.life + ")";
30
+ $.ctx.beginPath();
31
+ if ($.particles[i - 1]) {
32
+ $.ctx.moveTo(this.x, this.y);
33
+ $.ctx.lineTo($.particles[i - 1].x, $.particles[i - 1].y);
34
+ }
35
+ $.ctx.stroke();
36
+
37
+ $.ctx.beginPath();
38
+ $.ctx.arc(
39
+ this.x,
40
+ this.y,
41
+ Math.max(0.001, this.life * this.radius),
42
+ 0,
43
+ $.TWO_PI
44
+ );
45
+ $.ctx.fill();
46
+
47
+ var size = Math.random() * 1.25;
48
+ $.ctx.fillRect(
49
+ ~~(this.x + (Math.random() - 0.5) * 35 * this.life),
50
+ ~~(this.y + (Math.random() - 0.5) * 35 * this.life),
51
+ size,
52
+ size
53
+ );
54
+ };
55
+
56
+ $.step = function() {
57
+ $.particles.push(
58
+ new $.Particle({
59
+ x: $.width / 2 + (Math.cos($.tick / 20) * $.min) / 2,
60
+ y: $.height / 2 + (Math.sin($.tick / 20) * $.min) / 2,
61
+ angle: $.globalRotation + $.globalAngle,
62
+ speed: 0,
63
+ accel: 0.01
64
+ })
65
+ );
66
+
67
+ $.particles.forEach(function(elem, index) {
68
+ elem.step(index);
69
+ });
70
+
71
+ $.globalRotation += $.PI / 6;
72
+ $.globalAngle += $.PI / 6;
73
+ };
74
+
75
+ $.draw = function() {
76
+ $.ctx.clearRect(0, 0, $.width, $.height);
77
+
78
+ $.particles.forEach(function(elem, index) {
79
+ elem.draw(index);
80
+ });
81
+ };
82
+
83
+ $.init = function() {
84
+ $.canvas = document.createElement("canvas");
85
+ $.ctx = $.canvas.getContext("2d");
86
+ $.width = 300;
87
+ $.height = 300;
88
+ $.canvas.width = $.width * window.devicePixelRatio;
89
+ $.canvas.height = $.height * window.devicePixelRatio;
90
+ $.canvas.style.width = $.width + "px";
91
+ $.canvas.style.height = $.height + "px";
92
+ $.ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
93
+ $.min = $.width * 0.5;
94
+ $.particles = [];
95
+ $.globalAngle = 0;
96
+ $.globalRotation = 0;
97
+ $.tick = 0;
98
+ $.PI = Math.PI;
99
+ $.TWO_PI = $.PI * 2;
100
+ $.ctx.globalCompositeOperation = "lighter";
101
+ document.body.appendChild($.canvas);
102
+ $.loop();
103
+ };
104
+
105
+ $.loop = function() {
106
+ requestAnimationFrame($.loop);
107
+ $.step();
108
+ $.draw();
109
+ $.tick++;
110
+ };
111
+
112
+ $.init();
package/max.js ADDED
@@ -0,0 +1,50 @@
1
+
2
+ export function getRandomLetterA() {
3
+ var randomIndex = Math.floor(Math.random() * 26);
4
+ var randomLetter = String.fromCharCode(65 + randomIndex);
5
+ return randomLetter;
6
+ }
7
+
8
+ export function getRandomLetterB() {
9
+ var randomIndex = Math.floor(Math.random() * 26);
10
+ var randomLetter = String.fromCharCode(65 + randomIndex);
11
+ return randomLetter;
12
+ }
13
+
14
+
15
+ export function getRandomLetterC() {
16
+ var randomIndex = Math.floor(Math.random() * 26);
17
+ var randomLetter = String.fromCharCode(65 + randomIndex);
18
+ return randomLetter;
19
+ }
20
+
21
+
22
+ export function getRandomLetterD() {
23
+ var randomIndex = Math.floor(Math.random() * 26);
24
+ var randomLetter = String.fromCharCode(65 + randomIndex);
25
+ return randomLetter;
26
+ }
27
+
28
+ export function getRandomLetterE() {
29
+ var randomIndex = Math.floor(Math.random() * 26);
30
+ var randomLetter = String.fromCharCode(65 + randomIndex);
31
+ return randomLetter;
32
+ }
33
+
34
+ export function getRandomLetterF() {
35
+ var randomIndex = Math.floor(Math.random() * 26);
36
+ var randomLetter = String.fromCharCode(65 + randomIndex);
37
+ return randomLetter;
38
+ }
39
+
40
+ export function getRandomLetterG() {
41
+ var randomIndex = Math.floor(Math.random() * 26);
42
+ var randomLetter = String.fromCharCode(65 + randomIndex);
43
+ return randomLetter;
44
+ }
45
+
46
+ export function getRandomLetterH() {
47
+ var randomIndex = Math.floor(Math.random() * 26);
48
+ var randomLetter = String.fromCharCode(65 + randomIndex);
49
+ return randomLetter;
50
+ }
package/oss.js ADDED
@@ -0,0 +1,40 @@
1
+ let OSS = require('ali-oss')
2
+
3
+ let client = new OSS({
4
+ region: 'oss-cn-beijing', //创建的时候,bucket所在的区域,华北2->oss-cn-beijing ;其他的可以去百度
5
+ accessKeyId: 'LTAI5tSgyjpiqFK4aGi2geXi',// 阿里云控制台创建的AccessKey
6
+ accessKeySecret: 'IQd3MjCjqmxnZLaDjmH9bH1pMS6vJh', //阿里云控制台创建的AccessSecret
7
+ bucket: 'mz-app-develop', //创建的bucket的名称
8
+ // endpoint: false
9
+ // stsToken: 'IQd3MjCjqmxnZLaDjmH9bH1pMS6vJh',
10
+ // retryCount: 10,
11
+ timeout: 999999
12
+ })
13
+
14
+ export const put = async (ObjName, fileUrl) => {
15
+ try {
16
+ let result = await client.put(`${ObjName}`, fileUrl)
17
+ // ObjName为文件名字,可以只写名字,就直接储存在 bucket 的根路径,如需放在文件夹下面直接在文件名前面加上文件夹名称
18
+ return result
19
+ } catch (e) {
20
+ console.log(e)
21
+ }
22
+ }
23
+
24
+ // 上传成功之后,转换真实的地址
25
+ export const signatureUrl= async (ObjName) => {
26
+ try {
27
+ let result = await client.signatureUrl(`${ObjName}`)
28
+ return result
29
+ } catch (e) {
30
+ console.log(e)
31
+ }
32
+ }
33
+
34
+ export const getFileNameUUID = () => {
35
+ function rx() {
36
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
37
+ }
38
+ return `${+new Date()}_${rx()}${rx()}`
39
+ }
40
+
package/ossFP.js ADDED
@@ -0,0 +1,82 @@
1
+ const OSS = require('ali-oss');
2
+
3
+ const client = new OSS({
4
+ region: 'oss-cn-beijing',
5
+ accessKeyId: 'LTAI5tSgyjpiqFK4aGi2geXi',
6
+ accessKeySecret: 'IQd3MjCjqmxnZLaDjmH9bH1pMS6vJh',
7
+ bucket: 'mz-app-develop',
8
+ });
9
+
10
+ const chunkSize = 1024 * 1024; // 1MB
11
+
12
+ export const uploadFileInChunksToOSS = async (fileName, file) => {
13
+ try {
14
+ // const { name, type } = file;
15
+ // const fileName = getFileNameUUID(name);
16
+ const totalChunks = Math.ceil(file.size / chunkSize);
17
+ let currentChunk = 0;
18
+
19
+
20
+ console.log(file)
21
+ const uploadChunk = async (chunk) => {
22
+ const partNumber = currentChunk + 1;
23
+ const buffer = await fileToBuffer(file);
24
+ const result = await client.uploadPart(fileName, partNumber, buffer, {
25
+ headers: {
26
+ 'Content-Type': 'file'
27
+ },
28
+ // ...options
29
+ });
30
+ currentChunk++;
31
+ if (currentChunk < totalChunks) {
32
+ const start = currentChunk * chunkSize;
33
+ const end = Math.min(start + chunkSize, file.size);
34
+ const nextChunk = file.slice(start, end);
35
+ await uploadChunk(nextChunk);
36
+ } else {
37
+ await handleUploadComplete(fileName);
38
+ }
39
+ };
40
+
41
+ const start = currentChunk * chunkSize;
42
+ const end = Math.min(start + chunkSize, file.size);
43
+ const chunk = file.slice(start, end);
44
+ await uploadChunk(chunk);
45
+ } catch (e) {
46
+ console.error('Error uploading file in chunks to OSS:', e);
47
+ throw e;
48
+ }
49
+ };
50
+
51
+ const handleUploadComplete = async (fileName) => {
52
+ try {
53
+ const result = await client.initMultipartUpload(fileName);
54
+ const uploadId = result.uploadId;
55
+ const parts = [];
56
+ for (let i = 1; i <= totalChunks; i++) {
57
+ const part = await client.uploadPart(fileName, uploadId, i, `${fileName}-${i}`);
58
+ parts.push({ PartNumber: i, ETag: part.ETag });
59
+ }
60
+ const completeResult = await client.completeMultipartUpload(fileName, uploadId, parts);
61
+ console.log('File uploaded to OSS, complete result:', completeResult);
62
+ } catch (e) {
63
+ console.error('Error completing multipart upload:', e);
64
+ throw e;
65
+ }
66
+ };
67
+
68
+ const fileToBuffer = async (blob) => {
69
+ return new Promise((resolve, reject) => {
70
+ const reader = new FileReader();
71
+ reader.onload = () => resolve(reader.result);
72
+ reader.onerror = reject;
73
+ reader.readAsArrayBuffer(blob);
74
+ });
75
+ };
76
+
77
+ const getFileNameUUID = () => {
78
+ function rx() {
79
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
80
+ }
81
+ return `${+new Date()}_${rx()}${rx()}`
82
+ };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "guci-date",
3
+ "version": "1.0.0",
4
+ "description": "A golden bottle of sake costs ten thousand yuan, and a jade plate costs ten thousand yuan.",
5
+ "main": "king and throw chopsticks, unable to eat. Draw your sword and look around in confusion.",
6
+ "scripts": {
7
+ "test": "oss the frozen Yellow River and climb the snowy Taihang Mountains."
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "in my spare time, and suddenly boarded a boat to dream of the sun."
12
+ },
13
+ "keywords": [
14
+ "rney",
15
+ "is",
16
+ "difficult",
17
+ "and",
18
+ "there",
19
+ "are",
20
+ "many",
21
+ "detours.",
22
+ "Where",
23
+ "is",
24
+ "it",
25
+ "now?",
26
+ "I",
27
+ "will",
28
+ "mount",
29
+ "a",
30
+ "long",
31
+ "wind",
32
+ "some",
33
+ "day",
34
+ "and",
35
+ "break",
36
+ "the",
37
+ "heavy",
38
+ "waves",
39
+ "and",
40
+ "set",
41
+ "my",
42
+ "cloudy",
43
+ "sail",
44
+ "straight",
45
+ "and",
46
+ "bridge",
47
+ "the",
48
+ "deep",
49
+ "deep",
50
+ "sea."
51
+ ],
52
+ "author": "Guci",
53
+ "license": "ISC"
54
+ }
@@ -0,0 +1,39 @@
1
+
2
+
3
+ import axios from "axios";
4
+ import apiBaseUrl from "../../config/api";
5
+
6
+
7
+ export const handleStudent = (type) =>{
8
+
9
+ let date = []
10
+
11
+ if(type === 1){
12
+
13
+ }
14
+
15
+ else if(type === 2){
16
+
17
+ }
18
+
19
+ else{
20
+
21
+ }
22
+
23
+
24
+ return date
25
+ }
26
+
27
+
28
+ export const handleTeacher = async () => {
29
+ try {
30
+ const response = await axios.get(`${ apiBaseUrl }/questionnaire/queryCreator`, { headers: { 'authorization': sessionStorage.getItem('tokenInfo') } })
31
+ const data = response.data.data || []
32
+ return data
33
+
34
+ } catch (error) {
35
+
36
+ console.error("Error fetching teacher data:", error)
37
+ return []
38
+ }
39
+ };
@@ -0,0 +1,28 @@
1
+ /*
2
+ * {array} userRouter 后端返回的路由权限
3
+ *{array} allRouter 前端配置好的路由权限
4
+ * realRoutes 过滤后的路由
5
+ * */
6
+ export function recursionRouter(userRouter = [], allRouter = []) {
7
+ var realRoutes = [];
8
+ allRouter.forEach((v, i) => {
9
+ userRouter.forEach((item, index) => {
10
+ if (item.jurTitle === v.meta.name) {
11
+ if (item.children && item.children.length > 0) {
12
+ v.children = recursionRouter(item.children, v.children);
13
+ }
14
+ realRoutes.push(v)
15
+ }
16
+ })
17
+ })
18
+ return realRoutes;
19
+ }
20
+
21
+ export function setDefaultRoute(routes) {
22
+ routes.forEach((v, i) => {
23
+ if (v.children && v.children.length > 0) {
24
+ v.redirect = {name: caches.children[0].naem}
25
+ setDefaultRoute(v.children);
26
+ }
27
+ })
28
+ }
package/request.js ADDED
@@ -0,0 +1,52 @@
1
+ // // 封装axios用于发请求
2
+ import axios from 'axios'
3
+ import router from '@/router';
4
+ import { Message } from 'element-ui';
5
+ import apiBaseUrl from "../../config/api";
6
+ // // 创建一个新的axios实例
7
+ const request = axios.create({
8
+ baseURL: apiBaseUrl,
9
+ timeout: 99999,
10
+ })
11
+ // // 添加请求拦截器
12
+ request.interceptors.request.use(function (config) {
13
+ config.headers["authorization"] = sessionStorage.getItem('tokenInfo') ? sessionStorage.getItem('tokenInfo') : ''
14
+ // config.headers["auth"] = localStorage.getItem('tokenInfo')
15
+ config.headers["Username"] = JSON.parse(window.localStorage.getItem('admin')).adminNo;
16
+ // console.log(config);
17
+ return config
18
+ }, function (error) {
19
+ console.log("请求失败");
20
+ // 对错误做处理
21
+ return Promise.reject(error)
22
+ })
23
+ // 添加响应拦截器(注意:函数都有返回值)
24
+ request.interceptors.response.use(function (response) {
25
+ return response.data
26
+ }, function (error) {
27
+ // 对响应错误做点什么 普通错误 + 401情况
28
+ console.log(error)
29
+ // 外面包一层error.response判断可以防止error.response为空 时内部代码报错
30
+ if (error.response) {
31
+ // 请求拦截器中 判断请求中是否验证token 是否过期 如果过期就返回 -1 跳转登录界面
32
+ if (error.code === -1) {
33
+ Message.error('登录已过期,请重新登录')
34
+ sessionStorage.removeItem('tokenInfo');
35
+ router.push('/')
36
+ }
37
+ if (error.response.status === 402 || error.response.status === 403) {
38
+ // 清空token 跳转到登录页 给个提示
39
+ Message.error('登录已过期,请重新登录')
40
+ // 提交清除token的mutation
41
+ sessionStorage.removeItem('tokenInfo');
42
+ // 跳转到登录页
43
+ router.push('/')
44
+ } else {
45
+ // 给个提示
46
+ Message.error(error.response.data.message)
47
+ }
48
+ }
49
+ return Promise.reject(error)
50
+ })
51
+ // 导出
52
+ export default request
package/retnue.js ADDED
@@ -0,0 +1,19 @@
1
+
2
+
3
+ import router from '@/router';
4
+ import { Message } from 'element-ui';
5
+ export function isReturn(code) {
6
+ if(code === -1){
7
+ sessionStorage.removeItem('tokenInfo')
8
+ Message.error('登录已过期,请重新登录')
9
+ router.push("/");
10
+ }else{
11
+ // Message.success('查询成功')
12
+ return
13
+ }
14
+ return
15
+ }
16
+
17
+
18
+
19
+
package/util.js ADDED
@@ -0,0 +1,18 @@
1
+ export const fromData = function (value) {
2
+ const date = new Date(value)
3
+ const year = date.getFullYear()
4
+ const month = date.getMonth() + 1
5
+ const day = date.getDate()
6
+ const hour = date.getHours()
7
+ const minute = date.getMinutes()
8
+ const second = date.getSeconds()
9
+ // 位数不够两位,前面加0
10
+ const formatNumber = n => {
11
+ n = n.toString()
12
+ return n[1] ? n : '0' + n
13
+ }
14
+ return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':')
15
+ };
16
+
17
+ // 判断是手机端还是pc端
18
+ export const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);