Skip to content

Commit

Permalink
feature: adjust the main layout
Browse files Browse the repository at this point in the history
  • Loading branch information
terasum committed Dec 7, 2023
1 parent d2ed5aa commit a7c57b9
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 17 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/layout/AppFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
>
</span>

<span class="split-line"></span>
<!-- <span class="split-line"></span>
<span class="hyperlink">
<b>
<span class="icon icon-gauge"></span>
Expand All @@ -50,7 +50,7 @@
<span class="icon icon-book"></span>
词典下载
</b>
</span>
</span> -->

<span class="split-line"></span>

Expand Down
28 changes: 22 additions & 6 deletions frontend/src/view/main/MainContentFrame.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,26 @@
width: 100%;
height: calc(100% - $layout-header-height);
.app-content-main-toolbar {
height: 26px;
height: 30px;
display: flex;
flex-direction: row-reverse;
background-color: #f6f8fa;
flex-direction: row;
justify-content: space-between;
box-shadow: inset 0 calc(max(1px, 0.0625rem) * -1) #d0d7de;
background-color: #f6f8fa;
.toolbar-dicts{
width: calc(100% - 30px);
}
.toolbar-boxes{
display: flex;
.app-content-main-toolbar-box {
display: block;
height: 22px;
width: 22px;
height: 24px;
width: 24px;
border: 1px solid #d1d7dd;
font-size: 16px;
text-align: center;
line-height: 22px;
line-height: 24px;
margin-left: 3px;
margin-right: 3px;
margin-top: 2px;
Expand All @@ -48,6 +55,7 @@
}
}
}
}
#app-content-main-iframe-wrapper {
height: calc(100% - 16px);
padding: 8px 4px;
Expand All @@ -60,7 +68,12 @@
</style>
<template>
<div class="app-content-main">

<div class="app-content-main-toolbar">
<div class="toolbar-dicts">
<MainDictsToolbar/>
</div>
<div class="toolbar-boxes">
<span class="app-content-main-toolbar-box" @click="todo"
><NIcon><Bug16Regular /></NIcon
></span>
Expand All @@ -77,6 +90,7 @@
<span class="app-content-main-toolbar-box" @click="zoomOut"
><NIcon><ZoomIn16Regular /></NIcon
></span>
</div>
</div>
<div id="app-content-main-iframe-wrapper"></div>
</div>
Expand All @@ -89,6 +103,8 @@ import { ZoomIn16Regular, ZoomOut16Regular,ArrowClockwise20Filled, Bug16Regular,
import { NIcon } from 'naive-ui';
import { useMessage } from 'naive-ui';
import MainDictsToolbar from "./MainDictsToolbar.vue";
const dictQueryStore = useDictQueryStore();
const message = useMessage();
Expand Down
170 changes: 170 additions & 0 deletions frontend/src/view/main/MainDictsToolbar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<!--
Copyright (C) 2023 Quan Chen <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<style lang="scss" scoped>
@import '@/style/variables.scss';
.dictionaries {
display: flex;
flex-direction: row;
height: 100%;
.dictionary-item {
margin: 4px 3px;
display: block;
width: 22px;
height: 22px;
text-align: center;
line-height: 26px;
border-radius: 3px;
cursor: pointer;
user-select: none;
-webkit-user-select: none;
// box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;
box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px,
rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;
&:hover {
background-color: #f1f1f1;
}
}
.dictionary-item-active {
}
}
</style>
<template>
<div class="dictionaries">
<span
v-for="item in state.dictList"
class="dictionary-item"
:class="
item.id == dictQueryStore.selectDict.id ? 'dictionary-item-active' : ''
"
:key="item.id"
@click="chooseDict(item)"
:style="getBackground(item)"
></span>
</div>
</template>
<script setup>
import { useDictQueryStore } from '@/store/dict';
import { useUIStore } from '@/store/ui';
import { reactive, onMounted } from 'vue';
import { BuildIndex } from '@/apis/dicts-api';
import AppRightToolbar from '@/components/layout/AppRightToolbar.vue';
import { NPopover } from 'naive-ui';
const dictQueryStore = useDictQueryStore();
const uiStore = useUIStore();
const state = reactive({
dictList: [],
});
function chooseDict(item) {
dictQueryStore.updateSelectDict(item);
}
function getBackground(item) {
if (item.background) {
let style = `background:url(${item.background});`;
style += `background-size:cover;`;
style += `background-repeat:no-repeat;`;
style += `background-position:center;`;
style += `color: #fff;`;
return style;
}
return '';
}
function loadDictionaries() {
dictQueryStore.queryDictList().then((res) => {
console.log('[app-init] loading dictionaries success, result:', res);
if (res.length > 0) {
dictQueryStore.updateSelectDict(res[0]);
}
const totalNumber = res.length;
const updater = updateProgress(totalNumber);
function sequenceHandle(promiseArr) {
const pro = promiseArr.shift();
if (pro && pro.handle) {
pro.handle().then((resp) => {
pro.callback(resp);
sequenceHandle(promiseArr);
});
}
}
function buildIndexPromise(i, id, name) {
return {
handle: function () {
return BuildIndex(id);
},
callback: function (resp) {
let progressHint = `词典 ${name} 加载完成`;
console.log(`[app-init] building success, index: ${i}`, resp);
updater(progressHint);
},
};
}
let promiseArray = [];
for (let i = 0; i < res.length; i++) {
state.dictList.push(res[i]);
promiseArray.push(buildIndexPromise(i, res[i].id, res[i].name));
}
sequenceHandle(promiseArray);
});
}
function updateProgress(totalNumber) {
let total = totalNumber;
let count = 0;
let plist = [];
let progress = 0;
let intv = setInterval(() => {
if (plist.length > 0) {
let item = plist.shift();
count++;
progress = (count / total) * 100;
uiStore.updateProgress(item.hint, progress);
if (progress >= 100) {
clearInterval(intv);
setTimeout(() => {
uiStore.updateProgress('全部加载完成', 100);
}, 150);
}
}
}, 200);
return function (hint) {
plist.push({
hint: hint,
});
};
}
onMounted(() => {
dictQueryStore.initDicts().then((res) => {
console.log('[dict-api] init dicts success, result:', res);
loadDictionaries();
});
});
</script>
8 changes: 4 additions & 4 deletions frontend/src/view/main/MainFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@

<template>
<AppFooter>
<div class="building-index-process">
<!-- <div class="building-index-process">
<n-progress
type="line"
color="#c1c1c1"
:show-indicator="false"
:percentage="percnetage"
/>
</div>
<span class="split-line"></span>
</div> -->
<!-- <span class="split-line"></span> -->

<span class="index-process-hint">
<em>{{ percentage_hint }}</em>
<span>{{ percentage_hint }}</span>
</span>
</AppFooter>
</template>
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/view/main/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
</div>
</div>
</div>
<div class="x-layout-right-toolbar">
<!-- <div class="x-layout-right-toolbar">
<MainRightToolbar />
</div>
</div> -->
</div>
<div class="n-layout-footer">
<MainFooter />
Expand Down Expand Up @@ -97,9 +97,8 @@ uiStore.updateCurrentTab("search");
}
.x-layout-content {
width: calc(
100% - $layout-left-sidebar-width - $layout-right-toolbar-width
);
// width: calc(100% - $layout-left-sidebar-width - $layout-right-toolbar-width);
width: calc(100% - $layout-left-sidebar-width);
height: 100%;
padding: 0;
margin: 0;
Expand Down

0 comments on commit a7c57b9

Please sign in to comment.