💄 Now create post in realm will auto linking

This commit is contained in:
LittleSheep 2024-03-20 23:06:50 +08:00
parent 87603e8bc5
commit 8c7338a752
3 changed files with 40 additions and 25 deletions

View File

@ -123,11 +123,12 @@ import { useEditor } from "@/stores/editor"
import { getAtk } from "@/stores/userinfo" import { getAtk } from "@/stores/userinfo"
import { useRealms } from "@/stores/realms"; import { useRealms } from "@/stores/realms";
import { computed, reactive, ref, watch } from "vue"; import { computed, reactive, ref, watch } from "vue";
import { useRouter } from "vue-router" import { useRoute, useRouter } from "vue-router"
import PlannedPublish from "@/components/publish/parts/PlannedPublish.vue" import PlannedPublish from "@/components/publish/parts/PlannedPublish.vue"
import Media from "@/components/publish/parts/Media.vue" import Media from "@/components/publish/parts/Media.vue"
import PublishArea from "@/components/publish/parts/PublishArea.vue"; import PublishArea from "@/components/publish/parts/PublishArea.vue";
const route = useRoute()
const realms = useRealms() const realms = useRealms()
const editor = useEditor() const editor = useEditor()
@ -220,6 +221,16 @@ watch(editor.related, (val) => {
}) })
} }
}) })
watch(
() => route.params.realmId,
(val) => {
if (val) {
data.value.realm_id = parseInt(val as string)
}
},
{ deep: true, immediate: true }
)
</script> </script>
<style scoped> <style scoped>

View File

@ -32,36 +32,31 @@
<v-tooltip text="Media" location="start"> <v-tooltip text="Media" location="start">
<template #activator="{ props }"> <template #activator="{ props }">
<v-btn <v-btn
v-if="data.attachments.length <= 0"
v-bind="props" v-bind="props"
icon
class="text-none"
type="button" type="button"
variant="text" variant="text"
icon="mdi-camera"
size="small" size="small"
@click="dialogs.media = true" @click="dialogs.media = true"
/> >
<v-badge v-else size="small" color="red" :content="data.attachments.length"> <v-badge v-if="data.attachments.length > 0" :content="data.attachments.length">
<v-btn <v-icon icon="mdi-camera" />
v-bind="props" </v-badge>
type="button"
variant="text" <v-icon v-else icon="mdi-camera" />
icon="mdi-camera" </v-btn>
size="small"
@click="dialogs.media = true"
/>
</v-badge>
</template> </template>
</v-tooltip> </v-tooltip>
<v-tooltip text="Publish area" location="start"> <v-tooltip text="Publish area" location="start">
<template #activator="{ props }"> <template #activator="{ props }">
<v-btn <v-btn v-bind="props" icon type="button" variant="text" size="small" @click="dialogs.area = true">
v-bind="props" <v-badge v-if="data.realm_id" dot>
type="button" <v-icon icon="mdi-account-group" />
variant="text" </v-badge>
icon="mdi-account-group"
size="small" <v-icon v-else icon="mdi-account-group" />
@click="dialogs.area = true" </v-btn>
/>
</template> </template>
</v-tooltip> </v-tooltip>
</div> </div>
@ -95,11 +90,12 @@ import { request } from "@/scripts/request"
import { useEditor } from "@/stores/editor" import { useEditor } from "@/stores/editor"
import { getAtk } from "@/stores/userinfo" import { getAtk } from "@/stores/userinfo"
import { reactive, ref, watch } from "vue" import { reactive, ref, watch } from "vue"
import { useRouter } from "vue-router" import { useRoute, useRouter } from "vue-router"
import PlannedPublish from "@/components/publish/parts/PlannedPublish.vue" import PlannedPublish from "@/components/publish/parts/PlannedPublish.vue"
import Media from "@/components/publish/parts/Media.vue" import Media from "@/components/publish/parts/Media.vue"
import PublishArea from "@/components/publish/parts/PublishArea.vue" import PublishArea from "@/components/publish/parts/PublishArea.vue"
const route = useRoute()
const editor = useEditor() const editor = useEditor()
const dialogs = reactive({ const dialogs = reactive({
@ -167,6 +163,16 @@ watch(editor.related, (val) => {
data.value = val.edit_to data.value = val.edit_to
} }
}) })
watch(
() => route.params.realmId,
(val) => {
if (val) {
data.value.realm_id = parseInt(val as string)
}
},
{ deep: true, immediate: true }
)
</script> </script>
<style> <style>

View File

@ -28,11 +28,9 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useEditor } from "@/stores/editor";
import { useRealms } from "@/stores/realms"; import { useRealms } from "@/stores/realms";
const realms = useRealms(); const realms = useRealms();
const editor = useEditor();
const props = defineProps<{ show: boolean; value: string | null }>(); const props = defineProps<{ show: boolean; value: string | null }>();
const emits = defineEmits(["update:show", "update:value"]); const emits = defineEmits(["update:show", "update:value"]);