Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
163 additions
and
32 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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,103 @@ | ||
/* | ||
* 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 { DynamicConfig, PlatformType } from "~/src/components/set/publish/platform/dynamicConfig.ts" | ||
import { useVueI18n } from "~/src/composables/useVueI18n.ts" | ||
import { pre } from "~/src/utils/import/pre.ts" | ||
|
||
/** | ||
* 通用平台定义 | ||
* | ||
* @returns {Object} - 包含平台类型列表、getPlatformType函数和getPrePlatform函数的对象。 | ||
* @since 0.9.0 | ||
*/ | ||
export const usePlatformDefine = () => { | ||
const { t } = useVueI18n() | ||
|
||
const platformTypeList = [ | ||
{ | ||
type: PlatformType.Common, | ||
title: t("setting.platform.universal"), | ||
img: "./images/universal.webp", | ||
description: t("setting.platform.universal.desc"), | ||
}, | ||
{ | ||
type: PlatformType.Github, | ||
title: t("setting.platform.github"), | ||
img: "./images/github.png", | ||
description: t("setting.platform.github.desc"), | ||
}, | ||
{ | ||
type: PlatformType.Metaweblog, | ||
title: t("setting.platform.metaweblog"), | ||
img: "./images/metaweblog.jpg", | ||
description: t("setting.platform.metaweblog.desc"), | ||
}, | ||
{ | ||
type: PlatformType.Wordpress, | ||
title: t("setting.platform.wordpress"), | ||
img: "./images/wordpress-logo.svg", | ||
description: t("setting.platform.wordpress.desc"), | ||
}, | ||
// { | ||
// type: PlatformType.Custom, | ||
// title: t("setting.platform.other"), | ||
// img: "./images/other-platform.png", | ||
// description: t("setting.platform.other.desc"), | ||
// }, | ||
] | ||
|
||
const prePlatformList: DynamicConfig[] = [ | ||
...pre.commonCfg, | ||
...pre.githubCfg, | ||
...pre.metaweblogCfg, | ||
...pre.wordpressCfg, | ||
] | ||
|
||
/** | ||
* 根据键获取平台类型 | ||
* | ||
* @param {string} key - 平台类型的键 | ||
* @returns {Object} - 平台类型对象 | ||
*/ | ||
const getPlatformType = (key) => { | ||
return platformTypeList.find((platformType) => platformType.type === key) | ||
} | ||
|
||
/** | ||
* 根据类型获取预定义平台 | ||
* | ||
* @returns {Object} - 预定义平台对象 | ||
*/ | ||
const getPrePlatform = (key: string) => { | ||
return prePlatformList.find((platform) => platform.platformKey === key) | ||
} | ||
|
||
return { | ||
platformTypeList, | ||
getPlatformType, | ||
getPrePlatform, | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
export const pre = { | ||
commonCfg: [], | ||
githubCfg: [ | ||
{ | ||
platformType: "Github", | ||
subPlatformType: "Github_Hugo", | ||
platformKey: "githubHugo-zdlc6l", | ||
platformName: "Docsy", | ||
}, | ||
{ | ||
platformType: "Github", | ||
subPlatformType: "Github_Vitepress", | ||
platformKey: "githubVitepress-mhxj3", | ||
platformName: "Vitepress", | ||
}, | ||
{ | ||
platformType: "Github", | ||
subPlatformType: "Github_Nuxt", | ||
platformKey: "githubNuxt-z1xcb7x", | ||
platformName: "Nuxt content", | ||
}, | ||
{ | ||
platformType: "Github", | ||
subPlatformType: "Github_Next", | ||
platformKey: "githubNext-ziz9v8", | ||
platformName: "Nextra", | ||
}, | ||
], | ||
metaweblogCfg: [ | ||
{ | ||
platformType: "Metaweblog", | ||
subPlatformType: "none", | ||
platformKey: "metaweblog-zahrlw", | ||
platformName: "开源中国", | ||
}, | ||
{ | ||
platformType: "Metaweblog", | ||
subPlatformType: "none", | ||
platformKey: "metaweblog-22pamt", | ||
platformName: "Typecho", | ||
}, | ||
], | ||
wordpressCfg: [], | ||
} |