IT-TOOLS-PRO v1 - 定制版开发者工具站

12个原创工具(批量条码/二维码识别/在线翻译/OCR/面单设计/AI修图/网站收藏/PDF工具/图片工具/文档转换等)
+ 卡密授权系统(CardAuth对接,30分钟试用,换卡/撤销)
+ 体验优化(中文默认/收藏/最近使用/菜单展开/宽屏/品牌页脚)
This commit is contained in:
personal82555 committed 2026-10-11 23:58:39 +08:00
commit 01ff133ac9
528 files changed
+50026

No files matched your search

+165
View File
@@ -0,0 +1,165 @@
<script setup lang="ts">
import { useStorage } from '@vueuse/core';
import { useThemeVars } from 'naive-ui';
import { RouterLink, useRoute } from 'vue-router';
import MenuIconItem from './MenuIconItem.vue';
import type { Tool, ToolCategory } from '@/tools/tools.types';
const props = withDefaults(defineProps<{ toolsByCategory?: ToolCategory[] }>(), { toolsByCategory: () => [] });
const { toolsByCategory } = toRefs(props);
const route = useRoute();
const makeLabel = (tool: Tool) => () => h(RouterLink, { to: tool.path }, { default: () => tool.name });
const makeIcon = (tool: Tool) => () => h(MenuIconItem, { tool });
const collapsedCategories = useStorage<Record<string, boolean>>(
'menu-tool-option:collapsed-categories',
{},
undefined,
{
deep: true,
serializer: {
read: v => (v ? JSON.parse(v) : null),
write: v => JSON.stringify(v),
},
},
);
function toggleCategoryCollapse({ name }: { name: string }) {
collapsedCategories.value[name] = !collapsedCategories.value[name];
}
function expandAll() {
const m: Record<string, boolean> = {};
for (const { name } of toolsByCategory.value) {
m[name] = false;
}
collapsedCategories.value = m;
}
function collapseAll() {
const m: Record<string, boolean> = {};
for (const { name } of toolsByCategory.value) {
m[name] = true;
}
collapsedCategories.value = m;
}
const menuOptions = computed(() =>
toolsByCategory.value.map(({ name, components }) => ({
name,
isCollapsed: collapsedCategories.value[name],
tools: components.map(tool => ({
label: makeLabel(tool),
icon: makeIcon(tool),
key: tool.path,
})),
})),
);
const themeVars = useThemeVars();
</script>
<template>
<div class="menu-actions">
<a href="javascript:;" class="menu-action" title="展开所有分类" @click="expandAll">⊕ 展开全部</a>
<span class="menu-action-sep" />
<a href="javascript:;" class="menu-action" title="收起所有分类" @click="collapseAll">⊖ 收起全部</a>
</div>
<div v-for="{ name, tools, isCollapsed } of menuOptions" :key="name">
<div ml-6px mt-12px flex cursor-pointer items-center op-60 @click="toggleCategoryCollapse({ name })">
<span :class="{ 'rotate-0': isCollapsed, 'rotate-90': !isCollapsed }" text-16px lh-1 op-50 transition-transform>
<icon-mdi-chevron-right />
</span>
<span ml-8px text-13px>
{{ name }}
</span>
</div>
<n-collapse-transition :show="!isCollapsed">
<div class="menu-wrapper">
<div class="toggle-bar" @click="toggleCategoryCollapse({ name })" />
<n-menu
class="menu"
:value="route.path"
:collapsed-width="64"
:collapsed-icon-size="22"
:options="tools"
:indent="8"
:default-expand-all="true"
/>
</div>
</n-collapse-transition>
</div>
</template>
<style scoped lang="less">
.menu-actions {
display: flex;
align-items: center;
gap: 8px;
padding: 2px 6px 0 6px;
.menu-action {
font-size: 12px;
color: inherit;
opacity: 0.55;
text-decoration: none;
padding: 2px 4px;
border-radius: 4px;
transition: opacity 0.15s, color 0.15s;
&:hover {
opacity: 1;
color: #18a058;
}
}
.menu-action-sep {
width: 1px;
height: 11px;
background: currentColor;
opacity: 0.2;
}
}
.menu-wrapper {
display: flex;
flex-direction: row;
.menu {
flex: 1;
margin-bottom: 5px;
::v-deep(.n-menu-item-content::before) {
left: 0;
right: 13px;
}
}
.toggle-bar {
width: 24px;
opacity: 0.1;
transition: opacity ease 0.2s;
position: relative;
cursor: pointer;
&::before {
width: 2px;
height: 100%;
content: ' ';
background-color: v-bind('themeVars.textColor3');
border-radius: 2px;
position: absolute;
top: 0;
left: 14px;
}
&:hover {
opacity: 0.5;
}
}
}
</style>