diff --git a/components.d.ts b/components.d.ts
index b1f6ca2..4e81e9c 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -11,15 +11,27 @@ declare module '@vue/runtime-core' {
export interface GlobalComponents {
ChangeLocal: typeof import('./src/components/set/preference/ChangeLocal.vue')['default']
CnblogsTest: typeof import('./src/components/test/CnblogsTest.vue')['default']
+ ElAlert: typeof import('element-plus/es')['ElAlert']
+ ElAside: typeof import('element-plus/es')['ElAside']
ElButton: typeof import('element-plus/es')['ElButton']
+ ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
+ ElContainer: typeof import('element-plus/es')['ElContainer']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
+ ElHeader: typeof import('element-plus/es')['ElHeader']
+ ElIcon: typeof import('element-plus/es')['ElIcon']
ElInput: typeof import('element-plus/es')['ElInput']
+ ElMain: typeof import('element-plus/es')['ElMain']
ElOption: typeof import('element-plus/es')['ElOption']
+ ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
ElSelect: typeof import('element-plus/es')['ElSelect']
+ ElSpace: typeof import('element-plus/es')['ElSpace']
+ ElTable: typeof import('element-plus/es')['ElTable']
+ ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
+ ElText: typeof import('element-plus/es')['ElText']
GeneralSetting: typeof import('./src/components/set/GeneralSetting.vue')['default']
HexoTest: typeof import('./src/components/test/HexoTest.vue')['default']
HugoTest: typeof import('./src/components/test/HugoTest.vue')['default']
diff --git a/package.json b/package.json
index e7f63cb..0183aa0 100644
--- a/package.json
+++ b/package.json
@@ -46,17 +46,19 @@
"element-plus": "^2.3.7",
"js-base64": "^3.7.5",
"pinia": "^2.1.4",
+ "shorthash2": "^1.0.3",
"simple-xmlrpc": "^1.4.2",
+ "uuid": "^9.0.0",
"vue": "^3.3.4",
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.2",
"xmlbuilder2": "^3.1.1",
- "zhi-blog-api": "^1.13.3",
- "zhi-common": "^1.11.2",
+ "zhi-blog-api": "^1.13.4",
+ "zhi-common": "^1.11.3",
"zhi-device": "^2.3.0",
- "zhi-fetch-middleware": "^0.1.16",
+ "zhi-fetch-middleware": "^0.1.17",
"zhi-lib-base": "0.4.1",
- "zhi-siyuan-api": "^1.25.3",
- "zhi-xmlrpc-middleware": "^0.2.16"
+ "zhi-siyuan-api": "^1.25.4",
+ "zhi-xmlrpc-middleware": "^0.2.17"
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 71004f0..1b4cade 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -23,9 +23,15 @@ dependencies:
pinia:
specifier: ^2.1.4
version: 2.1.4(typescript@5.1.3)(vue@3.3.4)
+ shorthash2:
+ specifier: ^1.0.3
+ version: 1.0.3
simple-xmlrpc:
specifier: ^1.4.2
version: 1.4.2
+ uuid:
+ specifier: ^9.0.0
+ version: 9.0.0
vue:
specifier: ^3.3.4
version: 3.3.4
@@ -39,31 +45,31 @@ dependencies:
specifier: ^3.1.1
version: 3.1.1
zhi-blog-api:
- specifier: ^1.13.3
- version: 1.13.3
+ specifier: ^1.13.4
+ version: 1.13.4
zhi-common:
- specifier: ^1.11.2
- version: 1.11.2
+ specifier: ^1.11.3
+ version: 1.11.3
zhi-device:
specifier: ^2.3.0
version: 2.3.0
zhi-fetch-middleware:
- specifier: ^0.1.16
- version: 0.1.16
+ specifier: ^0.1.17
+ version: 0.1.17
zhi-lib-base:
specifier: 0.4.1
version: 0.4.1
zhi-siyuan-api:
- specifier: ^1.25.3
- version: 1.25.3
+ specifier: ^1.25.4
+ version: 1.25.4
zhi-xmlrpc-middleware:
- specifier: ^0.2.16
- version: 0.2.16
+ specifier: ^0.2.17
+ version: 0.2.17
devDependencies:
'@terwer/eslint-config-custom':
specifier: ^1.3.6
- version: 1.3.6(@nuxt/eslint-config@0.1.1)(@typescript-eslint/eslint-plugin@5.60.0)(astro-eslint-parser@0.13.3)(eslint-config-prettier@8.8.0)(eslint-config-turbo@1.10.6)(eslint-plugin-prettier@4.2.1)(eslint-plugin-svelte@2.31.0)(eslint-plugin-vue@9.15.0)(eslint@8.43.0)(prettier-plugin-svelte@2.10.1)(prettier@2.8.8)(typescript@5.1.3)
+ version: 1.3.6(@nuxt/eslint-config@0.1.1)(@typescript-eslint/eslint-plugin@5.60.0)(astro-eslint-parser@0.13.3)(eslint-config-prettier@8.8.0)(eslint-config-turbo@1.10.6)(eslint-plugin-prettier@4.2.1)(eslint-plugin-svelte@2.31.1)(eslint-plugin-vue@9.15.1)(eslint@8.43.0)(prettier-plugin-svelte@2.10.1)(prettier@2.8.8)(typescript@5.1.3)
'@types/node':
specifier: ^18.16.18
version: 18.16.18
@@ -2077,7 +2083,7 @@ packages:
'@typescript-eslint/eslint-plugin': 5.60.0(@typescript-eslint/parser@5.60.0)(eslint@8.43.0)(typescript@4.9.5)
'@typescript-eslint/parser': 5.60.0(eslint@8.43.0)(typescript@4.9.5)
eslint: 8.43.0
- eslint-plugin-vue: 9.15.0(eslint@8.43.0)
+ eslint-plugin-vue: 9.15.1(eslint@8.43.0)
typescript: 4.9.5
transitivePeerDependencies:
- supports-color
@@ -2200,7 +2206,7 @@ packages:
defer-to-connect: 2.0.1
dev: true
- /@terwer/eslint-config-custom@1.3.6(@nuxt/eslint-config@0.1.1)(@typescript-eslint/eslint-plugin@5.60.0)(astro-eslint-parser@0.13.3)(eslint-config-prettier@8.8.0)(eslint-config-turbo@1.10.6)(eslint-plugin-prettier@4.2.1)(eslint-plugin-svelte@2.31.0)(eslint-plugin-vue@9.15.0)(eslint@8.43.0)(prettier-plugin-svelte@2.10.1)(prettier@2.8.8)(typescript@5.1.3):
+ /@terwer/eslint-config-custom@1.3.6(@nuxt/eslint-config@0.1.1)(@typescript-eslint/eslint-plugin@5.60.0)(astro-eslint-parser@0.13.3)(eslint-config-prettier@8.8.0)(eslint-config-turbo@1.10.6)(eslint-plugin-prettier@4.2.1)(eslint-plugin-svelte@2.31.1)(eslint-plugin-vue@9.15.1)(eslint@8.43.0)(prettier-plugin-svelte@2.10.1)(prettier@2.8.8)(typescript@5.1.3):
resolution: {integrity: sha512-W0dFSTYfkzpp71LW8cDZUgLrNa004KDctojbiQrJrF4FIDmlwND/LyPUqfe1Eg8sulB5qkNX9qMgFWZ4SAVXBQ==}
peerDependencies:
'@nuxt/eslint-config': ^0.1.1
@@ -2223,8 +2229,8 @@ packages:
eslint-config-prettier: 8.8.0(eslint@8.43.0)
eslint-config-turbo: 1.10.6(eslint@8.43.0)
eslint-plugin-prettier: 4.2.1(eslint-config-prettier@8.8.0)(eslint@8.43.0)(prettier@2.8.8)
- eslint-plugin-svelte: 2.31.0(eslint@8.43.0)(svelte@4.0.0)
- eslint-plugin-vue: 9.15.0(eslint@8.43.0)
+ eslint-plugin-svelte: 2.31.1(eslint@8.43.0)(svelte@4.0.0)
+ eslint-plugin-vue: 9.15.1(eslint@8.43.0)
prettier: 2.8.8
prettier-plugin-svelte: 2.10.1(prettier@2.8.8)(svelte@4.0.0)
typescript: 5.1.3
@@ -4744,8 +4750,8 @@ packages:
prettier-linter-helpers: 1.0.0
dev: true
- /eslint-plugin-svelte@2.31.0(eslint@8.43.0)(svelte@4.0.0):
- resolution: {integrity: sha512-Q70jPFRraTkc/giPSfY7yuatmJcb5fPelWNplevqd45gfaJDjc3qXRtWQ6m9U5tWVVYERU9dcdUod294vwD8Gw==}
+ /eslint-plugin-svelte@2.31.1(eslint@8.43.0)(svelte@4.0.0):
+ resolution: {integrity: sha512-08v+DqzHiwIVEbi+266D7+BDhayp9OSqCwa/lHaZlZOlFY0vZLYs/h7SkkUPzA5fTVt8OUJBtvCxFiWEYOvvGg==}
engines: {node: ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^7.0.0 || ^8.0.0-0
@@ -4764,6 +4770,7 @@ packages:
postcss-load-config: 3.1.4(postcss@8.4.24)
postcss-safe-parser: 6.0.0(postcss@8.4.24)
postcss-selector-parser: 6.0.13
+ semver: 7.5.3
svelte: 4.0.0
svelte-eslint-parser: 0.31.0(svelte@4.0.0)
transitivePeerDependencies:
@@ -4780,8 +4787,8 @@ packages:
eslint: 8.43.0
dev: true
- /eslint-plugin-vue@9.15.0(eslint@8.43.0):
- resolution: {integrity: sha512-XYzpK6e2REli100+6iCeBA69v6Sm0D/yK2FZP+fCeNt0yH/m82qZQq+ztseyV0JsKdhFysuSEzeE1yCmSC92BA==}
+ /eslint-plugin-vue@9.15.1(eslint@8.43.0):
+ resolution: {integrity: sha512-CJE/oZOslvmAR9hf8SClTdQ9JLweghT6JCBQNrT2Iel1uVw0W0OLJxzvPd6CxmABKCvLrtyDnqGV37O7KQv6+A==}
engines: {node: ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.2.0 || ^7.0.0 || ^8.0.0
@@ -8087,6 +8094,10 @@ packages:
engines: {node: '>=8'}
dev: true
+ /shorthash2@1.0.3:
+ resolution: {integrity: sha512-oB8s64JsyJ2xhHJlnTwGg++Y3BTF6XnXeXMC7OygD8vtNcCRDiMxEGONvUOeZbxfwEXENmRlqPDouMR/OtGDsw==}
+ dev: false
+
/side-channel@1.0.4:
resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==}
dependencies:
@@ -8854,6 +8865,11 @@ packages:
engines: {node: '>= 0.4.0'}
dev: true
+ /uuid@9.0.0:
+ resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==}
+ hasBin: true
+ dev: false
+
/uvu@0.5.6:
resolution: {integrity: sha512-+g8ENReyr8YsOc6fv/NVJs2vFdHBnBNdfE49rshrTzDWOlUx4Gq7KOS2GD8eqhy2j+Ejq29+SbKH8yjkAqXqoA==}
engines: {node: '>=8'}
@@ -9301,14 +9317,14 @@ packages:
engines: {node: '>=10'}
dev: true
- /zhi-blog-api@1.13.3:
- resolution: {integrity: sha512-1tE77f3e4xpt7xOAaUm/S+nZKTZtqOJT/uyy+d1WkJWz4lEF6prR1kxuEKmFXTBXpYJxwZVRWztkkd9/9EyXtA==}
+ /zhi-blog-api@1.13.4:
+ resolution: {integrity: sha512-RZUAYISHSmPOd24xmOsqJXF8UAXqIfK2UHgEebZ41e/pXusA0NoCAywtVmz9Eqw50AKTEqhOZxPbNhFlE9PWNA==}
dependencies:
zhi-lib-base: 0.4.1
dev: false
- /zhi-common@1.11.2:
- resolution: {integrity: sha512-O67yy7ojeOhTWD1uahkoLcThSI9WJliHNYfLtNJoGH2FOp5f077NkO/pKfAXkBBmVD1XuZM1KlpmICb/NNAIzQ==}
+ /zhi-common@1.11.3:
+ resolution: {integrity: sha512-89iu4B2tMNw1gydF6aEdFLGP9QgEFIex6r96qVhPjdxMpVL1s8NwXeU5KZ1UhoPELfFKPmYdMtHneZNGeym6dg==}
dependencies:
zhi-lib-base: 0.4.1
dev: false
@@ -9317,10 +9333,10 @@ packages:
resolution: {integrity: sha512-we04mMt4BEqeKDxoqdJQsDFYImYlcp/yaAIkpxpMGg+9tBURfNeHPHIHkFias9VbM8yuk6xjAX6B2xJjvYE/iw==}
dev: false
- /zhi-fetch-middleware@0.1.16:
- resolution: {integrity: sha512-iMw7mfykRT3X75fUtLlB2MV1O9TQqCOdW+McWQ7GfEh76b8KTQJZm15ZrBx/bf8Jt9+2nbMcav3gRyjv3DQa5A==}
+ /zhi-fetch-middleware@0.1.17:
+ resolution: {integrity: sha512-QK5hg0PqmH0PYWcu++EbIQv0xX/iylsrVpsogfL+pAZfWEK5K95R1YJWYNBO/zeNgtFkbTdDqJ9qAWr44gNyaA==}
dependencies:
- zhi-common: 1.11.2
+ zhi-common: 1.11.3
zhi-device: 2.3.0
zhi-lib-base: 0.4.1
dev: false
@@ -9329,18 +9345,18 @@ packages:
resolution: {integrity: sha512-/wwfo0Z/86E5BW+mXN9amWAMEi0KLEoiOTNFb6BBtVuhDhypmZLRmfIvFk+E+UJU7bedTnkc6mRLAp7D+O9piw==}
dev: false
- /zhi-siyuan-api@1.25.3:
- resolution: {integrity: sha512-CoS5CSXuGCoPQRaXOcQQDL0nSHyvDp+C/6O5KfH3xq9Jl0vTh3MeNYdlt14hkJ0kO+eLtx0iEcqEZLom65rQmw==}
+ /zhi-siyuan-api@1.25.4:
+ resolution: {integrity: sha512-7BP15zf/up7f5wM6wB5riBF8XOFBANo21sf7wg2Ch+j0+Ot4Dtdxwla3VoBsyVrSSkN0UHD+brQSq3236rwloA==}
dependencies:
- zhi-blog-api: 1.13.3
- zhi-common: 1.11.2
+ zhi-blog-api: 1.13.4
+ zhi-common: 1.11.3
zhi-lib-base: 0.4.1
dev: false
- /zhi-xmlrpc-middleware@0.2.16:
- resolution: {integrity: sha512-S5zmjioheohTXO7IbcYYUH73vthclgTU5Z28D3eFksz0CkbW7AYpEk13TjsXziMJ3WnixTJSINOGUHjS2of+pA==}
+ /zhi-xmlrpc-middleware@0.2.17:
+ resolution: {integrity: sha512-87AzHTT/09iW5kzvzq25OIExfRjkYptN8jtt4BodOrNChQAa0DPYVxywKsH7LgMnLh4pULppyTA5/MgHYiuY6g==}
dependencies:
- zhi-common: 1.11.2
+ zhi-common: 1.11.3
zhi-device: 2.3.0
zhi-lib-base: 0.4.1
dev: false
diff --git a/src/adaptors/github/config/GithubConfig.ts b/src/adaptors/github/config/GithubConfig.ts
new file mode 100644
index 0000000..c367b89
--- /dev/null
+++ b/src/adaptors/github/config/GithubConfig.ts
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+class GithubConfig {}
+
+export { GithubConfig }
diff --git a/src/components/set/PlatformSetting.vue b/src/components/set/PlatformSetting.vue
index 0568c1d..061ddaa 100644
--- a/src/components/set/PlatformSetting.vue
+++ b/src/components/set/PlatformSetting.vue
@@ -23,10 +23,357 @@
- questions.
-->
-
+
- PlatformSetting
+
-
+
diff --git a/src/components/set/SetIndex.vue b/src/components/set/SetIndex.vue
index 68cd9be..996f803 100644
--- a/src/components/set/SetIndex.vue
+++ b/src/components/set/SetIndex.vue
@@ -26,12 +26,20 @@
+
+
+
+
+
+
diff --git a/src/components/set/platform/dynamicConfig.ts b/src/components/set/platform/dynamicConfig.ts
new file mode 100644
index 0000000..12827a3
--- /dev/null
+++ b/src/components/set/platform/dynamicConfig.ts
@@ -0,0 +1,337 @@
+/*
+ * 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.
+ */
+
+import { YamlConvertAdaptor } from "~/src/components/set/platform/yamlConvertAdaptor.ts"
+import idUtil from "~/src/utils/idUtil.ts"
+import { StrUtil } from "zhi-common"
+
+export class DynamicConfig {
+ /**
+ * 用于文章绑定的临时变量
+ */
+ posid?: any
+
+ /**
+ * 用于平台开关的临时变量
+ */
+ modelValue?: any
+
+ /**
+ * 动态平台类型(通用类型)
+ */
+ platformType: PlatformType
+
+ /**
+ * 子平台类型(细分子类型)
+ * @since 0.1.0+
+ */
+ subPlatformType?: SubPlatformType
+
+ /**
+ * 平台Key
+ */
+ platformKey: string
+
+ /**
+ * 平台名称
+ */
+ platformName: string
+
+ /**
+ * YAML转换器
+ */
+ yamlConverter?: YamlConvertAdaptor
+
+ constructor(platformType: PlatformType, platformKey: string, platformName: string) {
+ this.platformType = platformType
+ this.platformKey = platformKey
+ this.platformName = platformName
+ }
+}
+
+/**
+ * 动态平台类型枚举
+ */
+export enum PlatformType {
+ /**
+ * Metaweblog
+ */
+ Metaweblog = "Metaweblog",
+ /**
+ * WordPress
+ */
+ Wordpress = "Wordpress",
+ /**
+ * GitHub(Hugo、Hexo、Jekyll、Vuepress、Vitepress、Nuxt content、Next.js)
+ */
+ Github = "Github",
+ /**
+ * 自定义
+ */
+ Custom = "Custom",
+}
+
+/**
+ * 平台子类型
+ * @since 0.1.0+
+ * @author terwer
+ */
+export enum SubPlatformType {
+ Github_Hugo = "Hugo",
+ Github_Hexo = "Hexo",
+ Github_Jekyll = "Jekyll",
+ // Github_giteePages = "giteePages",
+ // Github_codingPages = "codingPages",
+ Github_Vuepress = "Vuepress",
+ Github_Vitepress = "Vitepress",
+ Github_Nuxt = "Nuxt",
+ Github_Next = "Next",
+ NONE = "none",
+}
+
+/**
+ * 动态配置类型封装
+ */
+export interface DynamicJsonCfg {
+ totalCfg: DynamicConfig[]
+ githubCfg: DynamicConfig[]
+ metaweblogCfg: DynamicConfig[]
+ wordpressCfg: DynamicConfig[]
+}
+
+/**
+ * 获取子平台列表
+ */
+export function getSubtypeList(ptype: PlatformType): SubPlatformType[] {
+ const subtypeList: SubPlatformType[] = []
+
+ switch (ptype) {
+ case PlatformType.Github:
+ subtypeList.push(SubPlatformType.Github_Hugo)
+ subtypeList.push(SubPlatformType.Github_Hexo)
+ subtypeList.push(SubPlatformType.Github_Jekyll)
+ // subtypeList.push(SubPlatformType.Github_giteePages)
+ // subtypeList.push(SubPlatformType.Github_codingPages)
+ subtypeList.push(SubPlatformType.Github_Vuepress)
+ subtypeList.push(SubPlatformType.Github_Vitepress)
+ subtypeList.push(SubPlatformType.Github_Nuxt)
+ subtypeList.push(SubPlatformType.Github_Next)
+ break
+ default:
+ break
+ }
+
+ return subtypeList
+}
+
+/**
+ * 设置动态平台JSON配置
+ *
+ * @param dynamicConfigArray
+ */
+export function setDynamicJsonCfg(dynamicConfigArray: DynamicConfig[]): DynamicJsonCfg {
+ const totalCfg: DynamicConfig[] = dynamicConfigArray
+ const githubCfg: DynamicConfig[] = []
+ const metaweblogCfg: DynamicConfig[] = []
+ const wordpressCfg: DynamicConfig[] = []
+
+ // 按照类型组装便于后面数据使用
+ totalCfg.forEach((item) => {
+ switch (item.platformType) {
+ case PlatformType.Github:
+ githubCfg.push(item)
+ break
+ case PlatformType.Metaweblog:
+ metaweblogCfg.push(item)
+ break
+ case PlatformType.Wordpress:
+ wordpressCfg.push(item)
+ break
+ default:
+ break
+ }
+ })
+
+ const dynamicJsonCfg: DynamicJsonCfg = {
+ totalCfg,
+ githubCfg,
+ metaweblogCfg,
+ wordpressCfg,
+ }
+
+ return dynamicJsonCfg
+}
+
+// =====================
+// 动态平台key规则
+// =====================
+/**
+ * 生成新的平台key
+ *
+ * 平台与ID之间用-分割
+ * 平台与子平台直接用_分割
+ * @param ptype 平台类型
+ * @param subtype 子平台类型
+ */
+export function getNewPlatformKey(ptype: PlatformType, subtype: SubPlatformType): string {
+ let ret
+ const newId = idUtil.newID()
+ ret = ptype.toLowerCase()
+
+ if (!StrUtil.isEmptyString(subtype) && SubPlatformType.NONE !== subtype) {
+ ret = [ret, StrUtil.upperFirst(subtype)].join("")
+ }
+ return [ret, "-", newId].join("")
+}
+
+/**
+ * 检测动态平台key是否重复
+ */
+export function isDynamicKeyExists(dynamicConfigArray: DynamicConfig[], key: string): boolean {
+ let flag = false
+ for (let i = 0; i < dynamicConfigArray.length; i++) {
+ if (dynamicConfigArray[i].platformKey === key) {
+ flag = true
+ break
+ }
+ }
+ return flag
+}
+
+/**
+ * 生成默认的平台名
+ * @param ptype 平台
+ * @param subtype 子平台
+ * @param isShowSubtype 是否显示子平台
+ */
+export function getDefaultPlatformName(ptype: PlatformType, subtype: SubPlatformType, isShowSubtype: boolean): string {
+ if (PlatformType.Github === ptype && SubPlatformType.NONE === subtype) {
+ return ""
+ }
+
+ let pname: string = ptype
+ if (isShowSubtype) {
+ pname = subtype
+ }
+ pname = pname + "-1"
+ return pname
+}
+
+// =====================
+// 动态平台开关key规则
+// =====================
+interface SwitchItem {
+ switchKey: string
+ switchValue: boolean
+}
+
+export function getDynSwitchKey(platformKey: string): string {
+ return "switch-" + platformKey
+}
+
+/**
+ * 平台开关启用状态值
+ * @param platformKey
+ */
+export function getDynSwitchActive(platformKey: string): string {
+ return platformKey + "_true"
+}
+
+/**
+ * 平台开关禁用状态值
+ * @param platformKey
+ */
+export function getDynSwitchInactive(platformKey: string): string {
+ return platformKey + "_false"
+}
+
+/**
+ * 组装Switch显示值
+ * @param switchItem 开关
+ */
+export function getDynSwitchModelValue(switchItem: SwitchItem): string {
+ return switchItem.switchKey + "_" + switchItem.switchValue.toString()
+}
+
+/**
+ * 解析选中项
+ * @param selectedText 选中的值
+ */
+export function getSwitchItem(selectedText: string): SwitchItem {
+ const valArr = selectedText.split("_")
+ const switchKey = getDynSwitchKey(valArr[0])
+ const switchStatus = valArr[1] === "true"
+
+ return {
+ switchKey,
+ switchValue: switchStatus,
+ }
+}
+
+// =====================
+// 动态平台文章ID规则
+// =====================
+/**
+ * 获取动态文章ID的key
+ * @param platformKey
+ */
+export function getDynPostidKey(platformKey: string): string {
+ return "custom-" + platformKey + "-post-id"
+}
+
+// ======================
+// 动态平台Object对象初始化
+// ======================
+/**
+ * 根据平台key获取YAML转换器
+ * @param platformKey
+ */
+export const getDynYamlConverterAdaptor = (platformKey: string): YamlConvertAdaptor => {
+ const yamlConverter = new YamlConvertAdaptor()
+ if (platformKey.includes("-")) {
+ const typeArr = platformKey.split("-")
+ if (typeArr.length > 0) {
+ const ptype = typeArr[0].toLowerCase()
+
+ // if (ptype.includes(SubPlatformType.Github_Vuepress.toLowerCase())) {
+ // yamlConverter = new VuepressYamlConvertAdaptor()
+ // } else if (ptype.includes(SubPlatformType.Github_Hugo.toLowerCase())) {
+ // yamlConverter = new HugoYamlConverterAdaptor()
+ // } else if (ptype.includes(SubPlatformType.Github_Hexo.toLowerCase())) {
+ // yamlConverter = new HexoYamlConverterAdaptor()
+ // } else if (ptype.includes(SubPlatformType.Github_Jekyll.toLowerCase())) {
+ // yamlConverter = new JekyllYamlConverterAdaptor()
+ // } else if (ptype.includes(SubPlatformType.Github_Vitepress.toLowerCase())) {
+ // yamlConverter = new VitepressYamlConverterAdaptor()
+ // } else if (ptype.includes(SubPlatformType.Github_Nuxt.toLowerCase())) {
+ // yamlConverter = new NuxtYamlConverterAdaptor()
+ // } else if (ptype.includes(SubPlatformType.Github_Next.toLowerCase())) {
+ // yamlConverter = new NextYamlConvertAdaptor()
+ // }
+ }
+ }
+
+ return yamlConverter
+}
diff --git a/src/components/set/platform/yamlConvertAdaptor.ts b/src/components/set/platform/yamlConvertAdaptor.ts
new file mode 100644
index 0000000..96cb474
--- /dev/null
+++ b/src/components/set/platform/yamlConvertAdaptor.ts
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+import { PostForm } from "~/src/models/postForm.ts"
+import { YamlFormatObj } from "~/src/models/yamlFormatObj.ts"
+import { GithubConfig } from "~/src/adaptors/github/config/GithubConfig.ts"
+
+export interface IYamlConvertAdaptor {
+ convertToYaml(postForm: PostForm, githubCfg?: GithubConfig): YamlFormatObj
+
+ convertToAttr(yamlObj: YamlFormatObj, githubCfg?: GithubConfig): PostForm
+}
+
+/**
+ * YAML转换适配器
+ */
+export class YamlConvertAdaptor implements IYamlConvertAdaptor {
+ convertToYaml(postForm: PostForm, githubCfg?: GithubConfig): YamlFormatObj {
+ throw new Error("YamlConvertAdaptor.convertToYaml: 该功能未实现,请在子类重写该方法")
+ }
+
+ convertToAttr(yamlFormatObj: YamlFormatObj, githubCfg?: GithubConfig): PostForm {
+ throw new Error("YamlConvertAdaptor.convertToAttr: 该功能未实现,请在子类重写该方法")
+ }
+}
diff --git a/src/layouts/default/DefaultFooter.vue b/src/layouts/default/DefaultFooter.vue
index 69d7617..35876a7 100644
--- a/src/layouts/default/DefaultFooter.vue
+++ b/src/layouts/default/DefaultFooter.vue
@@ -39,10 +39,12 @@
isDark ? t("theme.mode.light") : t("theme.mode.dark")
}}
+
.
diff --git a/src/locales/en_US.ts b/src/locales/en_US.ts
index 048714a..f6b4c4f 100644
--- a/src/locales/en_US.ts
+++ b/src/locales/en_US.ts
@@ -31,6 +31,7 @@ export default {
"theme.mode.light": "Light mode",
"service.tab.publish.service": "Publish service",
"service.tab.publish.setting": "Publish setting",
+ "service.tab.platform.setting": "Platform setting",
"service.tab.post.bind": "Post bind",
"service.tab.service.switch": "Service switch",
"service.tab.change.local": "Change language",
diff --git a/src/locales/zh_CN.ts b/src/locales/zh_CN.ts
index aecdfb6..3259130 100644
--- a/src/locales/zh_CN.ts
+++ b/src/locales/zh_CN.ts
@@ -31,6 +31,7 @@ export default {
"theme.mode.light": "浅色模式",
"service.tab.publish.service": "发布服务",
"service.tab.publish.setting": "发布配置",
+ "service.tab.platform.setting": "平台配置",
"service.tab.post.bind": "文章绑定",
"service.tab.service.switch": "服务开关",
"service.tab.change.local": "个性设置",
diff --git a/src/models/postForm.ts b/src/models/postForm.ts
new file mode 100644
index 0000000..36ab896
--- /dev/null
+++ b/src/models/postForm.ts
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+/**
+ * 通用发布表单数据定义
+ * @author terwer
+ * @since 0.1.0
+ */
+export class PostForm {
+ formData = {
+ title: "",
+ customSlug: "",
+ desc: "",
+ created: "",
+ tag: {
+ inputValue: "",
+ dynamicTags: [],
+ inputVisible: false,
+ },
+ customPath: "",
+ categories: ["默认分类"],
+ mdContent: "",
+ htmlContent: "",
+ usePermalink: true,
+ useDate: true,
+ linkTitle: "",
+ weight: 0,
+ }
+}
diff --git a/src/models/yamlFormatObj.ts b/src/models/yamlFormatObj.ts
new file mode 100644
index 0000000..7842cca
--- /dev/null
+++ b/src/models/yamlFormatObj.ts
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+/**
+ * 通用的YAML模型定义
+ * @author terwer
+ * @since 0.1.0
+ */
+export class YamlFormatObj {
+ /**
+ * YAML
+ */
+ yamlObj = {} as any
+ /**
+ * YAML字符串
+ */
+ formatter = ""
+ /**
+ * Markdown文本
+ */
+ mdContent = ""
+ /**
+ * YAML+MD
+ */
+ mdFullContent: string
+ /**
+ * HTML文本
+ */
+ htmlContent: string
+}
diff --git a/src/utils/constants.ts b/src/utils/constants.ts
index 26a25b4..dc0122b 100644
--- a/src/utils/constants.ts
+++ b/src/utils/constants.ts
@@ -25,3 +25,8 @@
export const isDev = process.env.DEV_MODE === "true"
export const moduleBase = process.env.APP_BASE
+
+/**
+ * 动态配置key,全系统唯一,请勿更改
+ */
+export const DYNAMIC_CONFIG_KEY = "dynamic-config"
diff --git a/src/utils/idUtil.ts b/src/utils/idUtil.ts
new file mode 100644
index 0000000..f9be5f9
--- /dev/null
+++ b/src/utils/idUtil.ts
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+import shortHash from "shorthash2"
+import { v4 as uuidv4 } from "uuid"
+
+/**
+ * 唯一ID
+ */
+const newID = (): string => {
+ const newstr = new Date().toISOString()
+ return shortHash(newstr).toLowerCase()
+}
+
+/**
+ * ID生成统一入口
+ */
+const newUuid = () => {
+ return uuidv4()
+}
+
+const idUtil = {
+ newUuid,
+ newID,
+}
+
+export default idUtil
diff --git a/syp.config.ts b/syp.config.ts
index 4112e80..6932960 100644
--- a/syp.config.ts
+++ b/syp.config.ts
@@ -23,14 +23,16 @@
* questions.
*/
+import { DYNAMIC_CONFIG_KEY } from "~/src/utils/constants.ts"
+
interface ISypConfig {
lang?: "zh_CN" | "en_US"
- "dynamic-config"?: string
+ [DYNAMIC_CONFIG_KEY]?: string
[key: string]: any
}
export const SypConfig: ISypConfig = {
lang: "zh_CN",
- "dynamic-config": "{}",
+ [DYNAMIC_CONFIG_KEY]: "{}",
}