📝: chore: 补充文档

This commit is contained in:
sight
2022-06-28 14:07:44 +08:00
parent 21835edb61
commit 8ffb6723d1
6 changed files with 242 additions and 45 deletions

View File

@@ -5,7 +5,7 @@
</form>
</template>
<script setup>
const emit = defineEmits("add", "sub");
const emit = defineEmits(["add", "sub"]);
const add = () => {
emit("add");

View File

@@ -12,6 +12,7 @@
</div>
</div>
<div :class="{ 'is-fixed': isFixContorl }" class="control">
<i class="layui-icon layui-icon-play btn" @click="onPlayground" />
<i class="layui-icon layui-icon-file btn" @click="copy"></i>
<i class="layui-icon layui-icon-fonts-code btn" @click="toggle"></i>
</div>
@@ -20,6 +21,7 @@
<script setup lang="ts">
import { onMounted, onUnmounted, ref, watch } from "vue";
import { usePlayGround } from "../composable/usePlayground";
const meta = ref<HTMLElement>({} as HTMLElement);
const isFixContorl = ref(false);
@@ -31,6 +33,13 @@ const toggle = function () {
show.value = !show.value;
};
const onPlayground = async function () {
const foundCode = meta.value.querySelector(".language-html");
const sourceCode = foundCode?.textContent ?? "";
const { link } = await usePlayGround(sourceCode, true);
window.open(link);
};
const copy = function () {
const foundCodes = meta.value.getElementsByClassName("language-html");
const foundCode = foundCodes[0];
@@ -64,7 +73,9 @@ const copy = function () {
}
if (successful) {
window.alert("复制成功");
} else {
window.alert("复制失败");
}
};