xs-common-plugins 1.3.9 → 1.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xs-common-plugins",
3
- "version": "1.3.9",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "description": "向上公共代码部分",
6
6
  "author": "祝玲云 <1902733517@qq.com>",
package/src/App.vue CHANGED
@@ -2,17 +2,13 @@
2
2
  <div id="app">
3
3
  <router-view/>
4
4
  <router-view name="websocket"/>
5
- <UpdateChecker />
6
5
  </div>
7
6
  </template>
8
7
 
9
8
  <script>
10
- import UpdateChecker from './components/UpdateChecker'
11
9
  export default {
12
10
  name: 'App',
13
- components: {
14
- UpdateChecker
15
- }
11
+ components: {}
16
12
  }
17
13
 
18
14
  </script>
@@ -1,88 +1,145 @@
1
1
  <script>
2
+ import trackerSend from '@/router/ca'
2
3
  import md5 from 'js-md5'
3
- import { defineComponent } from 'vue'
4
- import trackerSend from "@/router/ca";
4
+ import Vue from 'vue'
5
5
 
6
- function trackerSendUpdateChecker({action} = {}) {
7
- trackerSend({
8
- title: "检测到新版本",
9
- action
10
- })
6
+ function trackerSendUpdateChecker({ action } = {}) {
7
+ trackerSend({
8
+ title: '检测到新版本',
9
+ action
10
+ })
11
11
  }
12
12
 
13
- const DURATION = 1000 * 60 * 60 * 2
13
+ const DURATION = 1000 * 60 * 30
14
14
  export default {
15
- name: 'UpdateChecker',
16
- data () {
17
- return {
18
- md5: '',
19
- interval: null
20
- }
21
- },
22
- methods: {
23
- check() {
24
- return fetch(`${location.origin}${location.pathname}`, {
25
- cache: 'no-cache',
26
- }).then(async (res) => {
27
- return res.text()
28
- })
29
- },
30
- start() {
31
- this.stop()
32
- this.interval = setInterval(() => {
33
- this.check().then(text => {
34
- const newMd5 = md5(text)
35
- if (newMd5 !== this.md5) {
36
- this.stop()
37
- this.notify()
38
- trackerSendUpdateChecker({action: "检测到新版本通知用户"})
39
- }
40
- })
41
- }, DURATION)
42
- },
43
- stop() {
44
- if (!this.interval) return
45
- clearInterval(this.interval)
46
- },
47
- refresh() {
48
- trackerSendUpdateChecker({action: "检测到新版本刷新页面"})
49
- window.location.reload()
50
- },
51
- onClose() {
52
- this.start()
53
- trackerSendUpdateChecker({action: "检测到新版本关闭提示"})
54
- },
55
- notify() {
56
- this.$common.popup({
57
- title: '检测到新版本',
58
- component: defineComponent({
59
- template: `<div>
60
- <div style="font-size: 14px;color: #606266;line-height: 20px;padding: 10px 20px">
61
- 检测到有新版本已经发布,请刷新页面
62
- </div>
63
- <div style="text-align: center"><el-button type="primary" @click="refresh">刷新</el-button></div>
64
- </div>`,
65
- methods: {
66
- refresh: () => this.refresh(),
67
- beforeClose: (done) => {done(); this.onClose()}
68
- },
69
- }),
70
- dialogCfg: {
71
- closeOnClickModal: false,
72
- closeOnPressEscape: false
73
- }
74
- })
75
- }
76
- },
77
- mounted() {
78
- this.check().then(text => {
79
- this.md5 = md5(text)
80
- this.start()
81
- })
82
- },
83
- render() {
84
- return null
85
- }
15
+ name: 'UpdateChecker',
16
+ data() {
17
+ return {
18
+ md5: '',
19
+ interval: null
20
+ }
21
+ },
22
+ methods: {
23
+ check() {
24
+ return fetch(`${location.origin}${location.pathname}`, {
25
+ cache: 'no-cache'
26
+ }).then(async res => {
27
+ return res.text()
28
+ })
29
+ },
30
+ start() {
31
+ this.stop()
32
+ this.interval = setInterval(() => {
33
+ this.check().then(text => {
34
+ const newMd5 = md5(text)
35
+ if (newMd5 !== this.md5) {
36
+ this.stop()
37
+ this.notify()
38
+ trackerSendUpdateChecker({ action: '检测到新版本通知用户' })
39
+ }
40
+ })
41
+ }, DURATION)
42
+ },
43
+ stop() {
44
+ if (!this.interval) return
45
+ clearInterval(this.interval)
46
+ },
47
+ refresh() {
48
+ trackerSendUpdateChecker({ action: '检测到新版本刷新页面' })
49
+ window.location.reload()
50
+ },
51
+ onClose() {
52
+ this.start()
53
+ trackerSendUpdateChecker({ action: '检测到新版本关闭提示' })
54
+ },
55
+ notify() {
56
+ let vm = new Vue({
57
+ template: `
58
+ <div class='update-box'>
59
+ <div class='update-box-content'>
60
+ <p class='title'>版本更新</p>
61
+ <p class='message'>检测到有新版本已经发布,请刷新页面</p>
62
+ <div class='update-box-btn'>
63
+ <button class='button-close' @click='close'>关闭</button>
64
+ <button @click='refresh'>刷新</button>
65
+ </div>
66
+ </div>
67
+ </div>`,
68
+ methods: {
69
+ refresh: () => this.refresh(),
70
+ close: () => {
71
+ vm.$el.remove()
72
+ this.onClose()
73
+ }
74
+ }
75
+ })
76
+ vm.$mount()
77
+ document.body.appendChild(vm.$el)
78
+ }
79
+ },
80
+ mounted() {
81
+ this.check().then(text => {
82
+ this.md5 = md5(text)
83
+ this.start()
84
+ })
85
+ },
86
+ render() {
87
+ return null
88
+ }
86
89
  }
87
-
88
- </script>
90
+ </script>
91
+
92
+ <style lang="scss">
93
+ .update-box {
94
+ position: fixed;
95
+ width: 300px;
96
+ right: 0;
97
+ bottom: 0;
98
+ background-color: #fff;
99
+ border-radius: 5px;
100
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
101
+ z-index: 100;
102
+ transform: translateY(0);
103
+ transition: transform 0.3s;
104
+
105
+ .update-box-content {
106
+ padding: 20px;
107
+
108
+ .title {
109
+ font-size: 16px;
110
+ color: #333;
111
+ text-align: left;
112
+ margin-bottom: 20px;
113
+ margin-top: 0px;
114
+ }
115
+
116
+ .message {
117
+ font-size: 14px;
118
+ color: #606266;
119
+ text-align: center;
120
+ margin-bottom: 20px;
121
+ }
122
+
123
+ .update-box-btn {
124
+ text-align: center;
125
+
126
+ .button-close {
127
+ padding: 5px 10px;
128
+ background-color: #f56c6c;
129
+ color: #fff;
130
+ cursor: pointer;
131
+ margin-right: 20px;
132
+ }
133
+
134
+ button {
135
+ padding: 5px 10px;
136
+ border: none;
137
+ background-color: #409eff;
138
+ color: #fff;
139
+ border-radius: 4px;
140
+ cursor: pointer;
141
+ }
142
+ }
143
+ }
144
+ }
145
+ </style>
@@ -45,9 +45,6 @@
45
45
  />
46
46
  </el-badge>
47
47
  </div>
48
- <div class="changelog">
49
- <ChangeLog />
50
- </div>
51
48
  <div>
52
49
  <el-tag style="margin: 0 3px;">{{
53
50
  userProfile &&
@@ -119,7 +116,6 @@ import { mapGetters } from "vuex";
119
116
  import Breadcrumb from "@/components/Breadcrumb";
120
117
  import Hamburger from "@/components/Hamburger";
121
118
  import AllSearch from "./AllSearch";
122
- import ChangeLog from "./ChangeLog";
123
119
  import { getConfig } from "@/utils/global-config";
124
120
  import { getToken, removeToken, removeLocalToken } from "@/utils/auth"; // get token from cookie
125
121
  import ImCom from "@/components/im";
@@ -133,7 +129,6 @@ export default {
133
129
  Hamburger,
134
130
  AllSearch,
135
131
  ImCom,
136
- ChangeLog,
137
132
  },
138
133
  data() {
139
134
  return {
@@ -1,59 +0,0 @@
1
- <template>
2
- <div v-if="list.length > 0">
3
- <el-dropdown :hide-on-click="false" @command="handleCommand">
4
- <el-badge is-dot class="item">
5
- <i class="el-icon-bell"></i>
6
- </el-badge>
7
- <el-dropdown-menu slot="dropdown">
8
- <el-dropdown-item v-for="(item, index) in list" :key="index" :command="index">{{ item.title }}</el-dropdown-item>
9
- </el-dropdown-menu>
10
- </el-dropdown>
11
- </div>
12
- </template>
13
-
14
- <script>
15
- import {defineComponent, h} from "vue";
16
- import { getConfig } from "@/utils/global-config";
17
- export default {
18
- name: 'changeLog',
19
- data () {
20
- return {
21
- list: []
22
- }
23
- },
24
- methods: {
25
- handleCommand (command) {
26
- this.$common.popup({
27
- title: this.list[command].remark,
28
- component: defineComponent({
29
- template: `<div>
30
- <div style="font-size: 14px;color: #606266;line-height: 20px;padding: 10px 20px">${this.list[command].remark}</div>
31
- <div style="text-align: center"><el-button type="primary" @click="$emit('close')">关闭</el-button></div>
32
- </div>`
33
- })
34
- });
35
- },
36
- getChangeLog () {
37
- this.$ask.commng.api.commmng.Banner.Query.post({pageInfo: {
38
- page: 1,
39
- pageSize: 3
40
- },
41
- codeLike: `changelog#${getConfig('CLIENT_ID')}`
42
- }).then((result) => {
43
- if (result.code === 0 && result.data.data.length > 0) {
44
- this.list = result.data.data;
45
- }
46
- }).catch((err) => {
47
-
48
- }).finally(() => {
49
- setTimeout(() => {
50
- this.getChangeLog();
51
- }, 1000 * 60 * 60 * 12);
52
- })
53
- }
54
- },
55
- mounted () {
56
- this.getChangeLog();
57
- }
58
- }
59
- </script>