-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from terwer/dev
feat: 在线分享第一版-完成设置页面
- Loading branch information
Showing
33 changed files
with
1,228 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<!-- | ||
- 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"> | ||
import { usePost } from "~/composables/usePost" | ||
import { getFirstImageSrc, getSummery } from "~/utils/utils" | ||
import { createAppLogger } from "~/common/appLogger" | ||
const logger = createAppLogger("share-page") | ||
// props | ||
const props = defineProps({ | ||
showTitleSign: Boolean, | ||
overrideSeo: Boolean, | ||
pageId: { | ||
type: String, | ||
default: undefined, | ||
}, | ||
}) | ||
const { t } = useI18n() | ||
const { currentPost, setCurrentPost } = usePost() | ||
await setCurrentPost(props.pageId) | ||
// datas | ||
if (!props.overrideSeo) { | ||
const titleSign = " - " + t("blog.share") | ||
const title = `${currentPost.post.title}${props.showTitleSign ? titleSign : ""}` | ||
const desc = getSummery(currentPost.post.description) | ||
const headImage = await getFirstImageSrc(currentPost.post.description) | ||
const seoMeta = { | ||
title: title, | ||
ogTitle: title, | ||
description: desc, | ||
ogDescription: desc, | ||
} as any | ||
if (headImage) { | ||
logger.info("get a head image from doc=>", headImage) | ||
seoMeta.ogImage = headImage | ||
} | ||
useSeoMeta(seoMeta) | ||
} | ||
// https://stackoverflow.com/a/71781246/4037224 | ||
const VNode = () => | ||
h("div", { | ||
class: "", | ||
innerHTML: currentPost.post.editorDom?.replaceAll('contenteditable="true"', 'contenteditable="false"') ?? "", | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="fn__flex-1 protyle" data-loading="finished"> | ||
<div class="protyle-content protyle-content--transition" data-fullwidth="true"> | ||
<div class="protyle-title protyle-wysiwyg--attr"> | ||
<div | ||
contenteditable="false" | ||
data-position="center" | ||
spellcheck="false" | ||
class="protyle-title__input" | ||
data-render="true" | ||
> | ||
{{ currentPost.post.title }} | ||
</div> | ||
</div> | ||
<div | ||
class="protyle-wysiwyg protyle-wysiwyg--attr" | ||
spellcheck="false" | ||
contenteditable="false" | ||
data-doc-type="NodeDocument" | ||
> | ||
<VNode v-highlight /> | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<!-- | ||
- 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"> | ||
import { useSettingStore } from "~/stores/useSettingStore" | ||
import { createAppLogger } from "~/common/appLogger" | ||
const logger = createAppLogger("setting-page") | ||
const { t } = useI18n() | ||
const { getSetting, updateSetting } = useSettingStore() | ||
const setting = await getSetting() | ||
const title = `${t("blog.share")} - ${t("blog.share.setting")}` | ||
const seoMeta = { | ||
title: title, | ||
ogTitle: title, | ||
} as any | ||
useSeoMeta(seoMeta) | ||
// datas | ||
const formData = reactive({ | ||
homePageId: setting.homePageId, | ||
themes: { | ||
light: [ | ||
{ | ||
value: "daylight", | ||
label: "daylight", | ||
}, | ||
{ | ||
value: "Zhihu", | ||
label: "Zhihu", | ||
}, | ||
], | ||
dark: [ | ||
{ | ||
value: "midlight", | ||
label: "midlight", | ||
}, | ||
{ | ||
value: "Zhihu", | ||
label: "Zhihu", | ||
}, | ||
], | ||
}, | ||
lightTheme: setting?.theme?.lightTheme ?? "Zhihu", | ||
darkTheme: setting?.theme?.darkTheme ?? "Zhihu", | ||
}) | ||
// methods | ||
const onSubmit = async () => { | ||
try { | ||
setting.homePageId = formData.homePageId | ||
setting.theme ||= {} | ||
setting.theme.lightTheme = formData.lightTheme | ||
setting.theme.darkTheme = formData.darkTheme | ||
await updateSetting(setting) | ||
ElMessage.success(t("main.opt.success")) | ||
} catch (e) { | ||
logger.error(t("main.opt.failure"), e) | ||
ElMessage({ | ||
type: "error", | ||
message: t("main.opt.failure") + e, | ||
}) | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="basic-setting"> | ||
<el-form label-width="85px"> | ||
<el-form-item :label="t('setting.basic.homePageId')"> | ||
<el-input v-model="formData.homePageId" /> | ||
</el-form-item> | ||
<el-form-item :label="t('siyuan.theme.light')"> | ||
<el-select v-model="formData.lightTheme" class="m-2" :placeholder="t('siyuan.theme.select')"> | ||
<el-option v-for="item in formData.themes.light" :key="item.value" :label="item.label" :value="item.value" /> | ||
</el-select> | ||
</el-form-item> | ||
<el-form-item :label="t('siyuan.theme.dark')"> | ||
<el-select v-model="formData.darkTheme" class="m-2" :placeholder="t('siyuan.theme.select')"> | ||
<el-option v-for="item in formData.themes.dark" :key="item.value" :label="item.label" :value="item.value" /> | ||
</el-select> | ||
</el-form-item> | ||
<el-form-item> | ||
<el-button type="primary" @click="onSubmit">{{ t("main.opt.save") }}</el-button> | ||
</el-form-item> | ||
</el-form> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!-- | ||
- Copyright (c) 2022-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 lang="ts" setup> | ||
import { useI18n } from "vue-i18n" | ||
import { useSettingStore } from "~/stores/useSettingStore" | ||
import { createAppLogger } from "~/common/appLogger" | ||
const logger = createAppLogger("change-local") | ||
const { getSetting, updateSetting } = useSettingStore() | ||
const { t, locale } = useI18n() | ||
const langs = [ | ||
{ | ||
value: "zh_CN", | ||
label: "简体中文", | ||
}, | ||
{ | ||
value: "en_US", | ||
label: "English", | ||
}, | ||
] | ||
const setting = await getSetting() | ||
const langChanged = async (lang: string) => { | ||
locale.value = lang | ||
setting.lang = lang | ||
await updateSetting(setting) | ||
logger.info("lang changed to", lang) | ||
} | ||
// lifecycles | ||
onBeforeMount(() => { | ||
// 设置默认语言 | ||
if (setting?.lang) { | ||
locale.value = setting?.lang | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="locale-changer"> | ||
<el-form label-width="85px"> | ||
<!-- 语言选项 --> | ||
<el-form-item :label="t('lang.choose')"> | ||
<el-select v-model="locale" :placeholder="t('lang.choose.placeholder')" @change="langChanged"> | ||
<el-option v-for="(lang, i) in langs" :key="i" :label="lang.label" :value="lang.value" /> | ||
</el-select> | ||
</el-form-item> | ||
</el-form> | ||
</div> | ||
</template> |
Oops, something went wrong.
d3a7515
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
siyuan-blog – ./
siyuan-blog-git-main-terwergreen.vercel.app
node-siyuan.vercel.app
blog.terwer.space
siyuan-blog-terwergreen.vercel.app
siyuan.terwer.space