Skip to content

Commit

Permalink
Merge pull request #89 from GuoXiCheng/dev-c
Browse files Browse the repository at this point in the history
Dev c
  • Loading branch information
GuoXiCheng authored Jun 27, 2024
2 parents e3e04bc + 53580d8 commit bb3a4f3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 63 deletions.
4 changes: 2 additions & 2 deletions src/.vitepress/sidebars/ecma-script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@
- text: 切片或连接数组
link: /javascript/ecma-script/collection-reference/array/slice-or-concat-array
- text: Map
link: /map
link: /javascript/ecma-script/collection-reference/map
- text: Set
link: /set
link: /javascript/ecma-script/collection-reference/set
- text: 迭代器与生成器
items:
- text: 迭代器
Expand Down
95 changes: 36 additions & 59 deletions src/MarkMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,65 +47,35 @@ export default {
addToolbar(markmap);
});
// 简单的哈希函数
function simpleHash(s) {
var hash = 0;
for (var i = 0; i < s.length; i++) {
var character = s.charCodeAt(i);
hash = ((hash << 5) - hash) + character;
hash = hash & hash; // 将hash转换为32位整数
}
return hash;
}
// 清理带有指定前缀的localStorage中的键
function clearLocalStorageWithPrefix(prefix) {
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
if (key.startsWith(prefix)) {
localStorage.removeItem(key);
}
}
}
// 添加Toolbar
function addToolbar(markmap) {
const js = createElementDiv('JS');
const all = createElementDiv('All');
const react = createElementDiv('React');
const vue = createElementDiv('Vue');
Toolbar.defaultItems = [{
content: js,
title: 'JavaScript',
onClick: () => {
const raw = JSON.parse(localStorage.getItem('markmap-state-raw'));
localStorage.setItem('markmap-state-selected', JSON.stringify(raw.children[0]));
createOrUpdateMarkmap();
}
}, {
content: react,
title: 'React',
onClick: () => {
const raw = JSON.parse(localStorage.getItem('markmap-state-raw'));
localStorage.setItem('markmap-state-selected', JSON.stringify(raw.children[1].children[1]));
createOrUpdateMarkmap();
}
}, {
content: vue,
title: 'Vue',
onClick: () => {
const raw = JSON.parse(localStorage.getItem('markmap-state-raw'));
localStorage.setItem('markmap-state-selected', JSON.stringify(raw.children[1].children[0]));
createOrUpdateMarkmap();
}
}, {
content: all,
title: 'All',
onClick: () => {
localStorage.removeItem('markmap-state-selected');
createOrUpdateMarkmap();
const raw = JSON.parse(localStorage.getItem('markmap-state-raw'));
Toolbar.defaultItems = [
{
title: 'JavaScript',
data: raw.children[0],
}, {
title: 'NodeJS',
data: raw.children[2].children[0],
}, {
title: '云原生',
data: raw.children[3],
}, {
title: '方法论',
data: raw.children[4],
}, {
title: 'React',
data: raw.children[1].children[1],
}, {
title: 'Vue',
data: raw.children[1].children[0],
}, {
title: 'All',
data: raw,
}
}];
].map(item => createToolbarItem(item.title, item.data));
const toolbar = Toolbar.create(markmap);
toolbar.setBrand(false)
Expand All @@ -115,11 +85,18 @@ export default {
document.getElementById('container').appendChild(toolbar.el);
}
function createElementDiv(title) {
function createToolbarItem(title, data) {
const div = document.createElement('div');
div.innerHTML = title;
div.setAttribute('style', 'cursor: pointer;');
return div;
div.setAttribute('style', 'cursor: pointer;text-align: center;');
return {
content: div,
title,
onClick: () => {
localStorage.setItem('markmap-state-selected', JSON.stringify(data));
createOrUpdateMarkmap();
}
}
}
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/vue/introduction/what-is-vue.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
aside: false
---

# 什么是 Vue

## Vue 是什么
Expand Down
5 changes: 3 additions & 2 deletions sync.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import fs from "fs";
const repoURLs = [
'https://github.com/GuoXiCheng/react-sandbox.git',
'https://github.com/GuoXiCheng/javascript-sandbox.git',
'https://github.com/GuoXiCheng/vue-sandbox.git',
];

if (!fs.existsSync(projectsDir)) {
fs.mkdirSync(projectsDir);
}

repoURLs.forEach(repoURL => {
let cloneCommand;

Expand Down

0 comments on commit bb3a4f3

Please sign in to comment.