Skip to content

Commit

Permalink
fix: 修复平台名称被截断的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Oct 31, 2023
1 parent efb3e84 commit 76136e5
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 104 deletions.
34 changes: 34 additions & 0 deletions cross/crossPageUtils.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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 { describe, it } from "vitest"
import CrossPageUtils from "./crossPageUtils"

describe("test crossPageUtils", () => {
it("test subPlatformName", () => {
const result = CrossPageUtils.subPlatformName("Gitlabvuepress2", 11)
console.log(result)
})
})
8 changes: 4 additions & 4 deletions cross/crossPageUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* questions.
*/

import { HtmlUtil, StrUtil } from "zhi-common"
import { StrUtil } from "zhi-common"

/**
* 页面辅助函数
Expand All @@ -45,7 +45,7 @@ class CrossPageUtils {
if (!platformName.includes("_")) {
return this.shortPlatformName(platformName, length ?? 9)
}
return StrUtil.upperFirst(HtmlUtil.parseHtml(platformName.split("_")[1], length ?? 9))
return StrUtil.upperFirst(StrUtil.getByLength(platformName.split("_")[1], length ?? 9))
}

/**
Expand All @@ -58,7 +58,7 @@ class CrossPageUtils {
if (StrUtil.isEmptyString(platformName)) {
return ""
}
return StrUtil.upperFirst(HtmlUtil.parseHtml(platformName.replace("Gitlab", ""), length ?? 9))
return StrUtil.upperFirst(StrUtil.getByLength(platformName.replace("Gitlab", ""), length ?? 9))
}

/**
Expand All @@ -71,7 +71,7 @@ class CrossPageUtils {
if (StrUtil.isEmptyString(platformName)) {
return ""
}
const shortName = StrUtil.upperFirst(HtmlUtil.parseHtml(platformName.replace("Gitlab", ""), length ?? 9))
const shortName = StrUtil.upperFirst(StrUtil.getByLength(platformName.replace("Gitlab", ""), length ?? 9))
if (platformName.includes("Gitlab")) {
return `Gitlab-${shortName}`
}
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@terwer/eslint-config-custom": "^1.3.6",
"@types/crypto-js": "^4.1.3",
"@types/lodash": "^4.14.200",
"@types/node": "^18.18.7",
"@types/node": "^18.18.8",
"@vitejs/plugin-vue": "^4.4.0",
"@vitest/coverage-v8": "^0.34.6",
"@vue/test-utils": "^2.4.1",
Expand Down Expand Up @@ -69,22 +69,22 @@
"pinia": "^2.1.7",
"shorthash2": "^1.0.3",
"simple-xmlrpc": "^1.4.2",
"siyuan": "^0.8.7",
"siyuan": "^0.8.8",
"siyuan-plugin-picgo": "^1.4.4",
"uuid": "^9.0.1",
"vue": "^3.3.7",
"vue-i18n": "^9.6.2",
"vue-router": "^4.2.5",
"xmlbuilder2": "^3.1.1",
"zhi-blog-api": "^1.50.0",
"zhi-common": "^1.25.0",
"zhi-blog-api": "^1.50.2",
"zhi-common": "^1.26.1",
"zhi-device": "^2.10.0",
"zhi-fetch-middleware": "^0.7.11",
"zhi-github-middleware": "^0.4.8",
"zhi-gitlab-middleware": "^0.6.18",
"zhi-fetch-middleware": "^0.7.13",
"zhi-github-middleware": "^0.4.10",
"zhi-gitlab-middleware": "^0.6.20",
"zhi-lib-base": "^0.8.0",
"zhi-notion-markdown": "^0.1.4",
"zhi-siyuan-api": "^2.12.0",
"zhi-xmlrpc-middleware": "^0.6.11"
"zhi-siyuan-api": "^2.12.2",
"zhi-xmlrpc-middleware": "^0.6.13"
}
}
Loading

0 comments on commit 76136e5

Please sign in to comment.