diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 0000000..6734234 --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,11 @@ + +jsxBracketSameLine: true +jsxSingleQuote: true +semi: false +singleQuote: true +printWidth: 80 +useTabs: false +tabWidth: 2 +trailingComma: none +bracketSpacing: true +arrowParens: avoid diff --git a/.vscode/launch.json b/.vscode/launch.json index 473f63e..274a7c6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,10 +7,7 @@ "request": "launch", "cwd": "${workspaceRoot}", "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", - "windows": { - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd" - }, - "args": ["."] + "args": [".", "--NODE_ENV=development"] } ] } diff --git a/front-end/fite.config.js b/front-end/fite.config.js new file mode 100644 index 0000000..e79faa8 --- /dev/null +++ b/front-end/fite.config.js @@ -0,0 +1,44 @@ +import { resolve } from 'path' + +export default { + // 用于配置部署目录, 默认为根目录, 如果需要部署到二级目录的话, + // 请取消以下注释, 并填写你最终需要部署的二级目录名, 必须以 / 开头及结尾。如: '/foo/' + // base: '/', + devServer: { + port: 26666, + domain: '', + https: false, + ssl: { + key: '', + cert: '' + // ca: '' //可选 + } + }, + // 如果多页应用, 则这里写传入多个值即可(注意不是数组格式) + pages: { + // 这里的key值, 将是最终的页面的名称 + index: { + // 这里的resolve可将相对路径转为绝对路径 + // 如果传入的路径已经是绝对路径的, 可不需要resolve + entry: resolve('./src/main.js'), + title: 'fite-app 应用示例' + } + }, + inject: { + // v1.0.1之后, 可以注入一个scss, 所有的vue文件中的样式都会被注入这个公共scss + // 注意: 该文件不支持热更新, 不可被vue/js文件引用 (但可以被其他的scss文件引用) + scss: resolve('./src/inject.scss') + }, + // 以下cdn地址, 可自行修改为适合的 + // 有用到其他的库, 可以手动添加, + // 也可以在页面中直接引入完整的路径, 而不必须在这里声明 + imports: { + vue: '//jscdn.ink/vue/3.2.47/vue.runtime.esm-browser.prod.js', + // 这个vue-router库, 移除了 @vue/devtools-api 相关的代码。 以达到减少不必须的体积的效果 + // 如需要支持devtools的, 请修改为原版vue-router地址即可。 + 'vue-router': '//jscdn.ink/@bytedo/vue-router/4.1.6/vue-router.js', + // 'vue-router': '//jscdn.ink/vue-router/4.1.6/vue-router.esm-browser.js', + // '@vue/devtools-api': '//jscdn.ink/@vue/devtools-api/6.5.0/esm/index.js', + fetch: '//jscdn.ink/@bytedo/fetch/2.1.5/next.js' + } +} diff --git a/front-end/index.html b/front-end/index.html new file mode 100644 index 0000000..8b7c51f --- /dev/null +++ b/front-end/index.html @@ -0,0 +1,21 @@ + + + + + + + {{title}} + + + + + + {{#if process.env.NODE_ENV === 'development' }} + + {{#/if}} + + +
+ + + diff --git a/front-end/package.json b/front-end/package.json new file mode 100644 index 0000000..6f3e625 --- /dev/null +++ b/front-end/package.json @@ -0,0 +1,14 @@ + +{ + "name": "fite-app", + "type": "module", + "scripts": { + "start": "fite dev", + "build": "fite build", + "build:keep": "fite build --no-clean" + }, + "devDependencies": { + "fite": "^1.2.0" + } +} + \ No newline at end of file diff --git a/front-end/src/app.vue b/front-end/src/app.vue new file mode 100644 index 0000000..acc728b --- /dev/null +++ b/front-end/src/app.vue @@ -0,0 +1,83 @@ + + + + + + + diff --git a/front-end/src/assets/logo.svg b/front-end/src/assets/logo.svg new file mode 100644 index 0000000..e2a9ebf --- /dev/null +++ b/front-end/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/front-end/src/components/hello.vue b/front-end/src/components/hello.vue new file mode 100644 index 0000000..019fa52 --- /dev/null +++ b/front-end/src/components/hello.vue @@ -0,0 +1,52 @@ + + + + + diff --git a/front-end/src/main.js b/front-end/src/main.js new file mode 100644 index 0000000..01ddc6b --- /dev/null +++ b/front-end/src/main.js @@ -0,0 +1,7 @@ +import { createApp } from 'vue' +import App from './app.vue' + +import router from './router' +import store from './store' + +createApp(App).use(router).use(store).mount('#app') diff --git a/front-end/src/router.js b/front-end/src/router.js new file mode 100644 index 0000000..ea669d0 --- /dev/null +++ b/front-end/src/router.js @@ -0,0 +1,23 @@ + +import { createRouter, createWebHistory } from 'vue-router' +import Home from './views/home.vue' + +const router = createRouter({ + history: createWebHistory(), + routes: [ + { + path: '/', + name: 'home', + component: Home + }, + { + path: '/about', + name: 'about', + component: () => import('./views/about.vue') + } + ] +}) + +export default router + + diff --git a/front-end/src/store.js b/front-end/src/store.js new file mode 100644 index 0000000..7b51208 --- /dev/null +++ b/front-end/src/store.js @@ -0,0 +1,11 @@ + +import { reactive } from 'vue' + +const store = reactive({ + foo: 'bar', + version: '1.2.0' +}) + +export default function (app) { + app.config.globalProperties.$store = store +} diff --git a/front-end/src/views/about.vue b/front-end/src/views/about.vue new file mode 100644 index 0000000..d44f23e --- /dev/null +++ b/front-end/src/views/about.vue @@ -0,0 +1,27 @@ + + + + + diff --git a/front-end/src/views/home.vue b/front-end/src/views/home.vue new file mode 100644 index 0000000..797f67b --- /dev/null +++ b/front-end/src/views/home.vue @@ -0,0 +1,17 @@ + + + diff --git a/package.json b/package.json index 896f425..f5f1a50 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,6 @@ "description": "MySQL/MariaDB database management for Linux", "main": "src/main.js", "scripts": { - "preinstall": "source .npmrc", - "start": "electron .", "pack": "electron-builder --linux" }, "author": { diff --git a/src/index.html b/src/index.html deleted file mode 100644 index f8b44c0..0000000 --- a/src/index.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - Examples - - - - - -

It works!

- - \ No newline at end of file diff --git a/src/main.js b/src/main.js index 2189c9b..67451ad 100644 --- a/src/main.js +++ b/src/main.js @@ -45,9 +45,9 @@ protocol.registerSchemesAsPrivileged([ app.once('ready', () => { // 注册协议 protocol.registerStreamProtocol('app', function (req, cb) { - var file = decodeURIComponent(req.url.replace(/^app:\/\/local\//, '')) - var ext = path.extname(req.url) - file = path.resolve(__dirname, file) + let file = decodeURIComponent(req.url.replace(/^app:\/\/local\//, '')) + let ext = path.extname(req.url) + file = path.resolve(__dirname, 'dist/', file) cb({ data: fs.origin.createReadStream(file), diff --git a/src/tools/windows.js b/src/tools/windows.js index 3850729..83bef41 100644 --- a/src/tools/windows.js +++ b/src/tools/windows.js @@ -32,7 +32,11 @@ exports.createMainWindow = function (icon) { // 然后加载应用的 index.html。 - win.loadURL('app://local/index.html') + win.loadURL( + process.argv.includes('--NODE_ENV=development') + ? 'http://127.0.0.1:26666' + : 'app://local/index.html' + ) win.on('ready-to-show', _ => { win.show()