Skip to content

Commit

Permalink
Merge pull request #273 from GuoXiCheng/dev-c
Browse files Browse the repository at this point in the history
update
  • Loading branch information
GuoXiCheng authored Oct 16, 2024
2 parents 3ae8e2e + 83d5cc2 commit 4d9869a
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 未发布

### 修改

- 解决加载的配置文件包含 Unicode 编码时未转换为中文的问题

## v3.0.0 - 2024.09.27

### 新增
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ConfigReadRepository @Inject constructor(

val configReadSchemaList = gson.fromJson<List<ConfigReadSchema>>(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)
}
Expand Down Expand Up @@ -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()
}
}
}
15 changes: 13 additions & 2 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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/": [
Expand Down Expand Up @@ -128,6 +137,8 @@ export default defineConfig(
},
],
},

socialLinks: [{ icon: "github", link: "https://github.com/GuoXiCheng/SKIP" }],
},
})
);
8 changes: 8 additions & 0 deletions docs/public/js/baidu-analytics.js
Original file line number Diff line number Diff line change
@@ -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);
})();

18 changes: 18 additions & 0 deletions docs/visual/Header.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<div>配置版本号: {{ configVersion }}</div>
</template>

<script setup lang="ts">
import { computed } from "vue";
import CryptoJS from "crypto-js";
const props = defineProps<{
jsonConfig: any;
}>();
const configVersion = computed(() => md5(JSON.stringify(props.jsonConfig)));
function md5(input: string) {
return CryptoJS.MD5(CryptoJS.enc.Utf8.parse(input)).toString(CryptoJS.enc.Hex);
}
</script>
29 changes: 29 additions & 0 deletions docs/visual/Home.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<div>
<el-container>
<el-header><Header :json-config="jsonConfig" /></el-header>
<el-main>
<el-row>
<el-col :span="12"><LeftForm :json-config="jsonConfig" /></el-col>
<el-col :span="12"><RightCode :json-config="jsonConfig" /></el-col>
</el-row>
</el-main>
</el-container>
</div>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import LeftForm from "./LeftForm.vue";
import RightCode from "./RightCode.vue";
import Header from "./Header.vue";
import jsyaml from "js-yaml";
const jsonConfig = ref<any>(null);
onMounted(async () => {
const response = await fetch("https://skip.guoxicheng.top/skip_config_v3.yaml");
const skipYamlConfig = await response.text();
jsonConfig.value = jsyaml.load(skipYamlConfig);
});
</script>
24 changes: 24 additions & 0 deletions docs/visual/LeftForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div>
<el-collapse v-model="activeNames" @change="handleChange">
<template v-for="item in props.jsonConfig">
<el-collapse-item :title="item.appName" :name="item.packageName">
<!-- <div v-for="content in item.content">{{ content }}</div> -->
</el-collapse-item>
</template>
</el-collapse>
</div>
</template>

<script setup lang="ts">
import { ref } from "vue";
const activeNames = ref(["1"]);
const handleChange = (val: string[]) => {
console.log(val);
};
const props = defineProps<{
jsonConfig: any;
}>();
</script>
22 changes: 22 additions & 0 deletions docs/visual/RightCode.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<div>
<code-mirror v-model="code" :extensions="extensions" class="z-0" />
</div>
</template>

<script setup lang="ts">
import CodeMirror from "vue-codemirror6";
import { yaml } from "@codemirror/lang-yaml";
import { oneDark } from "@codemirror/theme-one-dark";
import { computed } from "vue";
import jsyaml from "js-yaml";
const extensions = [yaml(), oneDark];
const props = defineProps<{
jsonConfig: any;
}>();
const code = computed(() => {
return jsyaml.dump(props.jsonConfig);
});
</script>
9 changes: 9 additions & 0 deletions docs/visual/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: false
---

<script setup>
import Home from './Home.vue'
</script>

<Home />
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 4d9869a

Please sign in to comment.