Skip to content

Commit

Permalink
✨ Feature: using webview to show manual website
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuingsmile committed Aug 28, 2023
1 parent 636596a commit bc7a446
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
1 change: 1 addition & 0 deletions src/main/apis/app/window/windowList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const settingWindowOptions = {
transparent: true,
titleBarStyle: 'hidden',
webPreferences: {
webviewTag: true,
backgroundThrottling: false,
nodeIntegration: !!process.env.ELECTRON_NODE_INTEGRATION,
contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION,
Expand Down
31 changes: 3 additions & 28 deletions src/renderer/layouts/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
</el-icon>
<span>{{ $T('PLUGIN_SETTINGS') }}</span>
</el-menu-item>
<el-menu-item index="MANUAL">
<el-menu-item :index="routerConfig.DocumentPage">
<el-icon>
<Link />
</el-icon>
Expand Down Expand Up @@ -259,7 +259,7 @@ import {
} from '@element-plus/icons-vue'
// Element Plus 消息框组件
import { ElMessage as $message, ElMessageBox } from 'element-plus'
import { ElMessage as $message } from 'element-plus'
// 国际化函数
import { T as $T } from '@/i18n/index'
Expand Down Expand Up @@ -299,16 +299,12 @@ import {
SHOW_MAIN_PAGE_MENU,
SHOW_MAIN_PAGE_QRCODE,
SHOW_MAIN_PAGE_DONATION,
GET_PICBEDS,
OPEN_URL
GET_PICBEDS
} from '~/universal/events/constants'
// 数据发送工具函数
import { getConfig, sendToMain } from '@/utils/dataSender'
// Piclist 配置类型声明
import { IConfig } from 'piclist'
const version = ref(process.env.NODE_ENV === 'production' ? pkg.version : 'Dev')
const routerConfig = reactive(config)
const defaultActive = ref(routerConfig.UPLOAD_PAGE)
Expand Down Expand Up @@ -357,27 +353,6 @@ const handleGetPicPeds = () => {
}
const handleSelect = (index: string) => {
if (index === 'MANUAL') {
ElMessageBox.confirm($T('OPEN_MANUAL_LINK_HINT'), $T('OPEN_MANUAL_LINK'), {
confirmButtonText: $T('CONFIRM'),
cancelButtonText: $T('CANCEL'),
type: 'warning',
center: true
}).then(async () => {
let language = 'zh-CN'
const config = (await getConfig<IConfig>())!
if (config !== undefined) {
const settings = config.settings || {}
language = settings.language ?? 'zh-CN'
}
if (language === 'zh-CN' || language === 'zh-TW') {
sendToMain(OPEN_URL, 'https://piclist.cn/configure.html')
} else {
sendToMain(OPEN_URL, 'https://piclist.cn/en/configure.html')
}
}).catch(() => {})
return
}
defaultActive.value = index
const type = index.match(routerConfig.UPLOADER_CONFIG_PAGE)
if (type === null) {
Expand Down
16 changes: 16 additions & 0 deletions src/renderer/pages/DocumentPage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<webview
src="https://piclist.cn/app.html"
disablewebsecurity
allowpopups
autosize="on"
scrollbars="none"
style="width: 100%; height: 100%;"
/>
</template>

<script lang="ts">
export default {
name: 'DocumentPage'
}
</script>
1 change: 1 addition & 0 deletions src/renderer/router/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export const TOOLBOX_CONFIG_PAGE = 'ToolBoxPage'
export const TRAY_PAGE = 'TrayPage'
export const UPLOAD_PAGE = 'UploadPage'
export const UPLOADER_CONFIG_PAGE = 'UploaderConfigPage'
export const DocumentPage = 'DocumentPage'
5 changes: 5 additions & 0 deletions src/renderer/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export default createRouter({
component: () => import(/* webpackChunkName: "Plugin" */ '@/pages/Plugin.vue'),
name: config.PLUGIN_PAGE
},
{
path: 'documents',
component: () => import(/* webpackChunkName: "DocumentPage" */ '@/pages/DocumentPage.vue'),
name: config.DocumentPage
},
{
path: 'shortKey',
component: () => import(/* webpackChunkName: "ShortkeyPage" */ '@/pages/ShortKey.vue'),
Expand Down

0 comments on commit bc7a446

Please sign in to comment.