168 lines
4.3 KiB
Vue

<template>
<div class="location">
<el-tooltip
effect="dark"
:content="t('toolbar.location.to-begin')"
placement="bottom"
raw-content
>
<div
class="item iconfont icon-beginning"
@click="toBegin()"
/>
</el-tooltip>
<el-tooltip
effect="dark"
:content="t('toolbar.location.to-end')"
placement="bottom"
raw-content
>
<div
class="item iconfont icon-ending"
@click="toEnd()"
/>
</el-tooltip>
<el-divider direction="vertical"></el-divider>
<el-tooltip
effect="dark"
:content="t('toolbar.location.to-prev-change')"
placement="bottom"
raw-content
>
<div
class="item iconfont icon-arrow-to-previous"
:class="{ 'disable' : globalLookup.sidebarSelectedWireLinks.size === 0 }"
@click="toPrevChange()"
/>
</el-tooltip>
<el-tooltip
effect="dark"
:content="t('toolbar.location.to-next-change')"
placement="bottom"
raw-content
>
<div
class="item iconfont icon-arrow-to-next"
:class="{ 'disable' : globalLookup.sidebarSelectedWireLinks.size === 0 }"
@click="toNextChange()"
/>
</el-tooltip>
<el-divider direction="vertical"></el-divider>
<el-tooltip
effect="dark"
:content="t('toolbar.location.make-location')"
placement="bottom"
raw-content
>
<div
class="item iconfont icon-add-line"
:class="{ 'disable' : !SystemPivot.show }"
@click="makePivot()"
/>
</el-tooltip>
<el-tooltip
effect="dark"
:content="t('toolbar.location.clear-location')"
placement="bottom"
raw-content
>
<div
class="item iconfont icon-clear"
:class="{ 'disable' : UserPivots.size === 0 }"
@click="clearLocationDialogShow = true"
/>
</el-tooltip>
<el-dialog
v-model="clearLocationDialogShow"
class="language-dialog"
:title="t('tips')"
width="500"
>
<span>{{ t('toolbar.location.clear-location-dialog') }}</span>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="confirmClearLocation()">
{{ t('confirm') }}
</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { defineComponent, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { clearAllPivot, makePivot, toBegin, toEnd, toNextChange, toPrevChange } from './cursor-location';
import { globalLookup } from '@/hook/global';
import { SystemPivot } from '../pivot/cursor';
import { currentPivotId, Id2Pivot, orderedTimes, UserPivotCtxShows, UserPivots } from '../pivot/pivot-view';
defineComponent({ name: 'cursor-location' });
const { t } = useI18n();
const clearLocationDialogShow = ref(false);
function confirmClearLocation() {
orderedTimes.length === 0;
UserPivots.clear();
Id2Pivot.clear();
currentPivotId.value = 0;
UserPivotCtxShows.clear();
clearLocationDialogShow.value = false;
}
</script>
<style scoped>
.location {
display: flex;
align-items: center;
height: 32px;
padding: 1px 5px;
background-color: var(--sidebar);
border-radius: .5em;
}
.location .item {
border-radius: .5em;
display: flex;
align-items: center;
justify-content: center;
margin-left: 3px;
height: 32px;
font-weight: 800;
width: 32px;
cursor: pointer;
transition: var(--animation-3s);
}
.location .item:hover {
background-color: var(--main-color);
color: var(--sidebar);
transition: var(--animation-3s);
}
.disable {
opacity: 0.5;
cursor: not-allowed !important;
}
.location .item.disable:hover {
background-color: unset !important;
color: unset !important;
}
</style>