mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-08 13:28:13 -05:00
✨ Feature: add autoCopy option for users to use or not
This commit is contained in:
parent
cd70a1a5cc
commit
67e526f163
@ -15,6 +15,7 @@ import { IWindowList } from '~/main/apis/window/constants'
|
|||||||
import picgo from '~/main/apis/picgo'
|
import picgo from '~/main/apis/picgo'
|
||||||
import pasteTemplate from '#/utils/pasteTemplate'
|
import pasteTemplate from '#/utils/pasteTemplate'
|
||||||
import pkg from 'root/package.json'
|
import pkg from 'root/package.json'
|
||||||
|
import { handleCopyUrl } from '~/main/utils/common'
|
||||||
let contextMenu: Menu | null
|
let contextMenu: Menu | null
|
||||||
let menu: Menu | null
|
let menu: Menu | null
|
||||||
let tray: Tray | null
|
let tray: Tray | null
|
||||||
@ -148,8 +149,9 @@ export function createTray () {
|
|||||||
.setWebContents(trayWindow.webContents)
|
.setWebContents(trayWindow.webContents)
|
||||||
.upload(files)
|
.upload(files)
|
||||||
if (imgs !== false) {
|
if (imgs !== false) {
|
||||||
|
let pasteText = ''
|
||||||
for (let i = 0; i < imgs.length; i++) {
|
for (let i = 0; i < imgs.length; i++) {
|
||||||
clipboard.writeText(pasteTemplate(pasteStyle, imgs[i]))
|
pasteText += pasteTemplate(pasteStyle, imgs[i]) + '\r\n'
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: '上传成功',
|
title: '上传成功',
|
||||||
body: imgs[i].imgUrl!,
|
body: imgs[i].imgUrl!,
|
||||||
@ -160,6 +162,7 @@ export function createTray () {
|
|||||||
}, i * 100)
|
}, i * 100)
|
||||||
db.insert('uploaded', imgs[i])
|
db.insert('uploaded', imgs[i])
|
||||||
}
|
}
|
||||||
|
handleCopyUrl(pasteText)
|
||||||
trayWindow.webContents.send('dragFiles', imgs)
|
trayWindow.webContents.send('dragFiles', imgs)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -19,6 +19,7 @@ import {
|
|||||||
uploadChoosedFiles
|
uploadChoosedFiles
|
||||||
} from '~/main/apis/uploader/api'
|
} from '~/main/apis/uploader/api'
|
||||||
import picgoCoreIPC from './picgoCoreIPC'
|
import picgoCoreIPC from './picgoCoreIPC'
|
||||||
|
import { handleCopyUrl } from '~/main/utils/common'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
listen () {
|
listen () {
|
||||||
@ -29,7 +30,7 @@ export default {
|
|||||||
const img = await uploader.setWebContents(trayWindow.webContents).upload()
|
const img = await uploader.setWebContents(trayWindow.webContents).upload()
|
||||||
if (img !== false) {
|
if (img !== false) {
|
||||||
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
||||||
clipboard.writeText(pasteTemplate(pasteStyle, img[0]))
|
handleCopyUrl(pasteTemplate(pasteStyle, img[0]))
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: '上传成功',
|
title: '上传成功',
|
||||||
body: img[0].imgUrl!,
|
body: img[0].imgUrl!,
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
import db from '#/datastore'
|
import db from '#/datastore'
|
||||||
import uploader from '../uploader'
|
import uploader from '../uploader'
|
||||||
import pasteTemplate from '#/utils/pasteTemplate'
|
import pasteTemplate from '#/utils/pasteTemplate'
|
||||||
|
import { handleCopyUrl } from '~/main/utils/common'
|
||||||
import {
|
import {
|
||||||
getWindowId,
|
getWindowId,
|
||||||
getSettingWindowId
|
getSettingWindowId
|
||||||
@ -79,7 +80,7 @@ class GuiApi implements IGuiApi {
|
|||||||
}, i * 100)
|
}, i * 100)
|
||||||
db.insert('uploaded', imgs[i])
|
db.insert('uploaded', imgs[i])
|
||||||
}
|
}
|
||||||
clipboard.writeText(pasteText)
|
handleCopyUrl(pasteText)
|
||||||
webContents.send('uploadFiles', imgs)
|
webContents.send('uploadFiles', imgs)
|
||||||
webContents.send('updateGallery')
|
webContents.send('updateGallery')
|
||||||
return imgs
|
return imgs
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
clipboard,
|
|
||||||
Notification,
|
Notification,
|
||||||
WebContents
|
WebContents
|
||||||
} from 'electron'
|
} from 'electron'
|
||||||
@ -8,6 +7,7 @@ import { IWindowList } from '~/main/apis/window/constants'
|
|||||||
import uploader from './'
|
import uploader from './'
|
||||||
import pasteTemplate from '#/utils/pasteTemplate'
|
import pasteTemplate from '#/utils/pasteTemplate'
|
||||||
import db from '#/datastore'
|
import db from '#/datastore'
|
||||||
|
import { handleCopyUrl } from '~/main/utils/common'
|
||||||
export const uploadClipboardFiles = async (): Promise<string> => {
|
export const uploadClipboardFiles = async (): Promise<string> => {
|
||||||
const win = windowManager.getAvailableWindow()
|
const win = windowManager.getAvailableWindow()
|
||||||
let img = await uploader.setWebContents(win!.webContents).upload()
|
let img = await uploader.setWebContents(win!.webContents).upload()
|
||||||
@ -15,7 +15,7 @@ export const uploadClipboardFiles = async (): Promise<string> => {
|
|||||||
if (img.length > 0) {
|
if (img.length > 0) {
|
||||||
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)!
|
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)!
|
||||||
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
||||||
clipboard.writeText(pasteTemplate(pasteStyle, img[0]))
|
handleCopyUrl(pasteTemplate(pasteStyle, img[0]))
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: '上传成功',
|
title: '上传成功',
|
||||||
body: img[0].imgUrl!,
|
body: img[0].imgUrl!,
|
||||||
@ -62,7 +62,7 @@ export const uploadChoosedFiles = async (webContents: WebContents, files: IFileW
|
|||||||
db.insert('uploaded', imgs[i])
|
db.insert('uploaded', imgs[i])
|
||||||
result.push(imgs[i].imgUrl!)
|
result.push(imgs[i].imgUrl!)
|
||||||
}
|
}
|
||||||
clipboard.writeText(pasteText)
|
handleCopyUrl(pasteText)
|
||||||
windowManager.get(IWindowList.TRAY_WINDOW)!.webContents.send('uploadFiles', imgs)
|
windowManager.get(IWindowList.TRAY_WINDOW)!.webContents.send('uploadFiles', imgs)
|
||||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
|
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
|
||||||
|
@ -12,8 +12,8 @@ export const TRAY_WINDOW_URL = isDevelopment
|
|||||||
: `picgo://./index.html`
|
: `picgo://./index.html`
|
||||||
|
|
||||||
export const SETTING_WINDOW_URL = isDevelopment
|
export const SETTING_WINDOW_URL = isDevelopment
|
||||||
? `${(process.env.WEBPACK_DEV_SERVER_URL as string)}#setting/upload`
|
? `${(process.env.WEBPACK_DEV_SERVER_URL as string)}#main-page/upload`
|
||||||
: `picgo://./index.html#setting/upload`
|
: `picgo://./index.html#main-page/upload`
|
||||||
|
|
||||||
export const MINI_WINDOW_URL = isDevelopment
|
export const MINI_WINDOW_URL = isDevelopment
|
||||||
? `${(process.env.WEBPACK_DEV_SERVER_URL as string)}#mini-page`
|
? `${(process.env.WEBPACK_DEV_SERVER_URL as string)}#mini-page`
|
||||||
|
8
src/main/utils/common.ts
Normal file
8
src/main/utils/common.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import db from '#/datastore'
|
||||||
|
import { clipboard } from 'electron'
|
||||||
|
|
||||||
|
export function handleCopyUrl (str: string): void {
|
||||||
|
if (db.get('settings.autoCopy') === true) {
|
||||||
|
clipboard.writeText(str)
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="setting-page">
|
<div id="main-page">
|
||||||
<div class="fake-title-bar" :class="{ 'darwin': os === 'darwin' }">
|
<div class="fake-title-bar" :class="{ 'darwin': os === 'darwin' }">
|
||||||
<div class="fake-title-bar__title">
|
<div class="fake-title-bar__title">
|
||||||
PicGo - {{ version }}
|
PicGo - {{ version }}
|
||||||
@ -140,7 +140,7 @@ const customLinkRule = (rule: string, value: string, callback: (arg0?: Error) =>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Component({
|
@Component({
|
||||||
name: 'setting-page',
|
name: 'main-page',
|
||||||
mixins: [mixin],
|
mixins: [mixin],
|
||||||
components: {
|
components: {
|
||||||
InputBoxDialog
|
InputBoxDialog
|
||||||
@ -282,7 +282,7 @@ $darwinBg = transparentify(#172426, #000, 0.7)
|
|||||||
font-size 20px
|
font-size 20px
|
||||||
text-align center
|
text-align center
|
||||||
margin 10px auto
|
margin 10px auto
|
||||||
#setting-page
|
#main-page
|
||||||
.fake-title-bar
|
.fake-title-bar
|
||||||
-webkit-app-region drag
|
-webkit-app-region drag
|
||||||
height h = 22px
|
height h = 22px
|
@ -4,10 +4,10 @@
|
|||||||
PicGo设置 - <i class="el-icon-document" @click="goConfigPage"></i>
|
PicGo设置 - <i class="el-icon-document" @click="goConfigPage"></i>
|
||||||
</div>
|
</div>
|
||||||
<el-row class="setting-list">
|
<el-row class="setting-list">
|
||||||
<el-col :span="15" :offset="4">
|
<el-col :span="16" :offset="4">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-form
|
<el-form
|
||||||
label-width="120px"
|
label-width="160px"
|
||||||
label-position="right"
|
label-position="right"
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
@ -107,6 +107,16 @@
|
|||||||
@change="handleMiniWindowOntop"
|
@change="handleMiniWindowOntop"
|
||||||
></el-switch>
|
></el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="上传后自动复制URL"
|
||||||
|
>
|
||||||
|
<el-switch
|
||||||
|
v-model="form.autoCopyUrl"
|
||||||
|
active-text="开"
|
||||||
|
inactive-text="关"
|
||||||
|
@change="handleAutoCopyUrl"
|
||||||
|
></el-switch>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="选择显示的图床"
|
label="选择显示的图床"
|
||||||
>
|
>
|
||||||
@ -336,7 +346,8 @@ export default class extends Vue {
|
|||||||
autoRename: db.get('settings.autoRename') || false,
|
autoRename: db.get('settings.autoRename') || false,
|
||||||
uploadNotification: db.get('settings.uploadNotification') || false,
|
uploadNotification: db.get('settings.uploadNotification') || false,
|
||||||
miniWindowOntop: db.get('settings.miniWindowOntop') || false,
|
miniWindowOntop: db.get('settings.miniWindowOntop') || false,
|
||||||
logLevel
|
logLevel,
|
||||||
|
autoCopyUrl: db.get('settings.autoCopy') === undefined ? true : db.get('settings.autoCopy')
|
||||||
}
|
}
|
||||||
picBed: IPicBedType[] = []
|
picBed: IPicBedType[] = []
|
||||||
logFileVisible = false
|
logFileVisible = false
|
||||||
@ -513,6 +524,15 @@ export default class extends Vue {
|
|||||||
db.set('settings.miniWindowOntop', val)
|
db.set('settings.miniWindowOntop', val)
|
||||||
this.$message.info('需要重启生效')
|
this.$message.info('需要重启生效')
|
||||||
}
|
}
|
||||||
|
handleAutoCopyUrl (val: boolean) {
|
||||||
|
db.set('settings.autoCopy', val)
|
||||||
|
const successNotification = new Notification('设置自动复制链接', {
|
||||||
|
body: '设置成功'
|
||||||
|
})
|
||||||
|
successNotification.onclick = () => {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
confirmLogLevelSetting () {
|
confirmLogLevelSetting () {
|
||||||
if (this.form.logLevel.length === 0) {
|
if (this.form.logLevel.length === 0) {
|
||||||
return this.$message.error('请选择日志记录等级')
|
return this.$message.error('请选择日志记录等级')
|
||||||
|
@ -22,9 +22,9 @@ export default new Router({
|
|||||||
component: () => import(/* webpackChunkName: "MiniPage" */ '@/pages/MiniPage.vue')
|
component: () => import(/* webpackChunkName: "MiniPage" */ '@/pages/MiniPage.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/setting',
|
path: '/main-page',
|
||||||
name: 'setting-page',
|
name: 'main-page',
|
||||||
component: () => import(/* webpackChunkName: "SettingPage" */ '@/layouts/SettingPage.vue'),
|
component: () => import(/* webpackChunkName: "SettingPage" */ '@/layouts/Main.vue'),
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'upload',
|
path: 'upload',
|
||||||
|
1
src/universal/types/view.d.ts
vendored
1
src/universal/types/view.d.ts
vendored
@ -7,6 +7,7 @@ interface ISettingForm {
|
|||||||
uploadNotification: boolean
|
uploadNotification: boolean
|
||||||
miniWindowOntop: boolean
|
miniWindowOntop: boolean
|
||||||
logLevel: string[]
|
logLevel: string[]
|
||||||
|
autoCopyUrl: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IShortKeyMap {
|
interface IShortKeyMap {
|
||||||
|
Loading…
Reference in New Issue
Block a user