Skip to content

Commit

Permalink
feat: add share setting
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Apr 19, 2024
1 parent a26e3cf commit 56513d5
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 26 deletions.
86 changes: 86 additions & 0 deletions components/common/BackPage.vue
@@ -0,0 +1,86 @@
<!--
- Copyright (c) 2023, Terwer . All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License version 2 only, as
- published by the Free Software Foundation. Terwer designates this
- particular file as subject to the "Classpath" exception as provided
- by Terwer in the LICENSE file that accompanied this code.
-
- This code is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- version 2 for more details (a copy is included in the LICENSE file that
- accompanied this code).
-
- You should have received a copy of the GNU General Public License version
- 2 along with this work; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-
- Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
- or visit www.terwer.space if you need additional information or have any
- questions.
-->

<script setup lang="ts">
// uses
import { useRoute, useRouter } from "vue-router"
import { ref } from "vue"
import { createAppLogger } from "~/common/appLogger"
import { ArrowLeft } from "@element-plus/icons-vue"
const logger = createAppLogger("back-page")
const router = useRouter()
const { query } = useRoute()
// props
const props = defineProps({
title: {
type: String,
default: "",
},
hasBackEmit: {
type: Boolean,
default: false,
},
})
// datas
const showBack = ref(query.showBack === "true")
// emits
const emit = defineEmits(["backEmit"])
const onBack = () => {
if (emit && props.hasBackEmit) {
logger.info("using backEmit do back")
emit("backEmit")
} else {
logger.warn("no backEmit, using router handle back")
router.back()
}
}
</script>

<template>
<div id="page-body">
<div v-if="showBack" class="page-head">
<el-page-header :icon="ArrowLeft" title="返回" @click="onBack">
<template #content>
<div class="flex items-center">
<span class="text-large font-600 mr-3">{{ props.title }}</span>
</div>
</template>
</el-page-header>
</div>
<div class="page-content-box">
<slot />
</div>
</div>
</template>

