Skip to content

Commit

Permalink
feat(settings): display different content for desktop and web
Browse files Browse the repository at this point in the history
  • Loading branch information
Red-Asuka committed Dec 6, 2024
1 parent 935439c commit 2763cf0
Show file tree
Hide file tree
Showing 9 changed files with 287 additions and 29 deletions.
108 changes: 108 additions & 0 deletions apps/desktop/electron.vite.config.1733454662388.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// electron.vite.config.ts
import { resolve } from 'node:path'
import vue from '@vitejs/plugin-vue'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import AutoImport from 'unplugin-auto-import/vite'
import { FileSystemIconLoader } from 'unplugin-icons/loaders'
import IconsResolver from 'unplugin-icons/resolver'
import Icons from 'unplugin-icons/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import VueRouter from 'unplugin-vue-router/vite'

const electron_vite_config_default = defineConfig({
main: {
plugins: [externalizeDepsPlugin()],
},
preload: {
plugins: [externalizeDepsPlugin()],
},
renderer: {
resolve: {
alias: {
'@database': resolve('src/database'),
'@': resolve('src/renderer/src'),
},
},
plugins: [
VueRouter({
routesFolder: [
{
src: 'src/renderer/src/pages',
},
],
}),
vue(),
AutoImport({
// targets to transform
include: [
/\.[tj]sx?$/,
// .ts, .tsx, .js, .jsx
/\.vue$/,
/\.vue\?vue/,
// .vue
/\.md$/,
// .md
],
// global imports to register
imports: [
'vue',
'vue-router',
'vue-i18n',
'pinia',
],
// Auto import for module exports under directories
// by default it only scan one level of modules under the directory
dirs: [
'./src/composables',
// only root modules
'../../../../packages/ui/src/composables',
// only root modules
],
// Auto import inside Vue template
vueTemplate: true,
}),
Components({
dts: true,
directoryAsNamespace: true,
dirs: ['src/components', '../../../../packages/ui/src/components'],
resolvers: [
ElementPlusResolver(),
IconsResolver({
prefix: 'icon',
customCollections: [
'custom',
],
}),
],
}),
Icons({
compiler: 'vue3',
customCollections: {
custom: FileSystemIconLoader('../../packages/ui/src/assets/icons'),
},
}),
{
name: 'element-plus-night-theme',
transform(code, id) {
if (id.endsWith('packages/ui/src/styles/index.scss')) {
const nightThemeCode = code.replace(/html\.dark/g, 'html.night')
return `${code}
${nightThemeCode}`
}
return code
},
},
],
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
},
},
},
},
})
export {
electron_vite_config_default as default,
}
1 change: 1 addition & 0 deletions apps/desktop/src/renderer/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ declare module 'vue' {
ElContainer: typeof import('element-plus/es')['ElContainer']
ElDivider: typeof import('element-plus/es')['ElDivider']
ElIconDelete: typeof import('@element-plus/icons-vue')['Delete']
ElIconDownload: typeof import('@element-plus/icons-vue')['Download']
ElIconPrinter: typeof import('@element-plus/icons-vue')['Printer']
ElIconUpload: typeof import('@element-plus/icons-vue')['Upload']
ElIconWarning: typeof import('@element-plus/icons-vue')['Warning']
Expand Down
8 changes: 5 additions & 3 deletions apps/desktop/src/renderer/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import type { PlatformType } from 'mqttx'
import useSettingsService from '@database/services/SettingsService'
import { i18n } from '@mqttx/ui/i18n'

import { i18n } from '@mqttx/ui/i18n'
import App from './App.vue'
import { router } from './router'

import { router } from './router'
import '@mqttx/ui/styles.scss'
import './assets/scss/main.scss'

// Create Vue
const app = createApp(App)

const pinia = createPinia()

app.provide<PlatformType>('platformType', 'desktop')

app.use(router).use(pinia)

const { getSettingsInDB } = useSettingsService()
Expand Down
1 change: 1 addition & 0 deletions apps/web/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ declare module 'vue' {
ElContainer: typeof import('element-plus/es')['ElContainer']
ElDivider: typeof import('element-plus/es')['ElDivider']
ElIconDelete: typeof import('@element-plus/icons-vue')['Delete']
ElIconDownload: typeof import('@element-plus/icons-vue')['Download']
ElIconPrinter: typeof import('@element-plus/icons-vue')['Printer']
ElIconUpload: typeof import('@element-plus/icons-vue')['Upload']
ElIconWarning: typeof import('@element-plus/icons-vue')['Warning']
Expand Down
8 changes: 5 additions & 3 deletions apps/web/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { PlatformType } from 'mqttx'
import { i18n } from '@mqttx/ui/i18n'
import App from './App.vue'

import App from './App.vue'
import { createDatabase } from './database'
import useSettingsService from './database/services/SettingsService'

import useSettingsService from './database/services/SettingsService'
import { router } from './router'
import '@mqttx/ui/styles.scss'
import './assets/scss/main.scss'
Expand All @@ -12,9 +13,10 @@ const database = createDatabase()

// Create Vue
const app = createApp(App)

const pinia = createPinia()

app.provide<PlatformType>('platformType', 'web')

app.use(router).use(pinia)

database.then(async (db) => {
Expand Down
100 changes: 100 additions & 0 deletions apps/web/vite.config.ts.timestamp-1733454661961-468eda2520392.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// vite.config.ts
import { fileURLToPath, URL } from "node:url";
import vue from "file:///Users/yingdongli/next/MQTTX/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@vitejs/plugin-vue/dist/index.mjs";
import vueJsx from "file:///Users/yingdongli/next/MQTTX/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@vitejs/plugin-vue-jsx/dist/index.mjs";
import AutoImport from "file:///Users/yingdongli/next/MQTTX/node_modules/.pnpm/[email protected]/node_modules/unplugin-auto-import/dist/vite.js";
import { FileSystemIconLoader } from "file:///Users/yingdongli/next/MQTTX/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/unplugin-icons/dist/loaders.js";
import IconsResolver from "file:///Users/yingdongli/next/MQTTX/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/unplugin-icons/dist/resolver.js";
import Icons from "file:///Users/yingdongli/next/MQTTX/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/unplugin-icons/dist/vite.js";
import { ElementPlusResolver } from "file:///Users/yingdongli/next/MQTTX/node_modules/.pnpm/[email protected][email protected]/node_modules/unplugin-vue-components/dist/resolvers.js";
import Components from "file:///Users/yingdongli/next/MQTTX/node_modules/.pnpm/[email protected][email protected]/node_modules/unplugin-vue-components/dist/vite.js";
import VueRouter from "file:///Users/yingdongli/next/MQTTX/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/unplugin-vue-router/dist/vite.js";
import { defineConfig } from "file:///Users/yingdongli/next/MQTTX/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/index.js";
var __vite_injected_original_import_meta_url = "file:///Users/yingdongli/next/MQTTX/apps/web/vite.config.ts";
var vite_config_default = defineConfig({
plugins: [
VueRouter(),
vue(),
vueJsx(),
AutoImport({
// targets to transform
include: [
/\.[tj]sx?$/,
// .ts, .tsx, .js, .jsx
/\.vue$/,
/\.vue\?vue/,
// .vue
/\.md$/
// .md
],
// global imports to register
imports: [
"vue",
"vue-router",
"vue-i18n",
"pinia"
],
// Auto import for module exports under directories
// by default it only scan one level of modules under the directory
dirs: [
"./src/composables",
// only root modules
"../../packages/ui/src/composables"
// only root modules
],
// Auto import inside Vue template
vueTemplate: true
}),
Components({
dts: true,
directoryAsNamespace: true,
dirs: ["src/components", "../../packages/ui/src/components"],
resolvers: [
ElementPlusResolver(),
IconsResolver({
prefix: "icon",
customCollections: [
"custom"
]
})
]
}),
Icons({
compiler: "vue3",
customCollections: {
custom: FileSystemIconLoader("../../packages/ui/src/assets/icons")
}
}),
{
name: "element-plus-night-theme",
transform(code, id) {
if (id.endsWith("packages/ui/src/styles/index.scss")) {
const nightThemeCode = code.replace(/html\.dark/g, "html.night");
return `${code}
${nightThemeCode}`;
}
return code;
}
}
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", __vite_injected_original_import_meta_url))
}
},
server: {
host: "0.0.0.0",
port: 3e3
},
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler"
}
}
}
});
export {
vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0Nv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FRO0FBQUEsSUFDTixNQUFNO0FBQUEsSUFDTixNQUFNO0FBQUEsRUFDUjtBQUFBLEVBQ0EsS0FBSztBQUFBLElBQ0gscUJBQXFCO0FBQUEsTUFDbkIsTUFBTTtBQUFBLFFBQ0osS0FBSztBQUFBLE1BQ1A7QUFBQSxJQUNGO0FBQUEsRUFDRjtBQUNGLENBQUM7IiwKICAibmFtZXMiOiBbXQp9Cg==
2 changes: 2 additions & 0 deletions packages/types/base.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export type PlatformType = 'desktop' | 'web'

export type MQTTVersion = 3 | 4 | 5

export type Protocol = 'mqtt' | 'mqtts'
Expand Down
1 change: 1 addition & 0 deletions packages/ui/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare module 'vue' {
ElCol: typeof import('element-plus/es')['ElCol']
ElDivider: typeof import('element-plus/es')['ElDivider']
ElIconDelete: typeof import('@element-plus/icons-vue')['Delete']
ElIconDownload: typeof import('@element-plus/icons-vue')['Download']
ElIconPrinter: typeof import('@element-plus/icons-vue')['Printer']
ElIconUpload: typeof import('@element-plus/icons-vue')['Upload']
ElIconWarning: typeof import('@element-plus/icons-vue')['Warning']
Expand Down
Loading

0 comments on commit 2763cf0

Please sign in to comment.