Skip to content

Commit

Permalink
支持编辑PHP安装扩展的脚本文件
Browse files Browse the repository at this point in the history
  • Loading branch information
xianyunleo committed Nov 23, 2023
1 parent 5f1fb2b commit ea33ae8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
18 changes: 16 additions & 2 deletions src/main/core/php/extension/Extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Path from "@/main/utils/Path";
import Php from "@/main/core/php/Php";
import FileUtil from "@/main/utils/FileUtil";
import { isWindows } from '@/main/utils/utils'
import GetPath from '@/shared/utils/GetPath'

export default class Extension {
static async getList(phpVersion) {
Expand Down Expand Up @@ -104,9 +105,9 @@ export default class Extension {
} else if (phpVersion < 7.2) {
return '4.5.11';
} else if (phpVersion < 8.0) {
return '4.8.11';
return '4.8.13';
} else {
return '5.0.0';
return '5.1.0';
}
case 'mongodb':
if (phpVersion <= 7.1) {
Expand Down Expand Up @@ -177,4 +178,17 @@ export default class Extension {
}
return null;
}

/**
*
* @param extName {string}
* @returns {string}
*/
static getInstallScriptPath(extName) {
if (isWindows) {
return Path.Join(GetPath.getScriptDir(), `php/common.ps1`)
} else {
return Path.Join(GetPath.getScriptDir(), `php/${extName}.sh`)
}
}
}
9 changes: 4 additions & 5 deletions src/main/core/php/extension/Installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,16 @@ export default class Installer {
}
let phpDir = GetPath.getPhpDir(this.phpVersion);

const scriptPath = Extension.getInstallScriptPath(this.extName);
if (isWindows) {
let scriptFilePath = Path.Join(GetPath.getScriptDir(), `php/common.ps1`);
let extFileName = Extension.getFileName(this.extName);
let phpExtDir = Php.getExtensionDir(this.phpVersion);
let dlFileName = this.getDownloadFileName();
commandStr = ` powershell.exe -ExecutionPolicy Bypass -File "${scriptFilePath}"`;
commandStr = ` powershell.exe -ExecutionPolicy Bypass -File "${scriptPath}"`;
commandStr += ` ${phpExtDlDir} ${phpDir} ${this.extVersion} ${this.extName} ${extFileName} ${phpExtDir} ${dlFileName}`;
} else {
let scriptFilePath = Path.Join(GetPath.getScriptDir(), `php/${this.extName}.sh`);
fs.chmodSync(scriptFilePath, '0755');
commandStr = `${scriptFilePath} ${phpExtDlDir} ${phpDir} ${this.extVersion}`;
fs.chmodSync(scriptPath, '0755');
commandStr = `${scriptPath} ${phpExtDlDir} ${phpDir} ${this.extVersion}`;
}

let childProcess = child_process.exec(commandStr);
Expand Down
8 changes: 7 additions & 1 deletion src/renderer/components/Software/PhpExtManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<a-button type="primary" disabled v-if="record.isInstalled">
{{t('Installed')}}
</a-button>
<a-button type="primary" style='margin-left: 10px' @click="editScript(record)">
{{mt('Edit','ws','Script')}}
</a-button>
</div>
</template>
</template>
Expand Down Expand Up @@ -106,7 +109,6 @@ const openExtDir = () => {
Native.openDirectory(Php.getExtensionDir(props.phpVersion));
}
let installer;
let eventEmitter;
const install = (item) => {
Expand Down Expand Up @@ -152,6 +154,10 @@ const install = (item) => {
})
}
const editScript = (item) => {
Native.openTextFile(Extension.getInstallScriptPath(item.name))
}
const closeTaskDialog = () => {
installer?.stop();
msg.value = '';
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default {
Error: 'Error',
Warning: 'Warning',
Match:'Match',
Script:'Script',
//Lowercase
none: 'none',
auto: 'auto',
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default {
Error: '错误',
Warning: '警告',
Match:'匹配',
Script:'脚本',
//Lowercase
none: '无',
auto: '自动',
Expand Down

0 comments on commit ea33ae8

Please sign in to comment.