You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/oaweb/pages/app/[id]/index.vue

58 lines
1.2 KiB
Vue

1 year ago
<!--
* index.vue
* Copyright (C) 2024 veypi <i@veypi.com>
* 2024-06-07 17:46
* Distributed under terms of the MIT license.
-->
<template>
<div>
11 months ago
<Editor style="" v-if="app.id" :eid="app.id + '.des'" v-model="preview_mode" :content="content" @save="save">
</Editor>
</div>
</template>
<script lang="ts" setup>
1 year ago
import type { models } from '#imports';
import { fs } from '@veypi/oaer'
1 year ago
11 months ago
const app = inject('app') as Ref<models.App>
let preview_mode = ref(true)
let content = ref('')
const sync = () => {
11 months ago
if (app.value.des) {
fs.app.getFileContents(fs.app.urlunwrap(app.value.des), { format: 'text' }).then((e) => {
1 year ago
content.value = e as string
})
}
}
11 months ago
watch(computed(() => app.value.id), () => {
sync()
}, { immediate: true })
const save = (des: string) => {
11 months ago
let furl = `/info/appdes/${app.value.id}.md`
fs.app.putFileContents(furl, des).then((e) => {
furl = fs.app.urlwrap(furl)
11 months ago
if (app.value.des !== furl) {
api.app.Patch(app.value.id, { des: furl }).then((e) => {
preview_mode.value = true
11 months ago
app.value.des = furl
})
} else {
preview_mode.value = true
}
})
}
onMounted(() => {
})
</script>
<style scoped></style>