@ldesign/desktop-public-next 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/es/App.js +61 -1
- package/es/index.js +45 -1
- package/es/public/Layout.js +22 -1
- package/es/public/Login.js +165 -1
- package/es/public/index.js +18 -1
- package/package.json +1 -1
package/es/App.js
CHANGED
@@ -1 +1,61 @@
|
|
1
|
-
|
1
|
+
function __$styleInject(css) {
|
2
|
+
if (!css) return;
|
3
|
+
|
4
|
+
if (typeof window == 'undefined') return;
|
5
|
+
var style = document.createElement('style');
|
6
|
+
style.setAttribute('media', 'screen');
|
7
|
+
|
8
|
+
style.innerHTML = css;
|
9
|
+
document.head.appendChild(style);
|
10
|
+
return css;
|
11
|
+
}
|
12
|
+
|
13
|
+
import { useConfigStore, RouterView } from '@ldesign/business-next';
|
14
|
+
import { ConfigProvider } from '@ldesign/desktop-next';
|
15
|
+
import { defineComponent, inject, computed, Transition, KeepAlive } from 'vue';
|
16
|
+
|
17
|
+
var App = defineComponent({
|
18
|
+
name: 'App',
|
19
|
+
setup: function setup() {
|
20
|
+
var $config = inject('$config', {});
|
21
|
+
var leapConfig = computed(function () {
|
22
|
+
return $config.getLeapConfig();
|
23
|
+
});
|
24
|
+
var appConfig = computed(function () {
|
25
|
+
return $config.getAppConfig();
|
26
|
+
});
|
27
|
+
var _useConfigStore = useConfigStore(),
|
28
|
+
$setInfo = _useConfigStore.$setInfo;
|
29
|
+
$setInfo('333');
|
30
|
+
return {
|
31
|
+
leapConfig: leapConfig,
|
32
|
+
appConfig: appConfig
|
33
|
+
};
|
34
|
+
},
|
35
|
+
render: function render() {
|
36
|
+
var _this = this;
|
37
|
+
var h = arguments[0];
|
38
|
+
return h(ConfigProvider, [h(RouterView, {
|
39
|
+
"directives": [{
|
40
|
+
name: "slots",
|
41
|
+
value: {
|
42
|
+
default: function _default(_ref) {
|
43
|
+
var Component = _ref.Component;
|
44
|
+
return h(Transition, {
|
45
|
+
"attrs": {
|
46
|
+
"name": 'fade'
|
47
|
+
}
|
48
|
+
}, [h(KeepAlive, [Component && h(Component, {
|
49
|
+
"attrs": {
|
50
|
+
"leapConfig": _this.leapConfig,
|
51
|
+
"appConfig": _this.appConfig
|
52
|
+
}
|
53
|
+
})])]);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}]
|
57
|
+
})]);
|
58
|
+
}
|
59
|
+
});
|
60
|
+
|
61
|
+
export { App as default };
|
package/es/index.js
CHANGED
@@ -1 +1,45 @@
|
|
1
|
-
|
1
|
+
function __$styleInject(css) {
|
2
|
+
if (!css) return;
|
3
|
+
|
4
|
+
if (typeof window == 'undefined') return;
|
5
|
+
var style = document.createElement('style');
|
6
|
+
style.setAttribute('media', 'screen');
|
7
|
+
|
8
|
+
style.innerHTML = css;
|
9
|
+
document.head.appendChild(style);
|
10
|
+
return css;
|
11
|
+
}
|
12
|
+
|
13
|
+
import { createApp } from 'vue';
|
14
|
+
import LDesign from '@ldesign/desktop-next';
|
15
|
+
import LDesignProfession from '@ldesign/desktop-profession-next';
|
16
|
+
import { LeapRouter, LeapApi, LeapConfig, pinia } from '@ldesign/business-next';
|
17
|
+
import App from './App.js';
|
18
|
+
export { default as Login } from './public/Login.js';
|
19
|
+
import '@babel/runtime/helpers/defineProperty';
|
20
|
+
import '@babel/runtime/helpers/asyncToGenerator';
|
21
|
+
import '@babel/runtime/regenerator';
|
22
|
+
|
23
|
+
__$styleInject("html,\nbody {\n height: 100%;\n margin: 0;\n}\n#app {\n height: 100%;\n}\n");
|
24
|
+
|
25
|
+
function createLeapApp(options) {
|
26
|
+
var env = options.env,
|
27
|
+
files = options.files;
|
28
|
+
/** 通用路由配置 */
|
29
|
+
var $router = new LeapRouter({
|
30
|
+
env: env,
|
31
|
+
files: files
|
32
|
+
});
|
33
|
+
/** 通用api */
|
34
|
+
var $api = new LeapApi({
|
35
|
+
env: env
|
36
|
+
});
|
37
|
+
/** 通用配置 */
|
38
|
+
var $config = new LeapConfig({
|
39
|
+
env: env
|
40
|
+
});
|
41
|
+
var app = createApp(App).use(LDesign).use(LDesignProfession).use(pinia).use($router.router).provide('$api', $api).provide('$config', $config).provide('$router', $router).mount(options.el);
|
42
|
+
return app;
|
43
|
+
}
|
44
|
+
|
45
|
+
export { createLeapApp };
|
package/es/public/Layout.js
CHANGED
@@ -1 +1,22 @@
|
|
1
|
-
|
1
|
+
function __$styleInject(css) {
|
2
|
+
if (!css) return;
|
3
|
+
|
4
|
+
if (typeof window == 'undefined') return;
|
5
|
+
var style = document.createElement('style');
|
6
|
+
style.setAttribute('media', 'screen');
|
7
|
+
|
8
|
+
style.innerHTML = css;
|
9
|
+
document.head.appendChild(style);
|
10
|
+
return css;
|
11
|
+
}
|
12
|
+
|
13
|
+
import { defineComponent } from 'vue';
|
14
|
+
|
15
|
+
var Layout = defineComponent({
|
16
|
+
name: 'Layout',
|
17
|
+
render: function render() {
|
18
|
+
return h("div", ["Layout"]);
|
19
|
+
}
|
20
|
+
});
|
21
|
+
|
22
|
+
export { Layout as default };
|
package/es/public/Login.js
CHANGED
@@ -1 +1,165 @@
|
|
1
|
-
|
1
|
+
function __$styleInject(css) {
|
2
|
+
if (!css) return;
|
3
|
+
|
4
|
+
if (typeof window == 'undefined') return;
|
5
|
+
var style = document.createElement('style');
|
6
|
+
style.setAttribute('media', 'screen');
|
7
|
+
|
8
|
+
style.innerHTML = css;
|
9
|
+
document.head.appendChild(style);
|
10
|
+
return css;
|
11
|
+
}
|
12
|
+
|
13
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
14
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
15
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
16
|
+
import { defineComponent, inject, computed, reactive, ref, onBeforeMount, toRefs } from 'vue';
|
17
|
+
import { LpLogin } from '@ldesign/desktop-profession-next';
|
18
|
+
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
21
|
+
var Login = defineComponent({
|
22
|
+
name: 'Login',
|
23
|
+
props: {
|
24
|
+
appConfig: {
|
25
|
+
type: Object,
|
26
|
+
default: {}
|
27
|
+
}
|
28
|
+
},
|
29
|
+
setup: function setup(props) {
|
30
|
+
var $router = inject('$router');
|
31
|
+
var $api = inject('$api', {});
|
32
|
+
/** 登录模板 */
|
33
|
+
var layout = computed(function () {
|
34
|
+
return props.appConfig.login_layout;
|
35
|
+
});
|
36
|
+
/** 登录数据 */
|
37
|
+
var form = reactive({
|
38
|
+
password: {
|
39
|
+
name: '',
|
40
|
+
password: '',
|
41
|
+
captcha: '',
|
42
|
+
remember: false
|
43
|
+
},
|
44
|
+
phone: {
|
45
|
+
name: '',
|
46
|
+
password: '',
|
47
|
+
captcha: '',
|
48
|
+
code: ''
|
49
|
+
}
|
50
|
+
});
|
51
|
+
/** 图片验证码地址 */
|
52
|
+
var captchaUrl = ref('');
|
53
|
+
var handleLogin = function handleLogin(res, type) {
|
54
|
+
return new Promise( /*#__PURE__*/function () {
|
55
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve) {
|
56
|
+
var cb;
|
57
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
58
|
+
while (1) switch (_context.prev = _context.next) {
|
59
|
+
case 0:
|
60
|
+
cb = null;
|
61
|
+
if (!(type === 'password')) {
|
62
|
+
_context.next = 5;
|
63
|
+
break;
|
64
|
+
}
|
65
|
+
_context.next = 4;
|
66
|
+
return $api.loginApi.loginByPassword(res.name, res.password, res.captcha);
|
67
|
+
case 4:
|
68
|
+
cb = _context.sent;
|
69
|
+
case 5:
|
70
|
+
resolve(cb);
|
71
|
+
case 6:
|
72
|
+
case "end":
|
73
|
+
return _context.stop();
|
74
|
+
}
|
75
|
+
}, _callee);
|
76
|
+
}));
|
77
|
+
return function (_x) {
|
78
|
+
return _ref.apply(this, arguments);
|
79
|
+
};
|
80
|
+
}());
|
81
|
+
};
|
82
|
+
var rememberPassword = function rememberPassword() {
|
83
|
+
var _form$password = form.password,
|
84
|
+
name = _form$password.name,
|
85
|
+
password = _form$password.password,
|
86
|
+
remember = _form$password.remember;
|
87
|
+
if (!remember) {
|
88
|
+
localStorage.removeItem("".concat(name, "_pass"));
|
89
|
+
localStorage.removeItem("".concat(name, "_code"));
|
90
|
+
localStorage.removeItem('LOGINUSER');
|
91
|
+
} else {
|
92
|
+
$api.loginApi.saveUserPasswordLocal(name, password);
|
93
|
+
}
|
94
|
+
};
|
95
|
+
var getLocalPassword = function getLocalPassword() {
|
96
|
+
var username = localStorage.getItem('LOGINUSER');
|
97
|
+
var password = $api.loginApi.getSavedPasswordByUser(username);
|
98
|
+
form.password.name = username;
|
99
|
+
form.password.password = password;
|
100
|
+
if (username && password) {
|
101
|
+
form.password.remember = true;
|
102
|
+
}
|
103
|
+
};
|
104
|
+
var handleLoginSuccess = /*#__PURE__*/function () {
|
105
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
106
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
107
|
+
while (1) switch (_context2.prev = _context2.next) {
|
108
|
+
case 0:
|
109
|
+
rememberPassword();
|
110
|
+
console.log('登录成功');
|
111
|
+
$router === null || $router === void 0 ? void 0 : $router.router.push({
|
112
|
+
path: '/'
|
113
|
+
});
|
114
|
+
case 3:
|
115
|
+
case "end":
|
116
|
+
return _context2.stop();
|
117
|
+
}
|
118
|
+
}, _callee2);
|
119
|
+
}));
|
120
|
+
return function handleLoginSuccess() {
|
121
|
+
return _ref2.apply(this, arguments);
|
122
|
+
};
|
123
|
+
}();
|
124
|
+
onBeforeMount( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
125
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
126
|
+
while (1) switch (_context3.prev = _context3.next) {
|
127
|
+
case 0:
|
128
|
+
_context3.next = 2;
|
129
|
+
return $api.loginApi.getSid();
|
130
|
+
case 2:
|
131
|
+
_context3.next = 4;
|
132
|
+
return getLocalPassword();
|
133
|
+
case 4:
|
134
|
+
captchaUrl.value = $api.loginApi.getValiCode();
|
135
|
+
case 5:
|
136
|
+
case "end":
|
137
|
+
return _context3.stop();
|
138
|
+
}
|
139
|
+
}, _callee3);
|
140
|
+
})));
|
141
|
+
return _objectSpread(_objectSpread({}, toRefs(props)), {}, {
|
142
|
+
form: form,
|
143
|
+
layout: layout,
|
144
|
+
captchaUrl: captchaUrl,
|
145
|
+
handleLogin: handleLogin,
|
146
|
+
handleLoginSuccess: handleLoginSuccess
|
147
|
+
});
|
148
|
+
},
|
149
|
+
render: function render() {
|
150
|
+
var h = arguments[0];
|
151
|
+
return h(LpLogin, {
|
152
|
+
"attrs": {
|
153
|
+
"value": this.form,
|
154
|
+
"layout": this.layout,
|
155
|
+
"captchaUrl": this.captchaUrl
|
156
|
+
},
|
157
|
+
"on": {
|
158
|
+
"login": this.handleLogin,
|
159
|
+
"loginSuccess": this.handleLoginSuccess
|
160
|
+
}
|
161
|
+
});
|
162
|
+
}
|
163
|
+
});
|
164
|
+
|
165
|
+
export { Login as default };
|
package/es/public/index.js
CHANGED
@@ -1 +1,18 @@
|
|
1
|
-
|
1
|
+
function __$styleInject(css) {
|
2
|
+
if (!css) return;
|
3
|
+
|
4
|
+
if (typeof window == 'undefined') return;
|
5
|
+
var style = document.createElement('style');
|
6
|
+
style.setAttribute('media', 'screen');
|
7
|
+
|
8
|
+
style.innerHTML = css;
|
9
|
+
document.head.appendChild(style);
|
10
|
+
return css;
|
11
|
+
}
|
12
|
+
|
13
|
+
export { default as Login } from './Login.js';
|
14
|
+
import '@babel/runtime/helpers/defineProperty';
|
15
|
+
import '@babel/runtime/helpers/asyncToGenerator';
|
16
|
+
import '@babel/runtime/regenerator';
|
17
|
+
import 'vue';
|
18
|
+
import '@ldesign/desktop-profession-next';
|