mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-05 21:57:45 +08:00
5df3b0e75d
* refactor: plugin build and plugin template * refactor: plugins' deps * refactor: plugins bugs * feat: add plugin static middleware * fix: bugs * refactor: frontend plugin add from remote * refactor: delete useless app/client/plugins * fix: requirejs move to local * fix: tests case * refactor: add src/client and src/server dir check * fix: lodash tree shaking * refactor: add BUILD_TIP * refactor: add file size tip * fix: bugs * fix: bug * fix: change china-division * fix: change plugins response * fix: recover dynamicImport * fix: change server src entry * fix: test error * fix: plugins sourcemap => false * fix: production file error * refactor: change build tools to vite and tsup * fix: yarn.lock * fix: bugs * fix: server build bugs * fix: delete .fatherrc.ts * fix: bug * fix: bug * fix: bugs * fix: bugs * fix: bugs * refactor: add plugin d.ts * refactor: delete fatherrc * refactor: delete father scripts * refactor: build bug * fix: bug * fix: deps adjust * fix: add build tips * fix: bug * refactor: ignore plugins when build client * docs: update doc * refactor: docs and build * fix: bug * refactor: build deps * fix: add USER_REMOTE_PLUGIN env * feat: add plugin static cache * feat: add build deps cache * fix: bugs * test: add test * fix: add plugin depden on plugin tip * fix: adjust shouldDevDependencies * fix: deps * fix: ajust deps * fix: mobile style error * fix: map error * fix: test * fix: bug * feat: lodash and dayjs import from themself * feat: @emotion/css 、ahooks and lodash to global * fix: theme-editor plugin error * fix: review * feat: move all plugins' dependencies to devDependencies * feat: change build * feat: add devPlugins * fix: bug * fix: bugs * fix: bugs * fix: bugs * feat: build bugs * fix: bugs * fix: bugs * fix: review * fix: bug * fix: change deps build * fix: bugs * fix: bug * fix: bug * fix: bugs * fix: bug * fix: bug * fix: multi language * fix: dist * fix: cronstrue * fix: getPackageClientStaticUrl * fix: antd dayjs locale * fix: plugin' d.ts import from dist * fix: multi language * fix: build types error * fix: requireModule * fix: plugin lifecycle * fix: client resource * fix: improve code * fix: locale * feat: custom build * fix: require locale * fix: improve code * fix: improve code * fix: skip preset * fix: collection undefined * feat: yarn build * fix: remove enabled * fix: update dockerfile * fix: formily version * docs: update v12 changelog * fix: devDependencies * feat: @nocobase/app * feat: generateAppDir * fix: improve code * fix: 0.11.1-alpha.5 * fix: missing @nocobase/client * fix: error * fix: add .npmignore * feat: upgrade antd version * fix: dependencies * fix: peerDependencies * fix: remove china-division dep * fix: toposort deps * fix: update dockerfile * fix: plugin template * fix: app client outputPath * feat: update docs * fix: nginx server root * fix: storage/.app-dev * fix: getChinaDivisionData * feat: plugin info * feat: update docs * fix: docs menu --------- Co-authored-by: chenos <chenlinxh@gmail.com>
177 lines
5.7 KiB
JavaScript
177 lines
5.7 KiB
JavaScript
showLog = true;
|
|
function log(m) {
|
|
if (window.console && showLog) {
|
|
console.log(m);
|
|
}
|
|
}
|
|
function css_browser_selector(u) {
|
|
var uaInfo = {},
|
|
screens = [320, 480, 640, 768, 1024, 1152, 1280, 1440, 1680, 1920, 2560],
|
|
allScreens = screens.length,
|
|
ua = u.toLowerCase(),
|
|
is = function (t) {
|
|
return RegExp(t, 'i').test(ua);
|
|
},
|
|
version = function (p, n) {
|
|
n = n.replace('.', '_');
|
|
var i = n.indexOf('_'),
|
|
ver = '';
|
|
while (i > 0) {
|
|
ver += ' ' + p + n.substring(0, i);
|
|
i = n.indexOf('_', i + 1);
|
|
}
|
|
ver += ' ' + p + n;
|
|
return ver;
|
|
},
|
|
g = 'gecko',
|
|
w = 'webkit',
|
|
c = 'chrome',
|
|
f = 'firefox',
|
|
s = 'safari',
|
|
o = 'opera',
|
|
m = 'mobile',
|
|
a = 'android',
|
|
bb = 'blackberry',
|
|
lang = 'lang_',
|
|
dv = 'device_',
|
|
html = document.documentElement,
|
|
b = [
|
|
(!/opera|webtv/i.test(ua) && /msie\s(\d+)/.test(ua)) || /trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/.test(ua)
|
|
? 'ie ie' + (/trident\/4\.0/.test(ua) ? '8' : RegExp.$1 == '11.0' ? '11' : RegExp.$1)
|
|
: is('firefox/')
|
|
? g +
|
|
' ' +
|
|
f +
|
|
(/firefox\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)
|
|
? ' ' + f + RegExp.$2 + ' ' + f + RegExp.$2 + '_' + RegExp.$4
|
|
: '')
|
|
: is('gecko/')
|
|
? g
|
|
: is('opera')
|
|
? o +
|
|
(/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)
|
|
? ' ' + o + RegExp.$2 + ' ' + o + RegExp.$2 + '_' + RegExp.$4
|
|
: /opera(\s|\/)(\d+)\.(\d+)/.test(ua)
|
|
? ' ' + o + RegExp.$2 + ' ' + o + RegExp.$2 + '_' + RegExp.$3
|
|
: '')
|
|
: is('konqueror')
|
|
? 'konqueror'
|
|
: is('blackberry')
|
|
? bb +
|
|
(/Version\/(\d+)(\.(\d+)+)/i.test(ua)
|
|
? ' ' + bb + RegExp.$1 + ' ' + bb + RegExp.$1 + RegExp.$2.replace('.', '_')
|
|
: /Blackberry ?(([0-9]+)([a-z]?))[\/|;]/gi.test(ua)
|
|
? ' ' + bb + RegExp.$2 + (RegExp.$3 ? ' ' + bb + RegExp.$2 + RegExp.$3 : '')
|
|
: '')
|
|
: is('android')
|
|
? a +
|
|
(/Version\/(\d+)(\.(\d+))+/i.test(ua)
|
|
? ' ' + a + RegExp.$1 + ' ' + a + RegExp.$1 + RegExp.$2.replace('.', '_')
|
|
: '') +
|
|
(/Android (.+); (.+) Build/i.test(ua) ? ' ' + dv + RegExp.$2.replace(/ /g, '_').replace(/-/g, '_') : '')
|
|
: is('chrome')
|
|
? w +
|
|
' ' +
|
|
c +
|
|
(/chrome\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)
|
|
? ' ' + c + RegExp.$2 + (RegExp.$4 > 0 ? ' ' + c + RegExp.$2 + '_' + RegExp.$4 : '')
|
|
: '')
|
|
: is('iron')
|
|
? w + ' iron'
|
|
: is('applewebkit/')
|
|
? w +
|
|
' ' +
|
|
s +
|
|
(/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)
|
|
? ' ' + s + RegExp.$2 + ' ' + s + RegExp.$2 + RegExp.$3.replace('.', '_')
|
|
: / Safari\/(\d+)/i.test(ua)
|
|
? RegExp.$1 == '419' || RegExp.$1 == '417' || RegExp.$1 == '416' || RegExp.$1 == '412'
|
|
? ' ' + s + '2_0'
|
|
: RegExp.$1 == '312'
|
|
? ' ' + s + '1_3'
|
|
: RegExp.$1 == '125'
|
|
? ' ' + s + '1_2'
|
|
: RegExp.$1 == '85'
|
|
? ' ' + s + '1_0'
|
|
: ''
|
|
: '')
|
|
: is('mozilla/')
|
|
? g
|
|
: '',
|
|
is('android|mobi|mobile|j2me|iphone|ipod|ipad|blackberry|playbook|kindle|silk') ? m : '',
|
|
is('j2me')
|
|
? 'j2me'
|
|
: is('ipad|ipod|iphone')
|
|
? (/CPU( iPhone)? OS (\d+[_|\.]\d+([_|\.]\d+)*)/i.test(ua) ? 'ios' + version('ios', RegExp.$2) : '') +
|
|
' ' +
|
|
(/(ip(ad|od|hone))/gi.test(ua) ? RegExp.$1 : '')
|
|
: is('playbook')
|
|
? 'playbook'
|
|
: is('kindle|silk')
|
|
? 'kindle'
|
|
: is('playbook')
|
|
? 'playbook'
|
|
: is('mac')
|
|
? 'mac' +
|
|
(/mac os x ((\d+)[.|_](\d+))/.test(ua) ? ' mac' + RegExp.$2 + ' mac' + RegExp.$1.replace('.', '_') : '')
|
|
: is('win')
|
|
? 'win' +
|
|
(is('windows nt 6.2')
|
|
? ' win8'
|
|
: is('windows nt 6.1')
|
|
? ' win7'
|
|
: is('windows nt 6.0')
|
|
? ' vista'
|
|
: is('windows nt 5.2') || is('windows nt 5.1')
|
|
? ' win_xp'
|
|
: is('windows nt 5.0')
|
|
? ' win_2k'
|
|
: is('windows nt 4.0') || is('WinNT4.0')
|
|
? ' win_nt'
|
|
: '')
|
|
: is('freebsd')
|
|
? 'freebsd'
|
|
: is('x11|linux')
|
|
? 'linux'
|
|
: '',
|
|
/[; |\[](([a-z]{2})(\-[a-z]{2})?)[)|;|\]]/i.test(ua)
|
|
? (lang + RegExp.$2).replace('-', '_') + (RegExp.$3 != '' ? (' ' + lang + RegExp.$1).replace('-', '_') : '')
|
|
: '',
|
|
is('ipad|iphone|ipod') && !is('safari') ? 'ipad_app' : '',
|
|
];
|
|
console.debug(ua);
|
|
function screenSize() {
|
|
var w = window.outerWidth || html.clientWidth;
|
|
var h = window.outerHeight || html.clientHeight;
|
|
uaInfo.orientation = w < h ? 'portrait' : 'landscape';
|
|
html.className = html.className.replace(/ ?orientation_\w+/g, '').replace(/ [min|max|cl]+[w|h]_\d+/g, '');
|
|
for (var i = allScreens - 1; i >= 0; i--) {
|
|
if (w >= screens[i]) {
|
|
uaInfo.maxw = screens[i];
|
|
break;
|
|
}
|
|
}
|
|
widthClasses = '';
|
|
for (var info in uaInfo) {
|
|
widthClasses += ' ' + info + '_' + uaInfo[info];
|
|
}
|
|
html.className = html.className + widthClasses;
|
|
return widthClasses;
|
|
}
|
|
window.onresize = screenSize;
|
|
screenSize();
|
|
function retina() {
|
|
var r = window.devicePixelRatio > 1;
|
|
if (r) {
|
|
html.className += ' retina';
|
|
} else {
|
|
html.className += ' non-retina';
|
|
}
|
|
}
|
|
retina();
|
|
var cssbs = b.join(' ') + ' js ';
|
|
html.className = (cssbs + html.className.replace(/\b(no[-|_]?)?js\b/g, '')).replace(/^ /, '').replace(/ +/g, ' ');
|
|
return cssbs;
|
|
}
|
|
css_browser_selector(navigator.userAgent);
|