Browse Source

添加 electron systemAPI基础代码

master
unknown 4 years ago
parent
commit
79faa92a37
8 changed files with 63 additions and 39 deletions
  1. +3
    -1
      dist/static/css/main.css
  2. +2
    -0
      electron-main/preload.js
  3. +5
    -2
      main.js
  4. +0
    -11
      src/services/back.js
  5. +27
    -0
      src/services/system.js
  6. +24
    -23
      src/views/login/index.vue
  7. +1
    -1
      src/views/main_web/cloud.vue
  8. +1
    -1
      src/views/main_web/workspace.vue

+ 3
- 1
dist/static/css/main.css View File

@@ -2895,7 +2895,6 @@ button:focus {
.user_Img img {
max-width: 100px;
max-height: 100px;
cursor: pointer;
}
.userNamelabel {
@@ -3060,6 +3059,9 @@ button:focus {
.eidtimg {
position: relative;
}
.eidtimg > img {
cursor: pointer;
}
.eidtimg>div {
position: absolute;


+ 2
- 0
electron-main/preload.js View File

@@ -0,0 +1,2 @@
global.electron = require('electron');
global.os = require('os');

+ 5
- 2
main.js View File

@@ -7,10 +7,13 @@ const url = require('url')
function createWindow() {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
width: 1080,
height: 600,
webPreferences: {
// preload: path.join(__dirname, 'preload.js')
nodeIntegration: true,
// javascript: true,
// plugins: true,
preload: path.join(__dirname, 'electron-main', 'preload.js'),
}
})



+ 0
- 11
src/services/back.js View File

@@ -1,11 +0,0 @@
/**
* 模拟客户端back server
* 目前还不知道back的API及具体实现,暂时先抑制代码报错
*/

const back = {

}


export default back;

+ 27
- 0
src/services/system.js View File

@@ -0,0 +1,27 @@
/**
* 模拟客户端back server
* 目前还不知道back的API及具体实现,暂时先抑制代码报错
*/

export const isClient = process.env.IS_CLIENT;

const noop = () => {};

const safeCall = f => isClient ? f : noop;

const system = {
isClient,
test: safeCall(() => {
console.log('客户端 electron API 检测:', global.electron);
}),
/**
* 系统打开只当文件
*/
openFile: safeCall((filePath) => {
const { shell } = global.electron;
shell.openPath(filePath);
}),
}


export default system;

+ 24
- 23
src/views/login/index.vue View File

@@ -229,7 +229,7 @@
</style>
<script>
import BtnSmsCode from "@/components/BtnSmsCode/BtnSmsCode.vue";
import back from '@/services/back';
import system from '@/services/system';
// import { platform, PLATFORM_TYPE } from "@/utils/access";

export default {
@@ -262,6 +262,7 @@ export default {
},
created: function () {
sessionStorage.login = "";
system.test();
},
mounted: function () {
this.loadRemember();
@@ -484,28 +485,28 @@ export default {
}

// 客户端启动服务
if (thisApp.isClient) {
var userName = sessionStorage.userName;
back.startService(
sessionStorage.userId,
sessionStorage.companyId,
userName,
this.pwd
);
if (thisApp.isRemember) {
thisApp.$cookie.set("remember", true, { expires: 7 });
thisApp.$cookie.set("account", thisApp.account, { expires: 7 });
thisApp.$cookie.set("pwd", thisApp.pwd, { expires: 7 });
thisApp.$cookie.set("background", thisApp.isBackground, {
expires: 7,
});
} else {
thisApp.$cookie.remove("remember");
thisApp.$cookie.remove("account");
thisApp.$cookie.remove("pwd");
thisApp.$cookie.remove("background");
}
}
// if (thisApp.isClient) {
// var userName = sessionStorage.userName;
// back.startService(
// sessionStorage.userId,
// sessionStorage.companyId,
// userName,
// this.pwd
// );
// if (thisApp.isRemember) {
// thisApp.$cookie.set("remember", true, { expires: 7 });
// thisApp.$cookie.set("account", thisApp.account, { expires: 7 });
// thisApp.$cookie.set("pwd", thisApp.pwd, { expires: 7 });
// thisApp.$cookie.set("background", thisApp.isBackground, {
// expires: 7,
// });
// } else {
// thisApp.$cookie.remove("remember");
// thisApp.$cookie.remove("account");
// thisApp.$cookie.remove("pwd");
// thisApp.$cookie.remove("background");
// }
// }

thisApp.$router.push({
path: 'platform',


+ 1
- 1
src/views/main_web/cloud.vue View File

@@ -341,7 +341,7 @@
import officeview from "../components/officeview/officeview.vue";
import imageview from "../components/imageview/imageview.vue";
// import BMapComponent from "../components/map/bmap";
import back from '@/services/back';
import back from '@/services/system';
Vue.use(fileUploader);
const $ = window.jQuery;


+ 1
- 1
src/views/main_web/workspace.vue View File

@@ -2854,7 +2854,7 @@ import ProjSetting from "../components_web/projSetting/projSetting";
import FileShare from "../components_web/share_setting/fileshare";
import draggable from "vuedraggable";
import vuetify from "vuetify";
import back from '@/services/back';
import back from '@/services/system';
const $ = window.jQuery;
const Velocity = window.Velocity;


Loading…
Cancel
Save