Feature(custom): add manual page open setting

This commit is contained in:
Kuingsmile 2024-01-01 00:20:36 -08:00
parent 531b387621
commit e4f957d67d
8 changed files with 87 additions and 8 deletions

View File

@ -50,6 +50,11 @@ TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_WORKING: Proxy settings unavailable
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_TIPS: "The temporary folder path for clipboard pictures is: ${path}"
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS: "The temporary folder for clipboard pictures does not exist: ${path}"
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS: "Please create the folder yourself: ${path}"
MANUAL_PAGE_OPEN_TIP: Please select the way to open the manual
MANUAL_PAGE_OPEN_TIP_TITLE: Tips
MANUAL_PAGE_OPEN_BY_BROWSER: Browser
MANUAL_PAGE_OPEN_BY_BUILD_IN: Built-in
MANUAL_PAGE_OPEN_SETTING_TIP: Select the way to open the manual
# ---renderer i18n begin---

View File

@ -50,6 +50,11 @@ TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_WORKING: 代理设置不可用
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_TIPS: 剪贴板图片临时文件夹路径是:${path}
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS: 剪贴板图片临时文件夹不存在:${path}
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS: 请自行创建文件夹:${path}
MANUAL_PAGE_OPEN_TIP: 请选择打开方式
MANUAL_PAGE_OPEN_TIP_TITLE: Tips
MANUAL_PAGE_OPEN_BY_BROWSER: 浏览器
MANUAL_PAGE_OPEN_BY_BUILD_IN: 内置
MANUAL_PAGE_OPEN_SETTING_TIP: 选择手册打开方式
# ---renderer i18n begin---

View File

@ -50,6 +50,11 @@ TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_WORKING: 代理設置不可用
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_TIPS: 剪貼板圖片臨時文件夾路徑是:${path}
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS: 剪貼板圖片臨時文件夾不存在:${path}
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS: 請自行創建文件夾:${path}
MANUAL_PAGE_OPEN_TIP: 請選擇打開方式
MANUAL_PAGE_OPEN_TIP_TITLE: Tips
MANUAL_PAGE_OPEN_BY_BROWSER: 瀏覽器
MANUAL_PAGE_OPEN_BY_BUILD_IN: 內置
MANUAL_PAGE_OPEN_SETTING_TIP: 選擇打開手冊方式
# ---renderer i18n begin---

View File

@ -23,14 +23,12 @@ const multerStorage = multer.diskStorage({
cb(null, serverTempDir)
},
filename: function (_req: any, file: { originalname: any }, cb: (arg0: null, arg1: any) => void) {
console.log(file.originalname)
// eslint-disable-next-line no-control-regex
if (!/[^\u0000-\u00ff]/.test(file.originalname)) {
file.originalname = Buffer.from(file.originalname, 'latin1').toString(
'utf8'
)
}
console.log(file.originalname)
cb(null, file.originalname)
}
})

View File

