Skip to content

Commit

Permalink
feat: 新增OCS桌面版 MAC 版本适配
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Oct 21, 2023
1 parent 1b5f72a commit da2e91a
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dist"
],
"scripts": {
"build": "gulp -f ./scripts/build-app.js",
"build": "npm run tsc && gulp -f ./scripts/build-app.js",
"release": "sh ./scripts/release.sh",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md --same-file -r 0",
"tsc": "pnpm lint && gulp -f ./scripts/tsc.js",
Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/tasks/remote.register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const methods = {
getValidBrowsers: getValidBrowsers,
systemProcesses: () => si.processes(),
exportExcel: exportExcel,
statisticFolderSize: statisticFolderSize
statisticFolderSize: statisticFolderSize,
getPlatform: () => process.platform
};

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export function createWindow() {
icon: path.resolve('./public/favicon.ico'),
minHeight: 800,
minWidth: 1200,
width: 1200,
height: 800,
center: true,
hasShadow: true,
autoHideMenuBar: true,
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class ScriptWorker {
// 拓展文件夹路径
this.extensionPaths = fs
.readdirSync(store.paths.extensionsFolder)
.filter((f) => f !== '.DS_Store')
.map((file) => path.join(store.paths.extensionsFolder, file));

// 自动化脚本
Expand Down
15 changes: 10 additions & 5 deletions packages/web/src/components/Title.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="title ps-2">
<span
class="logo"
style="cursor: pointer; -webkit-app-region: no-drag"
@click="shell.openExternal('https://docs.ocsjs.com')"
>
Expand All @@ -12,7 +13,6 @@
</span>
<a-dropdown
class="tittle-dropdown"
position="bl"
trigger="hover"
:popup-max-height="false"
>
Expand Down Expand Up @@ -44,7 +44,6 @@
</a-dropdown>
<a-dropdown
class="tittle-dropdown"
position="bl"
trigger="hover"
:popup-max-height="false"
>
Expand Down Expand Up @@ -133,7 +132,7 @@

<a-dropdown
class="tittle-dropdown"
position="bl"
position="bottom"
trigger="hover"
:popup-max-height="false"
>
Expand Down Expand Up @@ -344,6 +343,10 @@ function reset() {
background-color: #f0f0f0;
}
}
> span {
display: flex;
}
}
:deep(.ant-dropdown-menu-item) {
font-size: 12px;
Expand All @@ -359,7 +362,9 @@ function reset() {
padding: 8px 12px 0px 12px !important;
}
.logo {
width: 18px;
body.platform-darwin {
.title {
justify-content: center;
}
}
</style>
5 changes: 5 additions & 0 deletions packages/web/src/components/browsers/FileOperators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import { RawPlaywrightScript } from '../playwright-scripts';
import PlaywrightScriptSelector from '../playwright-scripts/PlaywrightScriptSelector.vue';
import PlaywrightScriptTable from '../playwright-scripts/PlaywrightScriptTable.vue';
import { remote } from '../../utils/remote';
import { Message } from '@arco-design/web-vue';
const state = reactive({
showPlaywrightScriptSelector: false,
Expand Down Expand Up @@ -114,6 +115,10 @@ function newFolder() {
currentFolder.value.children[id] = folder;
}
function newBrowser(opts?: { name: string; playwrightScripts?: RawPlaywrightScript[]; store?: object }) {
if (!store?.render?.setting?.launchOptions?.executablePath) {
Message.error('检测到浏览器路径未填写,请在左侧软件设置中设置,然后重新创建浏览器!');
return;
}
// 关闭搜索模式
resetSearch();
const id = Entity.uuid();
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/components/setting/BrowserPath.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const launchOptions = store.render.setting.launchOptions;
*/
async function onDiy() {
if (launchOptions.executablePath) {
launchOptions.executablePath = launchOptions.executablePath.trim();
const exists = await remote.fs.call('existsSync', launchOptions.executablePath);
if (!exists) {
Message.error('浏览器路径不存在, 请点击右侧按钮查看教程。');
Expand Down
9 changes: 6 additions & 3 deletions packages/web/src/fs/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class Browser extends Entity implements BrowserOptions {
'--window-position=0,0',
'--no-first-run',
'--no-default-browser-check',
`--user-data-dir=${this.cachePath}`
`--user-data-dir="${this.cachePath}"`
]
.concat(formatExtensionArguments(extensionPaths))
.join(' ')} http://localhost:${store.server.port || 15319}/index.html#/bookmarks`;
Expand Down Expand Up @@ -155,6 +155,9 @@ export class Browser extends Entity implements BrowserOptions {
}

function formatExtensionArguments(extensionPaths: string[]) {
const paths = extensionPaths.map((p) => p.replace(/\\/g, '/')).join(',');
return [`--disable-extensions-except=${paths}`, `--load-extension=${paths}`];
const paths = extensionPaths
.filter((f) => f.includes('.DS_Store') === false)
.map((p) => p.replace(/\\/g, '/'))
.join(',');
return [`--load-extension="${paths}"`];
}
1 change: 1 addition & 0 deletions packages/web/src/pages/resources/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<a-col
v-if="fileStatus[file.url]"
flex="64px"
class="d-flex justify-content-center"
>
<a-space>
<template v-if="fileStatus[file.url].exists || fileStatus[file.url].downloadRate === 100">
Expand Down
34 changes: 19 additions & 15 deletions packages/web/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,25 @@ export async function about() {
});
}

export function changeTheme() {
if (store.render.setting.theme.dark) {
// 设置为暗黑主题
document.body.setAttribute('arco-theme', 'dark');
remote.win.call('setTitleBarOverlay', {
color: '#2C2C2C',
symbolColor: 'white'
});
} else {
// 恢复亮色主题
document.body.removeAttribute('arco-theme');
remote.win.call('setTitleBarOverlay', {
color: '#fff',
symbolColor: 'black'
});
export async function changeTheme() {
const platform = await remote.methods.call('getPlatform');
document.body.classList.add('platform-' + platform);
if (platform !== 'darwin') {
if (store.render.setting.theme.dark) {
// 设置为暗黑主题
document.body.setAttribute('arco-theme', 'dark');
remote.win.call('setTitleBarOverlay', {
color: '#2C2C2C',
symbolColor: 'white'
});
} else {
// 恢复亮色主题
document.body.removeAttribute('arco-theme');
remote.win.call('setTitleBarOverlay', {
color: '#fff',
symbolColor: 'black'
});
}
}
}

Expand Down

0 comments on commit da2e91a

Please # to comment.