Location>code7788 >text

Vue3-WebOS web version os system|vite5+pinia2+arco-design imitation macOS desktop os management

Popularity:643 ℃/2024-07-25 18:50:43

innovationVue3+Pinia2+ArcoDesignImitate macOS desktopWeb-based osmanagement systemViteMacOS

vite5-vue3-macosBased on the latest front-end technology+vue3+pinia2++sortablejs+echartsNew solution for building a web-based osx backend management system.be in favor ofwindows+macosTwo desktop modes, customizable desktop grid layout engine, drag-and-drop desktop menu/application docking menuand other features.

Use of technology

  • Development tools: Vscode
  • Technical framework: vite5.3.3+vue3.4.31+vue-router4.4+pinia2
  • UI component library: arco-design^2.55.3 (byte desktop version of vue3 component library)
  • Status management: pinia^2.1.7
  • Chart plugin: echarts^5.5.1
  • Drag and drop component: sortablejs^1.15.2
  • Rich text editor: wangeditor^4.7.15
  • Simulated data: mockjs^1.1.0
  • Style compilation: sass^1.77.8
  • Build tool: vite^5.3.3

Project Structure Catalog

vite-macOS use The build tool builds the project template, using thevue3 setup Syntax coding development.

Functional characteristics

  1. Desktop/Dock menu support for dynamic JSON configuration
  2. Supports both windows and macos desktop modes
  3. Drag-and-drop sorting of desktop and dock menus.
  4. Support custom desktop theme skin, bokeh hair glass UI texture
  5. New os-style back-office management system solution

The vue3-macos project has been synced to my original portfolio for those who need it.

/item/detail/1106413011

ArcoDesign Component Library

The UI component library used in the project is the vue3 component library introduced by the byte front-end team. Support vue and react framework.

Main Entrance Configuration

import { createApp } from 'vue'
import './'
import App from './'

// Introducing component libraries
import ArcoDesign from '@arco-design/web-vue'
import '@arco-design/web-vue/dist/'
// Additional introduction of icon libraries
import ArcoIcon from '@arco-design/web-vue/es/icon'
import VEPlus from 've-plus'
import 've-plus/dist/'

// Introduction of routing and state management
import Router from './router'
import Pinia from './pinia'

const app = createApp(App)

app
.use(ArcoDesign)
.use(ArcoIcon)
.use(VEPlus)
.use(Router)
.use(Pinia)
.mount('#app')

Desktop Layout Templates

Desktop Supportwindowscap (a poem)macosTwo models.

<script setup>
  import { appState } from '@/pinia/modules/app'

  // Introduction of layout templates
  import MacosLayout from './template/'
  import WindowsLayout from './template/'

  const appstate = appState()

  const DeskLayout = {
    macos: MacosLayout,
    windows: WindowsLayout
  }
</script>

<template>
  <div
    class="vu__container desktop flexbox flex-alignc flex-justifyc"
    :style="{'--themeSkin': }"
    @
  >
    <component :is="DeskLayout[]" />
  </div>
</template>

<template>
  <div class="vu__layout flexbox flex-col">
    <div class="vu__layout-header">
      <Toolbar />
    </div>
    <div class="vu__layout-body flex1 flexbox">
      <Desk />
    </div>
    <div class="vu__layout-footer">
      <Dock />
    </div>
    <!-- Hoverball (assisted touch)-->
    <Touch />
  </div>
</template>

vite-os desktop grid layout engine

Customizing Desktop Icon Variables

// Customized variables (desktop icons)
const deskVariable = ref({
  '--icon-radius': '8px', // rounded corner
  '--icon-size': '60px', // Icon size (set rpx to customize mobile device)
  '--icon-gap-col': '30px', // Horizontal spacing
  '--icon-gap-row': '30px', // vertical distance
  '--icon-labelSize': '12px', // Label Text Size
  '--icon-labelColor': '#fff', // label color
  '--icon-fit': 'contain', // Icon Adaptive Mode
})

Desktop os menu configuration items

