@vasakgroup/vue-libvasak 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ (function(c,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],s):(c=typeof globalThis<"u"?globalThis:c||self,s(c.VueLibVasak={},c.Vue))})(this,(function(c,s){"use strict";const B=(i,e)=>{const t=i.__vccOpts||i;for(const[l,a]of e)t[l]=a;return t},V={},M={class:"sidebar"};function F(i,e){return s.openBlock(),s.createElementBlock("div",M,[s.renderSlot(i.$slots,"default")])}const z=B(V,[["render",F]]),U={href:"#",class:"sidebar-button"},G=["src"],W=s.defineComponent({__name:"SideButton",props:{title:{type:String,default:"Link"},image:{type:String,default:""}},setup(i){return(e,t)=>(s.openBlock(),s.createElementBlock("a",U,[s.createElementVNode("img",{src:i.image,class:"img-fluid"},null,8,G)]))}});function $(i,e,t,l){if(typeof e=="function"?i!==e||!l:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?l:t==="a"?l.call(i):l?l.value:e.get(i)}function H(i,e,t,l,a){if(typeof e=="function"?i!==e||!0:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(i,t),t}typeof SuppressedError=="function"&&SuppressedError;var _;const u="__TAURI_TO_IPC_KEY__";function j(i,e=!1){return window.__TAURI_INTERNALS__.transformCallback(i,e)}async function n(i,e={},t){return window.__TAURI_INTERNALS__.invoke(i,e,t)}class q{get rid(){return $(this,_,"f")}constructor(e){_.set(this,void 0),H(this,_,e)}async close(){return n("plugin:resources|close",{rid:this.rid})}}_=new WeakMap;class k{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new g(this.width*e,this.height*e)}[u](){return{width:this.width,height:this.height}}toJSON(){return this[u]()}}class g{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new k(this.width/e,this.height/e)}[u](){return{width:this.width,height:this.height}}toJSON(){return this[u]()}}class h{constructor(e){this.size=e}toLogical(e){return this.size instanceof k?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof g?this.size:this.size.toPhysical(e)}[u](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[u]()}}class E{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new d(this.x*e,this.y*e)}[u](){return{x:this.x,y:this.y}}toJSON(){return this[u]()}}class d{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new E(this.x/e,this.y/e)}[u](){return{x:this.x,y:this.y}}toJSON(){return this[u]()}}class y{constructor(e){this.position=e}toLogical(e){return this.position instanceof E?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof d?this.position:this.position.toPhysical(e)}[u](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[u]()}}var o;(function(i){i.WINDOW_RESIZED="tauri://resize",i.WINDOW_MOVED="tauri://move",i.WINDOW_CLOSE_REQUESTED="tauri://close-requested",i.WINDOW_DESTROYED="tauri://destroyed",i.WINDOW_FOCUS="tauri://focus",i.WINDOW_BLUR="tauri://blur",i.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",i.WINDOW_THEME_CHANGED="tauri://theme-changed",i.WINDOW_CREATED="tauri://window-created",i.WEBVIEW_CREATED="tauri://webview-created",i.DRAG_ENTER="tauri://drag-enter",i.DRAG_OVER="tauri://drag-over",i.DRAG_DROP="tauri://drag-drop",i.DRAG_LEAVE="tauri://drag-leave"})(o||(o={}));async function N(i,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(i,e),await n("plugin:event|unlisten",{event:i,eventId:e})}async function x(i,e,t){var l;const a=typeof t?.target=="string"?{kind:"AnyLabel",label:t.target}:(l=t?.target)!==null&&l!==void 0?l:{kind:"Any"};return n("plugin:event|listen",{event:i,target:a,handler:j(e)}).then(w=>async()=>N(i,w))}async function J(i,e,t){return x(i,l=>{N(i,l.id),e(l)},t)}async function Z(i,e){await n("plugin:event|emit",{event:i,payload:e})}async function Q(i,e,t){await n("plugin:event|emit_to",{target:typeof i=="string"?{kind:"AnyLabel",label:i}:i,event:e,payload:t})}class p extends q{constructor(e){super(e)}static async new(e,t,l){return n("plugin:image|new",{rgba:m(e),width:t,height:l}).then(a=>new p(a))}static async fromBytes(e){return n("plugin:image|from_bytes",{bytes:m(e)}).then(t=>new p(t))}static async fromPath(e){return n("plugin:image|from_path",{path:e}).then(t=>new p(t))}async rgba(){return n("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return n("plugin:image|size",{rid:this.rid})}}function m(i){return i==null?null:typeof i=="string"?i:i instanceof p?i.rid:i}var f;(function(i){i[i.Critical=1]="Critical",i[i.Informational=2]="Informational"})(f||(f={}));class Y{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var C;(function(i){i.None="none",i.Normal="normal",i.Indeterminate="indeterminate",i.Paused="paused",i.Error="error"})(C||(C={}));function I(){return new O(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function v(){return n("plugin:window|get_all_windows").then(i=>i.map(e=>new O(e,{skip:!0})))}const D=["tauri://created","tauri://error"];class O{constructor(e,t={}){var l;this.label=e,this.listeners=Object.create(null),t?.skip||n("plugin:window|create",{options:{...t,parent:typeof t.parent=="string"?t.parent:(l=t.parent)===null||l===void 0?void 0:l.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var t;return(t=(await v()).find(l=>l.label===e))!==null&&t!==void 0?t:null}static getCurrent(){return I()}static async getAll(){return v()}static async getFocusedWindow(){for(const e of await v())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{const l=this.listeners[e];l.splice(l.indexOf(t),1)}:x(e,t,{target:{kind:"Window",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{const l=this.listeners[e];l.splice(l.indexOf(t),1)}:J(e,t,{target:{kind:"Window",label:this.label}})}async emit(e,t){if(D.includes(e)){for(const l of this.listeners[e]||[])l({event:e,id:-1,payload:t});return}return Z(e,t)}async emitTo(e,t,l){if(D.includes(t)){for(const a of this.listeners[t]||[])a({event:t,id:-1,payload:l});return}return Q(e,t,l)}_handleTauriEvent(e,t){return D.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async scaleFactor(){return n("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return n("plugin:window|inner_position",{label:this.label}).then(e=>new d(e))}async outerPosition(){return n("plugin:window|outer_position",{label:this.label}).then(e=>new d(e))}async innerSize(){return n("plugin:window|inner_size",{label:this.label}).then(e=>new g(e))}async outerSize(){return n("plugin:window|outer_size",{label:this.label}).then(e=>new g(e))}async isFullscreen(){return n("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return n("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return n("plugin:window|is_maximized",{label:this.label})}async isFocused(){return n("plugin:window|is_focused",{label:this.label})}async isDecorated(){return n("plugin:window|is_decorated",{label:this.label})}async isResizable(){return n("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return n("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return n("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return n("plugin:window|is_closable",{label:this.label})}async isVisible(){return n("plugin:window|is_visible",{label:this.label})}async title(){return n("plugin:window|title",{label:this.label})}async theme(){return n("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return n("plugin:window|is_always_on_top",{label:this.label})}async center(){return n("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(e===f.Critical?t={type:"Critical"}:t={type:"Informational"}),n("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return n("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return n("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return n("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return n("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return n("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return n("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return n("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return n("plugin:window|maximize",{label:this.label})}async unmaximize(){return n("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return n("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return n("plugin:window|minimize",{label:this.label})}async unminimize(){return n("plugin:window|unminimize",{label:this.label})}async show(){return n("plugin:window|show",{label:this.label})}async hide(){return n("plugin:window|hide",{label:this.label})}async close(){return n("plugin:window|close",{label:this.label})}async destroy(){return n("plugin:window|destroy",{label:this.label})}async setDecorations(e){return n("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return n("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return n("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return n("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return n("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return n("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return n("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return n("plugin:window|set_size",{label:this.label,value:e instanceof h?e:new h(e)})}async setMinSize(e){return n("plugin:window|set_min_size",{label:this.label,value:e instanceof h?e:e?new h(e):null})}async setMaxSize(e){return n("plugin:window|set_max_size",{label:this.label,value:e instanceof h?e:e?new h(e):null})}async setSizeConstraints(e){function t(l){return l?{Logical:l}:null}return n("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:t(e?.minWidth),minHeight:t(e?.minHeight),maxWidth:t(e?.maxWidth),maxHeight:t(e?.maxHeight)}})}async setPosition(e){return n("plugin:window|set_position",{label:this.label,value:e instanceof y?e:new y(e)})}async setFullscreen(e){return n("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return n("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return n("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return n("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return n("plugin:window|set_icon",{label:this.label,value:m(e)})}async setSkipTaskbar(e){return n("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return n("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return n("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return n("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return n("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return n("plugin:window|set_cursor_position",{label:this.label,value:e instanceof y?e:new y(e)})}async setIgnoreCursorEvents(e){return n("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return n("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return n("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return n("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return n("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return n("plugin:window|set_overlay_icon",{label:this.label,value:e?m(e):void 0})}async setProgressBar(e){return n("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return n("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return n("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return n("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(o.WINDOW_RESIZED,t=>{t.payload=new g(t.payload),e(t)})}async onMoved(e){return this.listen(o.WINDOW_MOVED,t=>{t.payload=new d(t.payload),e(t)})}async onCloseRequested(e){return this.listen(o.WINDOW_CLOSE_REQUESTED,async t=>{const l=new Y(t);await e(l),l.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const t=await this.listen(o.DRAG_ENTER,r=>{e({...r,payload:{type:"enter",paths:r.payload.paths,position:new d(r.payload.position)}})}),l=await this.listen(o.DRAG_OVER,r=>{e({...r,payload:{type:"over",position:new d(r.payload.position)}})}),a=await this.listen(o.DRAG_DROP,r=>{e({...r,payload:{type:"drop",paths:r.payload.paths,position:new d(r.payload.position)}})}),w=await this.listen(o.DRAG_LEAVE,r=>{e({...r,payload:{type:"leave"}})});return()=>{t(),a(),l(),w()}}async onFocusChanged(e){const t=await this.listen(o.WINDOW_FOCUS,a=>{e({...a,payload:!0})}),l=await this.listen(o.WINDOW_BLUR,a=>{e({...a,payload:!1})});return()=>{t(),l()}}async onScaleChanged(e){return this.listen(o.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(o.WINDOW_THEME_CHANGED,e)}}var A;(function(i){i.Disabled="disabled",i.Throttle="throttle",i.Suspend="suspend"})(A||(A={}));var L;(function(i){i.AppearanceBased="appearanceBased",i.Light="light",i.Dark="dark",i.MediumLight="mediumLight",i.UltraDark="ultraDark",i.Titlebar="titlebar",i.Selection="selection",i.Menu="menu",i.Popover="popover",i.Sidebar="sidebar",i.HeaderView="headerView",i.Sheet="sheet",i.WindowBackground="windowBackground",i.HudWindow="hudWindow",i.FullScreenUI="fullScreenUI",i.Tooltip="tooltip",i.ContentBackground="contentBackground",i.UnderWindowBackground="underWindowBackground",i.UnderPageBackground="underPageBackground",i.Mica="mica",i.Blur="blur",i.Acrylic="acrylic",i.Tabbed="tabbed",i.TabbedDark="tabbedDark",i.TabbedLight="tabbedLight"})(L||(L={}));var R;(function(i){i.FollowsWindowActiveState="followsWindowActiveState",i.Active="active",i.Inactive="inactive"})(R||(R={}));async function K(i){try{return await n("plugin:vicons|get_icon",{name:i})}catch(e){console.error("[Icon Error] Error obteniendo icono:",e)}return""}function X(i){try{const e=atob(i.substring(0,32)),t=new Uint8Array(e.length);for(let l=0;l<e.length;l++)t[l]=e.charCodeAt(l);return t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?"image/png":"image/svg+xml"}catch(e){return console.error("Error identificando tipo de imagen:",e),"image/png"}}async function S(i){try{const e=await K(i);return`data:${X(e)};base64,${e}`}catch(e){return console.error("[Icon Error] Error obteniendo icono:",e),""}}const ee={"data-tauri-drag-region":""},ie=["src"],te={"data-tauri-drag-region":""},ne={"data-tauri-drag-region":""},le=["src"],se=["src"],ae=["src"],re=s.defineComponent({__name:"TopBar",props:{title:String,image:String},setup(i){const e=s.ref(null),t=I(),l=s.ref(""),a=s.ref(""),w=s.ref(""),r=i;return s.onMounted(async()=>{l.value=await S("window-close"),a.value=await S("window-minimize"),w.value=await S("window-maximize")}),(ce,b)=>(s.openBlock(),s.createElementBlock("div",{"data-tauri-drag-region":"",class:"flex h-8 px-4 py-1 bg-vsk-primary rounded-t-window justify-between align-center",ref_key:"bar",ref:e},[s.createElementVNode("div",ee,[s.createElementVNode("img",{src:r.image,"data-tauri-drag-region":"",class:"h-6 w-auto"},null,8,ie)]),s.createElementVNode("div",te,s.toDisplayString(r.title),1),s.createElementVNode("div",ne,[s.createElementVNode("span",{class:"win-button",onClick:b[0]||(b[0]=T=>s.unref(t).minimize())},[s.createElementVNode("img",{src:a.value,class:"h-6 w-6 inline-block",alt:"Minimize"},null,8,le)]),s.createElementVNode("span",{class:"win-button",onClick:b[1]||(b[1]=T=>s.unref(t).toggleMaximize())},[s.createElementVNode("img",{src:w.value,class:"h-6 w-6 inline-block",alt:"Maximize"},null,8,se)]),s.createElementVNode("span",{class:"win-button",onClick:b[2]||(b[2]=T=>s.unref(t).close())},[s.createElementVNode("img",{src:l.value,class:"h-6 w-6 inline-block",alt:"Close"},null,8,ae)])])],512))}}),P=s.defineComponent({__name:"WindowFrame",props:{title:{type:String,default:"Vasak"},image:{type:String,default:""}},setup(i){const e=i;return(t,l)=>(s.openBlock(),s.createElementBlock(s.Fragment,null,[s.createVNode(re,{title:e.title,image:e.image},null,8,["title","image"]),s.renderSlot(t.$slots,"default")],64))}}),oe=[z,W,P],ue={install(i){oe.forEach(e=>{i.component(e.name,e)})}};c.SideBar=z,c.SideButton=W,c.WindowFrame=P,c.default=ue,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/package.json CHANGED
@@ -1,13 +1,20 @@
1
1
  {
2
2
  "name": "@vasakgroup/vue-libvasak",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "Vue componenets for VSK Applications",
5
- "main": "src/index.ts",
6
- "module": "src/index.ts",
7
- "types": "src/index.ts",
5
+ "main": "./dist/vue-libvasak.umd.js",
6
+ "module": "./dist/vue-libvasak.es.js",
7
+ "types": "./dist/index.d.ts",
8
8
  "files": [
9
+ "dist",
9
10
  "src"
10
11
  ],
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/vue-libvasak.es.js",
15
+ "require": "./dist/vue-libvasak.umd.js"
16
+ }
17
+ },
11
18
  "keywords": [
12
19
  "vue",
13
20
  "vsk",
@@ -35,7 +42,21 @@
35
42
  },
36
43
  "license": "GPLv3",
37
44
  "dependencies": {
38
- "vue": "^3.3.13",
39
- "vue-router": "^4.2.5"
45
+ "@tauri-apps/api": "^2.8.0",
46
+ "@vasakgroup/plugin-vicons": "^2.0.0",
47
+ "vue": "^3.5.20",
48
+ "vue-router": "^4.5.1"
49
+ },
50
+ "peerDependencies": {
51
+ "vue": "^3.0.0"
52
+ },
53
+ "devDependencies": {
54
+ "typescript": "^5.9.2",
55
+ "vite": "^7.1.3",
56
+ "@vitejs/plugin-vue": "^6.0.1"
57
+ },
58
+ "scripts": {
59
+ "build": "vite build",
60
+ "dev": "vite"
40
61
  }
41
62
  }
package/src/.d.ts CHANGED
File without changes
package/src/index.ts CHANGED
@@ -1,5 +1,16 @@
1
1
  import SideBar from "./sidebar/SideBar.vue";
2
2
  import SideButton from "./sidebar/SideButton.vue";
3
3
  import WindowFrame from "./window/WindowFrame.vue";
4
+ import type { App } from "vue";
5
+
6
+ const components = [SideBar, SideButton, WindowFrame];
7
+
8
+ export default {
9
+ install(app: App) {
10
+ components.forEach((component) => {
11
+ app.component(component.name as string, component);
12
+ });
13
+ },
14
+ };
4
15
 
5
16
  export { SideBar, SideButton, WindowFrame };
File without changes
File without changes
@@ -0,0 +1,10 @@
1
+ declare module '@vasakgroup/vue-libvasak' {
2
+ import { Plugin } from 'vue';
3
+ import { Component } from 'vue';
4
+
5
+ export const SideBar: Component;
6
+ export const SideButton: Component;
7
+ export const WindowFrame: Component;
8
+ const plugin: Plugin;
9
+ export default plugin;
10
+ }
@@ -1,59 +1,46 @@
1
1
  <script lang="ts" setup>
2
- import { defineProps, inject, onMounted, ref, computed } from "vue";
2
+ import { defineProps, ref, Ref, onMounted } from "vue";
3
+ import { getCurrentWindow } from "@tauri-apps/api/window";
4
+ import { getIconSource } from "@vasakgroup/plugin-vicons";
3
5
 
4
- const $vsk: any = inject("vsk");
5
6
  const bar = ref(null);
7
+ const appWindow = getCurrentWindow();
8
+ const closeIcon: Ref<string> = ref("");
9
+ const minimizeIcon: Ref<string> = ref("");
10
+ const maximizeIcon: Ref<string> = ref("");
6
11
 
7
12
  const props = defineProps({
8
13
  title: String,
9
14
  image: String,
10
- customColor: String,
11
15
  });
12
16
 
13
- const move = () => {
14
- $vsk.startMove();
15
- };
16
-
17
- const close = () => {
18
- $vsk.exit();
19
- };
20
-
21
- const minimize = () => {
22
- $vsk.minimize();
23
- };
24
-
25
- const toggleMaximize = () => {
26
- $vsk.toggleMaximize();
27
- };
28
-
29
- const isCustom = computed(() => {
30
- console.log('customColor', props.customColor);
31
- return props.customColor ? `custom`: '';
32
- });
33
-
34
- onMounted(() => {
35
- if (bar.value) {
36
- (bar.value as HTMLElement).addEventListener("mousedown", (e: any) => {
37
- move();
38
- });
39
- }
17
+ onMounted(async () => {
18
+ closeIcon.value = await getIconSource("window-close");
19
+ minimizeIcon.value = await getIconSource("window-minimize");
20
+ maximizeIcon.value = await getIconSource("window-maximize");
40
21
  });
41
22
  </script>
42
23
 
43
24
  <template>
44
- <div class="window-topbar" :class="isCustom" ref="bar" @click="move()">
45
- <div><img :src="image" class="img-fluid win-icon" /></div>
46
- <div>{{ title }}</div>
47
- <div>
48
- <a class="win-button" href="#" @click="minimize()">_</a>
49
- <a class="win-button" href="#" @click="toggleMaximize()">[]</a>
50
- <a class="win-button" href="#" @click="close()">X</a>
25
+ <div
26
+ data-tauri-drag-region
27
+ class="flex h-8 px-4 py-1 bg-vsk-primary rounded-t-window justify-between align-center"
28
+ ref="bar"
29
+ >
30
+ <div data-tauri-drag-region>
31
+ <img :src="props.image" data-tauri-drag-region class="h-6 w-auto" />
32
+ </div>
33
+ <div data-tauri-drag-region>{{ props.title }}</div>
34
+ <div data-tauri-drag-region>
35
+ <span class="win-button" @click="appWindow.minimize()">
36
+ <img :src="minimizeIcon" class="h-6 w-6 inline-block" alt="Minimize">
37
+ </span>
38
+ <span class="win-button" @click="appWindow.toggleMaximize()">
39
+ <img :src="maximizeIcon" class="h-6 w-6 inline-block" alt="Maximize">
40
+ </span>
41
+ <span class="win-button" @click="appWindow.close()">
42
+ <img :src="closeIcon" class="h-6 w-6 inline-block" alt="Close">
43
+ </span>
51
44
  </div>
52
45
  </div>
53
46
  </template>
54
-
55
- <style scoped>
56
- .custom{
57
- background-color: v-bind(props.customColor);
58
- }
59
- </style>
@@ -1,17 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import TopBar from "./TopBar.vue";
3
- import { defineProps, ref, inject, onMounted, computed } from 'vue';
4
-
5
- const $vsk: any = inject("vsk");
6
-
7
- const top = ref(null);
8
- const left = ref(null);
9
- const right = ref(null);
10
- const bottom = ref(null);
11
- const topleft = ref(null);
12
- const bottomleft = ref(null);
13
- const topright = ref(null);
14
- const bottomright = ref(null);
3
+ import { defineProps } from "vue";
15
4
 
16
5
  const props = defineProps({
17
6
  title: {
@@ -22,71 +11,10 @@ const props = defineProps({
22
11
  type: String,
23
12
  default: "",
24
13
  },
25
- customColor: {
26
- type: String,
27
- default: null,
28
- }
29
- });
30
-
31
- const resize = (dir: string) => {
32
- $vsk.startResize(dir);
33
- };
34
-
35
- onMounted(() => {
36
- if (top.value) {
37
- (top.value as HTMLElement).addEventListener("mousedown", (e: any) => {
38
- resize("top");
39
- });
40
- }
41
- if (bottom.value) {
42
- (bottom.value as HTMLElement).addEventListener("mousedown", (e: any) => {
43
- resize("bottom");
44
- });
45
- }
46
- if (left.value) {
47
- (left.value as HTMLElement).addEventListener("mousedown", (e: any) => {
48
- resize("left");
49
- });
50
- }
51
- if (right.value) {
52
- (right.value as HTMLElement).addEventListener("mousedown", (e: any) => {
53
- resize("right");
54
- });
55
- }
56
- if (topleft.value) {
57
- (topleft.value as HTMLElement).addEventListener("mousedown", (e: any) => {
58
- resize("topleft");
59
- });
60
- }
61
- if (bottomleft.value) {
62
- (bottomleft.value as HTMLElement).addEventListener("mousedown", (e: any) => {
63
- resize("bottomleft");
64
- });
65
- }
66
- if (topright.value) {
67
- (topright.value as HTMLElement).addEventListener("mousedown", (e: any) => {
68
- resize("topright");
69
- });
70
- }
71
- if (bottomright.value) {
72
- (bottomright.value as HTMLElement).addEventListener("mousedown", (e: any) => {
73
- resize("bottomright");
74
- });
75
- }
76
14
  });
77
15
  </script>
78
16
 
79
17
  <template>
80
- <TopBar :title :image :customColor />
81
- <div class="window">
82
- <slot />
83
- <div ref="top" class="win-edge win-edge-top"></div>
84
- <div ref="left" class="win-edge win-edge-left"></div>
85
- <div ref="right" class="win-edge win-edge-right"></div>
86
- <div ref="bottom" class="win-edge win-edge-bottom"></div>
87
- <div ref="topleft" class="win-edge win-edge-topleft"></div>
88
- <div ref="bottomleft" class="win-edge win-edge-bottomleft"></div>
89
- <div ref="topright" class="win-edge win-edge-topright"></div>
90
- <div ref="bottomright" class="win-edge win-edge-bottomright"></div>
91
- </div>
18
+ <TopBar :title="props.title" :image="props.image" />
19
+ <slot />
92
20
  </template>