From d09b0e84093f5172e596bc064ef74d749cab6a15 Mon Sep 17 00:00:00 2001
From: sight <1453017105@qq.com>
Date: Fri, 10 Jun 2022 18:46:55 +0800
Subject: [PATCH 1/3] =?UTF-8?q?chore:=20=E6=9B=B4=E6=94=B9=20layui=20?=
=?UTF-8?q?=E5=92=8C=20layui-vue=20=E7=9A=84=E5=88=87=E6=8D=A2=E6=96=B9?=
=?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Header.vue | 9 +++---
src/download/download.ts | 6 ++--
.../{vite.config.js => vite.config.ts} | 0
src/store.ts | 30 +++++++++----------
4 files changed, 23 insertions(+), 22 deletions(-)
rename src/download/template/{vite.config.js => vite.config.ts} (100%)
diff --git a/src/components/Header.vue b/src/components/Header.vue
index 88c462a..b092676 100644
--- a/src/components/Header.vue
+++ b/src/components/Header.vue
@@ -118,6 +118,7 @@ const { isFullscreen, toggle } = useFullscreen()
const UILibActiveRef = ref(versions.UILib.published[0])
const vueActiveRef = ref(versions.vue.published[0])
+const activeLibRef = ref(preferSFC.value ? "layuivue" : "layui")
watch(() => [versions.UILib.published, versions.vue.published], () => {
UILibActiveRef.value = versions.UILib.published[0]
@@ -146,10 +147,6 @@ const toggleLib = () => {
-
-
+
{{ versions.UILib.text }} :
-->
-
-
-
{{ versions.UILib.text }} :
-
-
-
+
@@ -239,7 +292,7 @@ h1 {
font-weight: 300;
display: inline-block;
vertical-align: middle;
- font-family: "Helvetica Neue", Helvetica, "PingFang SC", Tahoma, Arial,
+ font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', Tahoma, Arial,
sans-serif;
}
@@ -277,7 +330,7 @@ h1 img {
}
.active-version:after {
- content: "";
+ content: '';
width: 0;
height: 0;
border-left: 4px solid transparent;
@@ -369,7 +422,7 @@ nav .button {
border: none;
outline: none;
color: #fff;
- margin: .5rem 0;
+ margin: 0.5rem 0;
border-bottom: 2px solid var(--nav-button);
text-shadow: 1px 1px 1px var(--nav-button);
border-radius: 4px;
diff --git a/src/config/defaultAppTemplate.vue b/src/config/defaultAppTemplate.vue
index be9086c..2bdb05e 100644
--- a/src/config/defaultAppTemplate.vue
+++ b/src/config/defaultAppTemplate.vue
@@ -6,5 +6,5 @@ const msg = ref('Hello World!')
{{ msg }}
-
-
\ No newline at end of file
+
+
diff --git a/src/config/sandbox.config.ts b/src/config/sandbox.config.ts
index c593cb3..a6ee6a4 100644
--- a/src/config/sandbox.config.ts
+++ b/src/config/sandbox.config.ts
@@ -1,24 +1,24 @@
import defaultAppTemplate from './defaultAppTemplate.vue?raw'
export interface DependencySource {
// 依赖源名称
- name: string;
+ name: string
// 依赖源链接
- url: string;
+ url: string
}
export interface Dependency {
// 包名
- name: string;
+ name: string
// 描述
- description?: string;
+ description?: string
// 版本
- version?: string;
+ version?: string
// 路径
- path: string;
+ path: string
// 样式路径
- stylePath?: string;
+ stylePath?: string
// 依赖源
- source?: DependencySource["name"];
+ source?: DependencySource['name']
}
/**
@@ -44,7 +44,7 @@ export const config = {
//UIPackage: '@arco-design/web-vue',
minSupportedVersion: '0.2.5',
filterPreRelease: false,
- defaultAppTemplate: defaultAppTemplate.trim()
+ defaultAppTemplate: defaultAppTemplate.trim(),
}
export const dependencySources: DependencySource[] = [
@@ -64,7 +64,6 @@ export const dependencySources: DependencySource[] = [
name: 'custom',
url: 'import.meta.env.BASE_URL' + 'lib',
},
-
]
export const dependencies: Dependency[] = [
@@ -115,7 +114,7 @@ export const dependencies: Dependency[] = [
stylePath: '/dist/css/layui.css',
description: 'layui 组件库',
source: 'unpkg',
- }
+ },
// {
// name: 'element-plus',
diff --git a/src/download/download.ts b/src/download/download.ts
index 79695cc..ffad167 100644
--- a/src/download/download.ts
+++ b/src/download/download.ts
@@ -8,7 +8,6 @@ import config from './template/vite.config.js?raw'
import readme from './template/README.md?raw'
import tsconfig from './template/tsconfig.json?raw'
-
export async function downloadProject(store: any) {
/* if (!confirm('Download example project files?')) {
return
@@ -16,7 +15,11 @@ export async function downloadProject(store: any) {
const { default: JSZip } = await import('jszip')
const zip = new JSZip()
- const excludeFiles = [defaultMainFile, libInstallFile.value, 'import-map.json']
+ const excludeFiles = [
+ defaultMainFile,
+ libInstallFile.value,
+ 'import-map.json',
+ ]
// basic structure
zip.file('index.html', index)
@@ -25,7 +28,6 @@ export async function downloadProject(store: any) {
zip.file('vite.config.js', config)
zip.file('README.md', readme)
-
// project src
const src = zip.folder('src')!
src.file('main.ts', main)
diff --git a/src/download/template/main.ts b/src/download/template/main.ts
index 75f5a91..0ae1124 100644
--- a/src/download/template/main.ts
+++ b/src/download/template/main.ts
@@ -1,8 +1,8 @@
-import { createApp } from "vue";
-import App from "./App.vue";
-import "@layui/layui-vue/lib/index.css";
-import Layui from "@layui/layui-vue";
+import { createApp } from 'vue'
+import App from './App.vue'
+import '@layui/layui-vue/lib/index.css'
+import Layui from '@layui/layui-vue'
-const app = createApp(App);
+const app = createApp(App)
-app.use(Layui).mount("#app");
\ No newline at end of file
+app.use(Layui).mount('#app')
diff --git a/src/icons/Download.vue b/src/icons/Download.vue
index f76d035..a7c4ed1 100644
--- a/src/icons/Download.vue
+++ b/src/icons/Download.vue
@@ -26,4 +26,4 @@
-
\ No newline at end of file
+
diff --git a/src/icons/Moon.vue b/src/icons/Moon.vue
index 6b9f0d5..28948bd 100644
--- a/src/icons/Moon.vue
+++ b/src/icons/Moon.vue
@@ -1,8 +1,8 @@
-
\ No newline at end of file
+
diff --git a/src/icons/Sun.vue b/src/icons/Sun.vue
index 0951269..cfb0ca2 100644
--- a/src/icons/Sun.vue
+++ b/src/icons/Sun.vue
@@ -1,13 +1,31 @@
-
\ No newline at end of file
+
diff --git a/src/store.ts b/src/store.ts
index c459703..346e073 100644
--- a/src/store.ts
+++ b/src/store.ts
@@ -2,25 +2,24 @@ import { reactive, watchEffect } from 'vue'
import { compileFile, File } from '@vue/repl'
import { genImportMap, genLink, genVueLink } from './utils/dependency'
import { utoa, atou } from './utils/encode'
-import type { Store, SFCOptions, StoreState, OutputModes } from '@vue/repl'
-
import { config } from './config/sandbox.config'
+import type { Store, SFCOptions, StoreState, OutputModes } from '@vue/repl'
export type VersionKey = 'vue' | 'UILib'
export type Versions = Record
-export const preferSFC = ref(true);
+export const preferSFC = ref(true)
export const UIPackage = ref(config.UIPackage)
export const defaultHTMLFile = 'index.html'
export const defaultMainFile = 'PlaygroundMain.vue'
export const defaultAppFile = 'App.vue'
-export const libInstallFile = ref('LibInstall.js')
+export const libInstallFile = ref('LibInstall.js')
// FIXME 临时的兼容方法
-if (window.location.search.includes("deps=layui")) {
+if (window.location.search.includes('deps=layui')) {
preferSFC.value = false
- UIPackage.value = "layui"
- libInstallFile.value = UIPackage.value + '.js'
+ UIPackage.value = 'layui'
+ libInstallFile.value = `${UIPackage.value}.js`
}
// PlaygroundMain.vue
@@ -35,7 +34,9 @@ setupLib()
`.trim()
// App.vue
-const defaultAppFileTemplate = config.defaultAppTemplate ?? `
+const defaultAppFileTemplate =
+ config.defaultAppTemplate ??
+ `