Showing
5 changed files
with
0 additions
and
294 deletions
1 | -<!DOCTYPE html> | ||
2 | -<html lang="en"> | ||
3 | -<head> | ||
4 | - <meta charset="UTF-8"> | ||
5 | - <link rel="icon" href="public/shui.png"/> | ||
6 | - <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
7 | - <title>智能综合监控平台</title> | ||
8 | - <script src="public/lib/vue/vue.global.prod.js"></script> | ||
9 | - <script src="public/lib/vue/vue-router.global.prod.js"></script> | ||
10 | - <script src="public/lib/vue/vuex.global.prod.js"></script> | ||
11 | - <link href="public/lib/element-plus/index.css" rel="stylesheet"> | ||
12 | - <script src="public/lib/element-plus/index.full.js"></script> | ||
13 | - <script src="public/lib/element-plus/zh-cn.js"></script> | ||
14 | - <link href="public/lib/vant/index.css" rel="stylesheet"> | ||
15 | - <script src="public/lib/vant/vant.min.js"></script> | ||
16 | - <script src="public/lib/axios/axios.min.js"></script> | ||
17 | - <!-- <script src="public/lib/dayjs/dayjs.min.js"></script> --> | ||
18 | - <script src="public/lib/jquery/jquery.min.js"></script> | ||
19 | - | ||
20 | - <script src="public/lib/echarts/echarts.min.js"></script> | ||
21 | - <script type="text/javascript"> | ||
22 | - let version = (new Date()).getTime(); | ||
23 | - let basrUrl = '/vue3/src/'; | ||
24 | - window.__ver = '?v=' + version; | ||
25 | - window.__basrUrl = basrUrl | ||
26 | - </script> | ||
27 | - <!-- 全局样式 --> | ||
28 | - <link href="public/common/common.css" rel="stylesheet"> | ||
29 | - <script type="module" src="src/script/appImport.js"></script> | ||
30 | - <!-- <script type="module" src="public/utils/mic.js"></script> --> | ||
31 | - <style> | ||
32 | - #app { | ||
33 | - font-family: Avenir, Helvetica, Arial, sans-serif; | ||
34 | - -webkit-font-smoothing: antialiased; | ||
35 | - -moz-osx-font-smoothing: grayscale; | ||
36 | - text-align: center; | ||
37 | - color: #2c3e50; | ||
38 | - } | ||
39 | - </style> | ||
40 | -</head> | ||
41 | -<body> | ||
42 | - | ||
43 | -<div id="app"> | ||
44 | - <router-view></router-view> | ||
45 | - <!-- <div id="nav"> | ||
46 | - <p> | ||
47 | - <router-link to="/vue3/test/">首页</router-link> | ||
48 | - <router-link to="/vue3/test/About">关于</router-link> | ||
49 | - <router-link to="/vue3/test/component">异步组件</router-link> | ||
50 | - <router-link to="/vue3/test/store">状态管理</router-link> | ||
51 | - | ||
52 | - </p> | ||
53 | - <hr> | ||
54 | - <div style="text-align: left;margin-left: 100px;height: 450px;"> | ||
55 | - <router-view></router-view> | ||
56 | - </div> | ||
57 | - </div> | ||
58 | - <hr> | ||
59 | - <div style="text-align: left;"> | ||
60 | - vuex状态演示<br> | ||
61 | - $store.state :{{$store.state}} <br> | ||
62 | - | ||
63 | - <el-button type="primary" @click="setCount">更改状态</el-button> | ||
64 | - <br> | ||
65 | - </div> --> | ||
66 | -</div> | ||
67 | -<script type="module" src="src/main.js"></script> | ||
68 | -</body> | ||
69 | -</html> | ||
70 | - |
1 | -const ver = window.__ver || ''; | ||
2 | - | ||
3 | -Promise.all([ | ||
4 | - import('./store/index.js' + ver), | ||
5 | - import('./router/index.js' + ver), | ||
6 | - import('./app.js' + ver), | ||
7 | - import('./script/global.js' + ver), | ||
8 | - import('./script/http.js' + ver), | ||
9 | -]).then((res) => { | ||
10 | - | ||
11 | - // 创建vue3的实例 | ||
12 | - const app = Vue.createApp(res[2].default) | ||
13 | - .use(res[0].default) // 挂载vuex | ||
14 | - .use(res[1].default) // 挂载路由 | ||
15 | - | ||
16 | - | ||
17 | - | ||
18 | - .use(ElementPlus, { | ||
19 | - locale: ElementPlus.lang.zhCn | ||
20 | - }) | ||
21 | - .use(ElementPlus) // 加载ElementPlus | ||
22 | - .use(vant) // 加载vant | ||
23 | - .use(vant.Lazyload) // 加载vant | ||
24 | - | ||
25 | - // 全局注册公共组件 | ||
26 | - .component('res-type-tree', Vue.defineAsyncComponent(() => myImport('components/common/restypetree/index'))) | ||
27 | - .component('machine-room',Vue.defineAsyncComponent(() => myImport('components/common/machineroom/index'))); | ||
28 | - | ||
29 | - | ||
30 | - app.config.globalProperties.$global = res[3].default | ||
31 | - app.config.globalProperties.$http = res[4].default | ||
32 | - app.mount('#app'); // 挂载Vue的app实例 | ||
33 | -}) |
1 | -// 直接放在Window里面好了。。。 | ||
2 | -window.myImport = (url) => { | ||
3 | - return new Promise((resolve, reject) => { | ||
4 | - const ver = window.__ver || '' | ||
5 | - const baseUrl = window.__basrUrl || '/src/' | ||
6 | - console.log("加载组件===>"+baseUrl + url) | ||
7 | - // 先加载js | ||
8 | - import(baseUrl + url + '.js' + ver).then((resjs) => { | ||
9 | - const js = resjs.default | ||
10 | - if (js.template === '') { | ||
11 | - // 如果模板是空的,表示需要加载html作为模板 | ||
12 | - axios.get(baseUrl + url + '.html' + ver).then((resHTML) => { | ||
13 | - js.template = resHTML.data | ||
14 | - //console.log(js); | ||
15 | - resolve(js) | ||
16 | - }) | ||
17 | - } else { | ||
18 | - // 否则直接使用js注册组件 | ||
19 | - //console.log(js); | ||
20 | - resolve(js) | ||
21 | - } | ||
22 | - }) | ||
23 | - }) | ||
24 | -} |
1 | -/** | ||
2 | - * 系统公共配置项 | ||
3 | - */ | ||
4 | - | ||
5 | -/*设置全局请求地址*/ | ||
6 | -const domainName = "http://127.0.0.1:8183"; | ||
7 | - | ||
8 | - | ||
9 | -var global = {}; | ||
10 | - | ||
11 | -global.common = { | ||
12 | - domainName: domainName, | ||
13 | - tokenKey: 'access_token', // 存放token的key | ||
14 | - refreshToken: 'refresh_token', // 存放token的key | ||
15 | - hasEnter: false // 登陆状态 | ||
16 | -}; | ||
17 | - | ||
18 | -global.showLoading = (callback) => { | ||
19 | - const loading = ElementPlus.ElLoading.service({ | ||
20 | - lock: true, | ||
21 | - text: '加载中...', | ||
22 | - spinner: 'icon-mj', | ||
23 | - background: 'rgba(0, 0, 0, 0.7)', | ||
24 | - }); | ||
25 | - | ||
26 | - if (callback) { | ||
27 | - callback(loading); | ||
28 | - } | ||
29 | - return loading; | ||
30 | -} | ||
31 | - | ||
32 | - | ||
33 | -global.showMsg = (msg, type = 'success') => { | ||
34 | - ElementPlus.ElMessage.success({ | ||
35 | - message: msg, | ||
36 | - type: type, | ||
37 | - }) | ||
38 | -} | ||
39 | - | ||
40 | -export default global |
1 | - | ||
2 | -let http = { | ||
3 | - proxy: null, | ||
4 | - isJson: function(obj) { | ||
5 | - var isjson = typeof(obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == | ||
6 | - "[object object]" && | ||
7 | - !obj.length; | ||
8 | - return isjson; | ||
9 | - }, | ||
10 | - reqErr : function(status){ | ||
11 | - if(status && status == '401'){ | ||
12 | - // 登录超时,刷新当前页面===>跳转到登录页面 | ||
13 | - window.location.reload(); | ||
14 | - } | ||
15 | - }, | ||
16 | - post: function(requestUrl, data, callback) { | ||
17 | - if(http.proxy == null){ | ||
18 | - const { proxy } = Vue.getCurrentInstance() | ||
19 | - http.proxy = proxy; | ||
20 | - } | ||
21 | - | ||
22 | - const loading = http.proxy.$global.showLoading(); | ||
23 | - var access_token = 'access_token=' + http.getToken(); | ||
24 | - if (requestUrl.indexOf('?') == -1) { | ||
25 | - requestUrl += '?' + access_token; | ||
26 | - } else { | ||
27 | - requestUrl += '&' + access_token; | ||
28 | - } | ||
29 | - $.ajax({ | ||
30 | - url: sessionStorage.getItem('domainName') + requestUrl, | ||
31 | - method: "post", | ||
32 | - processData: false, | ||
33 | - contentType: "application/json;charset=UTF-8", | ||
34 | - dataType: "JSON", | ||
35 | - async: true, | ||
36 | - data: JSON.stringify(data), | ||
37 | - error: function(xhr, textStatus) { | ||
38 | - loading.close(); | ||
39 | - console.log("==>",requestUrl, xhr, textStatus) | ||
40 | - http.reqErr(textStatus.status); | ||
41 | - }, | ||
42 | - success: function(data, textStatus, jqXHR) { | ||
43 | - if (callback) { | ||
44 | - callback(data); | ||
45 | - } | ||
46 | - loading.close() | ||
47 | - //console.log("==>", requestUrl, jqXHR, textStatus) | ||
48 | - | ||
49 | - } | ||
50 | - }); | ||
51 | - | ||
52 | - }, | ||
53 | - get: function(requestUrl, data, callback,errFunc) { | ||
54 | - if(http.proxy == null){ | ||
55 | - const { proxy } = Vue.getCurrentInstance() | ||
56 | - http.proxy = proxy; | ||
57 | - } | ||
58 | - const loading = http.proxy.$global.showLoading(); | ||
59 | - var access_token = 'access_token=' + http.getToken(); | ||
60 | - if (requestUrl.indexOf('?') == -1) { | ||
61 | - requestUrl += '?' + access_token; | ||
62 | - } else { | ||
63 | - requestUrl += '&' + access_token; | ||
64 | - } | ||
65 | - $.ajax({ | ||
66 | - url: sessionStorage.getItem('domainName') + requestUrl, | ||
67 | - method: "get", | ||
68 | - headers: { | ||
69 | - "Authorization": "Bearer " + http.getToken() + "" | ||
70 | - }, | ||
71 | - data: data, | ||
72 | - error: function(xhr, textStatus) { | ||
73 | - loading.close(); | ||
74 | - console.log("==>",requestUrl, xhr, textStatus) | ||
75 | - http.reqErr(textStatus.status); | ||
76 | - | ||
77 | - if(errFunc){ | ||
78 | - errFunc(); | ||
79 | - } | ||
80 | - | ||
81 | - }, | ||
82 | - success: function(data, textStatus, jqXHR) { | ||
83 | - if (callback) { | ||
84 | - callback(data); | ||
85 | - } | ||
86 | - loading.close(); | ||
87 | - //console.log("==>", requestUrl, jqXHR, textStatus) | ||
88 | - } | ||
89 | - }); | ||
90 | - }, | ||
91 | - | ||
92 | - downloadFile(fileName, content) { | ||
93 | - var filename = fileName; | ||
94 | - var a = document.createElement('a') | ||
95 | - var blob = new Blob([content]) | ||
96 | - a.download = filename | ||
97 | - a.href = URL.createObjectURL(blob) | ||
98 | - a.click() | ||
99 | - URL.revokeObjectURL(blob) | ||
100 | - }, | ||
101 | - getToken() { | ||
102 | - return localStorage.getItem('access_token'); | ||
103 | - }, | ||
104 | - | ||
105 | - // showMsg(msg, type = 'success') { | ||
106 | - // ElementPlus.ElMessage.success({ | ||
107 | - // message: msg, | ||
108 | - // type: type, | ||
109 | - // }) | ||
110 | - // }, | ||
111 | - | ||
112 | - // showLoading(callback) { | ||
113 | - // const loading = ElementPlus.ElLoading.service({ | ||
114 | - // lock: true, | ||
115 | - // text: '加载中...', | ||
116 | - // spinner: 'el-icon-loading', | ||
117 | - // background: 'rgba(0, 0, 0, 0.7)', | ||
118 | - // }); | ||
119 | - | ||
120 | - // if (callback) { | ||
121 | - // callback(loading); | ||
122 | - // } | ||
123 | - // return loading; | ||
124 | - // } | ||
125 | -} | ||
126 | - | ||
127 | -export default http |
-
Please register or login to post a comment