Skip to content

Commit

Permalink
feat: allow custom footer
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Apr 22, 2024
1 parent 7e31895 commit dd4b446
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 39 deletions.
5 changes: 4 additions & 1 deletion components/setting/Preference.vue
Expand Up @@ -27,6 +27,7 @@
import { createAppLogger } from "~/common/appLogger"
import { useSettingStore } from "~/stores/useSettingStore"
import { version } from "~/package.json"
import { StrUtil } from "zhi-common"
const logger = createAppLogger("preference-page")
const { t } = useI18n()
Expand All @@ -46,7 +47,9 @@ const formData = reactive({
<span class="text">v${version}&nbsp;</span>
<span class="text s-dark"><a href="https://terwer.space/about" target="_blank">关于作者</a></span>
</div>`,
shareTemplate: setting.shareTemplate ?? "我给你分享了一篇文章:[title] (有效期 [expired])\n 打开链接:[url]",
shareTemplate: StrUtil.isEmptyString(setting.shareTemplate)
? "我给你分享了一篇文章:[title] (有效期 [expired] 秒)\n 打开链接:[url]"
: setting.shareTemplate,
})
// methods
Expand Down
6 changes: 3 additions & 3 deletions components/setting/System.vue
Expand Up @@ -34,12 +34,12 @@ const { t, locale } = useI18n()
const langs = [
{
value: "zh_CN",
label: "简体中文"
label: "简体中文",
},
{
value: "en_US",
label: "English"
}
label: "English",
},
]
const setting = await getSetting()
Expand Down
36 changes: 8 additions & 28 deletions nuxt.config.ts
Expand Up @@ -9,7 +9,7 @@ const generateDynamicV = () => {
}

const isDev = process.env.NODE_ENV === "development"
const appBase = "/plugins/siyuan-blog/"
const appBase = "/"
const staticV = generateDynamicV()

// https://nuxt.com/docs/api/configuration/nuxt-config
Expand All @@ -28,14 +28,7 @@ export default defineNuxtConfig({
},

// build modules
modules: [
"@vueuse/nuxt",
"@nuxtjs/i18n-edge",
"@element-plus/nuxt",
"@nuxtjs/color-mode",
"@pinia/nuxt",
"@nuxt/image",
],
modules: ["@vueuse/nuxt", "@nuxtjs/i18n", "@element-plus/nuxt", "@nuxtjs/color-mode", "@pinia/nuxt", "@nuxt/image"],

// vueuse
vueuse: {
Expand All @@ -58,7 +51,7 @@ export default defineNuxtConfig({
define: {
"process.env.DEV_MODE": `"${isDev}"`,
"process.env.APP_BASE": `"${appBase}"`,
"process.env.SSR": `"false"`,
"process.env.SSR": `"true"`,
},
plugins: [],
},
Expand All @@ -69,14 +62,6 @@ export default defineNuxtConfig({
themes: ["dark"],
},

// https://nuxt.com/docs/guide/going-further/custom-routing#hash-mode-spa
ssr: false,
router: {
options: {
hashMode: true,
},
},

css: ["~/assets/siyuan/style.styl", "~/assets/siyuan/index.styl"],

app: {
Expand Down Expand Up @@ -113,17 +98,12 @@ export default defineNuxtConfig({

// 环境变量
runtimeConfig: {
// siyuanAuthToken: process.env.NUXT_SIYUAN_AUTH_TOKEN,
siyuanAuthToken: "",
// siyuanCookie: process.env.NUXT_SIYUAN_COOKIE,
siyuanCookie: "",
siyuanAuthToken: process.env.NUXT_SIYUAN_AUTH_TOKEN,
siyuanCookie: process.env.NUXT_SIYUAN_COOKIE,
public: {
// defaultType: process.env.NUXT_PUBLIC_DEFAULT_TYPE,
defaultType: "siyuan",
// siyuanApiUrl: process.env.NUXT_PUBLIC_SIYUAN_API_URL,
siyuanApiUrl: "",
// waitTime: process.env.NUXT_PUBLIC_WAIT_TIME,
waitTime: "0",
defaultType: process.env.NUXT_PUBLIC_DEFAULT_TYPE ?? "siyuan",
siyuanApiUrl: process.env.NUXT_PUBLIC_SIYUAN_API_URL ?? "http://127.0.0.1:6806",
waitTime: process.env.NUXT_PUBLIC_WAIT_TIME,
},
},
})
9 changes: 8 additions & 1 deletion pages/share.vue
Expand Up @@ -108,7 +108,14 @@ const goHelp = async () => {
const copyWebLink = () => {
handleMethod(() => {
copy(formData.shareLink)
const shareTemplate =
(StrUtil.isEmptyString(setting.shareTemplate) ? formData.shareLink : setting.shareTemplate) ?? formData.shareLink
const copyText = shareTemplate
.replace(/\[expired]/g, StrUtil.isEmptyString(formData.expiredTime) ? "永久" : formData.expiredTime)
.replace(/\[title]/g, post.title)
.replace(/\[url]/g, formData.shareLink)
copy(copyText)
})
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/07.domparser.client.ts
Expand Up @@ -28,7 +28,7 @@ import { useSvg } from "~/plugins/domparser/useSvg"
import { useBlockRef } from "~/plugins/domparser/useBlockRef"

/**
* 页面渲染插件(图片、链接、公式等) - 客户端
* 页面渲染插件(图标等) - 客户端
* https://github.com/nuxt/nuxt/issues/13382
* client = browser only
*
Expand Down
2 changes: 1 addition & 1 deletion plugins/09.domparser.static.client.ts
Expand Up @@ -28,7 +28,7 @@ import { useSvg } from "~/plugins/domparser/useSvg"
import { useStaticBlockRef } from "~/plugins/domparser/useStaticBlockRef"

/**
* 页面渲染插件(图片、链接、公式等) - 客户端
* 页面渲染插件(图标等) - 客户端
* https://github.com/nuxt/nuxt/issues/13382
* client = browser only
*
Expand Down
2 changes: 1 addition & 1 deletion plugins/10.domparser.static.server.ts
Expand Up @@ -26,4 +26,4 @@
// stub - block nuxt getSSRProps error
export default defineNuxtPlugin(({ vueApp }) => {
vueApp.directive("sdomparser", {})
})
})
6 changes: 3 additions & 3 deletions plugins/renderer/useStaticClientAssets.ts
Expand Up @@ -55,7 +55,7 @@ export const useStaticClientAssets = () => {
}
}

const downloadAssetsToPublic = async (html, saveFolder) => {
const downloadAssetsToPublic = async (html: string, saveFolder: string) => {
try {
const baseUrl = getClientBaseUrl()

Expand All @@ -77,11 +77,11 @@ export const useStaticClientAssets = () => {
}

// =========================================================================
const getImageBlob = async (url) => {
const getImageBlob = async (url: string) => {
try {
const response = await fetch(url)
return await response.blob()
} catch (error) {
} catch (e: any) {
logger.error("image read error", e)
return ""
}
Expand Down

0 comments on commit dd4b446

Please sign in to comment.