Skip to content

Commit

Permalink
fix(web): 修复加载本地脚本时应该指定为只有 .user.js 才能加载
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed May 31, 2023
1 parent 9b3f184 commit 8cc7114
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions packages/web/src/pages/user-scripts/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@
label="脚本主页"
>
<template v-if="script.info.url.startsWith('http')">
<a :href="script.info?.url || ''"> {{ script.info?.url || '' }} </a>
<a :href="script.info!.url "> {{ script.info!.url }} </a>
</template>
<template v-else>
<div
style="text-decoration: underline; cursor: pointer"
@click="shell.showItemInFolder(script.info.url)"
@click="shell.showItemInFolder(script.info!.url)"
>
{{ script.info?.url }}
</div>
Expand Down Expand Up @@ -201,7 +201,10 @@
</div>
</template>

<script setup lang="ts">
<script
setup
lang="ts"
>
import { ref, h } from 'vue';
import { config } from '../../config';
import { store, StoreUserScript } from '../../store';
Expand Down Expand Up @@ -315,7 +318,10 @@ function addScriptFromURL() {
}
</script>

<style scoped lang="less">
<style
scoped
lang="less"
>
.actions {
div + div {
margin-left: 4px;
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/utils/user-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { store } from '../store';
export function addScriptFromFile() {
remote.dialog
.call('showOpenDialog', {
title: '选择脚本文件(.user.js)',
title: '选择脚本文件,后缀必须为 (.user.js)',
buttonLabel: '添加脚本',
filters: [{ extensions: ['js', 'user.js'], name: '用户脚本' }]
filters: [{ extensions: ['user.js'], name: '用户脚本' }]
})
.then(async ({ canceled, filePaths }) => {
if (canceled === false && filePaths.length) {
Expand Down

0 comments on commit 8cc7114

Please # to comment.