Skip to content

Commit

Permalink
feat(layout): page basic Construction
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoJiSen committed Jul 10, 2024
1 parent 58e1ac5 commit 1a0e198
Show file tree
Hide file tree
Showing 26 changed files with 474 additions and 292 deletions.
7 changes: 7 additions & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ declare module 'vue' {
Hello: typeof import('./src/components/Hello.vue')['default']
NButton: typeof import('naive-ui')['NButton']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDrawer: typeof import('naive-ui')['NDrawer']
NDrawerContent: typeof import('naive-ui')['NDrawerContent']
NDropdown: typeof import('naive-ui')['NDropdown']
NFlex: typeof import('naive-ui')['NFlex']
NH2: typeof import('naive-ui')['NH2']
Expand All @@ -20,8 +22,13 @@ declare module 'vue' {
NLayoutHeader: typeof import('naive-ui')['NLayoutHeader']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NPopover: typeof import('naive-ui')['NPopover']
NSpace: typeof import('naive-ui')['NSpace']
NSpin: typeof import('naive-ui')['NSpin']
NSwitch: typeof import('naive-ui')['NSwitch']
NText: typeof import('naive-ui')['NText']
NTooltip: typeof import('naive-ui')['NTooltip']
NTree: typeof import('naive-ui')['NTree']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
SvgIcon: typeof import('./src/components/SvgIcon/index.vue')['default']
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"dependencies": {
"axios": "^1.7.2",
"mitt": "^3.0.1",
"normalize.css": "^8.0.1",
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1",
Expand All @@ -42,6 +43,8 @@
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
"naive-ui": "^2.38.2",
"postcss": "^8.4.39",
"postcss-scss": "^4.0.9",
"prettier": "^3.3.2",
"sass": "^1.77.6",
"stylelint": "^16.1.0",
Expand Down
477 changes: 248 additions & 229 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/API/modules/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const getPublic = (): Promise<any> => {
let requestUrl = '/api/v1/settings/public/';

const connectionToken = getQueryParamFromURL('token');
console.log(connectionToken);

// ! 解决 /luna/connect?connectToken= 直接方式权限认证问题
if (connectionToken) {
requestUrl += `?token=${connectionToken}`;
Expand Down
5 changes: 1 addition & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<n-config-provider :locale="zhCN" :date-locale="dateZhCN" :theme-overrides="ThemeOverride">
<n-config-provider :locale="zhCN" :date-locale="dateZhCN">
<n-message-provider>
<n-spin :show="isLoading">
<router-view />
Expand All @@ -16,7 +16,6 @@ import { useTheme } from '@/hooks/useTheme.ts';
import { useTranslations } from '@/hooks/useTranslate.ts';
import { useGlobalStore } from '@/stores/modules/global.ts';
import { useLoadingStore } from '@/stores/modules/loading.ts';
import { LightThemeOverrides, DarkThemeOverrides } from './themeOverride.ts';
import { setFavicon } from '@/utils';
Expand All @@ -29,8 +28,6 @@ const isLoading = computed(() => {
return loadingStore.isLoading;
});
console.log(LightThemeOverrides, DarkThemeOverrides);
onBeforeMount(() => {
// 初始化主题样式
initTheme();
Expand Down
2 changes: 1 addition & 1 deletion src/assets/icons/tree.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/components/SvgIcon/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ const props = withDefaults(defineProps<SvgProps>(), {
const symbolId = computed(() => `#${props.prefix}-${props.name}`);
</script>

<style lang="scss" scoped>
svg:focus {
outline: unset;
}
</style>
1 change: 1 addition & 0 deletions src/hooks/useTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const useTheme = () => {
const switchDark = (): void => {
const html: HTMLElement = document.documentElement;

console.log(isDark);
if (isDark.value) {
html.setAttribute('class', 'dark');
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/languages/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export default {
InvalidJson: 'Invalid JSON format.',
requiredHasUserNameMapped: 'Username attr is required.',
'Web Terminal': 'Web Terminal',
'Theme reset': 'The theme color has been reset to'
'Theme reset': 'The theme color has been reset to',
'Custom Setting': 'Custom Setting'
};
3 changes: 2 additions & 1 deletion src/languages/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export default {
InvalidJson: 'JSON 格式错误.',
requiredHasUserNameMapped: '用户名属性是必需的。',
'Web Terminal': 'Web 终端',
'Theme reset': '主题颜色已重置为'
'Theme reset': '主题颜色已重置为',
'Custom Setting': '自定义设置'
};
99 changes: 99 additions & 0 deletions src/layouts/components/FileManagement/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<template>
<n-tree
block-line
expand-on-click
:data="data"
:node-props="nodeProps"
:on-update:expanded-keys="updatePrefixWithExpaned"
/>
</template>

<script lang="ts">
import { defineComponent, h } from 'vue';
import { useMessage, NIcon, TreeOption } from 'naive-ui';
import { Folder, FolderOpenOutline, FileTrayFullOutline } from '@vicons/ionicons5';
export default defineComponent({
setup() {
const message = useMessage();
const updatePrefixWithExpaned = (
_keys: Array<string | number>,
_option: Array<TreeOption | null>,
meta: {
node: TreeOption | null;
action: 'expand' | 'collapse' | 'filter';
}
) => {
if (!meta.node) return;
switch (meta.action) {
case 'expand':
meta.node.prefix = () =>
h(NIcon, null, {
default: () => h(FolderOpenOutline)
});
break;
case 'collapse':
meta.node.prefix = () =>
h(NIcon, null, {
default: () => h(Folder)
});
break;
}
};
const nodeProps = ({ option }: { option: TreeOption }) => {
return {
onClick() {
if (!option.children && !option.disabled) {
message.info('[Click] ' + option.label);
}
}
};
};
return {
updatePrefixWithExpaned,
nodeProps,
data: [
{
key: '文件夹',
label: '文件夹',
prefix: () =>
h(NIcon, null, {
default: () => h(Folder)
}),
children: [
{
key: '空的',
label: '空的',
disabled: true,
prefix: () =>
h(NIcon, null, {
default: () => h(Folder)
})
},
{
key: '我的文件',
label: '我的文件',
prefix: () =>
h(NIcon, null, {
default: () => h(Folder)
}),
children: [
{
label: 'template.txt',
key: 'template.txt',
prefix: () =>
h(NIcon, null, {
default: () => h(FileTrayFullOutline)
})
}
]
}
]
}
]
};
}
});
</script>

<style scoped lang="scss"></style>

This file was deleted.

17 changes: 15 additions & 2 deletions src/layouts/components/Header/components/Setting/index.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
<template>
<svg-icon :name="name" :icon-style="iconStyle"></svg-icon>
<n-popover placement="right" trigger="hover">
<template #trigger>
<svg-icon :name="name" :icon-style="iconStyle" @click="handleSetting" />
</template>
{{ t('Custom Setting') }}
</n-popover>
</template>

<script setup lang="ts">
import { CSSProperties } from 'vue';
import { useI18n } from 'vue-i18n';
import SvgIcon from '@/components/SvgIcon/index.vue';
defineProps<{
const { t } = useI18n();
const props = defineProps<{
name: string;
iconStyle: CSSProperties;
onClick: () => void;
}>();
const handleSetting = () => {
props.onClick();
};
</script>
21 changes: 12 additions & 9 deletions src/layouts/components/Header/headerLeft.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<template>
<n-flex justify="center" align="center" class="top-item">
<logo :logo-image="logoImage!" />
<n-flex>
<svg-icon class="tree-icon" :name="icon.name" :icon-style="iconStyle" />
<n-flex justify="center" align="center">
<n-button text>
<svg-icon class="tree-icon" :name="icon.name" :icon-style="iconStyle" />
</n-button>
</n-flex>

<n-space class="action-options">
Expand All @@ -29,7 +31,7 @@ const globalStore = useGlobalStore();
const { updateTranslations } = useTranslations();
const iconStyle: CSSProperties = {
fill: '#fff',
fill: '#646A73',
width: '25px',
height: '25px',
transition: 'fill 0.3s'
Expand Down Expand Up @@ -178,14 +180,15 @@ watchEffect(() => {

<style scoped lang="scss">
.top-item {
gap: 15px 12px !important;
gap: 30px 12px !important;
width: 100%;
margin-top: 15px;
margin-top: 25px;
cursor: pointer;
}
:deep(.tree-icon) {
svg:hover {
fill: #000000 !important;
:deep(.n-flex) {
width: 100%;
.tree-icon:hover {
fill: var(--el-color-primary-light-1) !important;
}
}
}
</style>
7 changes: 6 additions & 1 deletion src/layouts/components/Header/headerRight.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:is="option.component"
:options="option.options"
:icon-style="option.iconStyle"
:on-click="option.onClick"
/>
</template>
</n-flex>
Expand All @@ -18,6 +19,8 @@ import { storeToRefs } from 'pinia';
import { useGlobalStore } from '@/stores/modules/global.ts';
import { NAvatar, NText } from 'naive-ui';
import mittBus from '@/utils/mittBus.ts';
import Help from './components/Help/index.vue';
import Profile from './components/Profile/index.vue';
import Setting from './components/Setting/index.vue';
Expand Down Expand Up @@ -120,7 +123,9 @@ const bottomOptions: HeaderRightOptions[] = [
iconStyle,
name: 'setting',
component: Setting,
options: []
onClick: () => {
mittBus.emit('openSettingDrawer');
}
}
];
</script>
Expand Down
5 changes: 4 additions & 1 deletion src/layouts/components/Header/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ export interface HeaderRightOptions {
component: Component;

// 下拉菜单选项
options: optionsDetail[];
options?: optionsDetail[];

// 顶层的回调
onClick?: () => void;
}
36 changes: 36 additions & 0 deletions src/layouts/components/SettingDrawer/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<n-drawer
v-model:show="showSettingDrawer"
:default-width="502"
placement="right"
resizable
closable
>
<n-drawer-content :title="t('Custom Setting')">
<n-flex justify="space-around" align="center">
主题切换:
<n-switch />
</n-flex>
</n-drawer-content>
</n-drawer>
</template>

<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import mittBus from '@/utils/mittBus.ts';
const { t } = useI18n();
const showSettingDrawer = ref<Boolean>(false);
mittBus.on('openSettingDrawer', () => {
showSettingDrawer.value = true;
});
onBeforeUnmount(() => {
mittBus.off('openSettingDrawer');
});
</script>

<style scoped lang="scss"></style>
3 changes: 3 additions & 0 deletions src/layouts/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
border-right: var(--el-aside-border-color);
}
}
.n-layout-sider {
background-color: var(--el-aside-tree-bg-color);
}
}
}
Loading

0 comments on commit 1a0e198

Please sign in to comment.