diff --git a/CHANGELOG.md b/CHANGELOG.md index 6164b8c..4735184 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 未发布 + +### 修改 + +- 解决加载的配置文件包含 Unicode 编码时未转换为中文的问题 + ## v3.0.0 - 2024.09.27 ### 新增 diff --git a/app/src/main/java/com/android/skip/data/config/ConfigReadRepository.kt b/app/src/main/java/com/android/skip/data/config/ConfigReadRepository.kt index 821ca85..ecfe40a 100644 --- a/app/src/main/java/com/android/skip/data/config/ConfigReadRepository.kt +++ b/app/src/main/java/com/android/skip/data/config/ConfigReadRepository.kt @@ -70,7 +70,7 @@ class ConfigReadRepository @Inject constructor( val configReadSchemaList = gson.fromJson>(customContent, type) - ConfigPostSchema(ConfigState.SUCCESS, md5(customContent), configReadSchemaList) + ConfigPostSchema(ConfigState.SUCCESS, md5(unicodeToChinese(customContent)), configReadSchemaList) } catch (e: Exception) { ConfigPostSchema(ConfigState.FAIL, getString(R.string.invalid_config), null) } @@ -142,8 +142,17 @@ class ConfigReadRepository @Inject constructor( // #region MD5 private fun md5(input: String): String { - val bytes = MessageDigest.getInstance("MD5").digest(input.toByteArray()) + val bytes = MessageDigest.getInstance("MD5").digest(input.toByteArray(Charsets.UTF_8)) return bytes.joinToString("") { "%02x".format(it) } } // #endregion MD5 + + private fun unicodeToChinese(unicodeStr: String): String { + val unicodeRegex = Regex("""\\u([0-9A-Fa-f]{4})""") + + return unicodeRegex.replace(unicodeStr) { matchResult -> + val unicodeValue = matchResult.groupValues[1].toInt(16) + unicodeValue.toChar().toString() + } + } } \ No newline at end of file diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 4de76e2..e311bf9 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -8,7 +8,10 @@ export default defineConfig( description: "SKIP APP Docs", base: "/", lastUpdated: true, - head: [["link", { rel: "icon", type: "image/x-icon", href: "/images/favicon.ico" }]], + head: [ + ["link", { rel: "icon", type: "image/x-icon", href: "/images/favicon.ico" }], + ["script", { src: "/js/baidu-analytics.js", async: true }], + ], themeConfig: { logo: "/images/favicon.ico", outline: { @@ -18,7 +21,13 @@ export default defineConfig( { text: "首页", link: "/" }, { text: "指南", link: "/guide/intro/what-is-skip" }, { text: "进阶", link: "/advance/layout-inspect/intro" }, - { text: "布局检查", link: "/inspect/index", target: "_blank" }, + { + text: "辅助功能", + items: [ + { text: "布局检查", link: "/inspect/index", target: "_blank" }, + // { text: "可视化配置", link: "/visual/index", target: "_blank" }, + ], + }, ], sidebar: { "/guide/": [ @@ -128,6 +137,8 @@ export default defineConfig( }, ], }, + + socialLinks: [{ icon: "github", link: "https://github.com/GuoXiCheng/SKIP" }], }, }) ); diff --git a/docs/public/js/baidu-analytics.js b/docs/public/js/baidu-analytics.js new file mode 100644 index 0000000..464ed15 --- /dev/null +++ b/docs/public/js/baidu-analytics.js @@ -0,0 +1,8 @@ +var _hmt = _hmt || []; +(function () { + var hm = document.createElement("script"); + hm.src = "https://hm.baidu.com/hm.js?d3d747ec2508d20c876d4d06e9dbd248"; + var s = document.getElementsByTagName("script")[0]; + s.parentNode.insertBefore(hm, s); +})(); + diff --git a/docs/visual/Header.vue b/docs/visual/Header.vue new file mode 100644 index 0000000..3a92d35 --- /dev/null +++ b/docs/visual/Header.vue @@ -0,0 +1,18 @@ + + + diff --git a/docs/visual/Home.vue b/docs/visual/Home.vue new file mode 100644 index 0000000..e37e194 --- /dev/null +++ b/docs/visual/Home.vue @@ -0,0 +1,29 @@ + + + diff --git a/docs/visual/LeftForm.vue b/docs/visual/LeftForm.vue new file mode 100644 index 0000000..53b5cea --- /dev/null +++ b/docs/visual/LeftForm.vue @@ -0,0 +1,24 @@ + + + diff --git a/docs/visual/RightCode.vue b/docs/visual/RightCode.vue new file mode 100644 index 0000000..1274869 --- /dev/null +++ b/docs/visual/RightCode.vue @@ -0,0 +1,22 @@ + + + diff --git a/docs/visual/index.md b/docs/visual/index.md new file mode 100644 index 0000000..887f385 --- /dev/null +++ b/docs/visual/index.md @@ -0,0 +1,9 @@ +--- +layout: false +--- + + + + diff --git a/package-lock.json b/package-lock.json index 062fd6e..d2afb46 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,10 +14,12 @@ "devDependencies": { "@codemirror/lang-yaml": "^6.1.1", "@codemirror/theme-one-dark": "^6.1.2", + "@types/crypto-js": "^4.2.2", "@types/jest": "^29.5.12", "@types/js-yaml": "^4.0.9", "autoprefixer": "^10.4.20", "codemirror": "^6.0.1", + "crypto-js": "^4.2.0", "element-plus": "^2.8.0", "idb": "^8.0.0", "jest": "^29.7.0", @@ -2262,6 +2264,13 @@ "@babel/types": "^7.20.7" } }, + "node_modules/@types/crypto-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.2.tgz", + "integrity": "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/d3-scale": { "version": "4.0.8", "dev": true, @@ -3361,6 +3370,13 @@ "node": ">= 8" } }, + "node_modules/crypto-js": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", + "dev": true, + "license": "MIT" + }, "node_modules/cssesc": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", diff --git a/package.json b/package.json index db11a8a..3c777bf 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,12 @@ "devDependencies": { "@codemirror/lang-yaml": "^6.1.1", "@codemirror/theme-one-dark": "^6.1.2", + "@types/crypto-js": "^4.2.2", "@types/jest": "^29.5.12", "@types/js-yaml": "^4.0.9", "autoprefixer": "^10.4.20", "codemirror": "^6.0.1", + "crypto-js": "^4.2.0", "element-plus": "^2.8.0", "idb": "^8.0.0", "jest": "^29.7.0",