Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/server.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
steps:
# 切出代码,使用该 Action 将可以拉取最新代码
- uses: actions/checkout@v2
- run: docker-compose -f docker-compose.dev.yaml up --build -d
- run: sudo docker-compose -f docker-compose.dev.yaml up --build -d
2 changes: 1 addition & 1 deletion .github/workflows/server.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
steps:
# 切出代码,使用该 Action 将可以拉取最新代码
- uses: actions/checkout@v2
- run: docker-compose up -f docker-compose.prod.yaml --build -d
- run: sudo docker-compose -f docker-compose.prod.yaml up --build -d
11 changes: 6 additions & 5 deletions UNO-client/src/plugins/dialog/Dialog.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div v-if="visible" z-99 flex flex-col items-center justify="center" w="100%" h="100%" bg="#00000033">
<div flex flex-col justify="between" relative w="60 sm:80" :bg="isDark ? 'black' : 'white'" b="rounded-4 gray-300 4 dashed">
<div flex flex-col justify="between" relative w="60 sm:80" :bg="isDark ? 'black' : 'white'"
b="rounded-4 gray-300 4 dashed">
<button absolute top="1" right="2" @click="handleClose">X</button>
<div b="b-4 gray-300 dashed" min-h="10" p="2" c="gray-700 dark:gray-200">
<slot name="title">
Expand All @@ -17,8 +18,8 @@
hover="bg-gray-400 text-white" px-3 py-1 @click="handleConfirm">
确认
</button>
<button v-if="showCancel" text="3.5" c-red b="red rounded-10 3 dashed hover:transparent" transition="duration-400"
hover="bg-red-400 text-white" px-3 py-1 @click="handleCancel">
<button v-if="showCancel" text="3.5" c-red b="red rounded-10 3 dashed hover:transparent"
transition="duration-400" hover="bg-red-400 text-white" px-3 py-1 @click="handleCancel">
取消
</button>
</div>
Expand All @@ -33,15 +34,15 @@ interface DialogProps {
title?: string;
visible?: boolean;
content?: string;
showCancel?:boolean
showCancel?: boolean
}

const emit = defineEmits(['close', 'open', 'confirm', 'cancel'])

withDefaults(defineProps<DialogProps>(), {
title: '',
content: '',
visible:true,
visible: true,
showCancel: true
})

Expand Down
2 changes: 1 addition & 1 deletion UNO-client/src/plugins/dialog/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Plugin, App } from 'vue';
import Dialog from './Dialog.vue';

const install = (app: App)=>{
const install = (app: App) => {
app.component('Dialog', Dialog);
return app;
}
Expand Down
2 changes: 1 addition & 1 deletion UNO-client/src/plugins/notification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Plugin, App } from 'vue';
import Notification from './Notification.vue'
import notify from './notify';

const install = (app: App)=>{
const install = (app: App) => {
app.config.globalProperties.$notify = notify;
app.component(Notification.name, Notification);
return app;
Expand Down
145 changes: 72 additions & 73 deletions UNO-client/src/plugins/notification/notify.ts
Original file line number Diff line number Diff line change
@@ -1,76 +1,75 @@
/**
* 创建通知插件的调用方法
*/
import { createApp, ComponentPublicInstance } from 'vue';
import Notification from './Notification.vue';

export type OptionsType = {
content: string;
duration?: number;
btn?: string;
};

type InstanceType = {
id: string;
vm: ComponentPublicInstance<any>;
}

const instances: InstanceType[] = [];
let seed = 1;

const removeInstance = (id: string, removeHeight: number): void => {
const index = instances.findIndex(item => item.id === id);
const len = instances.length;

// 删除 instance
instances.splice(index, 1);

if (len < 1) return;

for (let i = index; i < len - 1; i++) {
const inst = instances[i].vm;
inst.topOffset = inst.topOffset - removeHeight - 16;
}
};

const notify = (options: OptionsType): void => {
const id = `notification_${seed++}`;
const container = document.createElement('div');
document.body.appendChild(container);

let verticalOffset = 16;
instances.forEach(item => {
verticalOffset += item.vm.$el.offsetHeight + 16;
});

const instance = createApp({
data() {
return {
topOffset: verticalOffset
}
},
methods: {
closedFunc(height: number):void {
removeInstance(id, height);
document.body.removeChild(container)
instance.unmount();
}
},
render() {
return h(Notification,{
...options,
verticalOffset:this.topOffset,
onClosed:this.closedFunc
})
}
});

instances.push({
id,
vm: instance.mount(container)
});
};

export default notify;


import { createApp, ComponentPublicInstance } from 'vue';
import Notification from './Notification.vue';

export type OptionsType = {
content: string;
duration?: number;
btn?: string;
};

type InstanceType = {
id: string;
vm: ComponentPublicInstance<any>;
}

const instances: InstanceType[] = [];
let seed = 1;

const removeInstance = (id: string, removeHeight: number): void => {
const index = instances.findIndex(item => item.id === id);
const len = instances.length;

// 删除 instance
instances.splice(index, 1);

if (len < 1) return;

for (let i = index; i < len - 1; i++) {
const inst = instances[i].vm;
inst.topOffset = inst.topOffset - removeHeight - 16;
}
};

const notify = (options: OptionsType): void => {
const id = `notification_${seed++}`;
const container = document.createElement('div');
document.body.appendChild(container);

let verticalOffset = 16;
instances.forEach(item => {
verticalOffset += item.vm.$el.offsetHeight + 16;
});

const instance = createApp({
data() {
return {
topOffset: verticalOffset
}
},
methods: {
closedFunc(height: number): void {
removeInstance(id, height);
document.body.removeChild(container)
instance.unmount();
}
},
render() {
return h(Notification, {
...options,
verticalOffset: this.topOffset,
onClosed: this.closedFunc
})
}
});

instances.push({
id,
vm: instance.mount(container)
});
};

export default notify;