fix: 请求地址,localStorage(key)优化
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
<script>
|
||||
import { defaultPageSize } from '@/utils/constants'
|
||||
import { storageKey } from '@/utils/constants'
|
||||
|
||||
export default {
|
||||
name: 'pagination',
|
||||
@@ -132,7 +133,7 @@ export default {
|
||||
this.pageSize = this.postPageSizes[0]
|
||||
this.resetPageSizes()
|
||||
} else {
|
||||
const pageSize = localStorage.getItem('cn-pageSize-' + localStorage.getItem('cn-username') + '-' + this.tableId)
|
||||
const pageSize = localStorage.getItem(storageKey.pageSize + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId)
|
||||
if (pageSize != 'undefined' && pageSize != null) {
|
||||
this.pageSize = parseInt(pageSize)
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
<script>
|
||||
import { ref, computed } from 'vue'
|
||||
import MyDatePicker from '../MyDatePicker'
|
||||
import { storageKey } from '@/utils/constants'
|
||||
|
||||
export default {
|
||||
name: 'DateTimeRange',
|
||||
@@ -113,9 +114,9 @@ export default {
|
||||
const myStartTime = ref(props.startTime)
|
||||
const myEndTime = ref(props.endTime)
|
||||
const timeArr = ref([myStartTime.value, myEndTime.value])
|
||||
const address = localStorage.getItem('cn-sys-timezone')
|
||||
const utc = localStorage.getItem('cn-timezone-offset')
|
||||
const rangeHistory = ref(localStorage.getItem('date-range-history') ? JSON.parse(localStorage.getItem('date-range-history')) : [])
|
||||
const address = localStorage.getItem(storageKey.sysTimezone)
|
||||
const utc = localStorage.getItem(storageKey.timezoneOffset)
|
||||
const rangeHistory = ref(localStorage.getItem(storageKey.dataRangeHistory) ? JSON.parse(localStorage.getItem(storageKey.dataRangeHistory)) : [])
|
||||
const dateRangeValue = props.dateRange ? ref(props.dateRange) : ref(60)
|
||||
const isCustom = ref(false)
|
||||
const dateRangeArr = [
|
||||
@@ -235,7 +236,7 @@ export default {
|
||||
start: myStartTime.value,
|
||||
end: myEndTime.value
|
||||
})
|
||||
localStorage.setItem('date-range-history', JSON.stringify(rangeHistory.value))
|
||||
localStorage.setItem(storageKey.dataRangeHistory, JSON.stringify(rangeHistory.value))
|
||||
ctx.emit('change', myStartTime.value, myEndTime.value, dateRangeValue)
|
||||
dropdownFlag.value = false
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
import { post } from '@/utils/http'
|
||||
import { storageKey } from '@/utils/constants'
|
||||
|
||||
export default {
|
||||
name: 'TopToolMoreOptions',
|
||||
props: {
|
||||
@@ -107,7 +109,7 @@ export default {
|
||||
if (this.paramsType) {
|
||||
form.append('type', this.paramsType)
|
||||
}
|
||||
form.append('language', localStorage.getItem('cn-language') ? localStorage.getItem('cn-language') : 'en')
|
||||
form.append('language', localStorage.getItem(storageKey.language) ? localStorage.getItem(storageKey.language) : 'en')
|
||||
post(this.importUrl, form, { 'Content-Type': 'multipart/form-data' }).then(response => {
|
||||
if (response.code == 200 && response.msg == 'success') {
|
||||
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.importSuccess') })
|
||||
@@ -127,7 +129,7 @@ export default {
|
||||
this.importFile = null
|
||||
},
|
||||
downloadTemplate () {
|
||||
const language = localStorage.getItem('cn-language') || 'en' // 初始未选择默认 en 英文
|
||||
const language = localStorage.getItem(storageKey.language) || 'en' // 初始未选择默认 en 英文
|
||||
const fileName = this.exportFileName + '-' + this.$t('overall.template') + '-' + this.getTimeString() + '.json'
|
||||
|
||||
let url = null
|
||||
@@ -158,7 +160,7 @@ export default {
|
||||
})
|
||||
}
|
||||
params.pageSize = -1
|
||||
params.language = localStorage.getItem('cn-language') || 'en'
|
||||
params.language = localStorage.getItem(storageKey.language) || 'en'
|
||||
|
||||
this.export(this.exportUrl, params, this.exportFileName + '-' + this.getTimeString() + '.json')
|
||||
this.closeDialog()
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
import { useRoute } from 'vue-router'
|
||||
import { get, put } from '@/utils/http'
|
||||
import { entityType, storageKey } from '@/utils/constants'
|
||||
import { api } from '@/utils/api'
|
||||
|
||||
export default {
|
||||
name: 'Header',
|
||||
@@ -104,7 +105,7 @@ export default {
|
||||
}
|
||||
return {
|
||||
username: 'admin', // sessionStorage.getItem('cn-username'),
|
||||
language: localStorage.getItem('cn-language') ? localStorage.getItem('cn-language') : 'en',
|
||||
language: localStorage.getItem(storageKey.language) ? localStorage.getItem(storageKey.language) : 'en',
|
||||
showChangePin: false,
|
||||
from: '', // entity类型
|
||||
changePassForm: {
|
||||
@@ -171,8 +172,8 @@ export default {
|
||||
this.showChangePin = false
|
||||
},
|
||||
changeLocal (lang) {
|
||||
if (lang !== localStorage.getItem('cn-language')) {
|
||||
localStorage.setItem('cn-language', lang)
|
||||
if (lang !== localStorage.getItem(storageKey.language)) {
|
||||
localStorage.setItem(storageKey.language, lang)
|
||||
window.location.reload()
|
||||
}
|
||||
},
|
||||
@@ -181,10 +182,10 @@ export default {
|
||||
},
|
||||
logout () {
|
||||
localStorage.removeItem(storageKey.token)
|
||||
get('/logout')
|
||||
get(api.logout)
|
||||
},
|
||||
refreshLang () {
|
||||
this.language = localStorage.getItem('cn-language')
|
||||
this.language = localStorage.getItem(storageKey.language)
|
||||
this.$i18n.locale = this.language
|
||||
this.$nextTick(() => {
|
||||
window.location.reload()
|
||||
@@ -196,7 +197,7 @@ export default {
|
||||
submit () {
|
||||
this.$refs.changePassForm.validate((valid) => {
|
||||
if (valid) {
|
||||
put('sys/user/pin', { oldPin: this.changePassForm.oldPwd, newPin: this.changePassForm.newPwd }).then(res => {
|
||||
put(api.pin, { oldPin: this.changePassForm.oldPwd, newPin: this.changePassForm.newPwd }).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success('Success')
|
||||
this.showChangePin = false
|
||||
|
||||
@@ -70,11 +70,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { storageKey } from '@/utils/constants'
|
||||
|
||||
export default {
|
||||
name: 'LeftMenu',
|
||||
data () {
|
||||
return {
|
||||
systemName: localStorage.getItem('cn-sys-name'),
|
||||
systemName: localStorage.getItem(storageKey.sysName),
|
||||
logo: ''
|
||||
}
|
||||
},
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
<script>
|
||||
import rightBoxMixin from '@/mixins/right-box'
|
||||
import { get, post, put } from '@/utils/http'
|
||||
import { panelTypeAndRouteMapping } from '@/utils/constants'
|
||||
import { panelTypeAndRouteMapping, storageKey } from '@/utils/constants'
|
||||
import { api } from '@/utils/api'
|
||||
import { VAceEditor } from 'vue3-ace-editor'
|
||||
import 'ace-builds/src-noconflict/mode-javascript'
|
||||
@@ -149,7 +149,7 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
url: api.chart,
|
||||
loginName: localStorage.getItem('cn-username'),
|
||||
loginName: localStorage.getItem(storageKey.username),
|
||||
panelTypeAndRouteMapping: panelTypeAndRouteMapping,
|
||||
rules: { // 表单校验规则
|
||||
name: [
|
||||
@@ -355,7 +355,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
isCurrentUser (username) {
|
||||
return localStorage.getItem('cn-username') === username
|
||||
return localStorage.getItem(storageKey.username) === username
|
||||
},
|
||||
/* 密码失去焦点 检验确认密码 */
|
||||
pinBlur () {
|
||||
@@ -397,7 +397,7 @@ export default {
|
||||
})
|
||||
},
|
||||
async getChartData (value) {
|
||||
await get('/visual/chart?panelId=' + value).then(response => {
|
||||
await get(api.chart, { panelId: value }).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.chartData = response.data.list
|
||||
}
|
||||
|
||||
@@ -57,13 +57,16 @@
|
||||
<script>
|
||||
import rightBoxMixin from '@/mixins/right-box'
|
||||
import { get, post, put } from '@/utils/http'
|
||||
import { storageKey } from '@/utils/constants'
|
||||
import { api } from '@/utils/api'
|
||||
|
||||
export default {
|
||||
name: 'I18nBox',
|
||||
mixins: [rightBoxMixin],
|
||||
data () {
|
||||
return {
|
||||
url: 'sys/i18n',
|
||||
loginName: localStorage.getItem('cn-username'),
|
||||
url: api.i18nBox,
|
||||
loginName: localStorage.getItem(storageKey.username),
|
||||
rules: { // 表单校验规则
|
||||
name: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
@@ -88,7 +91,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
isCurrentUser (username) {
|
||||
return localStorage.getItem('cn-username') === username
|
||||
return localStorage.getItem(storageKey.username) === username
|
||||
},
|
||||
/* 密码失去焦点 检验确认密码 */
|
||||
pinBlur () {
|
||||
@@ -130,7 +133,7 @@ export default {
|
||||
})
|
||||
},
|
||||
getLangData () {
|
||||
get('sys/dict?type=lang&pageSize=-1').then(response => {
|
||||
get(api.dict, { type: 'lang', pageSize: -1 }).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.langData = response.data.list
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
<script>
|
||||
import rightBoxMixin from '@/mixins/right-box'
|
||||
import { get, post, put } from '@/utils/http'
|
||||
import { api } from '@/utils/api'
|
||||
|
||||
export default {
|
||||
name: 'userBox',
|
||||
mixins: [rightBoxMixin],
|
||||
@@ -64,7 +66,7 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
editRole: {},
|
||||
url: 'sys/role',
|
||||
url: api.role,
|
||||
rightBox: { model: { show: false } },
|
||||
rules: { // 表单校验规则
|
||||
name: [
|
||||
@@ -110,7 +112,7 @@ export default {
|
||||
return new Promise(resolve => {
|
||||
self.menus = []
|
||||
if (self.editRole.id) {
|
||||
get('/sys/role/menu/' + self.editRole.id).then(response => {
|
||||
get(api.menu + self.editRole.id).then(response => {
|
||||
if (response.code == 200) {
|
||||
self.menus = response.data.menus
|
||||
self.selectedIds = response.data.selectedIds
|
||||
@@ -120,7 +122,7 @@ export default {
|
||||
resolve()
|
||||
})
|
||||
} else {
|
||||
get('/sys/menu').then(response => {
|
||||
get(api.sysMenu).then(response => {
|
||||
if (response.code == 200) {
|
||||
self.menus = response.data.list
|
||||
} else {
|
||||
|
||||
@@ -116,7 +116,9 @@
|
||||
<script>
|
||||
import rightBoxMixin from '@/mixins/right-box'
|
||||
import { get, post, put } from '@/utils/http'
|
||||
import { themeData, langData } from '@/utils/constants'
|
||||
import { themeData, langData, storageKey } from '@/utils/constants'
|
||||
import { api } from '@/utils/api'
|
||||
|
||||
export default {
|
||||
name: 'UserBox',
|
||||
mixins: [rightBoxMixin],
|
||||
@@ -131,8 +133,8 @@ export default {
|
||||
}
|
||||
}
|
||||
return {
|
||||
url: 'sys/user',
|
||||
loginName: localStorage.getItem('cn-username'),
|
||||
url: api.user,
|
||||
loginName: localStorage.getItem(storageKey.username),
|
||||
rules: { // 表单校验规则
|
||||
name: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
@@ -180,7 +182,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
isCurrentUser (username) {
|
||||
return localStorage.getItem('cn-username') === username
|
||||
return localStorage.getItem(storageKey.username) === username
|
||||
},
|
||||
/* 密码失去焦点 检验确认密码 */
|
||||
pinBlur () {
|
||||
@@ -222,7 +224,7 @@ export default {
|
||||
})
|
||||
},
|
||||
getRoleData () {
|
||||
get('sys/role?pageSize=-1').then(response => {
|
||||
get(api.role, { pageSize: -1 }).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.roleData = response.data.list
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { storageKey } from '@/utils/constants'
|
||||
export default {
|
||||
props: {
|
||||
customTableTitle: Array, // 自定义的title
|
||||
@@ -51,9 +52,9 @@ export default {
|
||||
}
|
||||
},
|
||||
created () {
|
||||
const localStorageTitle = JSON.parse(localStorage.getItem('cn-tableTitle-' + localStorage.getItem('cn-username') + '-' + this.tableId))
|
||||
const localStorageTitle = JSON.parse(localStorage.getItem(storageKey.tableTitle + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId))
|
||||
if (localStorageTitle) {
|
||||
localStorage.setItem('cn-tableTitle-' + localStorage.getItem('cn-username') + '-' + this.tableId, JSON.stringify(localStorageTitle))
|
||||
localStorage.setItem(storageKey.tableTitle + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId, JSON.stringify(localStorageTitle))
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -92,10 +93,8 @@ export default {
|
||||
// 点击第二个cancel
|
||||
save () {
|
||||
this.$emit('update', this.custom)
|
||||
localStorage.setItem(
|
||||
'cn-tableTitle-' + localStorage.getItem('cn-username') + '-' + this.tableId,
|
||||
JSON.stringify(this.custom)
|
||||
)
|
||||
localStorage.setItem(storageKey.tableTitle + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId,
|
||||
JSON.stringify(this.custom))
|
||||
this.esc()
|
||||
}
|
||||
},
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
@header-dragend="dragend"
|
||||
@sort-change="tableDataSort"
|
||||
@selection-change="selectionChange"
|
||||
@select="select"
|
||||
>
|
||||
<el-table-column
|
||||
:resizable="false"
|
||||
@@ -69,7 +68,7 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="table-operation-all">
|
||||
<el-checkbox v-model="checkboxAll" @change="builtinReportCheckbox(tableData)"></el-checkbox>
|
||||
<el-checkbox v-model="checkboxAll" @change="selectAll(tableData)"></el-checkbox>
|
||||
<div class="table-operation-all-span">
|
||||
<span>{{ $t('overall.all') }}</span>
|
||||
<div class="table-operation-back-down" :class="{'table-operation-all-checkbox': batchDow, 'table-operation-all-loading': loading}" @click="tableOperation(['download', this.checkboxIds, 'builtin'])">
|
||||
@@ -128,7 +127,7 @@ export default {
|
||||
this.checkboxAll = objs.length > 0 || objs.length === this.tableData.length
|
||||
this.batchDow = objs.length > 0
|
||||
},
|
||||
builtinReportCheckbox (objs) {
|
||||
selectAll (objs) {
|
||||
if (objs) {
|
||||
objs.forEach(item => {
|
||||
this.$refs.dataTable.toggleAllSelection(item)
|
||||
|
||||
@@ -82,13 +82,14 @@
|
||||
<script>
|
||||
import table from '@/mixins/table'
|
||||
import { put } from '@/utils/http'
|
||||
import { storageKey } from '@/utils/constants'
|
||||
|
||||
export default {
|
||||
name: 'userTable',
|
||||
mixins: [table],
|
||||
data () {
|
||||
return {
|
||||
loginName: localStorage.getItem('cn-username'),
|
||||
loginName: localStorage.getItem(storageKey.username),
|
||||
tableTitle: [ // 原始table列
|
||||
{
|
||||
label: 'ID',
|
||||
|
||||
Reference in New Issue
Block a user