mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-13 19:35:24 +00:00
fix: 修复导入时url中有参数导致的拼接错误
perf: 优化一下获取url
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
|
||||
<script>
|
||||
import DataTable from '@/components/DataTable'
|
||||
import { sleep } from '@/utils/common'
|
||||
import { sleep, getUpdateObjURL } from '@/utils/common'
|
||||
import { EditableInputFormatter, StatusFormatter } from '@/components/TableFormatters'
|
||||
export default {
|
||||
name: 'ImportTable',
|
||||
@@ -350,7 +350,7 @@ export default {
|
||||
}
|
||||
},
|
||||
async performUpdateObject(item) {
|
||||
const updateUrl = `${this.url}${item.id}/`
|
||||
const updateUrl = getUpdateObjURL(this.url, item.id)
|
||||
return this.$axios.put(
|
||||
updateUrl,
|
||||
item,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import AutoDataForm from '@/components/AutoDataForm'
|
||||
import { getUpdateObjURL } from '@/utils/common'
|
||||
export default {
|
||||
name: 'GenericCreateUpdateForm',
|
||||
components: {
|
||||
@@ -129,7 +130,7 @@ export default {
|
||||
const params = this.$route.params
|
||||
let url = this.url
|
||||
if (params.id) {
|
||||
url = `${url}${params.id}/`
|
||||
url = getUpdateObjURL(url, params.id)
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
@@ -214,11 +214,22 @@ export function newURL(url) {
|
||||
if (url.indexOf('//') > -1) {
|
||||
obj = new URL(url)
|
||||
} else {
|
||||
obj = new URL(url, 'http://localhost')
|
||||
obj = new URL(url, location.origin)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
export function getUpdateObjURL(url, objId) {
|
||||
const urlObj = new URL(url, location.origin)
|
||||
let pathname = urlObj.pathname
|
||||
if (!pathname.endsWith('/')) {
|
||||
pathname += '/'
|
||||
}
|
||||
pathname += `${objId}/`
|
||||
urlObj.pathname = pathname
|
||||
return urlObj.href
|
||||
}
|
||||
|
||||
export const assignIfNot = _.partialRight(_.assignInWith, customizer)
|
||||
|
||||
const scheme = document.location.protocol
|
||||
|
||||
Reference in New Issue
Block a user