<style scoped lang="stylus">
#page-body
margin 10px 20px
</style>
8 changes: 4 additions & 4 deletions components/default/Footer.vue
Expand Up @@ -20,7 +20,7 @@ const goGithub = () => {
}
const goAbout = () => {
window.open("https://blog.terwer.space/about")
window.open("https://terwer.space/about")
}
// methods
Expand All @@ -44,9 +44,9 @@ const goHome = async () => {
<span class="text s-dark" @click="goAbout()">{{ t("syp.about") }}</span>

<span class="text">.</span>
<span class="text s-dark" @click="toggleDark()">{{
colorMode ? t("theme.mode.light") : t("theme.mode.dark")
}}</span>
<span class="text s-dark" @click="toggleDark()">
{{ colorMode ? t("theme.mode.light") : t("theme.mode.dark") }}
</span>
</div>
</div>
</template>
Expand Down
3 changes: 3 additions & 0 deletions locales/en_US.ts
Expand Up @@ -98,4 +98,7 @@ export default {
"share.accessCodeEnabled.tip":
"Special note: If you have enabled the authorization code after detection, please know if the document or settings are updated and need to be shared again.",
"share.public.tip": "Currently in public sharing mode",
"share.static.tip":
"Gentle reminder: Should access prove elusive, consider IP switching. In environments beyond 127.0.0.1, kindly navigate to Settings->About->Network Servers to initiate server activation.",
"share.setting": "Setting",
}
3 changes: 3 additions & 0 deletions locales/zh_CN.ts
Expand Up @@ -95,4 +95,7 @@ export default {
"change.ip.title": "切换IP",
"share.accessCodeEnabled.tip": "特别提示:为安全起见,1.9.0+ 将使用静态分享,若文档有更新,需重新分享,请知悉。",
"share.public.tip": "当前处于公共分享模式",
"share.static.tip":
"温馨提示:如果无法访问可通过切换IP(PC客户端)、或者在下方「偏好设置->设置自定义域名」(Docker)解决,外网访问需在「设置->关于->网络伺服」打开伺服",
"share.setting": "偏好设置",
}
36 changes: 21 additions & 15 deletions pages/setting.vue
Expand Up @@ -24,6 +24,8 @@
-->

<script setup lang="ts">
import BackPage from "~/components/common/BackPage.vue"
const { t } = useI18n()
definePageMeta({
Expand All @@ -32,26 +34,30 @@ definePageMeta({
</script>

<template>
<div>
<el-tabs tab-position="left">
<el-tab-pane :label="t('setting.basic')">
<default-setting-basic />
</el-tab-pane>
<el-tab-pane :label="t('setting.preference')">
<default-setting-preference />
</el-tab-pane>
<el-tab-pane :label="t('setting.system')">
<default-setting-change-local />
</el-tab-pane>
</el-tabs>
<back-page title="偏好设置">
<div class="setting-body">
<el-tabs tab-position="left">
<el-tab-pane :label="t('setting.basic')">
<default-setting-basic />
</el-tab-pane>
<el-tab-pane :label="t('setting.preference')">
<default-setting-preference />
</el-tab-pane>
<el-tab-pane :label="t('setting.system')">
<default-setting-change-local />
</el-tab-pane>
</el-tabs>

<div class="setting-tips">
<el-alert :title="t('setting.need.reload')" type="warning" />
<div class="setting-tips">
<el-alert :title="t('setting.need.reload')" type="warning" />
</div>
</div>
</div>
</back-page>
</template>

<style lang="stylus" scoped>
.setting-tips
margin-top 20px
.setting-body
padding-top 10px
</style>
30 changes: 23 additions & 7 deletions pages/share.vue
Expand Up @@ -58,6 +58,7 @@ const id = useRouteQuery("id", "")
const origin = useRouteQuery("origin", "")
const isSsr = useRouteQuery("isSsr", "")
const basePath = String(isSsr.value) === "true" ? "/plugins/siyuan-blog" : "/plugins/siyuan-blog/#"
const route = useRouter()
// lifecycles
onMounted(async () => {
Expand Down Expand Up @@ -108,7 +109,6 @@ const goHelp = async () => {
const copyWebLink = () => {
handleMethod(() => {
copy(formData.shareLink)
ElMessage.info("注意:如果是非 127.0.0.1 环境,请通过 设置->关于->网络伺服 打开伺服")
})
}
Expand Down Expand Up @@ -208,6 +208,10 @@ const handleIpChange = (val: string) => {
url.hostname = val
formData.shareLink = url.toString()
}
const goSetting = () => {
route.push("/setting?showBack=true")
}
</script>

<template>
Expand Down Expand Up @@ -264,6 +268,9 @@ const handleIpChange = (val: string) => {
<el-option v-for="item in formData.ipList" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</div>
<div class="change-ip-tip">
{{ t("share.static.tip") }}
</div>
</div>
<el-divider class="share-split" />

Expand Down Expand Up @@ -317,20 +324,22 @@ const handleIpChange = (val: string) => {

<div class="share-item">
<div class="item-left">
<el-space direction="vertical">
<el-space direction="horizontal">
<el-text @click="goHelp">
<el-icon>
<el-icon-help />
</el-icon>
{{ t("share.help") }}
</el-text>

<el-text @click="goSetting">
<el-icon>
<el-icon-setting />
</el-icon>
{{ t("share.setting") }}
</el-text>
</el-space>
</div>
<!--
<div class="item-right">
<el-button :icon="Share" type="text">{{ t("share.copy.link") }}</el-button>
</div>
-->
</div>
<el-divider class="share-split" />

Expand Down Expand Up @@ -414,4 +423,11 @@ const handleIpChange = (val: string) => {
color #ea4aaa
.share-warn-tip
padding-left 6px
.change-ip-tip
color red
font-size 13px
padding-top 10px
.setting-btn
padding-left 10px
font-size 13px
</style>

0 comments on commit 56513d5

Please sign in to comment.