mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
修复windows下路径的问题,添加设置项,完善翻译
This commit is contained in:
1 parent
5980080302
commit
6ad41dc2ae
29 files changed
+368
-278
No files matched your search
+86
-85
@@ -1,100 +1,101 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
"root": true,
|
||||
"parser": "babel-eslint",
|
||||
"plugins": [
|
||||
"babel",
|
||||
"react"
|
||||
root: true,
|
||||
parser: 'babel-eslint',
|
||||
plugins: [
|
||||
'babel',
|
||||
'react',
|
||||
],
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"jquery": true,
|
||||
"commonjs": true
|
||||
env: {
|
||||
browser: true,
|
||||
es6: true,
|
||||
jquery: true,
|
||||
commonjs: true,
|
||||
},
|
||||
"extends": [
|
||||
"airbnb"
|
||||
extends: [
|
||||
'airbnb',
|
||||
],
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"ecmaVersion": 7,
|
||||
"ecmaFeatures": {
|
||||
"impliedStrict": true,
|
||||
"experimentalObjectRestSpread": true,
|
||||
"jsx": true,
|
||||
"legacyDecorators": true
|
||||
}
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 7,
|
||||
ecmaFeatures: {
|
||||
impliedStrict: true,
|
||||
experimentalObjectRestSpread: true,
|
||||
jsx: true,
|
||||
legacyDecorators: true,
|
||||
},
|
||||
},
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
"webpack": {
|
||||
"config": {
|
||||
"resolve": {
|
||||
"alias": {
|
||||
"vj": path.resolve(__dirname),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
webpack: {
|
||||
config: {
|
||||
resolve: {
|
||||
alias: {
|
||||
vj: path.resolve(__dirname),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"globals": {
|
||||
"__webpack_public_path__": true,
|
||||
"__webpack_require__": true,
|
||||
"UiContext": true,
|
||||
"UserContext": true,
|
||||
"Context": true,
|
||||
"LOCALES": true,
|
||||
"window": true,
|
||||
globals: {
|
||||
__webpack_public_path__: true,
|
||||
__webpack_require__: true,
|
||||
UiContext: true,
|
||||
UserContext: true,
|
||||
Context: true,
|
||||
LOCALES: true,
|
||||
window: true,
|
||||
},
|
||||
"rules": {
|
||||
"comma-dangle": [
|
||||
"error",
|
||||
"always-multiline"
|
||||
rules: {
|
||||
'comma-dangle': [
|
||||
'error',
|
||||
'always-multiline',
|
||||
],
|
||||
"indent": [
|
||||
"error",
|
||||
indent: [
|
||||
'error',
|
||||
2,
|
||||
{
|
||||
"SwitchCase": 0
|
||||
}
|
||||
SwitchCase: 0,
|
||||
},
|
||||
],
|
||||
"max-len": [
|
||||
"error",
|
||||
150
|
||||
'max-len': [
|
||||
'error',
|
||||
150,
|
||||
],
|
||||
"quotes": "warn",
|
||||
"func-names": "off",
|
||||
"class-methods-use-this": "off",
|
||||
"consistent-return": "warn",
|
||||
"no-restricted-syntax": "warn",
|
||||
"no-unused-vars": "warn",
|
||||
"no-console": "off",
|
||||
"no-continue": "off",
|
||||
"no-mixed-operators": "off",
|
||||
"no-plusplus": "off",
|
||||
"no-underscore-dangle": "off",
|
||||
"no-await-in-loop": "off",
|
||||
"no-lonely-if": "off",
|
||||
"import/first": "off",
|
||||
"react/prefer-stateless-function": "off",
|
||||
"react/self-closing-comp": "off",
|
||||
"react/prop-types": "off",
|
||||
"react/jsx-filename-extension": "off",
|
||||
"react/jsx-one-expression-per-line": "off",
|
||||
"react/no-string-refs": "off",
|
||||
"react/require-default-props": "off",
|
||||
"react/react-in-jsx-scope": "off",
|
||||
"react/destructuring-assignment": "off",
|
||||
"react/button-has-type": "off",
|
||||
"react/forbid-prop-types": "off",
|
||||
"jsx-a11y/no-static-element-interactions": "off",
|
||||
"jsx-a11y/anchor-is-valid": "off",
|
||||
"jsx-a11y/click-events-have-key-events": "off",
|
||||
"max-classes-per-file": "off",
|
||||
"react/jsx-props-no-spreading": "off",
|
||||
"react/static-property-placement": "off",
|
||||
"no-param-reassign": "off"
|
||||
}
|
||||
quotes: 'warn',
|
||||
'func-names': 'off',
|
||||
'class-methods-use-this': 'off',
|
||||
'consistent-return': 'warn',
|
||||
'no-restricted-syntax': 'warn',
|
||||
'no-unused-vars': 'warn',
|
||||
'no-console': 'off',
|
||||
'no-continue': 'off',
|
||||
'no-mixed-operators': 'off',
|
||||
'no-plusplus': 'off',
|
||||
'no-underscore-dangle': 'off',
|
||||
'no-await-in-loop': 'off',
|
||||
'no-lonely-if': 'off',
|
||||
'no-param-reassign': 'off',
|
||||
'no-bitwise': 'off',
|
||||
'import/first': 'off',
|
||||
'react/prefer-stateless-function': 'off',
|
||||
'react/self-closing-comp': 'off',
|
||||
'react/prop-types': 'off',
|
||||
'react/jsx-filename-extension': 'off',
|
||||
'react/jsx-one-expression-per-line': 'off',
|
||||
'react/no-string-refs': 'off',
|
||||
'react/require-default-props': 'off',
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/destructuring-assignment': 'off',
|
||||
'react/button-has-type': 'off',
|
||||
'react/forbid-prop-types': 'off',
|
||||
'jsx-a11y/no-static-element-interactions': 'off',
|
||||
'jsx-a11y/anchor-is-valid': 'off',
|
||||
'jsx-a11y/click-events-have-key-events': 'off',
|
||||
'max-classes-per-file': 'off',
|
||||
'react/jsx-props-no-spreading': 'off',
|
||||
'react/static-property-placement': 'off',
|
||||
},
|
||||
};
|
||||
@@ -1,5 +1,9 @@
|
||||
import { AutoloadPage } from 'vj/misc/PageLoader';
|
||||
import { InfoDialog } from 'vj/components/dialog';
|
||||
import Notification from 'vj/components/notification';
|
||||
import { FLAG_ALERT } from 'vj/constant/message';
|
||||
import i18n from 'vj/utils/i18n';
|
||||
import tpl from 'vj/utils/tpl';
|
||||
|
||||
const messagePage = new AutoloadPage('messagePage', () => {
|
||||
async function init() {
|
||||
@@ -8,12 +12,23 @@ const messagePage = new AutoloadPage('messagePage', () => {
|
||||
const sock = new SockJs(`/home/messages-conn?token=${UiContext.token}`);
|
||||
sock.onmessage = (message) => {
|
||||
const msg = JSON.parse(message.data);
|
||||
Notification.show({
|
||||
title: msg.udoc.uname,
|
||||
avatar: msg.udoc.gravatar,
|
||||
message: msg.mdoc.content,
|
||||
duration: 0,
|
||||
});
|
||||
if (msg.mdoc.flag | FLAG_ALERT) {
|
||||
// Is alert
|
||||
const dialog = new InfoDialog({
|
||||
$body: tpl`
|
||||
<div class="typo">
|
||||
<p>${i18n(msg.udoc.content)}</p>
|
||||
</div>`,
|
||||
});
|
||||
dialog.open();
|
||||
} else {
|
||||
// Is message
|
||||
Notification.show({
|
||||
title: msg.udoc.uname,
|
||||
avatar: msg.udoc.gravatar,
|
||||
message: msg.mdoc.content,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import Message from './MessageComponent';
|
||||
const mapStateToProps = (state) => ({
|
||||
activeId: state.activeId,
|
||||
item: state.activeId !== null
|
||||
? state.dialogues[state.activeId]
|
||||
? state.ues[state.activeId]
|
||||
: null,
|
||||
});
|
||||
|
||||
|
||||
@@ -5,6 +5,35 @@ let lastNotification = null;
|
||||
let autoHideTimer = null;
|
||||
|
||||
export default class Notification {
|
||||
constructor({
|
||||
avatar, title, message, type = '', duration = 3000, action,
|
||||
}) {
|
||||
this.type = type;
|
||||
if (avatar) this.type += ' avatar';
|
||||
if (title) this.type += ' title';
|
||||
this.action = (() => { }) || action;
|
||||
this.$dom = $(tpl`<div class="notification ${type} hide"></div>`);
|
||||
if (avatar) $(tpl`<img width="64" height="64" class="avatar" src="${avatar}"></img>`).appendTo(this.$dom);
|
||||
if (title) $(tpl`<h2>${title}</h2>`).appendTo(this.$dom);
|
||||
$(tpl`<p>${message}</p>`).appendTo(this.$dom);
|
||||
this.$dom.on('clink', this.handleClick.bind(this));
|
||||
this.$n = this.$dom
|
||||
.css('z-index', zIndexManager.getNext())
|
||||
.appendTo('body');
|
||||
this.$n.width(); // force reflow
|
||||
this.$n.removeClass('hide');
|
||||
this.autoHideTimer = setTimeout(this.hide.bind(this), duration);
|
||||
}
|
||||
|
||||
handleClick() {
|
||||
this.action();
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.$n.addClass('hide');
|
||||
setTimeout(() => this.$n.remove(), 200);
|
||||
}
|
||||
|
||||
static success(message, duration) {
|
||||
return Notification.show({ type: 'success', message, duration });
|
||||
}
|
||||
@@ -22,49 +51,37 @@ export default class Notification {
|
||||
}
|
||||
|
||||
static show({
|
||||
avatar, title, message, type = '', duration = 3000,
|
||||
actionButtons = [],
|
||||
avatar, title, message, type = '', duration = 3000, action,
|
||||
}) {
|
||||
if (duration && lastNotification) {
|
||||
Notification.hide();
|
||||
}
|
||||
if (lastNotification) Notification.hide();
|
||||
if (avatar) type += ' avatar';
|
||||
if (title) type += ' title';
|
||||
const $dom = $(tpl`<div class="notification ${type} hide"></div>`);
|
||||
if (avatar) $(tpl`<img width="64" height="64" class="avatar" src="${avatar}"></img>`).appendTo($dom);
|
||||
if (title) $(tpl`<h2>${title}</h2>`).appendTo($dom);
|
||||
$(tpl`<p>${message}</p>`).appendTo($dom);
|
||||
actionButtons.forEach((button) => {
|
||||
$(tpl`<button class="${button.class}" onclick="javascript:window.${button.funcName}();">${button.name}</button>`).appendTo($dom);
|
||||
});
|
||||
$dom.on('clink', action);
|
||||
const $n = $dom
|
||||
.css('z-index', zIndexManager.getNext())
|
||||
.appendTo('body');
|
||||
$n.width(); // force reflow
|
||||
$n.removeClass('hide');
|
||||
if (duration) {
|
||||
lastNotification = $n;
|
||||
autoHideTimer = setTimeout(Notification.hide, duration);
|
||||
}
|
||||
lastNotification = $n;
|
||||
autoHideTimer = setTimeout(Notification.hide, duration);
|
||||
return $n;
|
||||
}
|
||||
|
||||
static hide($node) {
|
||||
if (!$node) {
|
||||
if (!lastNotification) {
|
||||
return;
|
||||
}
|
||||
if (autoHideTimer) {
|
||||
clearTimeout(autoHideTimer);
|
||||
autoHideTimer = null;
|
||||
}
|
||||
const $n = lastNotification;
|
||||
$n.addClass('hide');
|
||||
setTimeout(() => $n.remove(), 200);
|
||||
lastNotification = null;
|
||||
} else {
|
||||
$node.addClass('hide');
|
||||
setTimeout(() => $node.remove(), 200);
|
||||
static hide() {
|
||||
if (!lastNotification) {
|
||||
return;
|
||||
}
|
||||
if (autoHideTimer) {
|
||||
clearTimeout(autoHideTimer);
|
||||
autoHideTimer = null;
|
||||
}
|
||||
const $n = lastNotification;
|
||||
$n.addClass('hide');
|
||||
setTimeout(() => $n.remove(), 200);
|
||||
lastNotification = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export const FLAG_UNREAD = 1;
|
||||
export const FLAG_ALERT = 2;
|
||||
@@ -15,28 +15,3 @@ export const FUNCTION_RANGE = {
|
||||
1: 'Enabled',
|
||||
};
|
||||
attachObjectMeta(FUNCTION_RANGE, 'intKey', true);
|
||||
|
||||
export const BACKGROUND_RANGE = {
|
||||
1: 'Bg1',
|
||||
2: 'Bg2',
|
||||
3: 'Bg3',
|
||||
4: 'Bg4',
|
||||
5: 'Bg5',
|
||||
6: 'Bg6',
|
||||
7: 'Bg7',
|
||||
8: 'Bg8',
|
||||
9: 'Bg9',
|
||||
10: 'Bg10',
|
||||
11: 'Bg11',
|
||||
12: 'Bg12',
|
||||
13: 'Bg13',
|
||||
14: 'Bg14',
|
||||
15: 'Bg15',
|
||||
16: 'Bg16',
|
||||
17: 'Bg17',
|
||||
18: 'Bg18',
|
||||
19: 'Bg19',
|
||||
20: 'Bg20',
|
||||
21: 'Bg21',
|
||||
};
|
||||
attachObjectMeta(BACKGROUND_RANGE, 'intKey', true);
|
||||
Reference in new issue
Block a user