-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
14 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 12 additions & 15 deletions
27
src/AntDesign.Charts/wwwroot/AntDesign.Charts.lib.module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,31 @@ | ||
var beforeStartCalled = false; | ||
var afterStartedCalled = false; | ||
|
||
export function beforeWebStart() { | ||
export function beforeWebStart() { | ||
loadScriptAndStyle(); | ||
} | ||
|
||
export function beforeStart(options, extensions) { | ||
loadScriptAndStyle(); | ||
loadScriptAndStyle(); | ||
} | ||
|
||
function loadScriptAndStyle() { | ||
if (beforeStartCalled) { | ||
return; | ||
} | ||
|
||
beforeStartCalled = true; | ||
|
||
const interopJS = "_content/AntDesign.Charts/ant-design-charts-blazor.js"; | ||
const cdnJS = "https://unpkg.com/@antv/[email protected]/dist/g2plot.min.js"; | ||
const localJS = "_content/AntDesign.Charts/g2plot.min.js"; | ||
const cdnFlag = document.querySelector('[use-ant-design-charts-cdn]'); | ||
|
||
if (!document.querySelector(`[src="${interopJS}"]`)) { | ||
var chartJS = cdnFlag ? cdnJS : localJS; | ||
var chartScript = document.createElement('script'); | ||
const chartJS = cdnFlag ? cdnJS : localJS; | ||
const chartScript = document.createElement('script'); | ||
chartScript.setAttribute('src', chartJS); | ||
|
||
document.body.insertBefore(chartScript, document.body.querySelector("script")); | ||
const jsMark = document.querySelector("script"); | ||
if (jsMark) { | ||
jsMark.before(chartScript); | ||
} | ||
else { | ||
document.body.appendChild(chartScript); | ||
} | ||
|
||
var interopScript = document.createElement('script'); | ||
const interopScript = document.createElement('script'); | ||
interopScript.setAttribute('src', interopJS); | ||
chartScript.after(interopScript); | ||
} | ||
|