feat: page width disabled

This commit is contained in:
KUN1007 2023-09-10 23:37:47 +08:00
parent 01b8da9fbb
commit 30c2898416
3 changed files with 31 additions and 4 deletions

View file

@ -5,12 +5,18 @@ import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia'
const route = useRoute()
const settingsStore = useKUNGalgameSettingsStore()
const { showKUNGalgamePageWidth } = storeToRefs(settingsStore)
//
const pageWidth = ref(0)
//
const routeName = computed(() => route.name as string)
//
const isDisabled = ref(false)
//
const pageNameArray = [
'KUN',
'Topic',
@ -22,14 +28,21 @@ const pageNameArray = [
'ThanksList',
]
//
const initPageWidth = () => {
if (pageNameArray.includes(routeName.value)) {
// store
pageWidth.value = showKUNGalgamePageWidth.value[routeName.value]
//
isDisabled.value = false
} else {
isDisabled.value = true
}
}
watch(pageWidth, () => {
if (pageNameArray.includes(routeName.value)) {
// store
showKUNGalgamePageWidth.value[routeName.value] = pageWidth.value
}
})
@ -45,21 +58,27 @@ onActivated(() => {
<template>
<!-- 设置某些页面的宽度 -->
<div class="width">
<div
class="width"
:class="isDisabled ? 'disabled' : ''"
:title="isDisabled ? `${$tm('header.settings.disabled')}` : ''"
>
<div class="width-container">
<span>{{ $tm('header.settings.width') }}</span>
<span>{{ pageWidth }}%</span>
</div>
<div class="page-width">
<span>50%</span
><input
<span>50%</span>
<input
class="main"
min="50"
max="90"
step="0.1"
type="range"
v-model="pageWidth"
/><span>90%</span>
:disabled="isDisabled"
/>
<span>90%</span>
</div>
</div>
</template>
@ -84,4 +103,10 @@ onActivated(() => {
display: flex;
justify-content: space-between;
}
/* 调整页面宽度被禁用时的样式 */
.disabled {
cursor: not-allowed;
color: var(--kungalgame-font-color-0);
}
</style>

View file

@ -14,6 +14,7 @@ export default {
default: 'System Default',
fontInput: 'Input font name here',
width: 'Page Width',
disabled: 'The page does not allow width adjustment',
background: 'Background Setting',
preset: 'Use our preset background',
custom: 'Custom Background',

View file

@ -14,6 +14,7 @@ export default {
default: '系统默认',
fontInput: '请在这里输入字体的名字',
width: '页面宽度',
disabled: '该页面不允许调整宽度',
background: '背景设置',
preset: '点击使用我们预设的背景',
custom: '自定义背景',