@owdproject/core 3.1.3 → 3.1.4
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.
- package/CHANGELOG.md +25 -0
- package/README.md +6 -7
- package/bin/owd.js +14 -14
- package/index.ts +5 -2
- package/module.ts +78 -61
- package/package.json +19 -17
- package/project.json +4 -0
- package/runtime/components/Core/Application/CoreApplicationRender.vue +6 -5
- package/runtime/components/Core/Application/CoreApplicationWindowsRender.vue +8 -8
- package/runtime/components/Core/Background/CoreBackground.vue +1 -1
- package/runtime/components/Core/Desktop/CoreDesktop.vue +31 -24
- package/runtime/components/Core/Explorer/CoreExplorerFile.vue +47 -38
- package/runtime/components/Core/Explorer/CoreExplorerFolder.vue +0 -1
- package/runtime/components/Core/Time/CoreTime.vue +10 -7
- package/runtime/components/Core/Window/CoreWindow.vue +49 -35
- package/runtime/components/Core/Window/CoreWindowContent.vue +3 -5
- package/runtime/components/Core/Window/CoreWindowNav.vue +12 -7
- package/runtime/composables/useApplicationEntries.ts +51 -0
- package/runtime/composables/useApplicationManager.ts +278 -5
- package/runtime/composables/useDesktopManager.ts +22 -4
- package/runtime/composables/useTerminalManager.ts +63 -4
- package/runtime/core/controllers/ApplicationController.ts +203 -192
- package/runtime/core/controllers/WindowController.ts +342 -334
- package/runtime/plugins/resize.client.ts +4 -4
- package/runtime/stores/storeApplication.ts +236 -0
- package/runtime/stores/storeApplicationMeta.ts +12 -8
- package/runtime/stores/storeApplicationWindows.ts +16 -12
- package/runtime/stores/storeDesktop.ts +35 -29
- package/runtime/stores/storeDesktopDefaultApps.ts +53 -0
- package/runtime/stores/storeDesktopVolume.ts +12 -12
- package/runtime/stores/storeDesktopWindow.ts +13 -13
- package/runtime/stores/storeDesktopWorkspace.ts +35 -31
- package/runtime/utils/utilApp.ts +27 -22
- package/runtime/utils/utilCommon.ts +43 -43
- package/runtime/utils/utilDebug.ts +17 -17
- package/runtime/utils/utilDesktop.ts +4 -4
- package/runtime/utils/utilTerminal.ts +6 -5
- package/runtime/utils/utilWindow.ts +11 -11
- package/test/fixtures/basic/app.vue +1 -2
- package/test/fixtures/basic/nuxt.config.ts +1 -3
- package/tsconfig.app.json +1 -1
- package/tsconfig.json +1 -1
- package/types/index.d.ts +235 -207
- package/vitest.config.ts +3 -3
- package/eslint.config.mjs +0 -30
- package/runtime/composables/useAppEntries.ts +0 -36
- package/runtime/composables/useClipboardFs.ts +0 -25
- package/runtime/core/managers/ApplicationManager.ts +0 -237
- package/runtime/core/managers/DesktopManager.ts +0 -37
- package/runtime/core/managers/TerminalManager.ts +0 -44
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import VueResizable from 'vue-resizable/src/components/vue-resizable.vue'
|
|
2
|
-
import {defineNuxtPlugin} from
|
|
2
|
+
import { defineNuxtPlugin } from 'nuxt/app'
|
|
3
3
|
|
|
4
|
-
export default defineNuxtPlugin(nuxtApp => {
|
|
5
|
-
|
|
6
|
-
})
|
|
4
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
5
|
+
nuxtApp.vueApp.component('vue-resizable', VueResizable)
|
|
6
|
+
})
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// actually unused
|
|
2
|
+
|
|
3
|
+
import { defineStore } from 'pinia'
|
|
4
|
+
import { reactive, ref, computed } from 'vue'
|
|
5
|
+
import { nanoid } from 'nanoid'
|
|
6
|
+
import { WindowController } from '../core/controllers/WindowController'
|
|
7
|
+
import { useApplicationManager } from '../composables/useApplicationManager'
|
|
8
|
+
import { useApplicationWindowsStore } from './storeApplicationWindows'
|
|
9
|
+
import { useApplicationMetaStore } from './storeApplicationMeta'
|
|
10
|
+
import { useTerminalManager } from '../composables/useTerminalManager'
|
|
11
|
+
import { useDesktopDefaultAppsStore } from './storeDesktopDefaultApps'
|
|
12
|
+
import { useDesktopWorkspaceStore } from './storeDesktopWorkspace'
|
|
13
|
+
import { debugLog, debugError } from '../utils/utilDebug'
|
|
14
|
+
|
|
15
|
+
interface WindowStoredState {
|
|
16
|
+
model: string
|
|
17
|
+
state: any
|
|
18
|
+
meta?: any
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const useApplicationStore = function(applicationId: string, applicationConfig: ApplicationConfig) {
|
|
22
|
+
return defineStore(`owd/application/${applicationId}`, () => {
|
|
23
|
+
// reactive state
|
|
24
|
+
const windows = reactive(new Map<string, WindowController>())
|
|
25
|
+
const isRunning = ref<boolean>(false)
|
|
26
|
+
|
|
27
|
+
// composables and external stores
|
|
28
|
+
const applicationManager = useApplicationManager()
|
|
29
|
+
const terminalManager = useTerminalManager()
|
|
30
|
+
const desktopDefaultAppsStore = useDesktopDefaultAppsStore()
|
|
31
|
+
const desktopWorkspaceStore = useDesktopWorkspaceStore()
|
|
32
|
+
|
|
33
|
+
let storeWindows: ReturnType<typeof useApplicationWindowsStore>
|
|
34
|
+
let storeMeta: ReturnType<typeof useApplicationMetaStore>
|
|
35
|
+
|
|
36
|
+
// init application
|
|
37
|
+
async function initApplication() {
|
|
38
|
+
storeWindows = useApplicationWindowsStore(applicationId)
|
|
39
|
+
storeMeta = useApplicationMetaStore(applicationId)
|
|
40
|
+
|
|
41
|
+
// set default app
|
|
42
|
+
if (applicationConfig.provides) {
|
|
43
|
+
const existingDefault = desktopDefaultAppsStore.getDefaultApp(
|
|
44
|
+
applicationConfig.provides.name,
|
|
45
|
+
)
|
|
46
|
+
if (!existingDefault) {
|
|
47
|
+
desktopDefaultAppsStore.setDefaultApp(
|
|
48
|
+
applicationConfig.provides.name,
|
|
49
|
+
store, // store o qualcosa che rappresenta questa app?
|
|
50
|
+
applicationConfig.entries![applicationConfig.provides.entry]!,
|
|
51
|
+
)
|
|
52
|
+
debugLog(
|
|
53
|
+
`${applicationConfig.title} set as predefined app for "${applicationConfig.provides.name}"`,
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// register terminal commands
|
|
59
|
+
if (applicationConfig.commands) {
|
|
60
|
+
for (const commandKey of Object.keys(applicationConfig.commands)) {
|
|
61
|
+
terminalManager.addCommand({
|
|
62
|
+
applicationId,
|
|
63
|
+
name: commandKey,
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (storeWindows.$persistedState) await storeWindows.$persistedState.isReady()
|
|
69
|
+
if (storeMeta.$persistedState) await storeMeta.$persistedState.isReady()
|
|
70
|
+
|
|
71
|
+
await restoreApplication()
|
|
72
|
+
|
|
73
|
+
if (typeof applicationConfig.onReady === 'function') {
|
|
74
|
+
applicationConfig.onReady(store)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// restore
|
|
79
|
+
async function restoreApplication() {
|
|
80
|
+
if (typeof applicationConfig.onRestore === 'function') {
|
|
81
|
+
await applicationConfig.onRestore(store)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!storeWindows.windows || Object.keys(storeWindows.windows).length === 0) {
|
|
85
|
+
return false
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
restoreWindows()
|
|
89
|
+
setRunning(true)
|
|
90
|
+
return true
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function restoreWindows() {
|
|
94
|
+
Object.keys(storeWindows.windows).forEach((windowId) => {
|
|
95
|
+
const windowStore = storeWindows.windows[windowId]
|
|
96
|
+
if (windowStore) {
|
|
97
|
+
openWindow(windowStore.model, windowStore, { isRestoring: true })
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
debugLog('Windows restored', windows)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// open window
|
|
104
|
+
function openWindow(
|
|
105
|
+
model: string,
|
|
106
|
+
windowStoredState?: WindowStoredState,
|
|
107
|
+
meta?: any,
|
|
108
|
+
): WindowController | undefined {
|
|
109
|
+
if (!applicationConfig.windows || !applicationConfig.windows.hasOwnProperty(model)) {
|
|
110
|
+
debugError(`Window model "${model}" not found`)
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let windowId: string
|
|
115
|
+
|
|
116
|
+
if (!windowStoredState) {
|
|
117
|
+
windowId = `${model}-${nanoid(6)}`
|
|
118
|
+
const windowConfig = applicationConfig.windows[model] as WindowConfig
|
|
119
|
+
const screenHeight = window.innerHeight
|
|
120
|
+
const centerY = (screenHeight - Number(windowConfig.size.height)) / 2
|
|
121
|
+
const positionY =
|
|
122
|
+
windowConfig.position?.y !== undefined
|
|
123
|
+
? window.scrollY + windowConfig.position.y
|
|
124
|
+
: window.scrollY + centerY
|
|
125
|
+
|
|
126
|
+
storeWindows.windows[windowId] = {
|
|
127
|
+
model,
|
|
128
|
+
state: {
|
|
129
|
+
id: windowId,
|
|
130
|
+
active: true,
|
|
131
|
+
focused: false,
|
|
132
|
+
position: {
|
|
133
|
+
x: windowConfig.position?.x,
|
|
134
|
+
y: positionY,
|
|
135
|
+
},
|
|
136
|
+
createdAt: +new Date(),
|
|
137
|
+
workspace: desktopWorkspaceStore.active,
|
|
138
|
+
},
|
|
139
|
+
meta,
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
windowStoredState = storeWindows.windows[windowId]
|
|
143
|
+
} else {
|
|
144
|
+
windowId = windowStoredState.state.id
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const windowConfig = applicationConfig.windows[model] as WindowConfig
|
|
148
|
+
const windowController = new WindowController(store, model, windowConfig, windowStoredState!)
|
|
149
|
+
|
|
150
|
+
if (!meta?.isRestoring) {
|
|
151
|
+
windowController.actions.bringToFront()
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
windows.set(windowId, windowController)
|
|
155
|
+
setRunning(true)
|
|
156
|
+
|
|
157
|
+
return windowController
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// close window
|
|
161
|
+
function closeWindow(windowId: string) {
|
|
162
|
+
delete storeWindows.windows[windowId]
|
|
163
|
+
windows.delete(windowId)
|
|
164
|
+
|
|
165
|
+
if (windows.size === 0) {
|
|
166
|
+
applicationManager.closeApp(applicationId)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// close all windows
|
|
171
|
+
function closeAllWindows() {
|
|
172
|
+
storeWindows.windows = {}
|
|
173
|
+
windows.clear()
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// getters
|
|
177
|
+
const windowsOpened = computed(() => windows)
|
|
178
|
+
|
|
179
|
+
function getWindowById(id: string) {
|
|
180
|
+
return windows.get(id)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function getWindowsByModel(model: string) {
|
|
184
|
+
return Array.from(windows.values()).filter((w) => w.model === model)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function getFirstWindowByModel(model: string) {
|
|
188
|
+
return Array.from(windows.values()).find((w) => w.model === model)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function setRunning(value: boolean) {
|
|
192
|
+
isRunning.value = value
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// meta management
|
|
196
|
+
const meta = computed(() => storeMeta.meta)
|
|
197
|
+
|
|
198
|
+
function getMeta(key: string) {
|
|
199
|
+
return meta.value[key]
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function setMeta(key: string, value: any) {
|
|
203
|
+
storeMeta.meta[key] = value
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// command exec
|
|
207
|
+
async function execCommand(command: string) {
|
|
208
|
+
return applicationManager.execAppCommand(applicationId, command)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const store = {
|
|
212
|
+
id: applicationId,
|
|
213
|
+
config: applicationConfig,
|
|
214
|
+
storeWindows,
|
|
215
|
+
storeMeta,
|
|
216
|
+
windows,
|
|
217
|
+
isRunning,
|
|
218
|
+
initApplication,
|
|
219
|
+
restoreApplication,
|
|
220
|
+
openWindow,
|
|
221
|
+
closeWindow,
|
|
222
|
+
closeAllWindows,
|
|
223
|
+
windowsOpened,
|
|
224
|
+
getWindowById,
|
|
225
|
+
getWindowsByModel,
|
|
226
|
+
getFirstWindowByModel,
|
|
227
|
+
setRunning,
|
|
228
|
+
meta,
|
|
229
|
+
getMeta,
|
|
230
|
+
setMeta,
|
|
231
|
+
execCommand,
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return store
|
|
235
|
+
})()
|
|
236
|
+
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {defineStore} from
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
2
|
|
|
3
3
|
export const useApplicationMetaStore = (appId: string, states: any = {}) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
return defineStore(
|
|
5
|
+
`owd/application/${appId}/meta`,
|
|
6
|
+
() => {
|
|
7
|
+
return states
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
persistedState: {
|
|
11
|
+
persist: true,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
)
|
|
11
15
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import {defineStore} from
|
|
2
|
-
import {ref} from
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { ref } from 'vue'
|
|
3
3
|
|
|
4
4
|
export const useApplicationWindowsStore = (appId: string) => {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
return defineStore(
|
|
6
|
+
`owd/application/${appId}/windows`,
|
|
7
|
+
() => {
|
|
8
|
+
const windows: Ref<{ [windowId: string]: WindowStoredState }> = ref({})
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
return {
|
|
11
|
+
windows,
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
persistedState: {
|
|
16
|
+
persist: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
)()
|
|
16
20
|
}
|
|
@@ -1,39 +1,45 @@
|
|
|
1
|
-
import {defineStore} from
|
|
2
|
-
import {ref} from
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { ref } from 'vue'
|
|
3
3
|
|
|
4
|
-
export const useDesktopStore = defineStore(
|
|
4
|
+
export const useDesktopStore = defineStore(
|
|
5
|
+
'owd/desktop',
|
|
6
|
+
() => {
|
|
5
7
|
const state = ref<{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
workspace: {
|
|
9
|
+
overview: boolean
|
|
10
|
+
active: string
|
|
11
|
+
list: string[]
|
|
12
|
+
}
|
|
13
|
+
volume: {
|
|
14
|
+
master: number
|
|
15
|
+
}
|
|
16
|
+
window: {
|
|
17
|
+
positionZ: number
|
|
18
|
+
}
|
|
19
|
+
defaultApps: {[key: string]: string}
|
|
17
20
|
}>({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
workspace: {
|
|
22
|
+
overview: false,
|
|
23
|
+
active: '',
|
|
24
|
+
list: [],
|
|
25
|
+
},
|
|
26
|
+
volume: {
|
|
27
|
+
master: 100,
|
|
28
|
+
},
|
|
29
|
+
window: {
|
|
30
|
+
positionZ: 0,
|
|
31
|
+
},
|
|
32
|
+
defaultApps: {}
|
|
29
33
|
})
|
|
30
34
|
|
|
31
35
|
return {
|
|
32
|
-
|
|
36
|
+
state,
|
|
33
37
|
}
|
|
34
|
-
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
35
40
|
// @ts-expect-error
|
|
36
41
|
persistedState: {
|
|
37
|
-
|
|
42
|
+
persist: true,
|
|
38
43
|
},
|
|
39
|
-
}
|
|
44
|
+
},
|
|
45
|
+
)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { useDesktopStore } from './storeDesktop'
|
|
3
|
+
|
|
4
|
+
export const useDesktopDefaultAppsStore = defineStore(
|
|
5
|
+
'owd/desktop/defaultApps',
|
|
6
|
+
() => {
|
|
7
|
+
const desktopStore = useDesktopStore()
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Sets a default app for a given feature
|
|
11
|
+
*/
|
|
12
|
+
function setDefaultApp(
|
|
13
|
+
feature: string,
|
|
14
|
+
application: IApplicationController,
|
|
15
|
+
entry: string,
|
|
16
|
+
) {
|
|
17
|
+
if (!desktopStore.state.hasOwnProperty('defaultApps')) {
|
|
18
|
+
desktopStore.state.defaultApps = {}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
desktopStore.state.defaultApps[feature] = {
|
|
22
|
+
applicationId: application.id,
|
|
23
|
+
entry,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Gets the default app config for a given feature
|
|
29
|
+
*/
|
|
30
|
+
function getDefaultApp(feature: string): DefaultAppConfig {
|
|
31
|
+
if (!desktopStore.state.hasOwnProperty('defaultApps')) {
|
|
32
|
+
desktopStore.state.defaultApps = {}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return desktopStore.state.defaultApps[feature] as DefaultAppConfig
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Loads default apps from current config
|
|
40
|
+
*/
|
|
41
|
+
function loadDefaultAppsFromConfig(runtimeConfig) {
|
|
42
|
+
if (runtimeConfig.public.desktop.defaultApps) {
|
|
43
|
+
desktopStore.state.defaultApps = runtimeConfig.public.desktop.defaultApps
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
setDefaultApp,
|
|
49
|
+
getDefaultApp,
|
|
50
|
+
loadDefaultAppsFromConfig,
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
)
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {defineStore} from
|
|
2
|
-
import {computed} from
|
|
3
|
-
import {useDesktopStore} from
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useDesktopStore } from './storeDesktop'
|
|
4
4
|
|
|
5
5
|
export const useDesktopVolumeStore = defineStore('owd/desktop/volume', () => {
|
|
6
|
-
|
|
6
|
+
const desktopStore = useDesktopStore()
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const master = computed(() => desktopStore.state.volume.master)
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
function setMasterVolume(value: number) {
|
|
11
|
+
desktopStore.state.volume.master = value
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
return {
|
|
15
|
+
master,
|
|
16
|
+
setMasterVolume,
|
|
17
|
+
}
|
|
18
18
|
})
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {defineStore} from
|
|
2
|
-
import {computed} from
|
|
3
|
-
import {useDesktopStore} from
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useDesktopStore } from './storeDesktop'
|
|
4
4
|
|
|
5
5
|
export const useDesktopWindowStore = defineStore('owd/desktop/window', () => {
|
|
6
|
-
|
|
6
|
+
const desktopStore = useDesktopStore()
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const positionZ = computed(() => desktopStore.state.window.positionZ)
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
function incrementPositionZ() {
|
|
11
|
+
desktopStore.state.window.positionZ++
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
return desktopStore.state.window.positionZ
|
|
14
|
+
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
return {
|
|
17
|
+
positionZ,
|
|
18
|
+
incrementPositionZ,
|
|
19
|
+
}
|
|
20
20
|
})
|
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
import {defineStore} from
|
|
2
|
-
import {computed} from
|
|
3
|
-
import {useDesktopStore} from
|
|
4
|
-
import {nanoid} from
|
|
5
|
-
|
|
6
|
-
export const useDesktopWorkspaceStore = defineStore(
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useDesktopStore } from './storeDesktop'
|
|
4
|
+
import { nanoid } from 'nanoid'
|
|
5
|
+
|
|
6
|
+
export const useDesktopWorkspaceStore = defineStore(
|
|
7
|
+
'owd/desktop/workspace',
|
|
8
|
+
() => {
|
|
7
9
|
const desktopStore = useDesktopStore()
|
|
8
10
|
|
|
9
11
|
const active = computed(() => {
|
|
10
|
-
|
|
12
|
+
return desktopStore.state.workspace.active
|
|
11
13
|
})
|
|
12
14
|
|
|
13
15
|
const overview = computed(() => {
|
|
14
|
-
|
|
16
|
+
return desktopStore.state.workspace.overview
|
|
15
17
|
})
|
|
16
18
|
|
|
17
19
|
const list = computed(() => {
|
|
18
|
-
|
|
20
|
+
return desktopStore.state.workspace.list
|
|
19
21
|
})
|
|
20
22
|
|
|
21
23
|
function setupWorkspaces() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
if (desktopStore.state.workspace.list.length === 0) {
|
|
25
|
+
createWorkspace()
|
|
26
|
+
desktopStore.state.workspace.active = desktopStore.state.workspace
|
|
27
|
+
.list[0] as string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (desktopStore.state.workspace.list.length === 1) {
|
|
31
|
+
createWorkspace()
|
|
32
|
+
}
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
function setOverview(value: boolean) {
|
|
33
|
-
|
|
36
|
+
desktopStore.state.workspace.overview = value
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
function setWorkspace(value: string) {
|
|
37
|
-
|
|
40
|
+
desktopStore.state.workspace.active = value
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
function createWorkspace() {
|
|
41
|
-
|
|
44
|
+
desktopStore.state.workspace.list.push(nanoid(8))
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
const workspaceActiveIndex = computed(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
return desktopStore.state.workspace.list.findIndex(
|
|
49
|
+
(workspace) => workspace === desktopStore.state.workspace.active,
|
|
50
|
+
)
|
|
48
51
|
})
|
|
49
52
|
|
|
50
53
|
return {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
active,
|
|
55
|
+
overview,
|
|
56
|
+
list,
|
|
57
|
+
workspaceActiveIndex,
|
|
58
|
+
setupWorkspaces,
|
|
59
|
+
setOverview,
|
|
60
|
+
setWorkspace,
|
|
58
61
|
}
|
|
59
|
-
}
|
|
62
|
+
},
|
|
63
|
+
)
|
package/runtime/utils/utilApp.ts
CHANGED
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
import type {Nuxt} from
|
|
1
|
+
import type { Nuxt } from '@nuxt/schema'
|
|
2
2
|
|
|
3
|
-
export function normalizeApplicationConfig(
|
|
4
|
-
|
|
3
|
+
export function normalizeApplicationConfig(
|
|
4
|
+
config: ApplicationConfig,
|
|
5
|
+
): ApplicationConfig {
|
|
6
|
+
const normalizedEntries: Record<string, ApplicationEntry> = {}
|
|
5
7
|
|
|
8
|
+
if (config.entries) {
|
|
6
9
|
for (const [key, entry] of Object.entries(config.entries)) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
normalizedEntries[key] = {
|
|
11
|
+
...entry,
|
|
12
|
+
title: entry.title ?? config.title,
|
|
13
|
+
icon: entry.icon ?? config.icon,
|
|
14
|
+
category: entry.category ?? config.category,
|
|
15
|
+
visibility: entry.visibility ?? 'primary',
|
|
16
|
+
}
|
|
14
17
|
}
|
|
18
|
+
}
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
return {
|
|
21
|
+
...config,
|
|
22
|
+
version: config.version ?? 'unknown',
|
|
23
|
+
description: config.description ?? '',
|
|
24
|
+
category: config.category ?? 'other',
|
|
25
|
+
entries: normalizedEntries,
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
export function registerTailwindPath(nuxt: Nuxt, path: string) {
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
nuxt.options.runtimeConfig.app.owd = nuxt.options.runtimeConfig.app.owd || {}
|
|
31
|
+
nuxt.options.runtimeConfig.app.owd.tailwindPaths =
|
|
32
|
+
nuxt.options.runtimeConfig.app.owd.tailwindPaths || []
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
if (!nuxt.options.runtimeConfig.app.owd.tailwindPaths.includes(path)) {
|
|
35
|
+
nuxt.options.runtimeConfig.app.owd.tailwindPaths.push(path)
|
|
36
|
+
}
|
|
32
37
|
}
|