Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bkvision #461

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions src/frontend/src/views/statement-manage/detail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<script setup lang="ts">
import {
onMounted,
onUnmounted,
watch,
} from 'vue';
import {
Expand All @@ -43,6 +44,7 @@
const route = useRoute();
const { messageError } = useMessage();
const { emit } = useEventBus();
let app: any;

const loadScript = (src: string) => new Promise((resolve, reject) => {
const script = document.createElement('script');
Expand All @@ -62,41 +64,34 @@
}
};

const render = () => {
window.BkVisionSDK.init(
'#panel',
route.params.id,
{
apiPrefix: `${window.PROJECT_CONFIG.AJAX_URL_PREFIX}/bkvision/`,
chartToolMenu: [
{ type: 'tool', id: 'fullscreen', build_in: true },
{ type: 'tool', id: 'refresh', build_in: true },
{ type: 'menu', id: 'excel', build_in: true },
],
handleError,
},
);
const change = (uid: string) => {
app.update(uid);
};

const init = async () => {
try {
// 样式文件
const link = document.createElement('link');
link.href = 'https://staticfile.qq.com/bkvision/p7e76e4518060411cb65c6bc2eaea9c03/latest/main.css?v=1704275097';
link.rel = 'stylesheet';
document.body.append(link);
await loadScript('https://staticfile.qq.com/bkvision/p7e76e4518060411cb65c6bc2eaea9c03/latest/chunk-vendors.js?v=1704275097');
await loadScript('https://staticfile.qq.com/bkvision/p7e76e4518060411cb65c6bc2eaea9c03/latest/chunk-bk-magic-vue.js?v=1704275097');
await loadScript('https://staticfile.qq.com/bkvision/p7e76e4518060411cb65c6bc2eaea9c03/latest/main.js?v=1704275097');
render();
await loadScript('https://staticfile.qq.com/bkvision/pbb9b207ba200407982a9bd3d3f2895d4/latest/main.js');
app = await window.BkVisionSDK.init(
'#panel',
route.params.id,
{
apiPrefix: `${window.PROJECT_CONFIG.AJAX_URL_PREFIX}/bkvision/`,
chartToolMenu: [
{ type: 'tool', id: 'fullscreen', build_in: true },
{ type: 'tool', id: 'refresh', build_in: true },
{ type: 'menu', id: 'excel', build_in: true },
],
handleError,
},
);
} catch (error) {
console.error(error);
}
};

watch(() => route, () => {
if (route.params.id !== '' && route.name === 'statementManageDetail') {
render();
change(route.params.id as string);
}
}, {
deep: true,
Expand All @@ -105,4 +100,10 @@
onMounted(() => {
init();
});

onUnmounted(() => {
if (app) {
app.unmount();
}
});
</script>
Loading