Skip to content

Commit

Permalink
fix: playground
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Nov 28, 2020
1 parent 3fa90ed commit a867126
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
26 changes: 14 additions & 12 deletions playground/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<a-button type="primary" html-type="submit" :loading="loading">
Generate
</a-button>
<a-button type="info" @click="copyURL" style="margin-left: 20px">
<a-button type="default" @click="copyURL" style="margin-left: 20px">
<!-- <MessageOutlined :style="{ fontSize: '16px', color: '#08c' }" /> -->
Share
</a-button>
Expand All @@ -48,7 +48,7 @@

<script setup>
import { ref, reactive, onMounted, watch, toRefs } from "vue";
import copy from "https://cdn.skypack.dev/copy-to-clipboard";
import copy from "https://cdn.skypack.dev/copy-to-clipboard@3.3.1";
import { message, notification } from "ant-design-vue";
import Render from "./components/Render.vue";
import CodeMirror from "./components/CodeMirror.vue";
Expand All @@ -57,17 +57,17 @@ import TEMPLATE_DEFAULT from "./template/default";
const loading = ref(false);
let template = ref(TEMPLATE_DEFAULT);
const _form = reactive({
const formReactive = reactive({
username: "axetroy",
repo: "whatchanged",
version: "HEAD~",
});
const form = toRefs(_form);
const form = toRefs(formReactive);
function watchAndUpdateQuery(field) {
watch(
() => _form[field],
() => formReactive[field],
(val) => {
syncQueryField(field, val);
}
Expand Down Expand Up @@ -104,9 +104,11 @@ function onSubmit() {
});
fetch(
`${import.meta.env.VITE_API_HOST}/?username=${_form.username || ""}&repo=${
_form.repo || ""
}&version=${_form.version || ""}&template=${tpl || ""}`
`${import.meta.env.VITE_API_HOST}/?username=${
formReactive.username || ""
}&repo=${formReactive.repo || ""}&version=${
formReactive.version || ""
}&template=${tpl || ""}`
)
.then((res) => res.text())
.then((markdown) => {
Expand Down Expand Up @@ -148,25 +150,25 @@ onMounted(() => {
let params = 0;
if (url.searchParams.has("username")) {
_form.username = url.searchParams.get("username");
formReactive.username = url.searchParams.get("username");
params++;
}
if (url.searchParams.has("repo")) {
_form.repo = url.searchParams.get("repo");
formReactive.repo = url.searchParams.get("repo");
params++;
}
if (url.searchParams.has("version")) {
_form.version = url.searchParams.get("version");
formReactive.version = url.searchParams.get("version");
}
if (url.searchParams.has("tpl")) {
params++;
template.value = url.searchParams.get("tpl");
}
if (params === 3 && _form.username && _form.repo) {
if (params === 3 && formReactive.username && formReactive.repo) {
onSubmit();
}
});
Expand Down
4 changes: 0 additions & 4 deletions playground/src/components/CodeMirror.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ let editor;
const input = ref(null);
watch(content, (val) => {
update(val);
});
onMounted(() => {
editor = CodeMirror.fromTextArea(input.value, {
lineNumbers: true,
Expand Down
5 changes: 0 additions & 5 deletions playground/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2060,11 +2060,6 @@ rollup-plugin-dynamic-import-variables@^1.1.0:
globby "^11.0.0"
magic-string "^0.25.7"

rollup-plugin-esm-import-to-url@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-esm-import-to-url/-/rollup-plugin-esm-import-to-url-2.1.0.tgz#b54519ead4244401a7dd6d21af97c064fc1f2676"
integrity sha512-/OSuqqZTrztz0NC9pcQcsEqEn5iQXYauFluh6CBSkRtNW4q6CTCxEsOAZFWTxizF2RKk9ZvaztlBBr/FuuWbwg==

rollup-plugin-terser@^7.0.2:
version "7.0.2"
resolved "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d"
Expand Down

0 comments on commit a867126

Please sign in to comment.