@ -124,7 +124,9 @@
</el-icon>
<span>{{ $T('PLUGIN_SETTINGS') }}</span>
</el-menu-item>
<el-menu-item :index="routerConfig.DocumentPage">
<el-menu-item
:index="routerConfig.DocumentPage"
>
<el-icon>
<Link />
</el-icon>
@ -232,7 +234,7 @@ import {
} from '@element-plus/icons-vue'
// Element Plus
import { ElMessage as $message } from 'element-plus'
import { ElMessage as $message, ElMessageBox } from 'element-plus'
//
import { T as $T } from '@/i18n/index'
@ -275,7 +277,8 @@ import {
} from '~/universal/events/constants'
//
import { getConfig, sendToMain } from '@/utils/dataSender'
import { getConfig, saveConfig, sendToMain } from '@/utils/dataSender'
import { openURL } from '@/utils/common'
const version = ref(process.env.NODE_ENV === 'production' ? pkg.version : 'Dev')
const routerConfig = reactive(config)
@ -320,10 +323,29 @@ const handleGetPicPeds = () => {
sendToMain(GET_PICBEDS)
}
const handleSelect = (index: string) => {
const handleSelect = async (index: string) => {
defaultActive.value = index
if (index === routerConfig.DocumentPage) {
ipcRenderer.send('openManualWindow')
const manualPageOpenSetting = await getConfig('settings.manualPageOpen')
const openManual = () => ipcRenderer.send('openManualWindow')
const openExternal = () => openURL('https://piclist.cn/app.html')
if (!manualPageOpenSetting) {
ElMessageBox.confirm($T('MANUAL_PAGE_OPEN_TIP'), $T('MANUAL_PAGE_OPEN_TIP_TITLE'), {
confirmButtonText: $T('MANUAL_PAGE_OPEN_BY_BROWSER'),
cancelButtonText: $T('MANUAL_PAGE_OPEN_BY_BUILD_IN'),
type: 'info',
center: true
}).then(() => {
saveConfig('settings.manualPageOpen', 'browser')
openExternal()
}).catch(() => {
saveConfig('settings.manualPageOpen', 'window')
openManual()
})
} else {
manualPageOpenSetting === 'window' ? openManual() : openExternal()
}
return
}
const type = index.match(routerConfig.UPLOADER_CONFIG_PAGE)

View File

@ -92,6 +92,26 @@
/>
</el-select>
</el-form-item>
<el-form-item
:label="$T('MANUAL_PAGE_OPEN_SETTING_TIP')"
>
<el-select
v-model="form.manualPageOpen"
size="small"
style="width: 50%"
:placeholder="$T('MANUAL_PAGE_OPEN_SETTING_TIP')"
:persistent="false"
teleported
@change="handleManualPageOpenChange"
>
<el-option
v-for="item in manualPageOpenList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item
v-if="os === 'darwin'"
:label="$T('SETTINGS_ISHIDEDOCK')"
@ -1622,6 +1642,16 @@ const shortUrlServerList = [{
}
]
const manualPageOpenList = [{
label: $T('MANUAL_PAGE_OPEN_BY_BUILD_IN'),
value: 'window'
},
{
label: $T('MANUAL_PAGE_OPEN_BY_BROWSER'),
value: 'browser'
}
]
const waterMarkPositionMap = new Map([
['north', $T('UPLOAD_PAGE_IMAGE_PROCESS_POSITION_TOP')],
['northeast', $T('UPLOAD_PAGE_IMAGE_PROCESS_POSITION_TOP_RIGHT')],
@ -1749,7 +1779,8 @@ const form = reactive<ISettingForm>({
yourlsSignature: '',
deleteLocalFile: false,
serverKey: '',
aesPassword: ''
aesPassword: '',
manualPageOpen: 'browser'
})
const languageList = i18nManager.languageList.map(item => ({
@ -1914,6 +1945,7 @@ async function initData () {
form.deleteLocalFile = settings.deleteLocalFile || false
form.serverKey = settings.serverKey || ''
form.aesPassword = settings.aesPassword || 'PicList-aesPassword'
form.manualPageOpen = settings.manualPageOpen || 'window'
currentLanguage.value = settings.language ?? 'zh-CN'
currentStartMode.value = settings.startMode || 'quiet'
customLink.value = settings.customLink || '![$fileName]($url)'
@ -2428,6 +2460,12 @@ function handleStartModeChange (val: 'quiet' | 'mini' | 'main' | 'no-tray') {
})
}
function handleManualPageOpenChange (val: string) {
saveConfig({
'settings.manualPageOpen': val
})
}
function goConfigPage () {
sendToMain(OPEN_URL, 'https://piclist.cn/configure.html')
}

View File

@ -51,6 +51,11 @@ interface ILocales {
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_TIPS: string
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS: string
TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS: string
MANUAL_PAGE_OPEN_TIP: string
MANUAL_PAGE_OPEN_TIP_TITLE: string
MANUAL_PAGE_OPEN_BY_BROWSER: string
MANUAL_PAGE_OPEN_BY_BUILD_IN: string
MANUAL_PAGE_OPEN_SETTING_TIP: string
CHOOSE_YOUR_DEFAULT_PICBED: string
UPLOAD_AREA: string
UPLOAD_VIEW_HINT: string

View File

@ -30,6 +30,7 @@ interface ISettingForm {
deleteLocalFile: boolean,
serverKey: string,
aesPassword: string,
manualPageOpen: string
}
interface IShortKeyMap {