vue2-client 1.2.86 → 1.2.88

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/CHANGELOG.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Change Log
2
2
  > 所有关于本项目的变化都在该文档里。
3
3
 
4
- **1.2.81 - 1.2.86 -2022-07-21 @朱子峰**
4
+ **1.2.81 - 1.2.88 -2022-07-21 @朱子峰**
5
5
  - 功能新增:
6
6
  - 兼容V4登陆
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.2.86",
3
+ "version": "1.2.88",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -1,269 +1,269 @@
1
- <template>
2
- <div>
3
- <custom-columns-drawer
4
- :columns-meta="jsonData"
5
- :columns.sync="tableColumns"
6
- :visible.sync="visible"/>
7
- <a-row :gutter="48">
8
- <a-col>
9
- <span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
10
- <slot name="expand"></slot>
11
- </span>
12
- </a-col>
13
- <a-col>
14
- <span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
15
- <a-button-group>
16
- <a-button @click="toggleIsFormShow">
17
- <a-icon :style="iconStyle" type="vertical-align-top"/>
18
- </a-button>
19
- <a-button @click="refresh(true)">
20
- <a-icon :style="iconStyle" type="reload" />
21
- </a-button>
22
- <a-button @click="showDrawer">
23
- <a-icon :style="iconStyle" type="table" />
24
- </a-button>
25
- <a-button v-if="!buttonState || buttonState.export" @click="exports">
26
- <a-icon :style="iconStyle" type="cloud-download"/>
27
- </a-button>
28
- </a-button-group>
29
- </span>
30
- </a-col>
31
- </a-row>
32
- <s-table
33
- ref="table"
34
- :alert="true"
35
- :columns="tableColumns"
36
- :data="loadData"
37
- :rowKey="rowKey"
38
- :rowSelection="rowSelection"
39
- :scroll="{ x: scrollXWidth, y: scrollYWidth }"
40
- showPagination="auto"
41
- size="default"
42
- >
43
- <template
44
- v-for="(item, index) in tableColumns"
45
- :slot="item.dataIndex"
46
- slot-scope="text, record">
47
- <!-- 文本溢出省略(ellipsis) -->
48
- <span v-if="item.slotType === 'ellipsis'" :key="index">
49
- <ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
50
- </span>
51
- <!-- 徽标(badge) -->
52
- <span v-else-if="item.slotType === 'badge'" :key="index">
53
- <x-badge :badge-key="item.slotKeyMap" :value="text" />
54
- </span>
55
- <!-- 日期(date) -->
56
- <span v-else-if="item.slotType === 'date'" :key="index">
57
- {{ format(text,'yyyy-MM-dd') }}
58
- </span>
59
- <!-- 日期时间(datetime) -->
60
- <span v-else-if="item.slotType === 'dateTime'" :key="index">
61
- {{ format(text,'yyyy-MM-dd hh:mm:ss') }}
62
- </span>
63
- <!-- 操作列(action) -->
64
- <span v-else-if="item.slotType === 'action'" :key="index">
65
- <a @click="action(record)">{{ item.slotValue }}</a>
66
- </span>
67
- </template>
68
- </s-table>
69
- </div>
70
- </template>
71
- <script>
72
- import { Ellipsis, STable } from '@vue2-client/components'
73
- import { formatDate } from '@vue2-client/utils/util'
74
- import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
75
-
76
- export default {
77
- name: 'XTable',
78
- components: {
79
- STable,
80
- Ellipsis
81
- },
82
- data () {
83
- return {
84
- // 加载数据方法 必须为 Promise 对象
85
- loadData: parameter => {
86
- // 取到表格携带的表单参数
87
- const requestParameters = Object.assign({}, parameter)
88
- // 取到父组件传入的表单参数
89
- const conditionParams = Object.assign(this.fixedQueryForm, this.form)
90
- // 如果适用了综合筛选表单,则进行数据处理
91
- if (conditionParams.rowIdName) {
92
- const rowIdName = conditionParams.rowIdName
93
- const rowIdValue = conditionParams.rowIdValue
94
- delete conditionParams.rowIdName
95
- delete conditionParams.rowIdValue
96
- if (rowIdValue) {
97
- conditionParams[rowIdName] = rowIdValue
98
- }
99
- }
100
- // 如果传了燃气公司字段,则进行数据处理
101
- if (conditionParams.orgName) {
102
- requestParameters.orgName = conditionParams.orgName
103
- delete conditionParams.orgName
104
- }
105
- requestParameters.conditionParams = conditionParams
106
- requestParameters.queryParamsName = this.queryParamsName
107
- requestParameters.queryParams = this.queryParams
108
- // 加载数据
109
- return this.loadTableData(requestParameters)
110
- },
111
- rowKey: undefined,
112
- scrollXWidth: 1600,
113
- scrollYWidth: 437,
114
- selectedRowKeys: [],
115
- selectedRows: [],
116
- // 数据列
117
- tableColumns: this.jsonData,
118
- // 是否显示展示列抽屉
119
- visible: false,
120
- dataSource: [],
121
- // 图标样式
122
- iconStyle: {
123
- position: 'relative',
124
- top: '1px'
125
- }
126
- }
127
- },
128
- watch: {
129
- form (rel) {
130
- this.form = rel
131
- this.refresh(true)
132
- },
133
- jsonData () {
134
- this.initTableParams()
135
- }
136
- },
137
- props: {
138
- jsonData: {
139
- type: Array,
140
- default: () => {
141
- return []
142
- }
143
- },
144
- queryParamsName: {
145
- type: String,
146
- default: () => {
147
- return ''
148
- }
149
- },
150
- // 查询参数对象, 用于没有对应查询配置文件名时
151
- queryParams: {
152
- type: Object,
153
- default: null
154
- },
155
- form: {
156
- type: Object,
157
- default: () => {
158
- return {}
159
- }
160
- },
161
- // 固定查询表单
162
- fixedQueryForm: {
163
- type: Object,
164
- default: () => {
165
- return {}
166
- }
167
- },
168
- // 按钮
169
- buttonState: {
170
- type: Object,
171
- default: () => {
172
- return undefined
173
- }
174
- }
175
- },
176
- computed: {
177
- rowSelection () {
178
- return {
179
- selectedRowKeys: this.selectedRowKeys,
180
- onChange: this.onSelectChange
181
- }
182
- }
183
- },
184
- mounted () {
185
- this.initTableParams()
186
- },
187
- methods: {
188
- exports () {
189
- const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
190
- const filterVal = this.tableColumns.map(res => res.dataIndex)
191
- const list = this.dataSource
192
- const data = this.formatJson(filterVal, list)
193
- exportJson(tHeader, data, new Date())
194
- },
195
- formatJson (filterVal, jsonData) {
196
- return jsonData.map(v => filterVal.map(j => v[j]))
197
- },
198
- badgeFilter (key, value) {
199
- return this.$appdata.getParam(key, value)
200
- },
201
- initTableParams () {
202
- let totalWidth = 0
203
- this.rowKey = this.tableColumns[0].dataIndex
204
- for (let i = 0; i < this.tableColumns.length; i++) {
205
- const item = this.tableColumns[i]
206
- if (item.dataIndex === 'action') {
207
- item.fixed = 'right'
208
- item.width = 70
209
- }
210
- if (item.width) {
211
- totalWidth = totalWidth + item.width
212
- } else {
213
- totalWidth = totalWidth + 180
214
- }
215
- }
216
- const width = document.documentElement.clientWidth
217
- if (width >= 1600) {
218
- this.scrollYWidth = 429
219
- } else if (width >= 1200) {
220
- this.scrollYWidth = 390
221
- } else {
222
- this.scrollYWidth = 343
223
- }
224
- // 横向滚动长度大于所有宽度,才能实现固定表头
225
- this.scrollXWidth = totalWidth
226
- },
227
- loadTableData (requestParameters) {
228
- let data = []
229
- this.$emit('loadData', requestParameters, val => {
230
- data = val
231
- })
232
- const _this = this
233
- data.then(res => {
234
- _this.dataSource = res.data
235
- })
236
- return data
237
- },
238
- action (record) {
239
- this.$emit('action', record, record[this.jsonData[0].dataIndex])
240
- },
241
- onSelectChange (selectedRowKeys, selectedRows) {
242
- this.selectedRowKeys = selectedRowKeys
243
- this.selectedRows = selectedRows
244
- this.$emit('selectRow', selectedRowKeys)
245
- },
246
- clearRowKeys () {
247
- this.$refs.table.clearSelected()
248
- },
249
- /**
250
- * 表格重新加载方法
251
- * 如果参数为 true, 则强制刷新到第一页
252
- */
253
- refresh (bool) {
254
- this.$refs.table.refresh(bool)
255
- },
256
- format (date, format) {
257
- return formatDate(date, format)
258
- },
259
- showDrawer () {
260
- this.visible = true
261
- },
262
- toggleIsFormShow () {
263
- this.$emit('toggleIsFormShow')
264
- }
265
- }
266
- }
267
- </script>
268
- <style lang="less" scoped>
269
- </style>
1
+ <template>
2
+ <div>
3
+ <custom-columns-drawer
4
+ :columns-meta="jsonData"
5
+ :columns.sync="tableColumns"
6
+ :visible.sync="visible"/>
7
+ <a-row :gutter="48">
8
+ <a-col>
9
+ <span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
10
+ <slot name="expand"></slot>
11
+ </span>
12
+ </a-col>
13
+ <a-col>
14
+ <span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
15
+ <a-button-group>
16
+ <a-button @click="toggleIsFormShow">
17
+ <a-icon :style="iconStyle" type="vertical-align-top"/>
18
+ </a-button>
19
+ <a-button @click="refresh(true)">
20
+ <a-icon :style="iconStyle" type="reload" />
21
+ </a-button>
22
+ <a-button @click="showDrawer">
23
+ <a-icon :style="iconStyle" type="table" />
24
+ </a-button>
25
+ <a-button v-if="!buttonState || buttonState.export" @click="exports">
26
+ <a-icon :style="iconStyle" type="cloud-download"/>
27
+ </a-button>
28
+ </a-button-group>
29
+ </span>
30
+ </a-col>
31
+ </a-row>
32
+ <s-table
33
+ ref="table"
34
+ :alert="true"
35
+ :columns="tableColumns"
36
+ :data="loadData"
37
+ :rowKey="rowKey"
38
+ :rowSelection="rowSelection"
39
+ :scroll="{ x: scrollXWidth, y: scrollYWidth }"
40
+ showPagination="auto"
41
+ size="default"
42
+ >
43
+ <template
44
+ v-for="(item, index) in tableColumns"
45
+ :slot="item.dataIndex"
46
+ slot-scope="text, record">
47
+ <!-- 文本溢出省略(ellipsis) -->
48
+ <span v-if="item.slotType === 'ellipsis'" :key="index">
49
+ <ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
50
+ </span>
51
+ <!-- 徽标(badge) -->
52
+ <span v-else-if="item.slotType === 'badge'" :key="index">
53
+ <x-badge :badge-key="item.slotKeyMap" :value="text" />
54
+ </span>
55
+ <!-- 日期(date) -->
56
+ <span v-else-if="item.slotType === 'date'" :key="index">
57
+ {{ format(text,'yyyy-MM-dd') }}
58
+ </span>
59
+ <!-- 日期时间(datetime) -->
60
+ <span v-else-if="item.slotType === 'dateTime'" :key="index">
61
+ {{ format(text,'yyyy-MM-dd hh:mm:ss') }}
62
+ </span>
63
+ <!-- 操作列(action) -->
64
+ <span v-else-if="item.slotType === 'action'" :key="index">
65
+ <a @click="action(record)">{{ item.slotValue }}</a>
66
+ </span>
67
+ </template>
68
+ </s-table>
69
+ </div>
70
+ </template>
71
+ <script>
72
+ import { Ellipsis, STable } from '@vue2-client/components'
73
+ import { formatDate } from '@vue2-client/utils/util'
74
+ import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
75
+
76
+ export default {
77
+ name: 'XTable',
78
+ components: {
79
+ STable,
80
+ Ellipsis
81
+ },
82
+ data () {
83
+ return {
84
+ // 加载数据方法 必须为 Promise 对象
85
+ loadData: parameter => {
86
+ // 取到表格携带的表单参数
87
+ const requestParameters = Object.assign({}, parameter)
88
+ // 取到父组件传入的表单参数
89
+ const conditionParams = Object.assign(this.fixedQueryForm, this.form)
90
+ // 如果适用了综合筛选表单,则进行数据处理
91
+ if (conditionParams.rowIdName) {
92
+ const rowIdName = conditionParams.rowIdName
93
+ const rowIdValue = conditionParams.rowIdValue
94
+ delete conditionParams.rowIdName
95
+ delete conditionParams.rowIdValue
96
+ if (rowIdValue) {
97
+ conditionParams[rowIdName] = rowIdValue
98
+ }
99
+ }
100
+ // 如果传了燃气公司字段,则进行数据处理
101
+ if (conditionParams.orgName) {
102
+ requestParameters.orgName = conditionParams.orgName
103
+ delete conditionParams.orgName
104
+ }
105
+ requestParameters.conditionParams = conditionParams
106
+ requestParameters.queryParamsName = this.queryParamsName
107
+ requestParameters.queryParams = this.queryParams
108
+ // 加载数据
109
+ return this.loadTableData(requestParameters)
110
+ },
111
+ rowKey: undefined,
112
+ scrollXWidth: 1600,
113
+ scrollYWidth: 437,
114
+ selectedRowKeys: [],
115
+ selectedRows: [],
116
+ // 数据列
117
+ tableColumns: this.jsonData,
118
+ // 是否显示展示列抽屉
119
+ visible: false,
120
+ dataSource: [],
121
+ // 图标样式
122
+ iconStyle: {
123
+ position: 'relative',
124
+ top: '1px'
125
+ }
126
+ }
127
+ },
128
+ watch: {
129
+ form (rel) {
130
+ this.form = rel
131
+ this.refresh(true)
132
+ },
133
+ jsonData () {
134
+ this.initTableParams()
135
+ }
136
+ },
137
+ props: {
138
+ jsonData: {
139
+ type: Array,
140
+ default: () => {
141
+ return []
142
+ }
143
+ },
144
+ queryParamsName: {
145
+ type: String,
146
+ default: () => {
147
+ return ''
148
+ }
149
+ },
150
+ // 查询参数对象, 用于没有对应查询配置文件名时
151
+ queryParams: {
152
+ type: Object,
153
+ default: null
154
+ },
155
+ form: {
156
+ type: Object,
157
+ default: () => {
158
+ return {}
159
+ }
160
+ },
161
+ // 固定查询表单
162
+ fixedQueryForm: {
163
+ type: Object,
164
+ default: () => {
165
+ return {}
166
+ }
167
+ },
168
+ // 按钮
169
+ buttonState: {
170
+ type: Object,
171
+ default: () => {
172
+ return undefined
173
+ }
174
+ }
175
+ },
176
+ computed: {
177
+ rowSelection () {
178
+ return {
179
+ selectedRowKeys: this.selectedRowKeys,
180
+ onChange: this.onSelectChange
181
+ }
182
+ }
183
+ },
184
+ mounted () {
185
+ this.initTableParams()
186
+ },
187
+ methods: {
188
+ exports () {
189
+ const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
190
+ const filterVal = this.tableColumns.map(res => res.dataIndex)
191
+ const list = this.dataSource
192
+ const data = this.formatJson(filterVal, list)
193
+ exportJson(tHeader, data, new Date())
194
+ },
195
+ formatJson (filterVal, jsonData) {
196
+ return jsonData.map(v => filterVal.map(j => v[j]))
197
+ },
198
+ badgeFilter (key, value) {
199
+ return this.$appdata.getParam(key, value)
200
+ },
201
+ initTableParams () {
202
+ let totalWidth = 0
203
+ this.rowKey = this.tableColumns[0].dataIndex
204
+ for (let i = 0; i < this.tableColumns.length; i++) {
205
+ const item = this.tableColumns[i]
206
+ if (item.dataIndex === 'action') {
207
+ item.fixed = 'right'
208
+ item.width = 70
209
+ }
210
+ if (item.width) {
211
+ totalWidth = totalWidth + item.width
212
+ } else {
213
+ totalWidth = totalWidth + 180
214
+ }
215
+ }
216
+ const width = document.documentElement.clientWidth
217
+ if (width >= 1600) {
218
+ this.scrollYWidth = 429
219
+ } else if (width >= 1200) {
220
+ this.scrollYWidth = 390
221
+ } else {
222
+ this.scrollYWidth = 343
223
+ }
224
+ // 横向滚动长度大于所有宽度,才能实现固定表头
225
+ this.scrollXWidth = totalWidth
226
+ },
227
+ loadTableData (requestParameters) {
228
+ let data = []
229
+ this.$emit('loadData', requestParameters, val => {
230
+ data = val
231
+ })
232
+ const _this = this
233
+ data.then(res => {
234
+ _this.dataSource = res.data
235
+ })
236
+ return data
237
+ },
238
+ action (record) {
239
+ this.$emit('action', record, record[this.jsonData[0].dataIndex])
240
+ },
241
+ onSelectChange (selectedRowKeys, selectedRows) {
242
+ this.selectedRowKeys = selectedRowKeys
243
+ this.selectedRows = selectedRows
244
+ this.$emit('selectRow', selectedRowKeys)
245
+ },
246
+ clearRowKeys () {
247
+ this.$refs.table.clearSelected()
248
+ },
249
+ /**
250
+ * 表格重新加载方法
251
+ * 如果参数为 true, 则强制刷新到第一页
252
+ */
253
+ refresh (bool) {
254
+ this.$refs.table.refresh(bool)
255
+ },
256
+ format (date, format) {
257
+ return formatDate(date, format)
258
+ },
259
+ showDrawer () {
260
+ this.visible = true
261
+ },
262
+ toggleIsFormShow () {
263
+ this.$emit('toggleIsFormShow')
264
+ }
265
+ }
266
+ }
267
+ </script>
268
+ <style lang="less" scoped>
269
+ </style>
@@ -93,7 +93,7 @@ export default {
93
93
  }
