🔧 ci: 更新 vite 打包脚本

This commit is contained in:
frostime 2024-10-16 14:43:56 +08:00
parent 4aee720da5
commit 591cf2e95e
10 changed files with 146 additions and 135 deletions

View file

@ -1,3 +1,11 @@
<!--
Copyright (c) 2024 by frostime. All Rights Reserved.
Author : frostime
Date : 2023-11-19 12:30:45
FilePath : /src/hello.svelte
LastEditTime : 2024-10-16 14:37:50
Description :
-->
<script lang="ts">
import { onDestroy, onMount } from "svelte";
import { version, sql as query } from "@/api";

View file

@ -1,26 +0,0 @@
#helloPanel {
border: 1px rgb(189, 119, 119) dashed;
}
.plugin-sample {
&__custom-tab {
background-color: var(--b3-theme-background);
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
&__custom-dock {
display: flex;
justify-content: center;
align-items: center;
}
&__time {
background: var(--b3-card-info-background);
border-radius: 4px;
padding: 2px 8px;
}
}

View file

@ -3,7 +3,7 @@
* @Author : frostime
* @Date : 2024-03-23 21:37:33
* @FilePath : /src/libs/dialog.ts
* @LastEditTime : 2024-07-19 15:34:39
* @LastEditTime : 2024-10-16 14:31:04
* @Description : Kits about dialogs
*/
import { Dialog } from "siyuan";
@ -135,7 +135,10 @@ export const simpleDialog = (args: {
destroyCallback: args.callback
});
dialog.element.querySelector(".dialog-content").appendChild(args.ele);
return dialog;
return {
dialog,
close: dialog.destroy.bind(dialog)
};
}
@ -147,9 +150,15 @@ export const svelteDialog = (args: {
let container = document.createElement('div')
container.style.display = 'contents';
let component = args.constructor(container);
simpleDialog({...args, ele: container, callback: () => {
component.$destroy();
if (args.callback) args.callback();;
}});
return component;
const { dialog, close } = simpleDialog({
...args, ele: container, callback: () => {
component.$destroy();
if (args.callback) args.callback();
}
});
return {
component,
dialog,
close
}
}

48
src/libs/promise-pool.ts Normal file
View file

@ -0,0 +1,48 @@
export default class PromiseLimitPool<T> {
private maxConcurrent: number;
private currentRunning = 0;
private queue: (() => void)[] = [];
private promises: Promise<T>[] = [];
constructor(maxConcurrent: number) {
this.maxConcurrent = maxConcurrent;
}
add(fn: () => Promise<T>): void {
const promise = new Promise<T>((resolve, reject) => {
const run = async () => {
try {
this.currentRunning++;
const result = await fn();
resolve(result);
} catch (error) {
reject(error);
} finally {
this.currentRunning--;
this.next();
}
};
if (this.currentRunning < this.maxConcurrent) {
run();
} else {
this.queue.push(run);
}
});
this.promises.push(promise);
}
async awaitAll(): Promise<T[]> {
return Promise.all(this.promises);
}
/**
* Handles the next task in the queue.
*/
private next(): void {
if (this.queue.length > 0 && this.currentRunning < this.maxConcurrent) {
const nextRun = this.queue.shift()!;
nextRun();
}
}
}