Skip to content

Commit 0f1e828

Browse files
committed
update: 更新文章
1 parent 06cf53b commit 0f1e828

File tree

22 files changed

+311
-101
lines changed

22 files changed

+311
-101
lines changed

.vitepress/sidebar/bugs.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ const bugsSidebar: SidebarType[] = [
100100
items: androidStudioItems
101101
}
102102
]
103-
},
104-
{
105-
text: '待分类',
106-
items: []
107103
}
108104
];
109105

.vitepress/sidebar/newTools.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { SidebarType } from '../../package/type';
2+
3+
const newToolsSidebar: SidebarType[] = [
4+
{
5+
text: '学不动,根本学不动',
6+
link: '/new-tools/',
7+
readonly: true,
8+
items: [
9+
{
10+
text: 'artalk 评论系统安装与配置教程(docker版)',
11+
link: '/new-tools/docker_install_artalk'
12+
}
13+
]
14+
}
15+
];
16+
17+
export default newToolsSidebar;

.vitepress/sidebar/test.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

.vitepress/themeConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ThemeConfig } from '../package/type';
22
import learnSidebar from './sidebar/learn';
33
import bugsSidebar from './sidebar/bugs';
4-
import testSidebar from './sidebar/test';
4+
import newToolsSidebar from './sidebar/newTools';
55