/**
  * label icon title
  * imgico icon (local or web image) support Arco Design built-in icon or custom iconfont icon
  * path Jump to route page
  * link Jump to external link
  * hideLabel whether to hide icon title
  * background Custom icon background color
  * color Custom icon color
  * size raster tile layout (16 kinds) 1x1 1x2 1x3 1x4, 2x1 2x2 2x3 2x4, 3x1 3x2 3x3 3x4, 4x1 4x2 4x3 4x4
  * onClick Click icon callback function
*/

set upchildrenparameter, then secondary menu configuration is supported.

Desktop menu configuration snippet

const deskMenu = [
  {
    pid: 20240507001,
    list: [
      {imgico: markRaw(Today), size: '2x2'},
      {imgico: markRaw(Weather), size: '2x2'},
      {label: 'Sticky Notes', imgico: markRaw(NoteBook), size: '4x2'},
      ...
    ]
  },
  {
    pid: 20240509002,
    list: [
      {label: 'Appstore', imgico: '/static/mac/'},
      {label: 'Map', imgico: '/static/mac/'},
      ...
    ]
  },
  {
    pid: 20240510001,
    list: [
      {label: 'Github', imgico: '/static/svg/', link: '/', background: '#607d8b',},
      ...
    ]
  },
  {
    uid: 'd141f210-207e-1e8e-9950-9deefac27e48',
    list: [
      {label: 'Vite^5.3.3', imgico: '/', link: '/'},
      ...
      {
        label: 'Component',
        children: [
          {label: 'Tables', imgico: '/static/svg/', path: '/components/table/all'},
          {label: 'Customized Forms', imgico: '/static/svg/', path: '/components/table/custom'},
          ...
        ]
      },
      {label: 'ChatGPT', imgico: '/static/svg/', link: '/chatgpt/', background: '#15A17F',},
      {label: 'Bilibili', imgico: '/static/svg/', link: '/', background: '#ff6899',},
      {
        label: 'Personal Center',
        children: [
          {label: 'Home', imgico: '/static/svg/', path: '/setting'},
          ...
        ]
      },
      {
        label: 'Settings',
        children: [
          {label: 'Site Settings', imgico: '/static/svg/', path: '/setting/system/website'},
          {label: 'Mail service', imgico: '/static/mac/', path: '/setting/system/mail'},
        ]
      },
      {
        label: 'Public', imgico: markRaw(IconWechat), color: '#07c160',
        onClick: () => {
          ...
        }
      },
    ]
  }
]

vue3-os implementation of the Dock menu

Dock menu support in macos desktop modePolymerization + SeparationTwo ways

<template>
  <div class="vu__macos-dock">
    <div class="vu__dock-wrap" :class="||'compact'">
      <div v-for="(data, key) in dockMenu" :key="key" class="vu__dock-group">
        <a v-for="(item, index) in data?.list" :key="index" class="vu__dock-item" @click="handleClickDock(item)">
          <span v-if="" class="label">{{}}</span>
          <!-- secondary menu-->
          <a-trigger v-if="isArray(item?.children)" trigger="click">
            <!-- Secondary Thumbnail-->
            <div class="thumb">
              <div class="vu__dock-thumbmenu">
                ...
              </div>
            </div>
            <template #content>
              <!-- Secondary pop-up menu-->
              <div class="vu__dock-thumbpopup">
                <a-scrollbar style="overflow: auto; margin-top: 10px; height: 210px;">
                  ...
                </a-scrollbar>
              </div>
            </template>
          </a-trigger>
          <div v-else class="imgico" :style="{'color': }">
            <template v-if="isImg()">
              <img :src="" />
            </template>
            <template v-else>
              <component v-if="isObject()" class="ico" :is="" />
              <i v-else class="ico elec-icon" :class=""></i>
            </template>
          </div>
        </a>
      </div>
    </div>
  </div>
</template>

End, in summary, is vue3+pinia+arcoDesign combat development web version of the webos management system to share some knowledge, I hope to help you!

Finally, I've attached the two latest cross-platform chat example projects

/xiaoyan2017/p/18290962

/xiaoyan2017/p/18165578