Feature(custom): optimize short url

ISSUES CLOSED: #252
This commit is contained in:
Kuingsmile
2024-11-16 10:14:52 +08:00
parent 4209838925
commit fd5316a7b9
8 changed files with 57 additions and 20 deletions

View File

@@ -326,7 +326,13 @@ export function createTray(tooltip: string) {
if (deleteLocalFile) {
await fs.remove(rawInput[i])
}
pasteText.push(await pasteTemplate(pasteStyle, imgs[i], db.get(configPaths.settings.customLink)))
const [pasteTextItem, shortUrl] = await pasteTemplate(
pasteStyle,
imgs[i],
db.get(configPaths.settings.customLink)
)
imgs[i].shortUrl = shortUrl
pasteText.push(pasteTextItem)
const isShowResultNotification =
db.get(configPaths.settings.uploadResultNotification) === undefined
? true
@@ -334,7 +340,7 @@ export function createTray(tooltip: string) {
if (isShowResultNotification) {
const notification = new Notification({
title: T('UPLOAD_SUCCEED'),
body: imgs[i].imgUrl!
body: shortUrl || imgs[i].imgUrl!
// icon: files[i]
})
setTimeout(() => {

View File

@@ -54,7 +54,9 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
if (img.length > 0) {
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)
const pasteStyle = db.get(configPaths.settings.pasteStyle) || IPasteStyle.MARKDOWN
handleCopyUrl(await pasteTemplate(pasteStyle, img[0], db.get(configPaths.settings.customLink)))
const [pastedText, shortUrl] = await pasteTemplate(pasteStyle, img[0], db.get(configPaths.settings.customLink))
img[0].shortUrl = shortUrl
handleCopyUrl(pastedText)
const isShowResultNotification =
db.get(configPaths.settings.uploadResultNotification) === undefined
? true
@@ -62,7 +64,7 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
if (isShowResultNotification) {
const notification = new Notification({
title: T('UPLOAD_SUCCEED'),
body: img[0].imgUrl!
body: shortUrl || img[0].imgUrl!
// icon: img[0].imgUrl
})
setTimeout(() => {
@@ -128,7 +130,13 @@ export const uploadChoosedFiles = async (
picgo.log.error(err)
})
}
pasteText.push(await pasteTemplate(pasteStyle, imgs[i], db.get(configPaths.settings.customLink)))
const [pasteTextItem, shortUrl] = await pasteTemplate(
pasteStyle,
imgs[i],
db.get(configPaths.settings.customLink)
)
imgs[i].shortUrl = shortUrl
pasteText.push(pasteTextItem)
const isShowResultNotification =
db.get(configPaths.settings.uploadResultNotification) === undefined
? true
@@ -136,7 +144,7 @@ export const uploadChoosedFiles = async (
if (isShowResultNotification) {
const notification = new Notification({
title: T('UPLOAD_SUCCEED'),
body: imgs[i].imgUrl!
body: shortUrl || imgs[i].imgUrl!
// icon: files[i].path
})
setTimeout(() => {

View File

@@ -95,7 +95,13 @@ class GuiApi implements IGuiApi {
if (deleteLocalFile) {
await fs.remove(rawInput[i])
}
pasteText.push(await pasteTemplate(pasteStyle, imgs[i], db.get(configPaths.settings.customLink)))
const [pasteTextItem, shortUrl] = await pasteTemplate(
pasteStyle,
imgs[i],
db.get(configPaths.settings.customLink)
)
imgs[i].shortUrl = shortUrl
pasteText.push(pasteTextItem)
const isShowResultNotification =
db.get(configPaths.settings.uploadResultNotification) === undefined
? true
@@ -103,7 +109,7 @@ class GuiApi implements IGuiApi {
if (isShowResultNotification) {
const notification = new Notification({
title: T('UPLOAD_SUCCEED'),
body: imgs[i].imgUrl as string
body: shortUrl || (imgs[i].imgUrl! as string)
// icon: imgs[i].imgUrl
})
setTimeout(() => {