Skip to content

Commit

Permalink
Merge pull request #355 from terwer/dev
Browse files Browse the repository at this point in the history
feat: adapt new theme
  • Loading branch information
terwer committed Apr 22, 2024
2 parents 29bd807 + dbe9285 commit f6a27ec
Show file tree
Hide file tree
Showing 141 changed files with 7,866 additions and 408 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -15,6 +15,8 @@ node_modules
# Logs
logs
*.log
cookie.txt
token.txt

# Misc
.DS_Store
Expand Down
50 changes: 50 additions & 0 deletions DEVELOPMENT.md
@@ -0,0 +1,50 @@
# Development

## Prerequisites

```bash
pnpm install
```

## Development

serve

```bash
pnpm serve
```

dev

```bash
pnpm makeLink
pnpm dev
```

## Build

```bash
pnpm build
```

## Package

```bash
pnpm package
```

artifacts structure

```
├── build
├── package.zip
├── siyuan-plugin-blog--1.8.5.zip
```

Note: vercel is also supported via `pnpm vercelBuild`

## Sync to legacy widget repo

```bash
pnpm syncWidgetRepo
```
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -58,6 +58,10 @@ The core idea of this plugin is: `Everything is a Page` . You can set a page to

Please refer to [CHANGELOG](https://github.com/terwer/siyuan-plugin-blog/blob/main/CHANGELOG.md)

## Development

Please refer to [DEVELOPMENT](./DEVELOPMENT.md)

## Donate

If you approve of this project, invite me to have a cup of coffee, which will encourage me to keep updating and create more useful tools~
Expand Down
4 changes: 4 additions & 0 deletions README_zh_CN.md
Expand Up @@ -58,6 +58,10 @@

请参考 [CHANGELOG](https://github.com/terwer/siyuan-plugin-blog/blob/main/CHANGELOG.md)

## 开发

请参考 [DEVELOPMENT](./DEVELOPMENT.md)

## 捐赠

如果您认可这个项目,请我喝一杯咖啡吧,这将鼓励我持续更新,并创作出更多好用的工具~
Expand Down
3 changes: 3 additions & 0 deletions app.config.ts
Expand Up @@ -32,11 +32,14 @@ interface AppConfig {
siteSlogan?: string
siteDescription?: string
homePageId?: string
footer?: string
shareTemplate?: string

theme?: {
mode?: ThemeType
lightTheme?: string
darkTheme?: string
themeVersion?: string
}

// 加上字符串索引签名,兼容 AppConfigInput 约束
Expand Down
17 changes: 16 additions & 1 deletion assets/siyuan/style.styl
Expand Up @@ -15,4 +15,19 @@
.protyle-wysiwyg .h3 img.emoji, .b3-typography h3 img.emoji {width:27px}
.protyle-wysiwyg .h4 img.emoji, .b3-typography h4 img.emoji {width:25px}
.protyle-wysiwyg .h5 img.emoji, .b3-typography h5 img.emoji {width:22px}
.protyle-wysiwyg .h6 img.emoji, .b3-typography h6 img.emoji {width:20px}
.protyle-wysiwyg .h6 img.emoji, .b3-typography h6 img.emoji {width:20px}

/* footer added since 1.9.0 */
.footer {
font-size: 12px;
color: #bbb;
text-align: center;
padding-bottom: 8px;
}
.footer .text {
vertical-align: middle;
}
.s-dark {
color: var(--el-color-primary);
cursor: pointer;
}
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>
71 changes: 10 additions & 61 deletions components/default/Footer.vue
@@ -1,70 +1,19 @@
<script setup lang="ts">
import { version } from "~/package.json"
import { DateUtil } from "zhi-common"
import { useI18n } from "vue-i18n"
import { useThemeMode } from "~/composables/useThemeMode"
import { useBaseUrl } from "~/plugins/renderer/useClientBaseUrl"
import { useSettingStore } from "~/stores/useSettingStore"
// uses
const { t } = useI18n()
const { colorMode, toggleDark } = await useThemeMode()
const { getHome } = useBaseUrl()
const { getSetting } = useSettingStore()
const setting = await getSetting()
await useThemeMode()
// datas
const v = ref(version)
const nowYear = DateUtil.nowYear()
// methods
const goGithub = () => {
window.open("https://github.com/terwer/siyuan-plugin-blog")
}
const goAbout = () => {
window.open("https://blog.terwer.space/about")
}
// methods
const goHome = async () => {
const home = getHome()
window.open(home)
}
const VNode = () =>
h("div", {
class: "",
innerHTML: setting.footer ?? "",
})
</script>

<template>
<div class="footer">
<div>
<span class="text"> &copy;2011-{{ nowYear }} </span>
<span class="text s-dark" @click="goGithub()">&nbsp;siyuan-plugin-blog&nbsp;</span>

<span class="text">v{{ v }}&nbsp;</span>

<span class="text s-dark" @click="goHome()">{{ t("go.home") }}</span>

<span class="text">.</span>
<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>
</div>
<VNode />
</div>
</template>

<style scoped>
.footer {
font-size: 12px;
color: #bbb;
text-align: center;
padding-bottom: 8px;
}
.footer .text {
vertical-align: middle;
}
.s-dark {
color: var(--el-color-primary);
cursor: pointer;
}
</style>
4 changes: 1 addition & 3 deletions components/default/Home.vue
Expand Up @@ -34,9 +34,7 @@ const props = defineProps({
</script>

<template>

<default-detail :page-id="props.pageId" :override-seo="true" />

<default-detail :page-id="props.pageId" :override-seo="true" />
</template>

<style scoped></style>
Expand Up @@ -53,6 +53,10 @@ const formData = reactive({
value: "Zhihu",
label: "Zhihu",
},
{
value: "Savor",
label: "写未",
},
],
dark: [
{
Expand All @@ -63,10 +67,20 @@ const formData = reactive({
value: "Zhihu",
label: "Zhihu",
},
{
value: "Savor",
label: "写未",
},
],
},
lightTheme: setting?.theme?.lightTheme ?? "Zhihu",
darkTheme: setting?.theme?.darkTheme ?? "Zhihu",
versionMap: {
midlight: "3.0.10",
daylight: "3.0.10",
Zhihu: "0.1.1",
Savor: "3.9.2",
} as any,
})
// methods
Expand All @@ -77,6 +91,7 @@ const onSubmit = async () => {
setting.theme ||= {}
setting.theme.lightTheme = formData.lightTheme
setting.theme.darkTheme = formData.darkTheme
setting.theme.themeVersion = formData.versionMap[toRaw(setting.theme.lightTheme)] ?? "0.1.1"
await updateSetting(setting)
ElMessage.success(t("main.opt.success"))
} catch (e) {
Expand Down

0 comments on commit f6a27ec

Please sign in to comment.