|
|
@ -17,7 +17,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router' |
|
|
|
import { useRoute, useRouter } from 'vue-router' |
|
|
|
import { defineComponent, toRefs, watch } from 'vue' |
|
|
|
import { defineComponent, toRefs, watch } from 'vue' |
|
|
|
import { NButton, NForm, NFormItem, NSpace } from 'naive-ui' |
|
|
|
import { NButton, NForm, NFormItem, NSpace, NSpin } from 'naive-ui' |
|
|
|
import { useI18n } from 'vue-i18n' |
|
|
|
import { useI18n } from 'vue-i18n' |
|
|
|
import { useForm } from './use-form' |
|
|
|
import { useForm } from './use-form' |
|
|
|
import { useEdit } from './use-edit' |
|
|
|
import { useEdit } from './use-edit' |
|
|
@ -38,7 +38,7 @@ export default defineComponent({ |
|
|
|
const { getResourceView, handleUpdateContent } = useEdit(state) |
|
|
|
const { getResourceView, handleUpdateContent } = useEdit(state) |
|
|
|
|
|
|
|
|
|
|
|
const handleFileContent = () => { |
|
|
|
const handleFileContent = () => { |
|
|
|
state.fileForm.content = resourceViewRef.value.content |
|
|
|
state.fileForm.content = resourceViewRef.state.value.content |
|
|
|
handleUpdateContent(fileId) |
|
|
|
handleUpdateContent(fileId) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -47,10 +47,9 @@ export default defineComponent({ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const resourceViewRef = getResourceView(fileId) |
|
|
|
const resourceViewRef = getResourceView(fileId) |
|
|
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
watch( |
|
|
|
() => resourceViewRef.value.content, |
|
|
|
() => resourceViewRef.state.value.content, |
|
|
|
() => (state.fileForm.content = resourceViewRef.value.content) |
|
|
|
() => (state.fileForm.content = resourceViewRef.state.value.content) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
@ -65,9 +64,10 @@ export default defineComponent({ |
|
|
|
const { t } = useI18n() |
|
|
|
const { t } = useI18n() |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Card title={t('resource.file.file_details')}> |
|
|
|
<Card title={t('resource.file.file_details')}> |
|
|
|
|
|
|
|
{this.resourceViewRef.isReady.value ? ( |
|
|
|
<div class={styles['file-edit-content']}> |
|
|
|
<div class={styles['file-edit-content']}> |
|
|
|
<h2> |
|
|
|
<h2> |
|
|
|
<span>{this.resourceViewRef.alias}</span> |
|
|
|
<span>{this.resourceViewRef.state.value.alias}</span> |
|
|
|
</h2> |
|
|
|
</h2> |
|
|
|
<NForm |
|
|
|
<NForm |
|
|
|
rules={this.rules} |
|
|
|
rules={this.rules} |
|
|
@ -76,7 +76,9 @@ export default defineComponent({ |
|
|
|
disabled={this.componentName !== 'resource-file-edit'} |
|
|
|
disabled={this.componentName !== 'resource-file-edit'} |
|
|
|
> |
|
|
|
> |
|
|
|
<NFormItem path='content'> |
|
|
|
<NFormItem path='content'> |
|
|
|
<MonacoEditor v-model={[this.resourceViewRef.content, 'value']} /> |
|
|
|
<MonacoEditor |
|
|
|
|
|
|
|
v-model={[this.resourceViewRef.state.value.content, 'value']} |
|
|
|
|
|
|
|
/> |
|
|
|
</NFormItem> |
|
|
|
</NFormItem> |
|
|
|
<NSpace> |
|
|
|
<NSpace> |
|
|
|
<NButton |
|
|
|
<NButton |
|
|
@ -103,6 +105,11 @@ export default defineComponent({ |
|
|
|
</NSpace> |
|
|
|
</NSpace> |
|
|
|
</NForm> |
|
|
|
</NForm> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<NSpace justify='center'> |
|
|
|
|
|
|
|
<NSpin show={true} /> |
|
|
|
|
|
|
|
</NSpace> |
|
|
|
|
|
|
|
)} |
|
|
|
</Card> |
|
|
|
</Card> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|