mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-21 22:55:36 +00:00
refactor:自定义后台入口优化
This commit is contained in:
parent
fdb24c9e18
commit
d29dd915c1
@ -102,11 +102,11 @@ class Config extends Backend
|
||||
// 修改 adminBaseRoutePath
|
||||
$adminBaseFilePath = Filesystem::fsFit(root_path() . $this->filePath['webAdminBase']);
|
||||
$adminBaseContent = @file_get_contents($adminBaseFilePath);
|
||||
if (!$adminBaseContent) $this->error('Configuration write failed: %s', [$this->filePath['webAdminBase']]);
|
||||
if (!$adminBaseContent) $this->error(__('Configuration write failed: %s', [$this->filePath['webAdminBase']]));
|
||||
|
||||
$adminBaseContent = str_replace("export const adminBaseRoutePath = '$backendEntrance'", "export const adminBaseRoutePath = '{$data[$item->name]}'", $adminBaseContent);
|
||||
$result = @file_put_contents($adminBaseFilePath, $adminBaseContent);
|
||||
if (!$result) $this->error('Configuration write failed: %s', [$this->filePath['webAdminBase']]);
|
||||
if (!$result) $this->error(__('Configuration write failed: %s', [$this->filePath['webAdminBase']]));
|
||||
|
||||
// 去除后台入口开头的斜杠
|
||||
$oldBackendEntrance = ltrim($backendEntrance, '/');
|
||||
@ -117,7 +117,7 @@ class Config extends Backend
|
||||
if (!in_array('admin', $denyAppList)) {
|
||||
$appConfigFilePath = Filesystem::fsFit(root_path() . $this->filePath['appConfig']);
|
||||
$appConfigContent = @file_get_contents($appConfigFilePath);
|
||||
if (!$appConfigContent) $this->error('Configuration write failed: %s', [$this->filePath['appConfig']]);
|
||||
if (!$appConfigContent) $this->error(__('Configuration write failed: %s', [$this->filePath['appConfig']]));
|
||||
|
||||
$denyAppListStr = '';
|
||||
foreach ($denyAppList as $appName) {
|
||||
@ -129,7 +129,7 @@ class Config extends Backend
|
||||
|
||||
$appConfigContent = preg_replace("/'deny_app_list'(\s+)=>(\s+)(.*)/", "'deny_app_list'\$1=>\$2$denyAppListStr,", $appConfigContent);
|
||||
$result = @file_put_contents($appConfigFilePath, $appConfigContent);
|
||||
if (!$result) $this->error('Configuration write failed: %s', [$this->filePath['appConfig']]);
|
||||
if (!$result) $this->error(__('Configuration write failed: %s', [$this->filePath['appConfig']]));
|
||||
}
|
||||
|
||||
// 建立API入口文件
|
||||
@ -137,9 +137,11 @@ class Config extends Backend
|
||||
$newBackendEntranceFile = Filesystem::fsFit(public_path() . $newBackendEntrance . '.php');
|
||||
if (file_exists($oldBackendEntranceFile)) @unlink($oldBackendEntranceFile);
|
||||
|
||||
$backendEntranceStub = @file_get_contents(Filesystem::fsFit($this->filePath['backendEntranceStub']));
|
||||
$result = @file_put_contents($newBackendEntranceFile, $backendEntranceStub);
|
||||
if (!$result) $this->error('Configuration write failed: %s', [$newBackendEntranceFile]);
|
||||
$backendEntranceStub = @file_get_contents(Filesystem::fsFit(root_path() . $this->filePath['backendEntranceStub']));
|
||||
if (!$backendEntranceStub) $this->error(__('Configuration write failed: %s', [$this->filePath['backendEntranceStub']]));
|
||||
|
||||
$result = @file_put_contents($newBackendEntranceFile, $backendEntranceStub);
|
||||
if (!$result) $this->error(__('Configuration write failed: %s', [$newBackendEntranceFile]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ref, reactive, onMounted, onActivated, onDeactivated, onUnmounted } from 'vue'
|
||||
import FormItem from '/@/components/formItem/index.vue'
|
||||
import { index, postData, del, postSendTestMail } from '/@/api/backend/routine/config'
|
||||
import { ElMessageBox, ElNotification } from 'element-plus'
|
||||
@ -276,6 +276,16 @@ const onTestSendMail = () => {
|
||||
|
||||
onMounted(() => {
|
||||
getIndex()
|
||||
if (import.meta.hot) import.meta.hot.send('custom:close-hot', { type: 'config' })
|
||||
})
|
||||
onActivated(() => {
|
||||
if (import.meta.hot) import.meta.hot.send('custom:close-hot', { type: 'config' })
|
||||
})
|
||||
onDeactivated(() => {
|
||||
if (import.meta.hot) import.meta.hot.send('custom:open-hot', { type: 'config' })
|
||||
})
|
||||
onUnmounted(() => {
|
||||
if (import.meta.hot) import.meta.hot.send('custom:open-hot', { type: 'config' })
|
||||
})
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user