mirror of https://github.com/Fabio286/antares.git
build: ts config for renderer
This commit is contained in:
parent
e0f85f469f
commit
d1bfa282c3
|
@ -183,7 +183,7 @@
|
||||||
"unzip-crx-3": "~0.2.0",
|
"unzip-crx-3": "~0.2.0",
|
||||||
"vue-eslint-parser": "~8.3.0",
|
"vue-eslint-parser": "~8.3.0",
|
||||||
"vue-loader": "~16.8.3",
|
"vue-loader": "~16.8.3",
|
||||||
"webpack": "~5.60.0",
|
"webpack": "~5.72.0",
|
||||||
"webpack-cli": "~4.9.1",
|
"webpack-cli": "~4.9.1",
|
||||||
"webpack-dev-server": "~4.4.0",
|
"webpack-dev-server": "~4.4.0",
|
||||||
"xvfb-maybe": "~0.2.1"
|
"xvfb-maybe": "~0.2.1"
|
||||||
|
|
|
@ -46,13 +46,15 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
export default {
|
import { computed, defineComponent, onBeforeUnmount } from 'vue';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
name: 'BaseConfirmModal',
|
name: 'BaseConfirmModal',
|
||||||
props: {
|
props: {
|
||||||
size: {
|
size: {
|
||||||
type: String,
|
type: String,
|
||||||
validator: prop => ['small', 'medium', '400', 'large'].includes(prop),
|
validator: (prop: string) => ['small', 'medium', '400', 'large'].includes(prop),
|
||||||
default: 'small'
|
default: 'small'
|
||||||
},
|
},
|
||||||
hideFooter: {
|
hideFooter: {
|
||||||
|
@ -63,48 +65,52 @@ export default {
|
||||||
cancelText: String
|
cancelText: String
|
||||||
},
|
},
|
||||||
emits: ['confirm', 'hide'],
|
emits: ['confirm', 'hide'],
|
||||||
computed: {
|
setup (props, { slots, emit }) {
|
||||||
hasHeader () {
|
const hasHeader = computed(() => !!slots.header);
|
||||||
return !!this.$slots.header;
|
const hasBody = computed(() => !!slots.body);
|
||||||
},
|
const hasDefault = computed(() => !!slots.default);
|
||||||
hasBody () {
|
const modalSizeClass = computed(() => {
|
||||||
return !!this.$slots.body;
|
if (props.size === 'small')
|
||||||
},
|
|
||||||
hasDefault () {
|
|
||||||
return !!this.$slots.default;
|
|
||||||
},
|
|
||||||
modalSizeClass () {
|
|
||||||
if (this.size === 'small')
|
|
||||||
return 'modal-sm';
|
return 'modal-sm';
|
||||||
if (this.size === '400')
|
if (props.size === '400')
|
||||||
return 'modal-400';
|
return 'modal-400';
|
||||||
else if (this.size === 'large')
|
else if (props.size === 'large')
|
||||||
return 'modal-lg';
|
return 'modal-lg';
|
||||||
else return '';
|
else return '';
|
||||||
}
|
});
|
||||||
},
|
|
||||||
created () {
|
|
||||||
window.addEventListener('keydown', this.onKey);
|
|
||||||
},
|
|
||||||
beforeUnmount () {
|
|
||||||
window.removeEventListener('keydown', this.onKey);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmModal () {
|
|
||||||
this.$emit('confirm');
|
|
||||||
this.hideModal();
|
|
||||||
},
|
|
||||||
|
|
||||||
hideModal () {
|
const confirmModal = () => {
|
||||||
this.$emit('hide');
|
emit('confirm');
|
||||||
},
|
hideModal();
|
||||||
onKey (e) {
|
};
|
||||||
|
|
||||||
|
const hideModal = () => {
|
||||||
|
emit('hide');
|
||||||
|
};
|
||||||
|
|
||||||
|
const onKey = (e: KeyboardEvent) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (e.key === 'Escape')
|
if (e.key === 'Escape')
|
||||||
this.hideModal();
|
hideModal();
|
||||||
}
|
};
|
||||||
|
|
||||||
|
window.addEventListener('keydown', onKey);
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
window.removeEventListener('keydown', onKey);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
hasHeader,
|
||||||
|
hasBody,
|
||||||
|
hasDefault,
|
||||||
|
modalSizeClass,
|
||||||
|
confirmModal,
|
||||||
|
hideModal,
|
||||||
|
onKey
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"include": [
|
"include": [
|
||||||
"./tests/**/*",
|
"./tests/**/*",
|
||||||
"./src/main/**/*",
|
"./src/main/**/*",
|
||||||
|
"./src/renderer/**/*",
|
||||||
"./src/common/interfaces/antares.ts"
|
"./src/common/interfaces/antares.ts"
|
||||||
],
|
],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
|
|
@ -44,7 +44,7 @@ const config = {
|
||||||
'@': path.resolve(__dirname, 'src/renderer'),
|
'@': path.resolve(__dirname, 'src/renderer'),
|
||||||
common: path.resolve(__dirname, 'src/common')
|
common: path.resolve(__dirname, 'src/common')
|
||||||
},
|
},
|
||||||
extensions: ['', '.js', '.vue', '.json'],
|
extensions: ['', '.js', '.vue', '.ts', '.json'],
|
||||||
fallback: {
|
fallback: {
|
||||||
fs: false,
|
fs: false,
|
||||||
path: false,
|
path: false,
|
||||||
|
@ -88,13 +88,22 @@ const config = {
|
||||||
use: 'babel-loader',
|
use: 'babel-loader',
|
||||||
exclude: /node_modules/
|
exclude: /node_modules/
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: /\.vue$/,
|
||||||
|
loader: 'vue-loader'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: /\.node$/,
|
test: /\.node$/,
|
||||||
use: 'node-loader'
|
use: 'node-loader'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.vue$/,
|
test: /\.ts$/,
|
||||||
loader: 'vue-loader'
|
exclude: /node_modules/,
|
||||||
|
loader: 'ts-loader',
|
||||||
|
options: {
|
||||||
|
appendTsSuffixTo: [/.vue$/],
|
||||||
|
transpileOnly: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.s(c|a)ss$/,
|
test: /\.s(c|a)ss$/,
|
||||||
|
|
Loading…
Reference in New Issue