feat: apply user settings to effect
This commit is contained in:
@@ -2,18 +2,20 @@
|
||||
import { computed } from 'vue'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { ChevronLeft, ChevronRight } from 'lucide-vue-next'
|
||||
import { useSiteSettings } from '@/composables/useSiteSettings'
|
||||
|
||||
const props = defineProps<{
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:page': [page: number]
|
||||
}>()
|
||||
|
||||
const totalPages = computed(() => Math.ceil(props.total / props.pageSize) || 1)
|
||||
const { pageSize } = useSiteSettings()
|
||||
|
||||
const totalPages = computed(() => Math.ceil(props.total / pageSize.value) || 1)
|
||||
|
||||
function prevPage() {
|
||||
if (props.page > 1) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ref } from 'vue'
|
||||
import { ref, computed } from 'vue'
|
||||
import { api, type SiteSettings } from '@/api'
|
||||
|
||||
const siteSettings = ref<SiteSettings>({
|
||||
@@ -27,6 +27,8 @@ function updateFavicon(svgContent: string) {
|
||||
link.href = url
|
||||
}
|
||||
|
||||
const pageSize = computed(() => parseInt(siteSettings.value.page_size) || 10)
|
||||
|
||||
export function useSiteSettings() {
|
||||
async function loadSettings() {
|
||||
if (loaded) return
|
||||
@@ -48,6 +50,7 @@ export function useSiteSettings() {
|
||||
|
||||
return {
|
||||
siteSettings,
|
||||
pageSize,
|
||||
loadSettings,
|
||||
refreshSettings,
|
||||
updateFavicon
|
||||
|
||||
@@ -10,6 +10,9 @@ import Pagination from '@/components/Pagination.vue'
|
||||
import { Plus, Pencil, Trash2, Eye, EyeOff, Search } from 'lucide-vue-next'
|
||||
import { api, type EnvVar } from '@/api'
|
||||
import { toast } from 'vue-sonner'
|
||||
import { useSiteSettings } from '@/composables/useSiteSettings'
|
||||
|
||||
const { pageSize } = useSiteSettings()
|
||||
|
||||
const envVars = ref<EnvVar[]>([])
|
||||
const showDialog = ref(false)
|
||||
@@ -21,7 +24,6 @@ const deleteEnvId = ref<number | null>(null)
|
||||
|
||||
const filterName = ref('')
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const total = ref(0)
|
||||
let searchTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
@@ -155,7 +157,7 @@ onMounted(loadEnvVars)
|
||||
</div>
|
||||
</div>
|
||||
<!-- 分页 -->
|
||||
<Pagination :total="total" :page="currentPage" :page-size="pageSize" @update:page="handlePageChange" />
|
||||
<Pagination :total="total" :page="currentPage" @update:page="handlePageChange" />
|
||||
</div>
|
||||
|
||||
<Dialog v-model:open="showDialog">
|
||||
|
||||
@@ -8,13 +8,15 @@ import { RefreshCw, X, Search, Maximize2 } from 'lucide-vue-next'
|
||||
import { api, type TaskLog, type LogDetail } from '@/api'
|
||||
import { toast } from 'vue-sonner'
|
||||
import pako from 'pako'
|
||||
import { useSiteSettings } from '@/composables/useSiteSettings'
|
||||
|
||||
const { pageSize } = useSiteSettings()
|
||||
|
||||
const logs = ref<TaskLog[]>([])
|
||||
const selectedLog = ref<TaskLog | null>(null)
|
||||
const logDetail = ref<LogDetail | null>(null)
|
||||
const filterKeyword = ref('')
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const total = ref(0)
|
||||
let searchTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
@@ -150,7 +152,7 @@ onMounted(loadLogs)
|
||||
</div>
|
||||
</div>
|
||||
<!-- 分页 -->
|
||||
<Pagination :total="total" :page="currentPage" :page-size="pageSize" @update:page="handlePageChange" />
|
||||
<Pagination :total="total" :page="currentPage" @update:page="handlePageChange" />
|
||||
</div>
|
||||
|
||||
<!-- 日志详情侧边栏 -->
|
||||
|
||||
@@ -9,6 +9,9 @@ import Pagination from '@/components/Pagination.vue'
|
||||
import { Plus, Play, Pencil, Trash2, Search } from 'lucide-vue-next'
|
||||
import { api, type Task } from '@/api'
|
||||
import { toast } from 'vue-sonner'
|
||||
import { useSiteSettings } from '@/composables/useSiteSettings'
|
||||
|
||||
const { pageSize } = useSiteSettings()
|
||||
|
||||
const tasks = ref<Task[]>([])
|
||||
const showDialog = ref(false)
|
||||
@@ -19,7 +22,6 @@ const deleteTaskId = ref<number | null>(null)
|
||||
|
||||
const filterName = ref('')
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const total = ref(0)
|
||||
let searchTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
@@ -174,7 +176,7 @@ onMounted(loadTasks)
|
||||
</div>
|
||||
</div>
|
||||
<!-- 分页 -->
|
||||
<Pagination :total="total" :page="currentPage" :page-size="pageSize" @update:page="handlePageChange" />
|
||||
<Pagination :total="total" :page="currentPage" @update:page="handlePageChange" />
|
||||
</div>
|
||||
|
||||
<Dialog v-model:open="showDialog">
|
||||
|
||||
Reference in New Issue
Block a user