Feature: add a new config item to close upload result notification

ISSUES CLOSED: #74
This commit is contained in:
萌萌哒赫萝 2023-07-17 23:54:50 -07:00
parent 58486a3997
commit c1698e8661
10 changed files with 78 additions and 40 deletions

View File

@ -172,6 +172,7 @@ SETTINGS_ADVANCED_RENAME: Advanced Rename
SETTINGS_ADVANCED_RENAME_ENABLE: Enable Advanced Rename SETTINGS_ADVANCED_RENAME_ENABLE: Enable Advanced Rename
SETTINGS_ADVANCED_RENAME_FORMAT: Advanced Rename Format SETTINGS_ADVANCED_RENAME_FORMAT: Advanced Rename Format
SETTINGS_OPEN_UPLOAD_TIPS: Open Upload Tips SETTINGS_OPEN_UPLOAD_TIPS: Open Upload Tips
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: Open Upload Result Tips
SETTINGS_MINI_WINDOW_ON_TOP: Mini Window On Top SETTINGS_MINI_WINDOW_ON_TOP: Mini Window On Top
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: Auto Copy URL After Upload SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: Auto Copy URL After Upload
SETTINGS_TIPS_PLACEHOLDER_URL: Use $url to represent url position SETTINGS_TIPS_PLACEHOLDER_URL: Use $url to represent url position

View File

@ -173,7 +173,8 @@ SETTINGS_TIMESTAMP_RENAME: 时间戳重命名
SETTINGS_ADVANCED_RENAME: 高级重命名 SETTINGS_ADVANCED_RENAME: 高级重命名
SETTINGS_ADVANCED_RENAME_ENABLE: 开启高级重命名 SETTINGS_ADVANCED_RENAME_ENABLE: 开启高级重命名
SETTINGS_ADVANCED_RENAME_FORMAT: 重命名格式 SETTINGS_ADVANCED_RENAME_FORMAT: 重命名格式
SETTINGS_OPEN_UPLOAD_TIPS: 开启上传提示 SETTINGS_OPEN_UPLOAD_TIPS: 开启上传进度提示
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: 开启上传结果提示
SETTINGS_MINI_WINDOW_ON_TOP: Mini窗口置顶 SETTINGS_MINI_WINDOW_ON_TOP: Mini窗口置顶
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: 上传后自动复制URL SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: 上传后自动复制URL
SETTINGS_TIPS_PLACEHOLDER_URL: 用占位符 $url 来表示url的位置 SETTINGS_TIPS_PLACEHOLDER_URL: 用占位符 $url 来表示url的位置

View File

@ -172,6 +172,7 @@ SETTINGS_ADVANCED_RENAME: 高級命名
SETTINGS_ADVANCED_RENAME_ENABLE: 啟用高級命名 SETTINGS_ADVANCED_RENAME_ENABLE: 啟用高級命名
SETTINGS_ADVANCED_RENAME_FORMAT: 高級命名格式 SETTINGS_ADVANCED_RENAME_FORMAT: 高級命名格式
SETTINGS_OPEN_UPLOAD_TIPS: 開啟上傳提示 SETTINGS_OPEN_UPLOAD_TIPS: 開啟上傳提示
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: 開啟上傳結果提示
SETTINGS_MINI_WINDOW_ON_TOP: Mini視窗置頂 SETTINGS_MINI_WINDOW_ON_TOP: Mini視窗置頂
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: 上傳後自動複製URL SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: 上傳後自動複製URL
SETTINGS_TIPS_PLACEHOLDER_URL: 用佔位符 $url 來表示URL的位置 SETTINGS_TIPS_PLACEHOLDER_URL: 用佔位符 $url 來表示URL的位置

View File

@ -392,14 +392,17 @@ export function createTray () {
await fs.remove(rawInput[i]) await fs.remove(rawInput[i])
} }
pasteText.push(await (pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))) pasteText.push(await (pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink'))))
const notification = new Notification({ const isShowResultNotification = db.get('settings.uploadResultNotification') === undefined ? true : !!db.get('settings.uploadResultNotification')
title: T('UPLOAD_SUCCEED'), if (isShowResultNotification) {
body: imgs[i].imgUrl! const notification = new Notification({
// icon: files[i] title: T('UPLOAD_SUCCEED'),
}) body: imgs[i].imgUrl!
setTimeout(() => { // icon: files[i]
notification.show() })
}, i * 100) setTimeout(() => {
notification.show()
}, i * 100)
}
await GalleryDB.getInstance().insert(imgs[i]) await GalleryDB.getInstance().insert(imgs[i])
} }
handleCopyUrl(pasteText.join('\n')) handleCopyUrl(pasteText.join('\n'))

