Skip to content

Commit

Permalink
fix(cdn): add the function of custom CDN (#25)
Browse files Browse the repository at this point in the history
* fix(cdn): add the function of custom CDN

* fix(cdn): add the function of custom CDN
  • Loading branch information
shenjunjian authored Oct 23, 2023
1 parent 3b72ee8 commit 2857645
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/utils/dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@ export interface Dependency {
}

export type Cdn = 'unpkg' | 'jsdelivr' | 'jsdelivr-fastly'
export const cdn = useLocalStorage('setting-cdn', 'jsdelivr-fastly')
export const cdn = useLocalStorage('setting-cdn', 'https://unpkg.com')

export function genCdnLink(pkg: string, version: string | undefined, path: string) {
version = version ? `@${version}` : ''
switch (cdn.value) {
case 'jsdelivr':
return `https://cdn.jsdelivr.net/npm/${pkg}${version}${path}`
case 'jsdelivr-fastly':
return `https://fastly.jsdelivr.net/npm/${pkg}${version}${path}`
case 'unpkg':
return `https://unpkg.com/${pkg}${version}${path}`
}
return `${cdn.value}/${pkg}${version}${path}`
}

export function genVueLink(version: string) {
Expand Down

0 comments on commit 2857645

Please sign in to comment.