mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
fix(projects): 修复百度地图sdk地址
This commit is contained in:
@ -7,7 +7,6 @@ import useRouteProps from './useRouteProps';
|
||||
import useBoolean from './useBoolean';
|
||||
import useLoading from './useLoading';
|
||||
import useScrollBehavior from './useScrollBehavior';
|
||||
import useScript from './useScript';
|
||||
|
||||
export {
|
||||
useAppTitle,
|
||||
@ -18,6 +17,5 @@ export {
|
||||
useRouteProps,
|
||||
useBoolean,
|
||||
useLoading,
|
||||
useScrollBehavior,
|
||||
useScript
|
||||
useScrollBehavior
|
||||
};
|
||||
|
@ -1,45 +0,0 @@
|
||||
import { onUnmounted } from 'vue';
|
||||
import useLoading from './useLoading';
|
||||
import useBoolean from './useBoolean';
|
||||
|
||||
export default function useScript(src: string) {
|
||||
const { loading, startLoading, endLoading } = useLoading();
|
||||
const { bool: isSuccess, setTrue: setIsSuccess, setFalse: setNotSuccess } = useBoolean();
|
||||
|
||||
let script: HTMLScriptElement;
|
||||
function removeScript() {
|
||||
if (script) {
|
||||
script.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function load() {
|
||||
startLoading();
|
||||
return new Promise((resolve, reject) => {
|
||||
script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.onload = () => {
|
||||
endLoading();
|
||||
setIsSuccess();
|
||||
resolve('');
|
||||
};
|
||||
script.onerror = err => {
|
||||
endLoading();
|
||||
setNotSuccess();
|
||||
reject(err);
|
||||
};
|
||||
script.src = src;
|
||||
document.head.appendChild(script);
|
||||
});
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
removeScript();
|
||||
});
|
||||
|
||||
return {
|
||||
loading,
|
||||
isSuccess,
|
||||
load
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user