mirror of
https://github.com/daief/gm-response-proxy.git
synced 2026-05-10 03:34:03 +08:00
wip: init setting panel
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>dsds {{ val }}</div>
|
<div v-if="show" @click="show = false">dsds {{ val }}</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -9,13 +9,14 @@ export default defineComponent({
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
val: 1,
|
val: 1,
|
||||||
|
show: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.div {
|
div {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,5 +2,16 @@ import { createApp } from 'vue';
|
|||||||
import App from './Panel.vue';
|
import App from './Panel.vue';
|
||||||
|
|
||||||
export function render(el: any) {
|
export function render(el: any) {
|
||||||
createApp(App).mount(el);
|
const vm = createApp(App);
|
||||||
|
const $root = vm.mount(el);
|
||||||
|
|
||||||
|
return {
|
||||||
|
$root,
|
||||||
|
open: () => {
|
||||||
|
($root.$data as any).show = true;
|
||||||
|
},
|
||||||
|
close: () => {
|
||||||
|
($root.$data as any).show = false;
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,10 @@
|
|||||||
z-index: 4000;
|
z-index: 4000;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: #6cf;
|
background-color: #6cf;
|
||||||
|
transition: all 0.3s;
|
||||||
|
|
||||||
|
&.hidden {
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/index.ts
19
src/index.ts
@@ -5,13 +5,26 @@ import './global.less';
|
|||||||
import { render } from './SettingPanel';
|
import { render } from './SettingPanel';
|
||||||
// import(/* webpackChunkName: 'setting-panel' */ './SettingPanel');
|
// import(/* webpackChunkName: 'setting-panel' */ './SettingPanel');
|
||||||
|
|
||||||
|
let handler: any;
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
const el = document.createElement('div');
|
const el = document.createElement('div');
|
||||||
el.innerText = '设置';
|
el.innerText = '设置';
|
||||||
el.className += 'response-proxy-page-root-fixed-button';
|
el.className = 'response-proxy-page-root-fixed-button';
|
||||||
|
|
||||||
el.addEventListener('click', async () => {
|
el.addEventListener('click', async () => {
|
||||||
//
|
if (!handler) {
|
||||||
render(el);
|
handler = render(elForMount);
|
||||||
|
handler.$root.$watch('show', (newVal: boolean) => {
|
||||||
|
el.classList[newVal ? 'add' : 'remove']('hidden');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.open();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const elForMount = document.createElement('div');
|
||||||
|
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
|
document.body.appendChild(elForMount);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user