Feature(custom): optimize i18n and platform funcs

This commit is contained in:
Kuingsmile
2025-08-01 13:38:37 +08:00
parent 15e2f11b69
commit 70396c3e5c
38 changed files with 16 additions and 164 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -1,18 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="referrer" content="never">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>PicList</title>
</head>
<body>
<noscript>
<strong>We're sorry but piclist-new doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

View File

@@ -1,34 +0,0 @@
#!/bin/sh
if [ "$XDG_SESSION_TYPE" = "x11" ]; then
# require xclip(see http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script/677212#677212)
command -v xclip >/dev/null 2>&1 || { echo >&1 "no xclip"; exit 1; }
# write image in clipboard to file (see http://unix.stackexchange.com/questions/145131/copy-image-from-clipboard-to-file)
filePath=`xclip -selection clipboard -o 2>/dev/null | grep ^file:// | cut -c8-`
if [ ! -n "$filePath" ] ;then
if
xclip -selection clipboard -target image/png -o >/dev/null 2>&1
then
xclip -selection clipboard -target image/png -o >$1 2>/dev/null
echo $1
else
echo "no image"
fi
else
echo $filePath
fi
elif [ "$XDG_SESSION_TYPE" = "wayland" ]; then
command -v wl-copy >/dev/null 2>&1 || { echo >&1 "no wl-clipboard"; exit 1; }
filePath=`wl-copy -o 2>/dev/null | grep ^file:// | cut -c8-`
if [ ! -n "$filePath" ] ;then
if
wl-copy -t image/png -o >/dev/null 2>&1
then
wl-copy -t image/png image/png -o >$1 2>/dev/null
echo $1
else
echo "no image"
fi
else
echo $filePath
fi
fi

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -1,26 +0,0 @@
param($imagePath)
# Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1
Add-Type -Assembly PresentationCore
$img = [Windows.Clipboard]::GetImage()
if ($img -eq $null) {
"no image"
Exit 1
}
if (-not $imagePath) {
"no image"
Exit 1
}
$fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0)
$stream = [IO.File]::Open($imagePath, "OpenOrCreate")
$encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
$encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null
$encoder.Save($stream) | out-null
$stream.Dispose() | out-null
$imagePath

View File

@@ -1,45 +0,0 @@
# Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1
param($imagePath)
# https://github.com/PowerShell/PowerShell/issues/7233
# fix the output encoding bug
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
Add-Type -Assembly PresentationCore
function main {
$img = [Windows.Clipboard]::GetImage()
if ($img -eq $null) {
"no image"
Exit 1
}
if (-not $imagePath) {
"no image"
Exit 1
}
$fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0)
$stream = [IO.File]::Open($imagePath, "OpenOrCreate")
$encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
$encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null
$encoder.Save($stream) | out-null
$stream.Dispose() | out-null
$imagePath
Exit 1
}
try {
# For WIN10
$file = Get-Clipboard -Format FileDropList
if ($file -ne $null) {
Convert-Path $file
Exit 1
}
} catch {
# For WIN7 WIN8 WIN10
main
}
main

View File

