依赖修复 合并“移除site-packages”和“移除 python/Script”按钮

This commit is contained in:
li-xiaochen 2024-11-28 20:46:18 +08:00
parent aba55813d2
commit 60d2f99675
2 changed files with 29 additions and 42 deletions

View file

@ -80,14 +80,14 @@ class Api:
site_packages_path = Path("./python/Lib/site-packages") site_packages_path = Path("./python/Lib/site-packages")
if site_packages_path.exists(): if site_packages_path.exists():
rmtree(site_packages_path) rmtree(site_packages_path)
return "移除成功" return "site-packages目录移除成功"
return "python\\Lib\\site-packages目录不存在" return "python\\Lib\\site-packages目录不存在"
def rm_python_script(self): def rm_python_scripts(self):
python_script_path = Path("./python/Scripts") python_scripts_path = Path("./python/Scripts")
if python_script_path.exists(): if python_scripts_path.exists():
rmtree(python_script_path) rmtree(python_scripts_path)
return "移除成功" return "Scripts目录移除成功"
return "python\\Scripts目录不存在" return "python\\Scripts目录不存在"
def run(self, command, cwd=None): def run(self, command, cwd=None):

View file

@ -1,37 +1,27 @@
<script setup> <script setup>
const running = inject('running') const running = inject('running')
const notification = useNotification() const notification = useNotification()
async function rm_site_packages() {
running.value = true
notification['info']({
content: '提示',
meta: '开始移除site-packages',
duration: 3000
})
const response = await pywebview.api.rm_site_packages()
notification['info']({
content: '提示',
meta: response,
duration: 3000
})
running.value = false
}
async function rm_site_packages_and_python_scripts() {
async function rm_python_script() { running.value = true
running.value = true notification['info']({
notification['info']({ content: '提示',
content: '提示', meta: '开始移除site-packages和python/Script目录',
meta: '开始移除python/Script', duration: 3000
duration: 3000 })
}) const response = await pywebview.api.rm_site_packages()
const response = await pywebview.api.rm_python_script() notification['info']({
notification['info']({ content: '提示',
content: '提示', meta: response,
meta: response, duration: 3000
duration: 3000 })
}) const response2 = await pywebview.api.rm_python_scripts()
running.value = false notification['info']({
content: '提示',
meta: response2,
duration: 3000
})
running.value = false
} }
</script> </script>
@ -44,18 +34,15 @@ async function rm_python_script() {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
"> ">
<n-button class="fix-btn" type="error" secondary size="large" @click="rm_site_packages"> <n-button class="fix-btn" type="error" secondary size="large" @click="rm_site_packages_and_python_scripts">
移除 site-packages 移除 site-packages python/Scripts 目录
</n-button>
<n-button class="fix-btn" type="error" secondary size="large" @click="rm_python_script">
移除 python/Script
</n-button> </n-button>
</n-flex> </n-flex>
</template> </template>
<style scoped> <style scoped>
.fix-btn { .fix-btn {
width: 200px; width: 320px;
height: 48px; height: 48px;
} }
</style> </style>