fix task article link drawer
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ClockCircleOutlined, ThunderboltOutlined } from '@ant-design/icons-vue'
|
||||
import { ref } from 'vue'
|
||||
import { ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
import CustomArticleTab from '@/components/CustomArticleTab.vue'
|
||||
import InstantGenerateModal from '@/components/InstantGenerateModal.vue'
|
||||
@@ -11,11 +12,48 @@ import ScheduleTaskModal from '@/components/ScheduleTaskModal.vue'
|
||||
import ScheduleTaskTab from '@/components/ScheduleTaskTab.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const activeTab = ref('articles')
|
||||
const customTabs = ['articles', 'instantTasks', 'scheduleTasks', 'promptRules'] as const
|
||||
type CustomTab = (typeof customTabs)[number]
|
||||
|
||||
const activeTab = ref<CustomTab>(normalizeCustomTab(route.query.tab))
|
||||
const instantModalOpen = ref(false)
|
||||
const scheduleModalOpen = ref(false)
|
||||
|
||||
function normalizeCustomTab(value: unknown): CustomTab {
|
||||
const tab = Array.isArray(value) ? value[0] : value
|
||||
return customTabs.includes(tab as CustomTab) ? (tab as CustomTab) : 'articles'
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.query.tab,
|
||||
(tab) => {
|
||||
const normalized = normalizeCustomTab(tab)
|
||||
if (activeTab.value !== normalized) {
|
||||
activeTab.value = normalized
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
watch(
|
||||
activeTab,
|
||||
(tab) => {
|
||||
if (route.query.tab === tab) {
|
||||
return
|
||||
}
|
||||
void router.replace({
|
||||
name: 'articles-custom',
|
||||
query: {
|
||||
...route.query,
|
||||
tab,
|
||||
},
|
||||
})
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
function openInstantModal(): void {
|
||||
instantModalOpen.value = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user