Skip to content

Commit 9ffdbc8

Browse files
committed
feat: shit-code cleanup & sidebar tips
1 parent 12070d9 commit 9ffdbc8

File tree

10 files changed

+116
-27
lines changed

10 files changed

+116
-27
lines changed

src-tauri/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ socket2 = "0.6.1"
4646
[target.'cfg(windows)'.dependencies]
4747
winreg = { version = "0.55.0" }
4848
windows = { version = "0.62.2", features = ["Win32_UI_HiDpi"] }
49+
50+
[profile.dev]
51+
opt-level = 0

src-tauri/src/core/utils/tags.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
use std::collections::HashMap;
2-
use std::sync::Mutex;
3-
4-
static TAG_CACHE: std::sync::LazyLock<Mutex<HashMap<String, &'static str>>> =
5-
std::sync::LazyLock::new(|| Mutex::new(HashMap::new()));
6-
71
fn make_tag_from_module_path(module_path: &str) -> String {
82
let cleaned = module_path.replace("::", ".");
93
let cleaned = cleaned
@@ -12,23 +6,27 @@ fn make_tag_from_module_path(module_path: &str) -> String {
126
format!("collapse.module.{cleaned}")
137
}
148

15-
pub fn collapse_module_tag_cached_from_module_path(module_path: &str) -> &'static str {
16-
let key = make_tag_from_module_path(module_path);
17-
let mut cache = TAG_CACHE.lock().unwrap();
18-
if let Some(&v) = cache.get(&key) {
19-
return v;
20-
}
21-
let leaked: &'static str = Box::leak(key.into_boxed_str());
22-
cache.insert(leaked.to_string(), leaked);
23-
leaked
9+
pub fn collapse_module_tag_from_module_path(module_path: &str) -> String {
10+
make_tag_from_module_path(module_path)
11+
}
12+
13+
pub fn collapse_module_tag_from_file(file_path: &str) -> String {
14+
let mut cleaned = file_path.replace("\\", "/");
15+
cleaned = cleaned.trim_start_matches("./").to_string();
16+
cleaned = cleaned
17+
.trim_start_matches("crate/")
18+
.trim_start_matches("/")
19+
.to_string();
20+
let cleaned = cleaned.replace('/', ".").replace('.', "_");
21+
format!("collapse.module.{cleaned}")
2422
}
2523

2624
#[macro_export]
2725
macro_rules! collapse_tag {
2826
() => {
29-
$crate::core::utils::tags::collapse_module_tag_cached_from_module_path(module_path!())
27+
$crate::core::utils::tags::collapse_module_tag_from_module_path(module_path!())
3028
};
3129
(file) => {
32-
$crate::core::utils::tags::collapse_module_tag_cached_from_file(file!())
30+
$crate::core::utils::tags::collapse_module_tag_from_file(file!())
3331
};
3432
}

src/assets/videos/sidebar-help.mp4

163 KB
Binary file not shown.

src/components/features/clients/ClientCard.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const slideDirection = ref<'left' | 'right'>('right');
6868
6969
const isScreenshotViewerOpen = ref(false);
7070
const currentScreenshotIndex = ref(0);
71-
const screenshotViewerRef = shallowRef<HTMLElement | null>(null);
7271
const isImageLoading = ref(false);
7372
const imageTransitionDirection = ref<'next' | 'prev'>('next');
7473
const imageRef = shallowRef<HTMLImageElement | null>(null);
@@ -78,7 +77,6 @@ const actionsRef = shallowRef<HTMLElement | null>(null);
7877
const favoriteRef = shallowRef<HTMLElement | null>(null);
7978
8079
const scrollContainer = shallowRef<HTMLElement | null>(null);
81-
const contentRef = shallowRef<HTMLElement | null>(null);
8280
const showScrollbar = ref(false);
8381
const thumbHeight = ref(20);
8482
const thumbTop = ref(0);

src/components/layout/Sidebar.vue

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
SlidersVertical,
1212
UserCog,
1313
} from 'lucide-vue-next';
14-
import { computed, onMounted, onUnmounted, ref } from 'vue';
14+
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
1515
import { useI18n } from 'vue-i18n';
1616
import { useFriends } from '../../composables/useFriends';
1717
import { useUser } from '../../composables/useUser';
@@ -23,6 +23,10 @@ const { adminStatus } = useUser();
2323
const halloweenActive = ref(isHalloweenEvent());
2424
const halloweenGreeting = ref(getEventGreeting());
2525
26+
const sidebarHelpVideo = new URL('../../assets/videos/sidebar-help.mp4', import.meta.url).href;
27+
const sidebarHelpKey = 'sidebar-help-shown';
28+
const showSidebarHelp = ref(false);
29+
2630
const props = defineProps<{
2731
activeTab: string;
2832
isOnline: boolean;
@@ -138,6 +142,9 @@ const startDrag = (event: MouseEvent) => {
138142
if (target.closest('button')) return;
139143
140144
isMouseDown.value = true;
145+
if (showSidebarHelp.value) {
146+
hideSidebarHelp();
147+
}
141148
document.addEventListener('mouseup', stopDrag);
142149
document.addEventListener('mousemove', onDrag);
143150
};
@@ -160,6 +167,9 @@ const toggleCenter = (event: MouseEvent) => {
160167
const target = event.target as HTMLElement;
161168
if (target.closest('button')) return;
162169
isCentered.value = !isCentered.value;
170+
if (showSidebarHelp.value) {
171+
hideSidebarHelp();
172+
}
163173
};
164174
165175
const currentPosition = computed(() => props.position || 'left');
@@ -203,6 +213,38 @@ const animationClass = computed(() => {
203213
return 'sidebar-entered';
204214
});
205215
216+
const helpTooltipClasses = computed(() => {
217+
const pos = currentPosition.value;
218+
if (pos === 'left') return 'left-24 top-6';
219+
if (pos === 'right') return 'right-24 top-6';
220+
if (pos === 'top') return 'left-1/2 top-24 transform -translate-x-1/2';
221+
if (pos === 'bottom') return 'left-1/2 bottom-24 transform -translate-x-1/2';
222+
return 'left-24 top-6';
223+
});
224+
225+
const sidebarRef = ref<HTMLElement | null>(null);
226+
const helpTooltipRef = ref<HTMLElement | null>(null);
227+
228+
const hideSidebarHelp = () => {
229+
try {
230+
localStorage.setItem(sidebarHelpKey, 'true');
231+
} catch {
232+
}
233+
showSidebarHelp.value = false;
234+
};
235+
236+
const handleDocumentClick = (event: MouseEvent) => {
237+
const target = event.target as Node;
238+
if (helpTooltipRef.value?.contains(target)) return;
239+
if (sidebarRef.value?.contains(target)) return;
240+
hideSidebarHelp();
241+
};
242+
243+
watch(showSidebarHelp, (val) => {
244+
if (val) document.addEventListener('click', handleDocumentClick);
245+
else document.removeEventListener('click', handleDocumentClick);
246+
});
247+
206248
onMounted(async () => {
207249
window.addEventListener('keydown', handleKeyDown);
208250
@@ -215,6 +257,14 @@ onMounted(async () => {
215257
216258
217259
isDev.value = await getIsDevelopment();
260+
261+
try {
262+
const shown = localStorage.getItem(sidebarHelpKey);
263+
if (!shown) {
264+
showSidebarHelp.value = true;
265+
}
266+
} catch {
267+
}
218268
});
219269
220270
onUnmounted(() => {
@@ -227,6 +277,7 @@ onUnmounted(() => {
227277
if (altPressTimeout.value) {
228278
clearTimeout(altPressTimeout.value);
229279
}
280+
document.removeEventListener('click', handleDocumentClick);
230281
});
231282
</script>
232283

@@ -246,7 +297,23 @@ onUnmounted(() => {
246297
</div>
247298
</div>
248299

249-
<div :class="[sidebarClasses, animationClass]" @mousedown="startDrag" @dblclick="toggleCenter">
300+
<div ref="sidebarRef" :class="[sidebarClasses, animationClass]" @mousedown="startDrag" @dblclick="toggleCenter">
301+
<div v-if="showSidebarHelp" ref="helpTooltipRef"
302+
:class="['sidebar-help-tooltip absolute z-60 p-3 w-80 origin-top-left bg-base-100 rounded-lg ml-3 mt-[100%]', helpTooltipClasses]">
303+
<div class="flex flex-col gap-2">
304+
<video class="w-full rounded-md mb-2" :src="sidebarHelpVideo" muted autoplay loop playsinline
305+
controls></video>
306+
<div class="text-sm">
307+
<strong>{{ t('navigation.sidebar_help.title') }}</strong>&nbsp;{{ t('navigation.sidebar_help.tip')
308+
}}
309+
</div>
310+
<div class="flex justify-end mt-1 gap-2">
311+
<button class="btn btn-ghost btn-xs" @click.stop="hideSidebarHelp">{{
312+
t('navigation.sidebar_help.got_it')
313+
}}</button>
314+
</div>
315+
</div>
316+
</div>
250317
<div class="transition-all duration-500 ease-in-out basis-0" :class="isCentered ? 'grow' : 'grow-0'">
251318
</div>
252319

@@ -478,4 +545,8 @@ onUnmounted(() => {
478545
.sidebar-entered .mt-auto>*:nth-child(3) {
479546
transition-delay: 0.30s;
480547
}
548+
549+
.sidebar-help-tooltip video {
550+
max-height: 180px;
551+
}
481552
</style>

src/components/modals/social/presets/ImportPresetModal.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</div>
4949
<div v-if="previewData.description">
5050
<strong>{{ $t('theme.presets.import_modal.preview_description') }}:</strong> {{
51-
previewData.description }}
51+
previewData.description }}
5252
</div>
5353
</div>
5454
</div>
@@ -86,7 +86,6 @@ const emit = defineEmits<Emits>();
8686
const { importPresetFromJSON } = usePresets();
8787
8888
const importMethod = ref<'file' | 'json'>('file');
89-
const fileInput = ref<HTMLInputElement>();
9089
const jsonInput = ref('');
9190
const error = ref('');
9291
const importing = ref(false);

src/i18n/locales/en.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,12 @@
801801
"admin": "Admin Panel",
802802
"news": "News",
803803
"customization": "Customization",
804-
"custom_clients": "Custom Clients"
804+
"custom_clients": "Custom Clients",
805+
"sidebar_help": {
806+
"title": "Tip:",
807+
"tip": "You can move the sidebar to any side of the screen. Double-click the sidebar to remove margin between icons.",
808+
"got_it": "Got it"
809+
}
805810
},
806811
"admin": {
807812
"title": "Administration Panel",

src/i18n/locales/ru.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,12 @@
801801
"admin": "Панель админа",
802802
"news": "Новости",
803803
"customization": "Кастомизация",
804-
"custom_clients": "Свои клиенты"
804+
"custom_clients": "Свои клиенты",
805+
"sidebar_help": {
806+
"title": "Совет:",
807+
"tip": "Вы можете переместить боковую панель на любую сторону экрана. Двойной щелчок по панели уберет отступы между иконками.",
808+
"got_it": "Понял"
809+
}
805810
},
806811
"toast": {
807812
"dev": {

src/i18n/locales/ua.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,12 @@
800800
"admin": "Адмін-панель",
801801
"news": "Новини",
802802
"customization": "Кастомізація",
803-
"custom_clients": "Власні клієнти"
803+
"custom_clients": "Власні клієнти",
804+
"sidebar_help": {
805+
"title": "Порада:",
806+
"tip": "Ви можете перемістити бічну панель на будь-який бік екрану. Подвійне клацання по бічній панелі прибирає відступи між іконками.",
807+
"got_it": "Зрозумів"
808+
}
804809
},
805810
"admin": {
806811
"title": "Панель адміністрування",

src/i18n/locales/zh_cn.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,12 @@
789789
"admin": "管理面板",
790790
"news": "新闻",
791791
"customization": "个性化",
792-
"custom_clients": "自定义客户端"
792+
"custom_clients": "自定义客户端",
793+
"sidebar_help": {
794+
"title": "提示:",
795+
"tip": "您可以将侧边栏移动到屏幕的任意一侧。双击侧边栏可移除图标之间的间距。",
796+
"got_it": "知道了"
797+
}
793798
},
794799
"admin": {
795800
"title": "管理面板",

0 commit comments

Comments
 (0)