View File

@ -32,14 +32,17 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
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'
handleCopyUrl(await (pasteTemplate(pasteStyle, img[0], db.get('settings.customLink')))) handleCopyUrl(await (pasteTemplate(pasteStyle, img[0], db.get('settings.customLink'))))
const notification = new Notification({ const isShowResultNotification = db.get('settings.uploadResultNotification') === undefined ? true : !!db.get('settings.uploadResultNotification')
title: T('UPLOAD_SUCCEED'), if (isShowResultNotification) {
body: img[0].imgUrl! const notification = new Notification({
// icon: img[0].imgUrl title: T('UPLOAD_SUCCEED'),
}) body: img[0].imgUrl!
setTimeout(() => { // icon: img[0].imgUrl
notification.show() })
}, 100) setTimeout(() => {
notification.show()
}, 100)
}
await GalleryDB.getInstance().insert(img[0]) await GalleryDB.getInstance().insert(img[0])
// trayWindow just be created in mac/windows, not in linux // trayWindow just be created in mac/windows, not in linux
trayWindow?.webContents?.send('clipboardFiles', []) trayWindow?.webContents?.send('clipboardFiles', [])
@ -88,14 +91,17 @@ export const uploadChoosedFiles = async (webContents: WebContents, files: IFileW
}) })
} }
pasteText.push(await (pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))) pasteText.push(await (pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink'))))
const notification = new Notification({ const isShowResultNotification = db.get('settings.uploadResultNotification') === undefined ? true : !!db.get('settings.uploadResultNotification')
title: T('UPLOAD_SUCCEED'), if (isShowResultNotification) {
body: imgs[i].imgUrl! const notification = new Notification({
// icon: files[i].path title: T('UPLOAD_SUCCEED'),
}) body: imgs[i].imgUrl!
setTimeout(() => { // icon: files[i].path
notification.show() })
}, i * 100) setTimeout(() => {
notification.show()
}, i * 100)
}
await GalleryDB.getInstance().insert(imgs[i]) await GalleryDB.getInstance().insert(imgs[i])
result.push({ result.push({
url: handleUrlEncodeWithSetting(imgs[i].imgUrl!), url: handleUrlEncodeWithSetting(imgs[i].imgUrl!),

View File

@ -89,14 +89,17 @@ class GuiApi implements IGuiApi {
await fs.remove(rawInput[i]) await fs.remove(rawInput[i])
} }
pasteText.push(await (pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))) pasteText.push(await (pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink'))))
const notification = new Notification({ const isShowResultNotification = db.get('settings.uploadResultNotification') === undefined ? true : !!db.get('settings.uploadResultNotification')
title: T('UPLOAD_SUCCEED'), if (isShowResultNotification) {
body: imgs[i].imgUrl as string const notification = new Notification({
// icon: imgs[i].imgUrl title: T('UPLOAD_SUCCEED'),
}) body: imgs[i].imgUrl as string
setTimeout(() => { // icon: imgs[i].imgUrl
notification.show() })
}, i * 100) setTimeout(() => {
notification.show()
}, i * 100)
}
await GalleryDB.getInstance().insert(imgs[i]) await GalleryDB.getInstance().insert(imgs[i])
} }
handleCopyUrl(pasteText.join('\n')) handleCopyUrl(pasteText.join('\n'))

View File

@ -58,13 +58,16 @@ export default {
if (img !== false) { if (img !== false) {
const pasteStyle = db.get('settings.pasteStyle') || 'markdown' const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
handleCopyUrl(await (pasteTemplate(pasteStyle, img[0], db.get('settings.customLink')))) handleCopyUrl(await (pasteTemplate(pasteStyle, img[0], db.get('settings.customLink'))))
const notification = new Notification({ const isShowResultNotification = db.get('settings.uploadResultNotification') === undefined ? true : !!db.get('settings.uploadResultNotification')
title: T('UPLOAD_SUCCEED'), if (isShowResultNotification) {
body: img[0].imgUrl! const notification = new Notification({
// icon: file[0] title: T('UPLOAD_SUCCEED'),
// icon: img[0].imgUrl body: img[0].imgUrl!
}) // icon: file[0]
notification.show() // icon: img[0].imgUrl
})
notification.show()
}
await GalleryDB.getInstance().insert(img[0]) await GalleryDB.getInstance().insert(img[0])
trayWindow.webContents.send('clipboardFiles', []) trayWindow.webContents.send('clipboardFiles', [])
if (windowManager.has(IWindowList.SETTING_WINDOW)) { if (windowManager.has(IWindowList.SETTING_WINDOW)) {

View File

@ -287,6 +287,16 @@
@change="handleUploadNotification" @change="handleUploadNotification"
/> />
</el-form-item> </el-form-item>
<el-form-item
:label="$T('SETTINGS_OPEN_UPLOAD_RESULT_TIPS')"
>
<el-switch
v-model="form.uploadResultNotification"
:active-text="$T('SETTINGS_OPEN')"
:inactive-text="$T('SETTINGS_CLOSE')"
@change="handleUploadResultNotification"
/>
</el-form-item>
<el-form-item <el-form-item
:label="$T('SETTINGS_COMPRESS_AND_WATERMARK')" :label="$T('SETTINGS_COMPRESS_AND_WATERMARK')"
> >
@ -1527,6 +1537,7 @@ const form = reactive<ISettingForm>({
rename: false, rename: false,
autoRename: false, autoRename: false,
uploadNotification: false, uploadNotification: false,
uploadResultNotification: true,
miniWindowOntop: false, miniWindowOntop: false,
logLevel: ['all'], logLevel: ['all'],
autoCopyUrl: true, autoCopyUrl: true,
@ -1680,6 +1691,7 @@ async function initData () {
form.rename = settings.rename || false form.rename = settings.rename || false
form.autoRename = settings.autoRename || false form.autoRename = settings.autoRename || false
form.uploadNotification = settings.uploadNotification || false form.uploadNotification = settings.uploadNotification || false
form.uploadResultNotification = settings.uploadResultNotification === undefined ? true : settings.uploadResultNotification
form.miniWindowOntop = settings.miniWindowOntop || false form.miniWindowOntop = settings.miniWindowOntop || false
form.logLevel = initLogLevel(settings.logLevel || []) form.logLevel = initLogLevel(settings.logLevel || [])
form.autoCopyUrl = settings.autoCopy === undefined ? true : settings.autoCopy form.autoCopyUrl = settings.autoCopy === undefined ? true : settings.autoCopy
@ -1952,6 +1964,12 @@ function handleUploadNotification (val: ICheckBoxValueType) {
}) })
} }
function handleUploadResultNotification (val: ICheckBoxValueType) {
saveConfig({
'settings.uploadResultNotification': val
})
}
async function cancelWindowSize () { async function cancelWindowSize () {
mainWindowSizeVisible.value = false mainWindowSizeVisible.value = false
mainWindowWidth.value = await getConfig<number>('settings.mainWindowWidth') || 1200 mainWindowWidth.value = await getConfig<number>('settings.mainWindowWidth') || 1200

View File

@ -167,6 +167,7 @@ interface ILocales {
SETTINGS_ADVANCED_RENAME_ENABLE: string SETTINGS_ADVANCED_RENAME_ENABLE: string
SETTINGS_ADVANCED_RENAME_FORMAT: string SETTINGS_ADVANCED_RENAME_FORMAT: string
SETTINGS_OPEN_UPLOAD_TIPS: string SETTINGS_OPEN_UPLOAD_TIPS: string
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: string
SETTINGS_MINI_WINDOW_ON_TOP: string SETTINGS_MINI_WINDOW_ON_TOP: string
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: string SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: string
SETTINGS_TIPS_PLACEHOLDER_URL: string SETTINGS_TIPS_PLACEHOLDER_URL: string

View File

@ -5,6 +5,7 @@ interface ISettingForm {
rename: boolean rename: boolean
autoRename: boolean autoRename: boolean
uploadNotification: boolean uploadNotification: boolean
uploadResultNotification: boolean
miniWindowOntop: boolean miniWindowOntop: boolean
logLevel: string[] logLevel: string[]
autoCopyUrl: boolean autoCopyUrl: boolean