diff --git a/cross/crossPageUtils.ts b/cross/crossPageUtils.ts new file mode 100644 index 00000000..6ffec630 --- /dev/null +++ b/cross/crossPageUtils.ts @@ -0,0 +1,60 @@ +/* + * 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 { HtmlUtil, StrUtil } from "zhi-common" + +/** + * 页面辅助函数 + * + * @author terwer + * @since 1.18.0 + */ +class CrossPageUtils { + /** + * 缩略展示平台名称 + * + * @param platformName + * @param length + */ + public static shortPlatformName(platformName: string, length?: number) { + return StrUtil.upperFirst(HtmlUtil.parseHtml(platformName.replace("Gitlab", ""), length ?? 9)) + } + + /** + * 缩略展示平台名称 + * + * @param platformName + * @param length + */ + public static longPlatformName(platformName: string, length?: number) { + const shortName = StrUtil.upperFirst(HtmlUtil.parseHtml(platformName.replace("Gitlab", ""), length ?? 9)) + if (platformName.includes("Gitlab")) { + return `Gitlab-${shortName}` + } + return shortName + } +} + +export default CrossPageUtils diff --git a/siyuan/topbar.ts b/siyuan/topbar.ts index 32d2e812..de43df91 100644 --- a/siyuan/topbar.ts +++ b/siyuan/topbar.ts @@ -34,6 +34,7 @@ import { PluginInvoke } from "./invoke/pluginInvoke" import { ObjectUtil } from "zhi-common" import { DYNAMIC_CONFIG_KEY } from "./Constants" import { ConfigManager } from "~/siyuan/store/config.ts" +import CrossPageUtils from "~/cross/crossPageUtils.ts" /** * 顶部按钮 @@ -93,11 +94,9 @@ export class Topbar { icon = `${icon}` } if (config.isEnabled === true) { - // http://127.0.0.1:6806/plugins/siyuan-plugin-publisher/i - const submenu = { iconHTML: `${icon}`, - label: config.platformName, + label: CrossPageUtils.longPlatformName(config.platformName, 11), disabled: !config.isAuth, click: async () => { const key = config.platformKey diff --git a/src/components/publish/SinglePublishSelectPlatform.vue b/src/components/publish/SinglePublishSelectPlatform.vue index 449207e1..af1e11ac 100644 --- a/src/components/publish/SinglePublishSelectPlatform.vue +++ b/src/components/publish/SinglePublishSelectPlatform.vue @@ -29,10 +29,11 @@ import { useVueI18n } from "~/src/composables/useVueI18n.ts" import { useRouter } from "vue-router" import { createAppLogger } from "~/src/utils/appLogger.ts" import { DynamicConfig, DynamicJsonCfg, getDynPostidKey } from "~/src/platforms/dynamicConfig.ts" -import { HtmlUtil, JsonUtil, ObjectUtil, StrUtil } from "zhi-common" +import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common" import { DYNAMIC_CONFIG_KEY } from "~/src/utils/constants.ts" import { useSettingStore } from "~/src/stores/useSettingStore.ts" import { useLoadingTimer } from "~/src/composables/useLoadingTimer.ts" +import CrossPageUtils from "~/cross/crossPageUtils.ts" const logger = createAppLogger("single-publish-select-platform") @@ -101,7 +102,7 @@ onMounted(async () => {