66
export default {
77
name: 'Tmiracle',
@@ -71,6 +71,6 @@ export default {
7171
sidebar: {
7272
'/learn/': learnSidebar,
7373
'/bugs/': bugsSidebar,
74-
'/test/': testSidebar
74+
'/new-tools/': newToolsSidebar
7575
}
7676
} as ThemeConfig;

package/components/NanoActionBarButton/index.vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,35 @@
44
un-p="[calc(var(--action-bar-size)*.1)]"
55
un-flex="center"
66
un-rounded="[calc(var(--action-bar-size)*.2)]"
7-
un-hover="bg-[var(--action-bar-btn-hover-bg)]"
8-
un-focus="bg-[var(--action-bar-btn-focus-bg)]"
9-
@click="button.clickFn"
7+
:un-hover="disabled ? 'bg-transparent' : 'bg-[var(--action-bar-btn-hover-bg)]'"
8+
:un-focus="disabled ? 'bg-transparent' : 'bg-[var(--action-bar-btn-focus-bg)]'"
9+
:class="{ 'cursor-not-allowed! opacity-50' : disabled }"
10+
@click.stop="triggerClickFn"
1011
>
1112
<Component
1213
:is="button.icon"
13-
class="w-full h-full fill-[#A0A3AD] group-focus:fill-white"
14+
class="w-full h-full fill-[#A0A3AD]"
15+
:class="{ 'group-hover:fill-[#FFFFFF]' : !disabled }"
1416
/>
1517
</button>
1618
</template>
1719

1820
<script setup lang="ts">
1921
import { NanoActionBarButtonType } from '@NanoUI/NanoActionBarButton/type';
22+
import { computed } from 'vue';
2023
21-
defineProps<{
24+
const props = defineProps<{
2225
button: NanoActionBarButtonType
2326
}>();
27+
28+
const disabled = computed(() => {
29+
return props.button.disabled ? props.button.disabled() : false;
30+
});
31+
32+
function triggerClickFn() {
33+
if (disabled.value) return;
34+
props.button.clickFn();
35+
}
2436
</script>
2537

2638
<style scoped lang="scss">

package/components/NanoActionBarButton/type.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import { ComponentCustomOptions } from 'vue';
33
export type NanoActionBarButtonType = {
44
id: string,
55
icon: ComponentCustomOptions,
6-
clickFn: () => any
6+
disabled?: () => boolean,
7+
clickFn: () => void
78
}

package/components/NanoContainer/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
:height-range="[ '60vh', '100vh' ]"
1010
class="nano-theme"
1111
>
12-
<div v-show="!loading" class="relative w-full h-full flex flex-col">
12+
<div class="relative w-full h-full flex flex-col">
1313
<NanoHeader ref="header" @dblclick.self="ctl.fullscreen = !ctl.fullscreen"/>
1414
<NanoBody>
1515
<template #content-footer>

package/components/NanoLeftActionBar/index.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,23 @@
3434
import { ref, shallowRef } from 'vue';
3535
import emitter from '../../emitter';
3636
import { type NanoActionBarButtonType } from '@NanoUI/NanoActionBarButton/type';
37+
import { useData } from 'vitepress';
38+
const { frontmatter } = useData();
3739
38-
const actionLeftBarTopBtnList = ref<NanoActionBarButtonType[]>([
40+
const actionLeftBarTopBtnList = ref<Array<NanoActionBarButtonType>>([
3941
{
4042
id: 'project',
4143
icon: shallowRef(ProjectIcon),
42-
clickFn: () => emitter.emit('toggle-dir-open-status')
44+
disabled: () => {
45+
return [ 'page' ].includes(frontmatter.value?.layout);
46+
},
47+
clickFn: () => {
48+
emitter.emit('toggle-dir-open-status');
49+
}
4350
}
4451
]);
4552
46-
const actionLeftBarBottomBtnList = ref<NanoActionBarButtonType[]>([]);
53+
const actionLeftBarBottomBtnList = ref<Array<NanoActionBarButtonType>>([]);
4754
</script>
4855

4956
<style scoped lang="scss">

package/components/NanoLoading/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="box w-full h-full rounded-6px">
2+
<div class="box absolute top-0 left-0 z-100 w-full h-full rounded-6px">
33
<div class="cat">
44
<div class="cat__body"/>
55
<div class="cat__body"/>

package/components/NanoMain/index.vue

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class="w-full h-full"
1414
:options="scrollbarOptions"
1515
defer
16-
@os-initialized="scrollbarInitialized"
16+
@os-initialized="scrollbarChanged"
1717
>
1818
<div :style="{ padding: articlePadding }">
1919
<article
@@ -44,11 +44,11 @@
4444
import scrollbarOptions from '../../config/scrollbarOptions';
4545
import { OverlayScrollbarsComponent } from 'overlayscrollbars-vue';
4646
import { computed, nextTick, onMounted, onUnmounted, ref, watch, watchEffect } from 'vue';
47-
import { Content, onContentUpdated, useData, useRoute } from 'vitepress';
47+
import { Content, useData, useRoute } from 'vitepress';
4848
import emitter from '../../emitter';
4949
import NotFound from 'vitepress/dist/client/theme-default/NotFound.vue';
5050
51-
const { page, theme, frontmatter } = useData();
51+
const { page, theme, frontmatter, hash } = useData();
5252
const route = useRoute();
5353
const scrollbars = ref<InstanceType<typeof OverlayScrollbarsComponent> | null>(null);
5454
const article = ref<HTMLElement | null>(null);
@@ -57,36 +57,34 @@
5757
const showDatetime = computed(() => frontmatter.value.lastUpdated !== false);
5858
5959
// Listen for routing changes and scroll to the top
60-
watch(() => route.path, () => {
60+
watch(() => [ route.path, hash ], ([ , hashValue ]) => {
6161
nextTick(() => {
62-
scrollbars.value?.osInstance()?.elements()?.viewport?.scrollTo({ top: 0 });
62+
if (hashValue) {
63+
setTimeout(() => {
64+
hashChange();
65+
});
66+
} else {
67+
scrollbars.value?.osInstance()?.elements()?.viewport?.scrollTo({ top: 0 });
68+
}
6369
});
64-
}, {
65-
immediate: true
66-
});
70+
}, { immediate: true });
6771
6872
// Listen for hash changes
69-
function hashChange() {
73+
const hashChange = () => {
74+
// console.log('hashChange', location.hash);
7075
if (location.hash) {
7176
const _hashText = decodeURIComponent(location.hash.replace('#', ''));
7277
emitter.emit('scroll-to-hash', _hashText);
7378
}
74-
}
79+
};
7580
76-
function scrollbarInitialized() {
77-
// console.log('scrollbarInitialized');
81+
function scrollbarChanged() {
82+
// console.log('scrollbarChanged');
7883
setTimeout(() => {
7984
hashChange();
8085
}, 0);
8186
}
8287
83-
onContentUpdated(() => {
84-
// console.log('content updated');
85-
setTimeout(() => {
86-
hashChange();
87-
}, 0);
88-
});
89-
9088
const resizeObserver = ref<ResizeObserver | null>(null);
9189
const articlePadding = ref<string>('calc(var(--base-size))');
9290
@@ -139,8 +137,6 @@
139137
}
140138
});
141139
resizeObserver.value.observe(article.value!);
142-
143-
scrollbars.value?.osInstance()?.update();
144140
});
145141
146142
onUnmounted(() => {

0 commit comments

Comments
 (0)