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

View file

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

View file

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