94
94
  case 'OA' : {
95
95
  loginStart(name, password).then(this.afterLoginOA).finally(() => { this.logging = false })
96
- break
96
+ break
97
97
  }
98
98
  case 'V4' : {
99
99
  V4Login(name, password).then(this.afterLoginV4)
@@ -116,23 +116,27 @@ export default {
116
116
  const password = this.form.getFieldValue('password')
117
117
  this.logging = false
118
118
  const loginRes = res
119
- const V4Token = { token: res.access_token, expire: res.expires_in }
120
- this.setV4AccessToken(V4Token)
121
119
  // 如果这是用户首次打开本系统,localStorage无法初始化,改用code判断
122
120
  let pass = false
121
+ let V4Token = {}
122
+ // 判断是否是第一次使用本系统
123
123
  if (res.code) {
124
124
  if (res.code === 200) {
125
125
  pass = true
126
+ // 如果返回值有code,证明是第一次使用系统,localStorage判断compatible失效
127
+ // token需要从.data中获取
128
+ V4Token = { token: res.data.access_token, expire: res.data.expires_in }
126
129
  }
130
+ } else {
131
+ V4Token = { token: res.access_token, expire: res.expires_in }
127
132
  }
133
+ this.setV4AccessToken(V4Token)
128
134
  // 向本地缓存中临时存储compatible
129
- console.log(loginRes)
130
135
  if (loginRes.access_token || pass) {
131
136
  const encrypt = new JSEncrypt()
132
137
  encrypt.setPublicKey('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqPvovSfXcwBbW8cKMCgwqNpsYuzF8RPAPFb7LGsnVo44JhM/xxzDyzoYtdfNmtbIuKVi9PzIsyp6rg+09gbuI6UGwBZ5DWBDBMqv5MPdOF5dCQkB2Bbr5yPfURPENypUz+pBFBg41d+BC+rwRiXELwKy7Y9caD/MtJyHydj8OUwIDAQAB')
133
138
  const data = encrypt.encrypt(JSON.stringify({ username: name, password: password }))
134
139
  // 获取路由配置
135
- console.log('开始请求智慧燃气')
136
140
  getRoutesConfig(data).then(result => {
137
141
  this.$login.login(result).then(() => {
138
142
  this.afterGeneral(result)
@@ -212,59 +216,59 @@ export default {
212
216
  </script>
213
217
 
214
218
  <style lang="less" scoped>
215
- .common-layout{
216
- .top {
217
- text-align: center;
218
- .header {
219
+ .common-layout{
220
+ .top {
221
+ text-align: center;
222
+ .header {
223
+ height: 44px;
224
+ line-height: 44px;
225
+ a {
226
+ text-decoration: none;
227
+ }
228
+ .logo {
219
229
  height: 44px;
220
- line-height: 44px;
221
- a {
222
- text-decoration: none;
223
- }
224
- .logo {
225
- height: 44px;
226
- vertical-align: top;
227
- margin-right: 16px;
228
- }
229
- .title {
230
- font-size: 33px;
231
- color: @title-color;
232
- font-family: 'Myriad Pro', 'Helvetica Neue', Arial, Helvetica, sans-serif;
233
- font-weight: 600;
234
- position: relative;
235
- top: 2px;
236
- }
230
+ vertical-align: top;
231
+ margin-right: 16px;
237
232
  }
238
- .desc {
239
- font-size: 14px;
240
- color: @text-color-second;
241
- margin-top: 12px;
242
- margin-bottom: 40px;
233
+ .title {
234
+ font-size: 33px;
235
+ color: @title-color;
236
+ font-family: 'Myriad Pro', 'Helvetica Neue', Arial, Helvetica, sans-serif;
237
+ font-weight: 600;
238
+ position: relative;
239
+ top: 2px;
243
240
  }
244
241
  }
245
- .login{
246
- width: 368px;
247
- margin: 0 auto;
248
- @media screen and (max-width: 576px) {
249
- width: 95%;
250
- }
251
- @media screen and (max-width: 320px) {
252
- .captcha-button{
253
- font-size: 14px;
254
- }
242
+ .desc {
243
+ font-size: 14px;
244
+ color: @text-color-second;
245
+ margin-top: 12px;
246
+ margin-bottom: 40px;
247
+ }
248
+ }
249
+ .login{
250
+ width: 368px;
251
+ margin: 0 auto;
252
+ @media screen and (max-width: 576px) {
253
+ width: 95%;
254
+ }
255
+ @media screen and (max-width: 320px) {
256
+ .captcha-button{
257
+ font-size: 14px;
255
258
  }
256
- .icon {
257
- font-size: 24px;
258
- color: @text-color-second;
259
- margin-left: 16px;
260
- vertical-align: middle;
261
- cursor: pointer;
262
- transition: color 0.3s;
259
+ }
260
+ .icon {
261
+ font-size: 24px;
262
+ color: @text-color-second;
263
+ margin-left: 16px;
264
+ vertical-align: middle;
265
+ cursor: pointer;
266
+ transition: color 0.3s;
263
267
 
264
- &:hover {
265
- color: @primary-color;
266
- }
268
+ &:hover {
269
+ color: @primary-color;
267
270
  }
268
271
  }
269
272
  }
273
+ }
270
274
  </style>
@@ -4,7 +4,7 @@ import Vue from 'vue'
4
4
  import { ACCESS_TOKEN } from '@vue2-client/store/mutation-types'
5
5
  import notification from 'ant-design-vue/es/notification'
6
6
 
7
- const compatible = localStorage.getItem('compatible')
7
+ let compatible
8
8
 
9
9
  // 跨域认证信息 header 名
10
10
  const xsrfHeaderName = 'Authorization'
@@ -151,10 +151,14 @@ function checkAuthorization (authType = AUTH_TYPE.BEARER) {
151
151
  function loadInterceptors () {
152
152
  // 加载请求拦截器
153
153
  axios.interceptors.request.use(config => {
154
- const token = localStorage.getItem(ACCESS_TOKEN)
154
+ const token = localStorage.getItem('ACCESS_TOKEN')
155
155
  // 如果 token 存在
156
156
  // 让每个请求携带自定义 token 请根据实际情况自行修改
157
157
  if (token) {
158
+ // 如果是首次使用系统LocalStorage需要初始化,在登陆之后重新获取一次compatible
159
+ if (compatible === null) {
160
+ compatible = localStorage.getItem('compatible')
161
+ }
158
162
  // 判断是否为V4环境
159
163
  if (compatible === 'V4') {
160
164
  // V4 环境则添加 V4请求头
@@ -171,7 +175,11 @@ function loadInterceptors () {
171
175
  }, errorHandler)
172
176
  // 加载响应拦截器
173
177
  axios.interceptors.response.use((response) => {
174
- // 判断是否为V4环境
178
+ // 判断是否为V4环境,不为compatible赋初始值
179
+ // 其有可能是undefined未定义,或第一次使用本系统LocalStorage在初始化,获得的值为null
180
+ if (compatible === null || compatible === undefined) {
181
+ compatible = localStorage.getItem('compatible')
182
+ }
175
183
  if (compatible === 'V4') {
176
184
  if (response.data.data) {
177
185
  return response.data.data