diff --git a/src/assets/main.css b/src/assets/main.css index b7ad290..6842d10 100644 --- a/src/assets/main.css +++ b/src/assets/main.css @@ -25,7 +25,7 @@ body { .content-block { margin-top: 70px; - padding: 0 20px; + padding: 0; /* background-color: #553333; */ } diff --git a/src/components/PlaceBlock.vue b/src/components/PlaceBlock.vue index 9c95d86..4680109 100644 --- a/src/components/PlaceBlock.vue +++ b/src/components/PlaceBlock.vue @@ -1,7 +1,7 @@ diff --git a/src/components/ScenariosEditorPage.vue b/src/components/ScenariosEditorPage.vue index 0c67ce2..6bb05b5 100644 --- a/src/components/ScenariosEditorPage.vue +++ b/src/components/ScenariosEditorPage.vue @@ -8,7 +8,7 @@ import { useRoute } from 'vue-router'; import { Icon } from '@vicons/utils' import { Settings } from '@vicons/carbon' import router from '@/router'; -import { NCard, NModal, NInput, NSpace, NText, NUpload, NUploadDragger, NSwitch, NDynamicInput } from 'naive-ui' +import { NCard, NModal, NInput, NSpace, NText, NUpload, NUploadDragger, NFlex, NSwitch, NDynamicInput } from 'naive-ui' import PlaceBlock from '@/components/PlaceBlock.vue'; const client = getAuthClient(); @@ -21,7 +21,6 @@ const deletedScenarioName = ref('') const message = useMessage() const fileList = ref([]) -const newPlaceFileList = ref([]) const scenario = ref({ id: undefined, @@ -41,7 +40,8 @@ const newPlace = ref({ hidden: undefined, applications: undefined, doors: undefined, - keys: undefined + keys: undefined, + mode: 'mini-add' }) async function getScenario(id: number) { @@ -51,6 +51,10 @@ async function getScenario(id: number) { return } scenario.value = res.scenario! + scenario.value.story?.places?.forEach((item) => { + item.oldCode = item.code + item.mode = 'show-editor' + }) } getScenario(Number(scenarioId)) @@ -101,27 +105,6 @@ function uint8ToBase64(uint8Array: Uint8Array) { return btoa(binaryString); } -function onCreateApplication(): Application { - return { - name: undefined, - image: undefined - } -} - -function onCreateDoor(): Door { - return { - code: undefined, - name: undefined, - keys: undefined - } -} - -function onCreateKey(): Key { - return { - name: undefined - } -} - async function addPlace() { const res = await client.AddScenarioPlace({ id: scenario.value.id, @@ -145,91 +128,73 @@ async function addPlace() { } } +async function collapseAddPlace(place: Place) { + place.mode = 'mini-add' +} + +async function cancelUpdatePlace(place: Place) { + await getScenario(Number(scenarioId)) + + place.mode = 'show-editor' +} + +async function updatePlace(place: Place) { + const res = await client.UpdateScenarioPlace({ + id: scenario.value.id, + code: place.oldCode, + place: place + }) + if (res.error != '') { + message.error(res.error!) + return + } + await getScenario(Number(scenarioId)) + + place.mode = 'show-editor' +} + +async function deletePlace(place: Place) { + const res = await client.DeleteScenarioPlace({ + id: scenario.value.id, + code: place.oldCode, + }) + if (res.error != '') { + message.error(res.error!) + return + } + await getScenario(Number(scenarioId)) +} +