feat: multiple page width settings

This commit is contained in:
KUN1007 2023-09-09 23:42:55 +08:00
parent 0f01c67467
commit 852503ec0b
18 changed files with 227 additions and 76 deletions

View file

@ -24,6 +24,7 @@
"Licence", "Licence",
"loli", "loli",
"majesticons", "majesticons",
"mingcute",
"mockjs", "mockjs",
"moemoe", "moemoe",
"moemoepoint", "moemoepoint",

View file

@ -79,8 +79,9 @@ const handelClickSettings = () => {
<li>{{ $tm('edit.help1') }}</li> <li>{{ $tm('edit.help1') }}</li>
<li>{{ $tm('edit.help2') }}</li> <li>{{ $tm('edit.help2') }}</li>
<li>{{ $tm('edit.help3') }}</li> <li>{{ $tm('edit.help3') }}</li>
<li>{{ $tm('edit.help4') }}</li>
<li> <li>
{{ $tm('edit.help4') }} {{ $tm('edit.help5') }}
<span @click="router.push('/contact')"> <span @click="router.push('/contact')">
{{ $tm('edit.contact') }} {{ $tm('edit.contact') }}
</span> </span>
@ -138,7 +139,6 @@ const handelClickSettings = () => {
ul { ul {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
border: 1px solid var(--kungalgame-blue-1);
background-color: var(--kungalgame-white); background-color: var(--kungalgame-white);
padding: 5px; padding: 5px;
border-radius: 5px; border-radius: 5px;

View file

@ -8,15 +8,15 @@ import Loli from './components/Loli.vue'
import Mode from './components/Mode.vue' import Mode from './components/Mode.vue'
// //
import SwitchLanguage from './components/SwitchLanguage.vue' import SwitchLanguage from './components/SwitchLanguage.vue'
//
import PageWidth from './components/PageWidth.vue'
// //
import Background from './components/Background.vue' import Background from './components/Background.vue'
// store // store
import { useKUNGalgameSettingsStore } from '@/store/modules/settings' import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia'
// 使 store // 使 store
const settingsStore = useKUNGalgameSettingsStore() const settingsStore = useKUNGalgameSettingsStore()
const { showKUNGalgameMainPageWidth } = storeToRefs(settingsStore)
const emits = defineEmits(['close']) const emits = defineEmits(['close'])
@ -46,24 +46,11 @@ const handelCloseSettingsPanel = () => {
<!-- 语言切换组件 --> <!-- 语言切换组件 -->
<SwitchLanguage /> <SwitchLanguage />
<div> <!-- 页面宽度调整组件 -->
<!-- 设置主页的宽度 --> <PageWidth />
<div class="width-container">
<span>{{ $tm('header.settings.width') }}</span> <!-- 设置页面的字体 TODO: -->
<span>{{ showKUNGalgameMainPageWidth }}%</span> <div class="font"></div>
</div>
<div class="page-width">
<span>50%</span
><input
class="main"
min="50"
max="90"
step="0.1"
type="range"
v-model="showKUNGalgameMainPageWidth"
/><span>90%</span>
</div>
</div>
<!-- 背景设置组件 --> <!-- 背景设置组件 -->
<Background /> <Background />
@ -128,24 +115,6 @@ const handelCloseSettingsPanel = () => {
} }
} }
.page-width {
font-size: 15px;
display: flex;
span {
margin-top: 15px;
}
}
/* 主页页面宽度滑动条 */
.main {
width: 100%;
height: 10px;
margin: 20px 0;
}
.width-container {
display: flex;
justify-content: space-between;
}
.reset { .reset {
font-size: 15px; font-size: 15px;
cursor: pointer; cursor: pointer;
@ -168,6 +137,7 @@ const handelCloseSettingsPanel = () => {
margin: 20px; margin: 20px;
cursor: pointer; cursor: pointer;
} }
@media (max-width: 1000px) { @media (max-width: 1000px) {
.root { .root {
display: none; display: none;

View file

@ -0,0 +1,86 @@
<script setup lang="ts">
import { ref, computed, onMounted, onActivated, watch } from 'vue'
import { useRoute } from 'vue-router'
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 pageNameArray = [
'KUN',
'Topic',
'Edit',
'KUNGalgame',
'Pool',
'Bylaw',
'Technique',
'ThanksList',
]
const initPageWidth = () => {
if (pageNameArray.includes(routeName.value)) {
pageWidth.value = showKUNGalgamePageWidth.value[routeName.value]
}
}
watch(pageWidth, () => {
if (pageNameArray.includes(routeName.value)) {
showKUNGalgamePageWidth.value[routeName.value] = pageWidth.value
}
})
onMounted(() => {
initPageWidth()
})
onActivated(() => {
initPageWidth()
})
</script>
<template>
<!-- 设置某些页面的宽度 -->
<div class="width">
<div class="width-container">
<span>{{ $tm('header.settings.width') }}</span>
<span>{{ pageWidth }}%</span>
</div>
<div class="page-width">
<span>50%</span
><input
class="main"
min="50"
max="90"
step="0.1"
type="range"
v-model="pageWidth"
/><span>90%</span>
</div>
</div>
</template>
<style lang="scss" scoped>
.page-width {
font-size: 15px;
display: flex;
span {
margin-top: 15px;
}
}
/* 主页页面宽度滑动条 */
.main {
width: 100%;
height: 10px;
margin: 20px 0;
}
.width-container {
display: flex;
justify-content: space-between;
}
</style>

View file

@ -92,7 +92,7 @@ onBeforeRouteLeave(() => {
enter-active-class="animate__animated animate__jackInTheBox animate__faster" enter-active-class="animate__animated animate__jackInTheBox animate__faster"
leave-active-class="animate__animated animate__fadeOutRight animate__faster" leave-active-class="animate__animated animate__fadeOutRight animate__faster"
> >
<KeepAlive> <KeepAlive exclude="PageWidth">
<KUNGalgameSettingsPanel <KUNGalgameSettingsPanel
v-if="showKUNGalgamePanel" v-if="showKUNGalgamePanel"
@close="showKUNGalgamePanel = false" @close="showKUNGalgamePanel = false"

View file

@ -10,7 +10,7 @@ export default {
name: 'Settings', name: 'Settings',
mode: 'Mode', mode: 'Mode',
language: 'Language', language: 'Language',
width: 'Main Page Width', width: 'Page Width',
background: 'Background Setting', background: 'Background Setting',
preset: 'Use our preset background', preset: 'Use our preset background',
custom: 'Custom Background', custom: 'Custom Background',
@ -133,8 +133,9 @@ export default {
refresh: 'Refresh the page', refresh: 'Refresh the page',
help1: "The topic's title length should be between 1 and 40 characters.", help1: "The topic's title length should be between 1 and 40 characters.",
help2: "You can click on the left settings to adjust the editor's mode.", help2: "You can click on the left settings to adjust the editor's mode.",
help3: "The website's code is handwritten, and errors are inevitable.", help3: 'We recommend finishing your text before formatting.',
help4: 'If you encounter any errors, please', help4: "The website's code is handwritten, and errors are inevitable.",
help5: 'If you encounter any errors, please',
contact: ' Contact Us.', contact: ' Contact Us.',
tags: 'Please input topic tags', tags: 'Please input topic tags',
hint: `Hint: (A single tag should be within 14 characters, choose at least one and up to 7 tags). You can enter text and press \`Enter\` to create a tag.`, hint: `Hint: (A single tag should be within 14 characters, choose at least one and up to 7 tags). You can enter text and press \`Enter\` to create a tag.`,

View file

@ -10,7 +10,7 @@ export default {
name: '设置面板', name: '设置面板',
mode: '模式切换', mode: '模式切换',
language: '网站语言设置', language: '网站语言设置',
width: '主页页面宽度设置', width: '页面宽度设置',
background: '背景设置', background: '背景设置',
preset: '点击使用我们预设的背景', preset: '点击使用我们预设的背景',
custom: '自定义背景', custom: '自定义背景',
@ -133,8 +133,9 @@ export default {
refresh: '刷新页面生效', refresh: '刷新页面生效',
help1: '话题的标题长度需要在 1 到 40 字之间', help1: '话题的标题长度需要在 1 到 40 字之间',
help2: '您可以点击左侧的设置调整编辑器的模式', help2: '您可以点击左侧的设置调整编辑器的模式',
help3: '网站的代码是手写的,错误在所难免', help3: '我们建议您写完文本再进行格式化',
help4: '如果您遇到错误,请', help4: '网站的代码是手写的,错误在所难免',
help5: '如果您遇到错误,请',
contact: ' 联系我们', contact: ' 联系我们',
tags: '请输入话题的关键词', tags: '请输入话题的关键词',
hint: `提示:(单个关键词 14 个字符以内,至少选择一个、最多 7 个), 您可以输入文字后按下 ' Enter ' 创建关键词`, hint: `提示:(单个关键词 14 个字符以内,至少选择一个、最多 7 个), 您可以输入文字后按下 ' Enter ' 创建关键词`,

View file

@ -10,7 +10,7 @@ const index: RouteRecordRaw[] = [
redirect: '/kun', redirect: '/kun',
children: [ children: [
{ {
name: 'index', name: 'KUN',
path: 'kun', path: 'kun',
component: () => import('@/views/Home/KUNGalgameMainPage.vue'), component: () => import('@/views/Home/KUNGalgameMainPage.vue'),
meta: { meta: {

View file

@ -11,7 +11,7 @@ interface KUNGalgameSettings {
// 网站显示语言 // 网站显示语言
showKUNGalgameLanguage: string showKUNGalgameLanguage: string
// 主页宽度 // 主页宽度
showKUNGalgameMainPageWidth: string showKUNGalgamePageWidth: Record<string, number>
// 背景图 // 背景图
showKUNGalgameBackground: string showKUNGalgameBackground: string
// 自定义背景图 // 自定义背景图
@ -25,7 +25,16 @@ export const useKUNGalgameSettingsStore = defineStore({
state: (): KUNGalgameSettings => ({ state: (): KUNGalgameSettings => ({
showKUNGalgameMode: mode, showKUNGalgameMode: mode,
showKUNGalgameLanguage: KUNGalgameLanguage, showKUNGalgameLanguage: KUNGalgameLanguage,
showKUNGalgameMainPageWidth: '61.8', showKUNGalgamePageWidth: {
KUN: 61.8,
Topic: 90,
Edit: 90,
KUNGalgame: 90,
Pool: 90,
Bylaw: 90,
Technique: 90,
ThanksList: 90,
},
showKUNGalgameBackground: 'none', showKUNGalgameBackground: 'none',
showKUNGalgameCustomBackground: '', showKUNGalgameCustomBackground: '',
}), }),

View file

@ -7,9 +7,9 @@ import { storeToRefs } from 'pinia'
import { computed } from 'vue' import { computed } from 'vue'
// 使 store // 使 store
const settingsStore = useKUNGalgameSettingsStore() const settingsStore = useKUNGalgameSettingsStore()
const { showKUNGalgameMainPageWidth } = storeToRefs(settingsStore) const { showKUNGalgamePageWidth } = storeToRefs(settingsStore)
const width = computed(() => { const mainPageWidth = computed(() => {
return showKUNGalgameMainPageWidth.value + '%' return showKUNGalgamePageWidth.value.KUN + '%'
}) })
</script> </script>
@ -41,7 +41,7 @@ const width = computed(() => {
} }
/* 可视内容部分宽度 */ /* 可视内容部分宽度 */
.content-container { .content-container {
width: v-bind(width); width: v-bind(mainPageWidth);
transition: all 0.2s; transition: all 0.2s;
height: 100%; height: 100%;
margin: 0 auto; margin: 0 auto;

View file

@ -1,5 +1,16 @@
<script setup lang="ts"> <script setup lang="ts">
import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue' import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue'
// store
import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia'
import { computed } from 'vue'
// 使 store
const settingsStore = useKUNGalgameSettingsStore()
const { showKUNGalgamePageWidth } = storeToRefs(settingsStore)
const bylawPageWidth = computed(() => {
return showKUNGalgamePageWidth.value.Bylaw + '%'
})
</script> </script>
<template> <template>
@ -99,7 +110,8 @@ import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue'
margin: 0 auto; margin: 0 auto;
padding: 5px; padding: 5px;
/* 固定宽高 */ /* 固定宽高 */
width: 70%; transition: all 0.2s;
width: v-bind(bylawPageWidth);
max-width: 1300px; max-width: 1300px;
height: 100%; height: 100%;
background-color: var(--kungalgame-trans-white-5); background-color: var(--kungalgame-trans-white-5);

View file

@ -4,6 +4,17 @@ import QuillEditor from '@/components/quill-editor/QuillEditor.vue'
import Tags from './components/Tags.vue' import Tags from './components/Tags.vue'
import Footer from './components/Footer.vue' import Footer from './components/Footer.vue'
import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue' import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue'
// store
import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia'
import { computed } from 'vue'
// 使 store
const settingsStore = useKUNGalgameSettingsStore()
const { showKUNGalgamePageWidth } = storeToRefs(settingsStore)
const editPageWidth = computed(() => {
return showKUNGalgamePageWidth.value.Edit + '%'
})
</script> </script>
<template> <template>
@ -46,7 +57,7 @@ import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue'
/* 内容部分的总容器 */ /* 内容部分的总容器 */
.container { .container {
transition: all 0.2s; transition: all 0.2s;
width: 80%; width: v-bind(editPageWidth);
max-width: 1500px; max-width: 1500px;
margin: 0 auto; margin: 0 auto;
/* 容器的阴影 */ /* 容器的阴影 */

View file

@ -3,6 +3,17 @@
import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue' import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue'
// Aside // Aside
import Aside from './components/Aside.vue' import Aside from './components/Aside.vue'
// store
import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia'
import { computed } from 'vue'
// 使 store
const settingsStore = useKUNGalgameSettingsStore()
const { showKUNGalgamePageWidth } = storeToRefs(settingsStore)
const kungalgamePageWidth = computed(() => {
return showKUNGalgamePageWidth.value.KUNGalgame + '%'
})
</script> </script>
<template> <template>
@ -189,7 +200,8 @@ import Aside from './components/Aside.vue'
border-radius: 7px; border-radius: 7px;
/* 固定高度 */ /* 固定高度 */
height: 1300px; height: 1300px;
width: 90%; transition: all 0.2s;
width: v-bind(kungalgamePageWidth);
max-width: 1300px; max-width: 1300px;
/* 居中 */ /* 居中 */
margin: auto; margin: auto;

View file

@ -5,6 +5,17 @@ import Topic from './components/Topic.vue'
import Bar from './components/Bar.vue' import Bar from './components/Bar.vue'
import { topic } from './components/topic' import { topic } from './components/topic'
// store
import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia'
import { computed } from 'vue'
// 使 store
const settingsStore = useKUNGalgameSettingsStore()
const { showKUNGalgamePageWidth } = storeToRefs(settingsStore)
const poolPageWidth = computed(() => {
return showKUNGalgamePageWidth.value.Pool + '%'
})
</script> </script>
<template> <template>
@ -39,7 +50,8 @@ import { topic } from './components/topic'
/* 话题池容器 */ /* 话题池容器 */
.pool-container { .pool-container {
/* 占页面的宽度比例 */ /* 占页面的宽度比例 */
width: 90%; transition: all 0.2s;
width: v-bind(poolPageWidth);
/* 居中 */ /* 居中 */
margin: 0 auto; margin: 0 auto;
display: flex; display: flex;

View file

@ -14,6 +14,17 @@ onBeforeMount(async () => {
console.error('Error fetching topics:', error) console.error('Error fetching topics:', error)
} }
}) })
// store
import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia'
import { computed } from 'vue'
// 使 store
const settingsStore = useKUNGalgameSettingsStore()
const { showKUNGalgamePageWidth } = storeToRefs(settingsStore)
const techniquePageWidth = computed(() => {
return showKUNGalgamePageWidth.value.Technique + '%'
})
</script> </script>
<template> <template>
@ -47,7 +58,8 @@ onBeforeMount(async () => {
padding: 5px; padding: 5px;
height: 1400px; height: 1400px;
/* 占总页面的宽度 */ /* 占总页面的宽度 */
width: 95%; transition: all 0.2s;
width: v-bind(techniquePageWidth);
/* 水平垂直居中 */ /* 水平垂直居中 */
margin: 0 auto; margin: 0 auto;
display: flex; display: flex;

View file

@ -1,6 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
// Footer // Footer
import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue' import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue'
// store
import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia'
import { computed } from 'vue'
// 使 store
const settingsStore = useKUNGalgameSettingsStore()
const { showKUNGalgamePageWidth } = storeToRefs(settingsStore)
const thanksListPageWidth = computed(() => {
return showKUNGalgamePageWidth.value.ThanksList + '%'
})
</script> </script>
<template> <template>
@ -97,7 +108,8 @@ import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue'
} }
.container { .container {
/* 固定宽高 */ /* 固定宽高 */
max-width: 900px; transition: all 0.2s;
width: v-bind(thanksListPageWidth);
height: 1300px; height: 1300px;
/* 居中 */ /* 居中 */
margin: auto; margin: auto;

View file

@ -4,27 +4,38 @@
<script setup lang="ts"> <script setup lang="ts">
import KUNGalgameTopicAside from './aside/KUNGalgameTopicAside.vue' import KUNGalgameTopicAside from './aside/KUNGalgameTopicAside.vue'
import KUNGalgameTopicContent from './content/KUNGalgameTopicContent.vue' import KUNGalgameTopicContent from './content/KUNGalgameTopicContent.vue'
// //
import { defineAsyncComponent, onBeforeMount } from 'vue'
// store
import { useKUNGalgameTopicStore } from '@/store/modules/topic'
import { storeToRefs } from 'pinia'
import { onBeforeRouteLeave } from 'vue-router'
// 使 store
const settingsStore = useKUNGalgameTopicStore()
const { isShowAdvance, isEdit } = storeToRefs(settingsStore)
const ReplyPanel = defineAsyncComponent( const ReplyPanel = defineAsyncComponent(
() => import('@/views/topic/content/components/ReplyPanel.vue') () => import('@/views/topic/content/components/ReplyPanel.vue')
) )
// import { defineAsyncComponent, onBeforeMount, computed } from 'vue'
import { onBeforeRouteLeave } from 'vue-router'
// store
import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
// store
import { useKUNGalgameTopicStore } from '@/store/modules/topic'
import { storeToRefs } from 'pinia'
// 使 store
const settingsStore = useKUNGalgameSettingsStore()
// 使 store
const topicStore = useKUNGalgameTopicStore()
const { showKUNGalgamePageWidth } = storeToRefs(settingsStore)
const { isShowAdvance, isEdit } = storeToRefs(topicStore)
/* 话题界面的页面宽度 */
const topicPageWidth = computed(() => {
return showKUNGalgamePageWidth.value.Topic + '%'
})
//
const resetPanelStatus = () => { const resetPanelStatus = () => {
isEdit.value = false
isShowAdvance.value = false isShowAdvance.value = false
isEdit.value = false
} }
onBeforeRouteLeave(() => { onBeforeRouteLeave(() => {
@ -67,7 +78,8 @@ onBeforeMount(() => {
} }
/* 下方可视内容区的容器 */ /* 下方可视内容区的容器 */
.content-wrapper { .content-wrapper {
width: 90%; width: v-bind(topicPageWidth);
transition: all 0.2s;
max-width: 1500px; max-width: 1500px;
height: 100%; height: 100%;
margin: 0 auto; margin: 0 auto;

View file

@ -36,7 +36,7 @@ const props = defineProps<{
flex-wrap: wrap; flex-wrap: wrap;
overflow-y: scroll; overflow-y: scroll;
li { li {
margin: 5px; margin: 3px;
font-size: small; font-size: small;
padding: 2px; padding: 2px;
background-color: var(--kungalgame-trans-blue-0); background-color: var(--kungalgame-trans-blue-0);