diff --git a/file.go b/file.go index 32b1f7d..6442b17 100644 --- a/file.go +++ b/file.go @@ -56,6 +56,8 @@ func (f *File) Do() (string, error) { if f.Action == "" { return "", nil } + f.lock.RLock() + defer f.lock.RUnlock() cmd := &exec.Cmd{} if runtime.GOOS == "windows" { cmd = exec.Command(WIN_SHELL, "/c", f.Action) diff --git a/src/main.scss b/src/main.scss index e238586..2e1e9b8 100644 --- a/src/main.scss +++ b/src/main.scss @@ -26,6 +26,11 @@ $modal-content-width: 90vw; display: inline-block; } +.icn-loading { + animation: spin-animation 3s infinite; + display: inline-block; +} + @keyframes spin-animation { 0% { transform: rotate(0deg); diff --git a/templates/base/script.tmpl b/templates/base/script.tmpl index 3486b16..2ee3685 100644 --- a/templates/base/script.tmpl +++ b/templates/base/script.tmpl @@ -59,8 +59,7 @@ async function FileApply(){ else { const res = await fetch('/api/apply?name='+ Active, { method: 'POST', - }).catch(err=>{console.log(err);return;}); - console.log("running") + }); if(!res.ok){ const result = await Catch(res) result_editor.session.setValue(result) diff --git a/templates/components/toolbar.tmpl b/templates/components/toolbar.tmpl index efa43c4..f4aebc3 100644 --- a/templates/components/toolbar.tmpl +++ b/templates/components/toolbar.tmpl @@ -15,7 +15,7 @@
@@ -53,9 +53,9 @@- @@ -63,16 +63,16 @@ {{if not .File.RO}}
{{if eq .File.Name .AppName}} - {{else}} - @@ -83,8 +83,8 @@
@@ -152,7 +152,7 @@ function toolFollow(){ let icon = document.getElementById('toolFollowIcon'); el.classList.remove('is-primary'); icon.classList.remove('icn-spinner'); - icon.innerText='pause'; + icon.innerText='sync_disabled'; } else { ToolIsFollow = true let el = document.getElementById('toolFollow'); @@ -165,24 +165,30 @@ function toolFollow(){ } async function toolRefresh(){ - let el = document.getElementById('toolRefresh'); - el.classList.add("is-loading") + let el = document.getElementById('toolRefreshIco'); + el.classList.toggle('icn-loading') await FileGet() - el.classList.remove("is-loading") + el.classList.toggle('icn-loading') } async function toolSave(){ - let el = document.getElementById('toolSave'); - el.classList.add("is-loading") + let el = document.getElementById('toolSaveIco'); + let originText = el.innerText; + el.innerText='refreash'; + el.classList.add("icn-loading") await FileSave() - el.classList.remove("is-loading") + el.innerText=originText; + el.classList.remove("icn-loading") } async function toolApply(){ - let el = document.getElementById('toolApply'); - el.classList.add("is-loading") - await FileApply() - el.classList.remove("is-loading") + let el = document.getElementById('toolApplyIco'); + let originText = el.innerText; + el.innerText='refreash'; + el.classList.add("icn-loading") + FileApply() + el.innerText=originText; + el.classList.remove("icn-loading") ResultViewTog() }