2017-12-06 22:26:29 -05:00
|
|
|
|
<template>
|
|
|
|
|
<div id="gallery-view">
|
|
|
|
|
<div class="view-title">
|
2023-01-06 04:21:27 -05:00
|
|
|
|
{{ $T('GALLERY') }} - {{ filterList.length }}
|
|
|
|
|
<el-icon
|
|
|
|
|
style="margin-left: 4px"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
@click="toggleHandleBar"
|
|
|
|
|
>
|
|
|
|
|
<CaretBottom v-show="!handleBarActive" />
|
|
|
|
|
<CaretTop v-show="handleBarActive" />
|
|
|
|
|
</el-icon>
|
2023-02-15 10:36:47 -05:00
|
|
|
|
<span
|
|
|
|
|
style="position: absolute; right: 0; top: 0; margin-right: 20px; font-size: 0.8em; color: #fff;"
|
|
|
|
|
>同步删除云端:
|
|
|
|
|
<el-switch
|
|
|
|
|
v-model="deleteCloud"
|
|
|
|
|
:active-text="$T('SETTINGS_OPEN')"
|
|
|
|
|
:inactive-text="$T('SETTINGS_CLOSE')"
|
|
|
|
|
@change="handleDeleteCloudFile"
|
|
|
|
|
/></span>
|
2017-12-06 22:26:29 -05:00
|
|
|
|
</div>
|
2018-12-18 22:52:27 -05:00
|
|
|
|
<transition name="el-zoom-in-top">
|
2018-07-05 08:21:43 -04:00
|
|
|
|
<el-row v-show="handleBarActive">
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<el-col
|
|
|
|
|
:span="20"
|
|
|
|
|
:offset="2"
|
|
|
|
|
>
|
|
|
|
|
<el-row
|
|
|
|
|
class="handle-bar"
|
|
|
|
|
:gutter="16"
|
|
|
|
|
>
|
2018-12-18 22:52:27 -05:00
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="choosedPicBed"
|
|
|
|
|
multiple
|
|
|
|
|
collapse-tags
|
2023-01-06 04:21:27 -05:00
|
|
|
|
size="small"
|
2018-12-18 22:52:27 -05:00
|
|
|
|
style="width: 100%"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
:placeholder="$T('CHOOSE_SHOWED_PICBED')"
|
|
|
|
|
>
|
2018-12-18 22:52:27 -05:00
|
|
|
|
<el-option
|
2018-12-23 10:15:00 -05:00
|
|
|
|
v-for="item in picBed"
|
2018-12-18 22:52:27 -05:00
|
|
|
|
:key="item.type"
|
|
|
|
|
:label="item.name"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
:value="item.type"
|
|
|
|
|
/>
|
2018-12-18 22:52:27 -05:00
|
|
|
|
</el-select>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="pasteStyle"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
size="small"
|
2018-12-18 22:52:27 -05:00
|
|
|
|
style="width: 100%"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
:placeholder="$T('CHOOSE_PASTE_FORMAT')"
|
2018-12-18 22:52:27 -05:00
|
|
|
|
@change="handlePasteStyleChange"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
>
|
2018-12-18 22:52:27 -05:00
|
|
|
|
<el-option
|
|
|
|
|
v-for="(value, key) in pasteStyleMap"
|
|
|
|
|
:key="key"
|
|
|
|
|
:label="key"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
:value="value"
|
|
|
|
|
/>
|
2018-12-18 22:52:27 -05:00
|
|
|
|
</el-select>
|
2018-07-05 08:21:43 -04:00
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<el-row
|
|
|
|
|
class="handle-bar"
|
|
|
|
|
:gutter="16"
|
|
|
|
|
>
|
2018-07-05 08:21:43 -04:00
|
|
|
|
<el-col :span="12">
|
2018-12-18 22:52:27 -05:00
|
|
|
|
<el-input
|
2023-01-06 04:21:27 -05:00
|
|
|
|
v-model="searchText"
|
2022-01-11 10:57:35 -05:00
|
|
|
|
:placeholder="$T('SEARCH')"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
size="small"
|
|
|
|
|
>
|
|
|
|
|
<template #suffix>
|
|
|
|
|
<el-icon
|
|
|
|
|
class="el-input__icon"
|
|
|
|
|
style="cursor: pointer;"
|
|
|
|
|
@click="cleanSearch"
|
|
|
|
|
>
|
|
|
|
|
<close />
|
|
|
|
|
</el-icon>
|
|
|
|
|
</template>
|
2018-07-23 10:24:18 -04:00
|
|
|
|
</el-input>
|
2018-07-05 08:21:43 -04:00
|
|
|
|
</el-col>
|
2020-04-26 09:15:12 -04:00
|
|
|
|
<el-col :span="4">
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<div
|
|
|
|
|
class="item-base copy round"
|
2023-02-15 10:36:47 -05:00
|
|
|
|
:class="{ active: isMultiple(choosedList) }"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
@click="multiCopy"
|
|
|
|
|
>
|
2022-01-11 10:57:35 -05:00
|
|
|
|
{{ $T('COPY') }}
|
2018-07-05 08:21:43 -04:00
|
|
|
|
</div>
|
|
|
|
|
</el-col>
|
2020-04-26 09:15:12 -04:00
|
|
|
|
<el-col :span="4">
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<div
|
|
|
|
|
class="item-base delete round"
|
2023-02-15 10:36:47 -05:00
|
|
|
|
:class="{ active: isMultiple(choosedList) }"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
@click="multiRemove"
|
|
|
|
|
>
|
2022-01-11 10:57:35 -05:00
|
|
|
|
{{ $T('DELETE') }}
|
2020-04-26 09:15:12 -04:00
|
|
|
|
</div>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="4">
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<div
|
|
|
|
|
class="item-base all-pick round"
|
2023-02-15 10:36:47 -05:00
|
|
|
|
:class="{ active: filterList.length > 0 }"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
@click="toggleSelectAll"
|
|
|
|
|
>
|
2023-02-15 10:36:47 -05:00
|
|
|
|
{{ isAllSelected? $T('CANCEL'): $T('SELECT_ALL') }}
|
2018-07-05 08:21:43 -04:00
|
|
|
|
</div>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</transition>
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<el-row
|
|
|
|
|
class="gallery-list"
|
|
|
|
|
:class="{ small: handleBarActive }"
|
|
|
|
|
>
|
|
|
|
|
<el-col
|
|
|
|
|
:span="20"
|
|
|
|
|
:offset="2"
|
|
|
|
|
>
|
2017-12-06 22:26:29 -05:00
|
|
|
|
<el-row :gutter="16">
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<photo-slider
|
|
|
|
|
:items="filterList"
|
|
|
|
|
:visible="gallerySliderControl.visible"
|
|
|
|
|
:index="gallerySliderControl.index"
|
|
|
|
|
:should-transition="true"
|
|
|
|
|
@change-index="zoomImage"
|
|
|
|
|
@click-mask="handleClose"
|
|
|
|
|
@close-modal="handleClose"
|
|
|
|
|
/>
|
|
|
|
|
<el-col
|
|
|
|
|
v-for="(item, index) in filterList"
|
|
|
|
|
:key="item.id"
|
2023-02-15 10:36:47 -05:00
|
|
|
|
:xs="24"
|
|
|
|
|
:sm="8"
|
|
|
|
|
:md="6"
|
|
|
|
|
:lg="4"
|
|
|
|
|
:xl="3"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
class="gallery-list__img"
|
|
|
|
|
>
|
2019-12-19 06:17:21 -05:00
|
|
|
|
<div
|
2017-12-06 22:26:29 -05:00
|
|
|
|
class="gallery-list__item"
|
|
|
|
|
@click="zoomImage(index)"
|
|
|
|
|
>
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<img
|
|
|
|
|
v-lazy="item.imgUrl"
|
|
|
|
|
class="gallery-list__item-img"
|
|
|
|
|
>
|
2017-12-06 22:26:29 -05:00
|
|
|
|
</div>
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<div
|
|
|
|
|
class="gallery-list__file-name"
|
|
|
|
|
:title="item.fileName"
|
|
|
|
|
>
|
2022-12-30 22:29:36 -05:00
|
|
|
|
{{ item.fileName }}
|
|
|
|
|
</div>
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<el-row
|
|
|
|
|
class="gallery-list__tool-panel"
|
|
|
|
|
justify="space-between"
|
|
|
|
|
align="middle"
|
|
|
|
|
>
|
|
|
|
|
<el-row>
|
|
|
|
|
<el-icon
|
|
|
|
|
class="cursor-pointer document"
|
|
|
|
|
@click="copy(item)"
|
|
|
|
|
>
|
|
|
|
|
<Document />
|
|
|
|
|
</el-icon>
|
|
|
|
|
<el-icon
|
|
|
|
|
class="cursor-pointer edit"
|
|
|
|
|
@click="openDialog(item)"
|
|
|
|
|
>
|
|
|
|
|
<Edit />
|
|
|
|
|
</el-icon>
|
|
|
|
|
<el-icon
|
|
|
|
|
class="cursor-pointer delete"
|
2023-02-15 10:36:47 -05:00
|
|
|
|
@click="remove(item)"
|
2023-01-06 04:21:27 -05:00
|
|
|
|
>
|
|
|
|
|
<Delete />
|
|
|
|
|
</el-icon>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-checkbox
|
|
|
|
|
v-model="choosedList[item.id ? item.id : '']"
|
|
|
|
|
@change="(val) => handleChooseImage(val, index)"
|
|
|
|
|
/>
|
|
|
|
|
</el-row>
|
2017-12-06 22:26:29 -05:00
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
2018-04-08 11:43:34 -04:00
|
|
|
|
<el-dialog
|
2023-01-06 04:21:27 -05:00
|
|
|
|
v-model="dialogVisible"
|
2022-01-11 10:57:35 -05:00
|
|
|
|
:title="$T('CHANGE_IMAGE_URL')"
|
2018-04-08 11:43:34 -04:00
|
|
|
|
width="500px"
|
|
|
|
|
:modal-append-to-body="false"
|
|
|
|
|
>
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<el-input v-model="imgInfo.imgUrl" />
|
2023-02-15 10:36:47 -05:00
|
|
|
|
<template #footer>
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<el-button @click="dialogVisible = false">
|
|
|
|
|
{{ $T('CANCEL') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="confirmModify"
|
|
|
|
|
>
|
|
|
|
|
{{ $T('CONFIRM') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</template>
|
2018-04-08 11:43:34 -04:00
|
|
|
|
</el-dialog>
|
2017-12-06 22:26:29 -05:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2023-01-06 04:21:27 -05:00
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import type { IResult } from '@picgo/store/dist/types'
|
2022-08-20 22:54:30 -04:00
|
|
|
|
import { PASTE_TEXT, GET_PICBEDS } from '#/events/constants'
|
2023-02-15 10:36:47 -05:00
|
|
|
|
import { CheckboxValueType, ElMessageBox, ElNotification } from 'element-plus'
|
2023-01-06 04:21:27 -05:00
|
|
|
|
import { Close, CaretBottom, Document, Edit, Delete, CaretTop } from '@element-plus/icons-vue'
|
2019-12-19 06:17:21 -05:00
|
|
|
|
import {
|
|
|
|
|
ipcRenderer,
|
|
|
|
|
clipboard,
|
|
|
|
|
IpcRendererEvent
|
|
|
|
|
} from 'electron'
|
2023-01-06 04:21:27 -05:00
|
|
|
|
import { computed, nextTick, onActivated, onBeforeUnmount, onBeforeMount, reactive, ref, watch } from 'vue'
|
|
|
|
|
import { getConfig, saveConfig, sendToMain } from '@/utils/dataSender'
|
|
|
|
|
import { onBeforeRouteUpdate } from 'vue-router'
|
|
|
|
|
import { T as $T } from '@/i18n/index'
|
|
|
|
|
import $$db from '@/utils/db'
|
2023-02-15 10:36:47 -05:00
|
|
|
|
import ALLApi from '@/apis/allApi'
|
2023-01-06 04:21:27 -05:00
|
|
|
|
const images = ref<ImgInfo[]>([])
|
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
const imgInfo = reactive({
|
|
|
|
|
id: '',
|
|
|
|
|
imgUrl: ''
|
2019-12-19 06:17:21 -05:00
|
|
|
|
})
|
2023-01-06 04:21:27 -05:00
|
|
|
|
const $confirm = ElMessageBox.confirm
|
|
|
|
|
const choosedList: IObjT<boolean> = reactive({})
|
|
|
|
|
const gallerySliderControl = reactive({
|
|
|
|
|
visible: false,
|
|
|
|
|
index: 0
|
|
|
|
|
})
|
2023-02-15 10:36:47 -05:00
|
|
|
|
const deleteCloud = ref<boolean>(false)
|
2023-01-06 04:21:27 -05:00
|
|
|
|
const choosedPicBed = ref<string[]>([])
|
|
|
|
|
const lastChoosed = ref<number>(-1)
|
|
|
|
|
const isShiftKeyPress = ref<boolean>(false)
|
|
|
|
|
const searchText = ref<string>('')
|
|
|
|
|
const handleBarActive = ref<boolean>(false)
|
|
|
|
|
const pasteStyle = ref<string>('')
|
|
|
|
|
const pasteStyleMap = {
|
|
|
|
|
Markdown: 'markdown',
|
|
|
|
|
HTML: 'HTML',
|
|
|
|
|
URL: 'URL',
|
|
|
|
|
UBB: 'UBB',
|
|
|
|
|
Custom: 'Custom'
|
|
|
|
|
}
|
|
|
|
|
const picBed = ref<IPicBedType[]>([])
|
|
|
|
|
onBeforeRouteUpdate((to, from) => {
|
|
|
|
|
if (from.name === 'gallery') {
|
|
|
|
|
clearChoosedList()
|
2019-12-19 06:17:21 -05:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
if (to.name === 'gallery') {
|
|
|
|
|
updateGallery()
|
2019-12-19 06:17:21 -05:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
})
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-02-15 10:36:47 -05:00
|
|
|
|
// init deleteCloud
|
|
|
|
|
async function initDeleteCloud () {
|
|
|
|
|
const config = await getConfig() as any
|
|
|
|
|
deleteCloud.value = config.settings.deleteCloudFile || false
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
onBeforeMount(async () => {
|
|
|
|
|
ipcRenderer.on('updateGallery', () => {
|
|
|
|
|
nextTick(async () => {
|
|
|
|
|
updateGallery()
|
2018-08-07 23:21:08 -04:00
|
|
|
|
})
|
2023-01-06 04:21:27 -05:00
|
|
|
|
})
|
|
|
|
|
sendToMain(GET_PICBEDS)
|
|
|
|
|
ipcRenderer.on(GET_PICBEDS, getPicBeds)
|
|
|
|
|
updateGallery()
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
document.addEventListener('keydown', handleDetectShiftKey)
|
|
|
|
|
document.addEventListener('keyup', handleDetectShiftKey)
|
|
|
|
|
})
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function handleDetectShiftKey (event: KeyboardEvent) {
|
|
|
|
|
if (event.key === 'Shift') {
|
|
|
|
|
if (event.type === 'keydown') {
|
|
|
|
|
isShiftKeyPress.value = true
|
|
|
|
|
} else if (event.type === 'keyup') {
|
|
|
|
|
isShiftKeyPress.value = false
|
2020-04-26 09:15:12 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
const filterList = computed(() => {
|
|
|
|
|
return getGallery()
|
|
|
|
|
})
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
const isAllSelected = computed(() => {
|
|
|
|
|
const values = Object.values(choosedList)
|
|
|
|
|
if (values.length === 0) {
|
|
|
|
|
return false
|
|
|
|
|
} else {
|
|
|
|
|
return filterList.value.every(item => {
|
|
|
|
|
return choosedList[item.id!]
|
|
|
|
|
})
|
2020-04-26 09:15:12 -04:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
})
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function getPicBeds (event: IpcRendererEvent, picBeds: IPicBedType[]) {
|
|
|
|
|
picBed.value = picBeds
|
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function getGallery (): IGalleryItem[] {
|
|
|
|
|
if (searchText.value || choosedPicBed.value.length > 0) {
|
|
|
|
|
return images.value
|
|
|
|
|
.filter(item => {
|
|
|
|
|
let isInChoosedPicBed = true
|
|
|
|
|
let isIncludesSearchText = true
|
|
|
|
|
if (choosedPicBed.value.length > 0) {
|
|
|
|
|
isInChoosedPicBed = choosedPicBed.value.some(type => type === item.type)
|
|
|
|
|
}
|
|
|
|
|
if (searchText.value) {
|
|
|
|
|
isIncludesSearchText = item.fileName?.includes(searchText.value) || false
|
|
|
|
|
}
|
|
|
|
|
return isIncludesSearchText && isInChoosedPicBed
|
|
|
|
|
}).map(item => {
|
|
|
|
|
return {
|
|
|
|
|
...item,
|
|
|
|
|
src: item.imgUrl || '',
|
|
|
|
|
key: (item.id || `${Date.now()}`),
|
|
|
|
|
intro: item.fileName || ''
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
return images.value.map(item => {
|
|
|
|
|
return {
|
|
|
|
|
...item,
|
|
|
|
|
src: item.imgUrl || '',
|
|
|
|
|
key: (item.id || `${Date.now()}`),
|
|
|
|
|
intro: item.fileName || ''
|
|
|
|
|
}
|
|
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
async function updateGallery () {
|
|
|
|
|
images.value = (await $$db.get({ orderBy: 'desc' })).data
|
|
|
|
|
}
|
2021-07-26 12:15:11 -04:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
watch(() => filterList, () => {
|
|
|
|
|
clearChoosedList()
|
|
|
|
|
})
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function handleChooseImage (val: CheckboxValueType, index: number) {
|
|
|
|
|
if (val === true) {
|
|
|
|
|
handleBarActive.value = true
|
|
|
|
|
if (lastChoosed.value !== -1 && isShiftKeyPress.value) {
|
|
|
|
|
const min = Math.min(lastChoosed.value, index)
|
|
|
|
|
const max = Math.max(lastChoosed.value, index)
|
|
|
|
|
for (let i = min + 1; i < max; i++) {
|
|
|
|
|
const id = filterList.value[i].id!
|
|
|
|
|
choosedList[id] = true
|
2020-04-26 09:15:12 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
lastChoosed.value = index
|
2020-04-26 09:15:12 -04:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function clearChoosedList () {
|
|
|
|
|
isShiftKeyPress.value = false
|
|
|
|
|
Object.keys(choosedList).forEach(key => {
|
|
|
|
|
choosedList[key] = false
|
|
|
|
|
})
|
|
|
|
|
lastChoosed.value = -1
|
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function zoomImage (index: number) {
|
|
|
|
|
gallerySliderControl.index = index
|
|
|
|
|
gallerySliderControl.visible = true
|
|
|
|
|
changeZIndexForGallery(true)
|
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function changeZIndexForGallery (isOpen: boolean) {
|
|
|
|
|
if (isOpen) {
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
document.querySelector('.main-content.el-row').style.zIndex = 101
|
|
|
|
|
} else {
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
document.querySelector('.main-content.el-row').style.zIndex = 10
|
2019-12-19 06:17:21 -05:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function handleClose () {
|
|
|
|
|
gallerySliderControl.index = 0
|
|
|
|
|
gallerySliderControl.visible = false
|
|
|
|
|
changeZIndexForGallery(false)
|
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
async function copy (item: ImgInfo) {
|
2023-02-20 22:59:26 -05:00
|
|
|
|
item.config = JSON.parse(JSON.stringify(item.config))
|
2023-01-06 04:21:27 -05:00
|
|
|
|
const copyLink = await ipcRenderer.invoke(PASTE_TEXT, item)
|
|
|
|
|
const obj = {
|
|
|
|
|
title: $T('COPY_LINK_SUCCEED'),
|
|
|
|
|
body: copyLink
|
|
|
|
|
// sometimes will cause lagging
|
|
|
|
|
// icon: item.url || item.imgUrl
|
|
|
|
|
}
|
|
|
|
|
const myNotification = new Notification(obj.title, obj)
|
|
|
|
|
myNotification.onclick = () => {
|
|
|
|
|
return true
|
2019-12-19 06:17:21 -05:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-02-15 10:36:47 -05:00
|
|
|
|
function remove (item: ImgInfo) {
|
|
|
|
|
if (item.id) {
|
2023-01-06 04:21:27 -05:00
|
|
|
|
$confirm($T('TIPS_REMOVE_LINK'), $T('TIPS_NOTICE'), {
|
|
|
|
|
confirmButtonText: $T('CONFIRM'),
|
|
|
|
|
cancelButtonText: $T('CANCEL'),
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(async () => {
|
2023-02-15 10:36:47 -05:00
|
|
|
|
const file = await $$db.getById(item.id!)
|
|
|
|
|
await $$db.removeById(item.id!)
|
2023-02-22 10:52:38 -05:00
|
|
|
|
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist']
|
2023-02-15 10:36:47 -05:00
|
|
|
|
if (await getConfig('settings.deleteCloudFile')) {
|
|
|
|
|
if (item.type !== undefined && picBedsCanbeDeleted.includes(item.type)) {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
ALLApi.delete(item).then((value: boolean) => {
|
|
|
|
|
if (value) {
|
|
|
|
|
ElNotification({
|
|
|
|
|
title: '通知',
|
|
|
|
|
message: `${item.fileName} 云端删除成功`,
|
|
|
|
|
type: 'success'
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
ElNotification({
|
|
|
|
|
title: '通知',
|
|
|
|
|
message: `${item.fileName} 云端删除失败`,
|
|
|
|
|
type: 'error'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}, 0)
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
sendToMain('removeFiles', [file])
|
|
|
|
|
const obj = {
|
|
|
|
|
title: $T('OPERATION_SUCCEED'),
|
|
|
|
|
body: ''
|
|
|
|
|
}
|
|
|
|
|
const myNotification = new Notification(obj.title, obj)
|
|
|
|
|
myNotification.onclick = () => {
|
2018-07-24 11:15:19 -04:00
|
|
|
|
return true
|
2023-01-06 04:21:27 -05:00
|
|
|
|
}
|
|
|
|
|
updateGallery()
|
|
|
|
|
}).catch((e) => {
|
|
|
|
|
console.log(e)
|
2019-12-19 06:17:21 -05:00
|
|
|
|
return true
|
2023-01-06 04:21:27 -05:00
|
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-02-15 10:36:47 -05:00
|
|
|
|
function handleDeleteCloudFile (val: ICheckBoxValueType) {
|
|
|
|
|
saveConfig({
|
|
|
|
|
'settings.deleteCloudFile': val
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function openDialog (item: ImgInfo) {
|
|
|
|
|
imgInfo.id = item.id!
|
|
|
|
|
imgInfo.imgUrl = item.imgUrl as string
|
|
|
|
|
dialogVisible.value = true
|
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
async function confirmModify () {
|
|
|
|
|
await $$db.updateById(imgInfo.id, {
|
|
|
|
|
imgUrl: imgInfo.imgUrl
|
|
|
|
|
})
|
|
|
|
|
const obj = {
|
|
|
|
|
title: $T('CHANGE_IMAGE_URL_SUCCEED'),
|
|
|
|
|
body: imgInfo.imgUrl
|
|
|
|
|
}
|
|
|
|
|
const myNotification = new Notification(obj.title, obj)
|
|
|
|
|
myNotification.onclick = () => {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
updateGallery()
|
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function cleanSearch () {
|
|
|
|
|
searchText.value = ''
|
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function isMultiple (obj: IObj) {
|
|
|
|
|
return Object.values(obj).some(item => item)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleSelectAll () {
|
|
|
|
|
const result = !isAllSelected.value
|
|
|
|
|
filterList.value.forEach(item => {
|
|
|
|
|
choosedList[item.id!] = result
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function multiRemove () {
|
|
|
|
|
// choosedList -> { [id]: true or false }; true means choosed. false means not choosed.
|
|
|
|
|
const multiRemoveNumber = Object.values(choosedList).filter(item => item).length
|
|
|
|
|
if (multiRemoveNumber) {
|
|
|
|
|
$confirm($T('TIPS_WILL_REMOVE_CHOOSED_IMAGES', {
|
|
|
|
|
m: multiRemoveNumber
|
|
|
|
|
}), $T('TIPS_NOTICE'), {
|
|
|
|
|
confirmButtonText: $T('CONFIRM'),
|
|
|
|
|
cancelButtonText: $T('CANCEL'),
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(async () => {
|
|
|
|
|
const files: IResult<ImgInfo>[] = []
|
|
|
|
|
const imageIDList = Object.keys(choosedList)
|
2023-02-15 10:36:47 -05:00
|
|
|
|
const isDeleteCloudFile = await getConfig('settings.deleteCloudFile')
|
|
|
|
|
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun']
|
|
|
|
|
if (isDeleteCloudFile) {
|
|
|
|
|
for (let i = 0; i < imageIDList.length; i++) {
|
|
|
|
|
const key = imageIDList[i]
|
|
|
|
|
if (choosedList[key]) {
|
|
|
|
|
const file = await $$db.getById<ImgInfo>(key)
|
|
|
|
|
if (file) {
|
|
|
|
|
if (file.type !== undefined && picBedsCanbeDeleted.includes(file.type)) {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
ALLApi.delete(file).then((value: boolean) => {
|
|
|
|
|
if (value) {
|
|
|
|
|
ElNotification({
|
|
|
|
|
title: '通知',
|
|
|
|
|
message: `${file.fileName} 云端删除成功`,
|
|
|
|
|
type: 'success',
|
|
|
|
|
duration: multiRemoveNumber > 5 ? 1000 : 2000
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
ElNotification({
|
|
|
|
|
title: '通知',
|
|
|
|
|
message: `${file.fileName} 云端删除失败`,
|
|
|
|
|
type: 'error',
|
|
|
|
|
duration: multiRemoveNumber > 5 ? 1000 : 2000
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}, 0)
|
|
|
|
|
}
|
|
|
|
|
files.push(file)
|
|
|
|
|
await $$db.removeById(key)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (let i = 0; i < imageIDList.length; i++) {
|
|
|
|
|
const key = imageIDList[i]
|
|
|
|
|
if (choosedList[key]) {
|
|
|
|
|
const file = await $$db.getById<ImgInfo>(key)
|
|
|
|
|
if (file) {
|
|
|
|
|
files.push(file)
|
|
|
|
|
await $$db.removeById(key)
|
|
|
|
|
}
|
2021-07-25 11:25:36 -04:00
|
|
|
|
}
|
2019-12-19 06:17:21 -05:00
|
|
|
|
}
|
2021-07-25 11:25:36 -04:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
clearChoosedList()
|
|
|
|
|
// TODO: check this
|
|
|
|
|
// choosedList = {} // 只有删除才能将这个置空
|
2018-04-08 11:43:34 -04:00
|
|
|
|
const obj = {
|
2023-01-06 04:21:27 -05:00
|
|
|
|
title: $T('OPERATION_SUCCEED'),
|
|
|
|
|
body: ''
|
2018-04-08 11:43:34 -04:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
sendToMain('removeFiles', files)
|
2019-12-19 06:17:21 -05:00
|
|
|
|
const myNotification = new Notification(obj.title, obj)
|
2018-04-08 11:43:34 -04:00
|
|
|
|
myNotification.onclick = () => {
|
|
|
|
|
return true
|
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
updateGallery()
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
return true
|
|
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
async function multiCopy () {
|
|
|
|
|
if (Object.values(choosedList).some(item => item)) {
|
|
|
|
|
const copyString: string[] = []
|
|
|
|
|
// choosedList -> { [id]: true or false }; true means choosed. false means not choosed.
|
|
|
|
|
const imageIDList = Object.keys(choosedList)
|
|
|
|
|
for (let i = 0; i < imageIDList.length; i++) {
|
|
|
|
|
const key = imageIDList[i]
|
|
|
|
|
if (choosedList[key]) {
|
|
|
|
|
const item = await $$db.getById<ImgInfo>(key)
|
|
|
|
|
if (item) {
|
|
|
|
|
const txt = await ipcRenderer.invoke(PASTE_TEXT, item)
|
|
|
|
|
copyString.push(txt)
|
|
|
|
|
choosedList[key] = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const obj = {
|
|
|
|
|
title: $T('BATCH_COPY_LINK_SUCCEED'),
|
|
|
|
|
body: copyString.join('\n')
|
|
|
|
|
}
|
|
|
|
|
const myNotification = new Notification(obj.title, obj)
|
|
|
|
|
clipboard.writeText(copyString.join('\n'))
|
|
|
|
|
myNotification.onclick = () => {
|
|
|
|
|
return true
|
|
|
|
|
}
|
2019-12-19 06:17:21 -05:00
|
|
|
|
}
|
2023-01-06 04:21:27 -05:00
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
function toggleHandleBar () {
|
|
|
|
|
handleBarActive.value = !handleBarActive.value
|
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
2023-01-06 04:21:27 -05:00
|
|
|
|
async function handlePasteStyleChange (val: string) {
|
|
|
|
|
saveConfig('settings.pasteStyle', val)
|
|
|
|
|
pasteStyle.value = val
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
ipcRenderer.removeAllListeners('updateGallery')
|
|
|
|
|
ipcRenderer.removeListener(GET_PICBEDS, getPicBeds)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onActivated(async () => {
|
|
|
|
|
pasteStyle.value = (await getConfig('settings.pasteStyle')) || 'markdown'
|
2023-02-15 10:36:47 -05:00
|
|
|
|
initDeleteCloud()
|
2023-01-06 04:21:27 -05:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
<script lang="ts">
|
|
|
|
|
export default {
|
|
|
|
|
name: 'GalleryPage'
|
2017-12-06 22:26:29 -05:00
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<style lang='stylus'>
|
2023-01-06 04:21:27 -05:00
|
|
|
|
.PhotoSlider
|
|
|
|
|
&__BannerIcon
|
|
|
|
|
&:nth-child(1)
|
|
|
|
|
display none
|
|
|
|
|
&__Counter
|
|
|
|
|
margin-top 20px
|
2017-12-06 22:26:29 -05:00
|
|
|
|
.view-title
|
|
|
|
|
color #eee
|
|
|
|
|
font-size 20px
|
|
|
|
|
text-align center
|
2018-04-28 04:22:35 -04:00
|
|
|
|
margin 10px auto
|
|
|
|
|
.sub-title
|
|
|
|
|
font-size 14px
|
2018-07-05 08:21:43 -04:00
|
|
|
|
.el-icon-caret-bottom
|
|
|
|
|
cursor: pointer
|
|
|
|
|
transition all .2s ease-in-out
|
|
|
|
|
&.active
|
|
|
|
|
transform: rotate(180deg)
|
2019-01-23 22:29:48 -05:00
|
|
|
|
#gallery-view
|
|
|
|
|
height 100%
|
2023-01-06 04:21:27 -05:00
|
|
|
|
.cursor-pointer
|
|
|
|
|
cursor pointer
|
2018-06-19 01:45:07 -04:00
|
|
|
|
.item-base
|
|
|
|
|
background #2E2E2E
|
|
|
|
|
text-align center
|
2018-06-20 08:45:12 -04:00
|
|
|
|
padding 5px 0
|
2018-06-19 01:45:07 -04:00
|
|
|
|
cursor pointer
|
|
|
|
|
font-size 13px
|
|
|
|
|
transition all .2s ease-in-out
|
2018-12-18 22:52:27 -05:00
|
|
|
|
height: 28px
|
|
|
|
|
box-sizing: border-box
|
2018-07-23 10:24:18 -04:00
|
|
|
|
&.copy
|
|
|
|
|
cursor not-allowed
|
|
|
|
|
background #49B1F5
|
|
|
|
|
&.active
|
|
|
|
|
cursor pointer
|
|
|
|
|
background #1B9EF3
|
|
|
|
|
color #fff
|
2018-06-19 01:45:07 -04:00
|
|
|
|
&.delete
|
|
|
|
|
cursor not-allowed
|
2018-06-20 08:45:12 -04:00
|
|
|
|
background #F47466
|
2018-07-23 10:24:18 -04:00
|
|
|
|
&.active
|
|
|
|
|
cursor pointer
|
|
|
|
|
background #F15140
|
|
|
|
|
color #fff
|
2020-04-26 09:15:12 -04:00
|
|
|
|
&.all-pick
|
|
|
|
|
cursor not-allowed
|
|
|
|
|
background #69C282
|
|
|
|
|
&.active
|
|
|
|
|
cursor pointer
|
|
|
|
|
background #44B363
|
|
|
|
|
color #fff
|
2017-12-06 22:26:29 -05:00
|
|
|
|
#gallery-view
|
2018-07-05 08:21:43 -04:00
|
|
|
|
position relative
|
2018-12-18 22:52:27 -05:00
|
|
|
|
.round
|
|
|
|
|
border-radius 14px
|
2018-06-19 01:45:07 -04:00
|
|
|
|
.pull-right
|
|
|
|
|
float right
|
2017-12-06 22:26:29 -05:00
|
|
|
|
.gallery-list
|
2023-02-15 10:36:47 -05:00
|
|
|
|
height 100%
|
2017-12-06 22:26:29 -05:00
|
|
|
|
box-sizing border-box
|
|
|
|
|
padding 8px 0
|
|
|
|
|
overflow-y auto
|
|
|
|
|
overflow-x hidden
|
2018-07-05 08:21:43 -04:00
|
|
|
|
position absolute
|
|
|
|
|
top: 38px
|
|
|
|
|
transition all .2s ease-in-out .1s
|
2018-07-06 11:54:36 -04:00
|
|
|
|
width 100%
|
2018-07-05 08:21:43 -04:00
|
|
|
|
&.small
|
2023-02-15 10:36:47 -05:00
|
|
|
|
height: 100%
|
2018-12-18 22:52:27 -05:00
|
|
|
|
top: 113px
|
2018-06-19 01:45:07 -04:00
|
|
|
|
&__img
|
2023-01-06 04:21:27 -05:00
|
|
|
|
// height 150px
|
2017-12-06 22:26:29 -05:00
|
|
|
|
position relative
|
2023-01-06 04:21:27 -05:00
|
|
|
|
margin-bottom 8px
|
2017-12-06 22:26:29 -05:00
|
|
|
|
&__item
|
|
|
|
|
width 100%
|
|
|
|
|
height 120px
|
|
|
|
|
transition all .2s ease-in-out
|
|
|
|
|
cursor pointer
|
2022-12-30 22:29:36 -05:00
|
|
|
|
margin-bottom 4px
|
2019-03-26 05:18:52 -04:00
|
|
|
|
overflow hidden
|
|
|
|
|
display flex
|
2023-01-06 04:21:27 -05:00
|
|
|
|
margin-bottom 6px
|
2017-12-06 22:26:29 -05:00
|
|
|
|
&-fake
|
|
|
|
|
position absolute
|
|
|
|
|
top 0
|
2019-12-19 06:17:21 -05:00
|
|
|
|
left 0
|
2017-12-06 22:26:29 -05:00
|
|
|
|
opacity 0
|
|
|
|
|
width 100%
|
|
|
|
|
z-index -1
|
|
|
|
|
&:hover
|
|
|
|
|
transform scale(1.1)
|
2019-03-26 05:18:52 -04:00
|
|
|
|
&-img
|
|
|
|
|
width 100%
|
|
|
|
|
object-fit fill
|
2017-12-06 22:26:29 -05:00
|
|
|
|
&__tool-panel
|
|
|
|
|
color #ddd
|
2022-12-30 22:29:36 -05:00
|
|
|
|
margin-bottom 4px
|
2023-01-06 04:21:27 -05:00
|
|
|
|
display flex
|
|
|
|
|
.el-checkbox
|
|
|
|
|
height 16px
|
2017-12-06 22:26:29 -05:00
|
|
|
|
i
|
|
|
|
|
cursor pointer
|
|
|
|
|
transition all .2s ease-in-out
|
2023-01-06 04:21:27 -05:00
|
|
|
|
margin-right 4px
|
|
|
|
|
&.document
|
2017-12-06 22:26:29 -05:00
|
|
|
|
&:hover
|
|
|
|
|
color #49B1F5
|
2023-01-06 04:21:27 -05:00
|
|
|
|
&.edit
|
2018-04-08 11:43:34 -04:00
|
|
|
|
&:hover
|
|
|
|
|
color #69C282
|
2023-01-06 04:21:27 -05:00
|
|
|
|
&.delete
|
2017-12-06 22:26:29 -05:00
|
|
|
|
&:hover
|
|
|
|
|
color #F15140
|
2022-12-30 22:29:36 -05:00
|
|
|
|
&__file-name
|
|
|
|
|
overflow hidden
|
|
|
|
|
text-overflow ellipsis
|
|
|
|
|
white-space nowrap
|
|
|
|
|
color #ddd
|
|
|
|
|
font-size 14px
|
|
|
|
|
margin-bottom 4px
|
2018-06-19 01:45:07 -04:00
|
|
|
|
.handle-bar
|
|
|
|
|
color #ddd
|
2018-12-18 22:52:27 -05:00
|
|
|
|
margin-bottom 10px
|
2019-12-19 06:17:21 -05:00
|
|
|
|
</style>
|