@@ -1,18 +0,0 @@
#!/bin/sh
# grab the paths
scriptPath=$(echo $0 | awk '{ print substr( $0, 1, length($0)-6 ) }')"windows10.ps1"
imagePath=$(echo $1 | awk '{ print substr( $0, 1, length($0)-18 ) }')
imageName=$(echo $1 | awk '{ print substr( $0, length($0)-17, length($0) ) }')
# run the powershell script
res=$(powershell.exe -noprofile -noninteractive -nologo -sta -executionpolicy unrestricted -file $(wslpath -w $scriptPath) $(wslpath -w $imagePath)"\\"$imageName)
# note that there is a return symbol in powershell result
noImage=$(echo "no image\r")
# check whether image exists
if [ "$res" = "$noImage" ] ;then
echo "no image"
else
echo $(wslpath -u $res)
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -1,17 +1,11 @@
import picgo from '@core/picgo'
import { app, IpcMainEvent, shell } from 'electron'
import { app, shell } from 'electron'
import { IRPCActionType } from '#/types/enum'
import { IIPCEvent } from '#/types/rpc'
import { i18nManager } from '~/i18n'
export default [
{
action: IRPCActionType.GET_PLATFORM,
handler: async (event: IIPCEvent) => {
(event as IpcMainEvent).returnValue = process.platform
}
},
{
action: IRPCActionType.RELOAD_APP,
handler: async () => {

View File

@@ -4,8 +4,8 @@ import path from 'node:path'
import { dbPathChecker } from '@core/datastore/dbChecker'
import fs from 'fs-extra'
import yaml from 'js-yaml'
import { ILocales } from 'root/src/universal/types/i18n'
import { ILocales } from '#/types/i18n'
import { i18nManager } from '~/i18n'
const configPath = dbPathChecker()

View File

@@ -49,6 +49,7 @@ try {
clipboard: {
writeText: clipboard.writeText
},
platform: process.platform,
sendRpcSync,
triggerRPC,
sendToMain,

View File

@@ -438,7 +438,7 @@ async function getBucketList () {
function transPathToUnix (filePath: string | undefined) {
if (!filePath) return ''
return window.electron.sendRpcSync(IRPCActionType.GET_PLATFORM) === 'win32'
return window.electron.platform === 'win32'
? filePath
.split(window.node.path.sep)
.join(window.node.path.posix.sep)

View File

@@ -1417,12 +1417,12 @@ const languageList = [
}
]
const startModeList = Object.values(ISartMode).map(item => ({
const startModeList = computed(() => Object.values(ISartMode).map(item => ({
label: t(`SETTINGS_START_MODE_${item.toUpperCase().replace(/-/g, '_')}` as any),
value: item
}))
})))
const manualPageOpenList = [
const manualPageOpenList = computed(() => [
{
label: t('MANUAL_PAGE_OPEN_BY_BUILD_IN'),
value: 'window'
@@ -1431,7 +1431,7 @@ const manualPageOpenList = [
label: t('MANUAL_PAGE_OPEN_BY_BROWSER'),
value: 'browser'
}
]
])
const showPicBedList = computed(
() =>
@@ -1676,12 +1676,12 @@ async function initData () {
formOfSetting.value.logLevel = initArray(settings.logLevel || [], ['all'])
formOfSetting.value.autoImportPicBed = initArray(settings.autoImportPicBed || [], [])
currentLanguage.value = valueToOptionItem(settings.language || 'zh-CN', languageList)
currentStartMode.value = valueToOptionItem(settings.startMode || ISartMode.QUIET, startModeList)
currentStartMode.value = valueToOptionItem(settings.startMode || ISartMode.QUIET, startModeList.value)
if (osGlobal.value === 'darwin' && currentStartMode.value.value === ISartMode.MINI) {
currentStartMode.value = valueToOptionItem(ISartMode.QUIET, startModeList)
currentStartMode.value = valueToOptionItem(ISartMode.QUIET, startModeList.value)
saveConfig(configPaths.settings.startMode, ISartMode.QUIET)
}
currentManualPageOpen.value = valueToOptionItem(settings.manualPageOpen || 'window', manualPageOpenList)
currentManualPageOpen.value = valueToOptionItem(settings.manualPageOpen || 'window', manualPageOpenList.value)
currentShortUrlServer.value = valueToOptionItem(settings.shortUrlServer || 'c1n', shortUrlServerList)
customLink.value = settings.customLink || '![$fileName]($url)'
proxy.value = picBed.proxy || ''
@@ -2040,7 +2040,7 @@ function handleStartModeChange (val: ISartModeValues) {
if (val === ISartMode.NO_TRAY) {
if (formOfSetting.value.isHideDock) {
ElMessage.warning(t('SETTINGS_ISHIDEDOCK_TIPS'))
currentStartMode.value = valueToOptionItem(ISartMode.QUIET, startModeList)
currentStartMode.value = valueToOptionItem(ISartMode.QUIET, startModeList.value)
return
}
$message.info(t('TIPS_NEED_RELOAD'))

View File

@@ -3,8 +3,8 @@ import { ref } from 'vue'
import { IRPCActionType } from '#/types/enum'
import { IPicBedType } from '#/types/types'
console.log('global.ts loaded', window.node.crypto.randomBytes(16).toString('hex'))
const osGlobal = ref<string>(window.electron.sendRpcSync(IRPCActionType.GET_PLATFORM))
console.log('global.ts loaded', window.electron.platform)
const osGlobal = ref<string>(window.electron.platform)
const picBedGlobal = ref<IPicBedType[]>([])
const pageReloadCount = ref(0)

View File

@@ -1,5 +1,3 @@
import { IRPCActionType } from '#/types/enum'
const isSpecialKey = (key: string) => {
const keyArr = ['Shift', 'Control', 'Alt', 'Meta']
@@ -7,7 +5,7 @@ const isSpecialKey = (key: string) => {
}
const keyBinding = (event: KeyboardEvent) => {
const meta = window.electron.sendRpcSync(IRPCActionType.GET_PLATFORM) === 'darwin' ? 'Cmd' : 'Super'
const meta = window.electron.platform === 'darwin' ? 'Cmd' : 'Super'
const specialKey = {
Ctrl: event.ctrlKey,
Shift: event.shiftKey,

View File

@@ -95,7 +95,6 @@ export enum IRPCActionType {
MAIN_WINDOW_ON_TOP = 'MAIN_WINDOW_ON_TOP',
UPDATE_MINI_WINDOW_ICON = 'UPDATE_MINI_WINDOW_ICON',
REFRESH_SETTING_WINDOW = 'REFRESH_SETTING_WINDOW',
GET_PLATFORM = 'GET_PLATFORM',
// picbed RPC
PICBED_GET_PICBED_CONFIG = 'PICBED_GET_PICBED_CONFIG',
PICBED_GET_CONFIG_LIST = 'PICBED_GET_CONFIG_LIST',

View File

@@ -22,6 +22,7 @@ declare global {
}
export interface Window {
electron: {
platform: string
setVisualZoomLevelLimits: (min: number, max: number) => void
sendRpcSync: (action: IRPCActionType, ...args: any[]) => any
triggerRPC: <T>(action: IRPCActionType, ...args: any[]) => Promise<T | undefined>