Skip to content

Commit

Permalink
style: format
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed May 31, 2024
1 parent cee10c1 commit f7ed42b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const previewOptions = {
presets: [],
}
<\/script>
`
`,
}
const initialUserOptions: UserOptions = {}
Expand Down
26 changes: 14 additions & 12 deletions src/composables/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const useStore = (initial: Initial) => {
vue: 'latest',
elementPlus: 'latest',
typescript: 'latest',
} satisfies Versions)
} satisfies Versions),
)

const compiler = shallowRef<typeof import('vue/compiler-sfc')>()
Expand Down Expand Up @@ -68,7 +68,7 @@ export const useStore = (initial: Initial) => {
})

const bultinImportMap = computed<ImportMap>(() =>
genImportMap(versions, nightly.value)
genImportMap(versions, nightly.value),
)
const userImportMap = computed<ImportMap>(() => {
const code = state.files[IMPORT_MAP]?.code.trim()
Expand All @@ -82,7 +82,7 @@ export const useStore = (initial: Initial) => {
return map
})
const importMap = computed<ImportMap>(() =>
mergeImportMap(bultinImportMap.value, userImportMap.value)
mergeImportMap(bultinImportMap.value, userImportMap.value),
)

// eslint-disable-next-line no-console
Expand All @@ -109,12 +109,12 @@ export const useStore = (initial: Initial) => {
const file = new File(
ELEMENT_PLUS_FILE,
generateElementPlusCode(version, userOptions.value.styleSource).trim(),
hideFile.value
hideFile.value,
)
state.files[ELEMENT_PLUS_FILE] = file
compileFile(store, file).then((errs) => (state.errors = errs))
},
{ immediate: true }
{ immediate: true },
)

function generateElementPlusCode(version: string, styleSource?: string) {
Expand All @@ -123,11 +123,11 @@ export const useStore = (initial: Initial) => {
: genCdnLink(
nightly.value ? '@element-plus/nightly' : 'element-plus',
version,
'/dist/index.css'
'/dist/index.css',
)
const darkStyle = style.replace(
'/dist/index.css',
'/theme-chalk/dark/css-vars.css'
'/theme-chalk/dark/css-vars.css',
)
return elementPlusCode
.replace('#STYLE#', style)
Expand Down Expand Up @@ -158,7 +158,9 @@ export const useStore = (initial: Initial) => {
}

watchEffect(() =>
compileFile(store, state.activeFile).then((errs) => (state.errors = errs))
compileFile(store, state.activeFile).then(
(errs) => (state.errors = errs),
),
)

watch(
Expand All @@ -169,7 +171,7 @@ export const useStore = (initial: Initial) => {
state.dependencyVersion,
],
useDebounceFn(() => store.reloadLanguageTools?.(), 300),
{ deep: true }
{ deep: true },
)

inited = true
Expand Down Expand Up @@ -219,7 +221,7 @@ export const useStore = (initial: Initial) => {
if (!files[IMPORT_MAP]) {
files[IMPORT_MAP] = new File(
IMPORT_MAP,
JSON.stringify({ imports: {} }, undefined, 2)
JSON.stringify({ imports: {} }, undefined, 2),
)
}
if (!files[TSCONFIG]) {
Expand Down Expand Up @@ -292,7 +294,7 @@ export const useStore = (initial: Initial) => {
].includes(filename)
) {
ElMessage.warning(
'You cannot remove it, because Element Plus requires it.'
'You cannot remove it, because Element Plus requires it.',
)
return
}
Expand All @@ -304,7 +306,7 @@ export const useStore = (initial: Initial) => {
title: 'Delete File',
type: 'warning',
center: true,
}
},
)
) {
if (state.activeFile.filename === filename) {
Expand Down
6 changes: 3 additions & 3 deletions src/template/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"types": ["element-plus/global.d.ts"],
"allowImportingTsExtensions": true,
"allowJs": true,
"checkJs": true
"checkJs": true,
},
"vueCompilerOptions": {
"target": 3.3
}
"target": 3.3,
},
}
20 changes: 10 additions & 10 deletions src/utils/dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const cdn = useLocalStorage<Cdn>('setting-cdn', 'jsdelivr-fastly')
export const genCdnLink = (
pkg: string,
version: string | undefined,
path: string
path: string,
) => {
version = version ? `@${version}` : ''
switch (cdn.value) {
Expand All @@ -33,12 +33,12 @@ export const genVueLink = (version: string) => {
const compilerSfc = genCdnLink(
'@vue/compiler-sfc',
version,
'/dist/compiler-sfc.esm-browser.js'
'/dist/compiler-sfc.esm-browser.js',
)
const runtimeDom = genCdnLink(
'@vue/runtime-dom',
version,
'/dist/runtime-dom.esm-browser.js'
'/dist/runtime-dom.esm-browser.js',
)
return {
compilerSfc,
Expand All @@ -48,7 +48,7 @@ export const genVueLink = (version: string) => {

export const genImportMap = (
{ vue, elementPlus }: Partial<Versions> = {},
nightly: boolean
nightly: boolean,
): ImportMap => {
const deps: Record<string, Dependency> = {
vue: {
Expand Down Expand Up @@ -81,14 +81,14 @@ export const genImportMap = (
Object.entries(deps).map(([key, dep]) => [
key,
genCdnLink(dep.pkg ?? key, dep.version, dep.path),
])
]),
),
}
}

export const getVersions = (pkg: MaybeRef<string>) => {
const url = computed(
() => `https://data.jsdelivr.com/v1/package/npm/${unref(pkg)}`
() => `https://data.jsdelivr.com/v1/package/npm/${unref(pkg)}`,
)
return useFetch(url, {
initialData: [],
Expand All @@ -100,22 +100,22 @@ export const getVersions = (pkg: MaybeRef<string>) => {
export const getSupportedVueVersions = () => {
const versions = getVersions('vue')
return computed(() =>
versions.value.filter((version) => gte(version, '3.2.0'))
versions.value.filter((version) => gte(version, '3.2.0')),
)
}

export const getSupportedTSVersions = () => {
const versions = getVersions('typescript')
return computed(() =>
versions.value.filter(
(version) => !version.includes('dev') && !version.includes('insiders')
)
(version) => !version.includes('dev') && !version.includes('insiders'),
),
)
}

export const getSupportedEpVersions = (nightly: MaybeRef<boolean>) => {
const pkg = computed(() =>
unref(nightly) ? '@element-plus/nightly' : 'element-plus'
unref(nightly) ? '@element-plus/nightly' : 'element-plus',
)
const versions = getVersions(pkg)
return computed(() => {
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
"@/*": ["src/*"],
},
"types": [],
"skipLibCheck": true
"skipLibCheck": true,
},
"references": [{ "path": "./tsconfig.vite-config.json" }],
"include": ["src"],
"exclude": ["src/template"]
"exclude": ["src/template"],
}

0 comments on commit f7ed42b

Please sign in to comment.