fix: 修复协议管理、远程升级上传文件获取base-path方式
This commit is contained in:
parent
4b84614f82
commit
0671e2d357
|
|
@ -31,10 +31,11 @@
|
||||||
<script setup lang="ts" name="FileUpload">
|
<script setup lang="ts" name="FileUpload">
|
||||||
import { LocalStore } from '@/utils/comm';
|
import { LocalStore } from '@/utils/comm';
|
||||||
import { TOKEN_KEY } from '@/utils/variable';
|
import { TOKEN_KEY } from '@/utils/variable';
|
||||||
import { FIRMWARE_UPLOAD, querySystemApi } from '@/api/device/firmware';
|
import { FIRMWARE_UPLOAD } from '@/api/device/firmware';
|
||||||
import { onlyMessage } from '@/utils/comm';
|
import { onlyMessage } from '@/utils/comm';
|
||||||
import type { UploadChangeParam } from 'ant-design-vue';
|
import type { UploadChangeParam } from 'ant-design-vue';
|
||||||
import { notification as Notification } from 'ant-design-vue';
|
import { notification as Notification } from 'ant-design-vue';
|
||||||
|
import { useSystem } from '@/store/system';
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'update:extraValue', 'change']);
|
const emit = defineEmits(['update:modelValue', 'update:extraValue', 'change']);
|
||||||
|
|
||||||
|
|
@ -45,6 +46,10 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const paths: string = useSystem().$state.configInfo.paths?.[
|
||||||
|
'base-path'
|
||||||
|
] as string;
|
||||||
|
|
||||||
const fileValue = ref(props.modelValue);
|
const fileValue = ref(props.modelValue);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
|
|
@ -53,11 +58,9 @@ const handleChange = async (info: UploadChangeParam) => {
|
||||||
if (info.file.status === 'done') {
|
if (info.file.status === 'done') {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
const result = info.file.response?.result;
|
const result = info.file.response?.result;
|
||||||
const api: any = await querySystemApi(['paths']); // todo base-path在pinia获取系统配置的
|
const f = `${paths || ''}/file/${result.id}?accessKey=${
|
||||||
const path = api.result[0]?.properties
|
result.others.accessKey
|
||||||
? api.result[0]?.properties['base-path']
|
}`;
|
||||||
: '';
|
|
||||||
const f = `${path}/file/${result.id}?accessKey=${result.others.accessKey}`;
|
|
||||||
onlyMessage('上传成功!', 'success');
|
onlyMessage('上传成功!', 'success');
|
||||||
fileValue.value = f;
|
fileValue.value = f;
|
||||||
emit('update:modelValue', f);
|
emit('update:modelValue', f);
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,11 @@
|
||||||
<script setup lang="ts" name="FileUpload">
|
<script setup lang="ts" name="FileUpload">
|
||||||
import { LocalStore } from '@/utils/comm';
|
import { LocalStore } from '@/utils/comm';
|
||||||
import { TOKEN_KEY } from '@/utils/variable';
|
import { TOKEN_KEY } from '@/utils/variable';
|
||||||
import { PROTOCOL_UPLOAD, querySystemApi } from '@/api/link/protocol';
|
import { PROTOCOL_UPLOAD } from '@/api/link/protocol';
|
||||||
import { onlyMessage } from '@/utils/comm';
|
import { onlyMessage } from '@/utils/comm';
|
||||||
import type { UploadChangeParam, UploadProps } from 'ant-design-vue';
|
import type { UploadChangeParam, UploadProps } from 'ant-design-vue';
|
||||||
import { notification as Notification } from 'ant-design-vue';
|
import { notification as Notification } from 'ant-design-vue';
|
||||||
|
import { useSystem } from '@/store/system';
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'change']);
|
const emit = defineEmits(['update:modelValue', 'change']);
|
||||||
|
|
||||||
|
|
@ -41,6 +42,10 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const paths: string = useSystem().$state.configInfo.paths?.[
|
||||||
|
'base-path'
|
||||||
|
] as string;
|
||||||
|
|
||||||
const value = ref(props.modelValue);
|
const value = ref(props.modelValue);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
|
|
@ -58,11 +63,9 @@ const handleChange = async (info: UploadChangeParam) => {
|
||||||
if (info.file.status === 'done') {
|
if (info.file.status === 'done') {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
const result = info.file.response?.result;
|
const result = info.file.response?.result;
|
||||||
const api: any = await querySystemApi(['paths']); // todo base-path在pinia获取系统配置的
|
const f = `${paths || ''}/file/${result.id}?accessKey=${
|
||||||
const path = api.result[0]?.properties
|
result.others.accessKey
|
||||||
? api.result[0]?.properties['base-path']
|
}`;
|
||||||
: '';
|
|
||||||
const f = `${path}/file/${result.id}?accessKey=${result.others.accessKey}`;
|
|
||||||
onlyMessage('上传成功!', 'success');
|
onlyMessage('上传成功!', 'success');
|
||||||
value.value = f;
|
value.value = f;
|
||||||
emit('update:modelValue', f);
|
emit('update:modelValue', f);
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
:disabled="!!id"
|
:disabled="!!id"
|
||||||
v-model:value="formData.type"
|
v-model:value="formData.type"
|
||||||
:options="options"
|
:options="options"
|
||||||
|
:column="2"
|
||||||
@change="changeType"
|
@change="changeType"
|
||||||
/>
|
/>
|
||||||
</j-form-item>
|
</j-form-item>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue