mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 16:46:22 +08:00
milestone: publish alpha version (#637)
- document folder - full-text search - blob storage - basic edgeless support Co-authored-by: tzhangchi <terry.zhangchi@outlook.com> Co-authored-by: QiShaoXuan <qishaoxuan777@gmail.com> Co-authored-by: DiamondThree <diamond.shx@gmail.com> Co-authored-by: MingLiang Wang <mingliangwang0o0@gmail.com> Co-authored-by: JimmFly <yangjinfei001@gmail.com> Co-authored-by: Yifeng Wang <doodlewind@toeverything.info> Co-authored-by: Himself65 <himself65@outlook.com> Co-authored-by: lawvs <18554747+lawvs@users.noreply.github.com> Co-authored-by: Qi <474021214@qq.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export const isDev = process.env['NODE_ENV'] === 'development';
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-useless-escape */
|
||||
// Inspire by https://stackoverflow.com/a/11381730/8415727
|
||||
export function isMobile(userAgent: string) {
|
||||
return !!(
|
||||
@@ -12,6 +13,7 @@ export function isMobile(userAgent: string) {
|
||||
|
||||
export const getIsMobile = function () {
|
||||
return isMobile(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
navigator?.userAgent || navigator?.vendor || (window as any)?.opera
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export { isDev } from './env';
|
||||
|
||||
export * from './useragent';
|
||||
|
||||
export * from './tools';
|
||||
@@ -1,9 +1,10 @@
|
||||
import getConfig from 'next/config';
|
||||
|
||||
// import { isDev } from './env';
|
||||
type Config = {
|
||||
BUILD_DATE: string;
|
||||
NODE_ENV: string;
|
||||
PROJECT_NAME: string;
|
||||
EDITOR_VERSION: string;
|
||||
VERSION: string;
|
||||
CI?: string;
|
||||
COMMIT_HASH: string;
|
||||
@@ -13,9 +14,9 @@ const nextConfig = getConfig();
|
||||
const publicRuntimeConfig: Config = nextConfig.publicRuntimeConfig;
|
||||
|
||||
const printBuildInfo = () => {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
return;
|
||||
}
|
||||
// if (isDev) {
|
||||
// return;
|
||||
// }
|
||||
console.group('Build info');
|
||||
console.log('Project:', publicRuntimeConfig.PROJECT_NAME);
|
||||
console.log(
|
||||
@@ -28,6 +29,7 @@ const printBuildInfo = () => {
|
||||
'Environment:',
|
||||
`${publicRuntimeConfig.NODE_ENV}${publicRuntimeConfig.CI ? '(ci)' : ''}`
|
||||
);
|
||||
console.log('Editor Version:', publicRuntimeConfig.EDITOR_VERSION);
|
||||
console.log('Version:', publicRuntimeConfig.VERSION);
|
||||
console.log(
|
||||
'AFFiNE is an open source project, you can view its source code on GitHub!'
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export function debounce(fn: Function, timeout: number) {
|
||||
let timeoutId: any;
|
||||
|
||||
return function (this: any) {
|
||||
clearTimeout(timeoutId);
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
timeoutId = setTimeout(() => fn.apply(this, arguments), timeout);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
function getUaHelper() {
|
||||
let uaHelper = null;
|
||||
(function (navigator) {
|
||||
const getUa = () => {
|
||||
const ua = navigator.userAgent;
|
||||
const uas = ua.toLowerCase();
|
||||
const mobile =
|
||||
/mobile|tablet|ip(ad|hone|od)|android/i.test(ua) ||
|
||||
(uas.indexOf('safari') > -1 &&
|
||||
/Mac OS/i.test(ua) &&
|
||||
/Macintosh/i.test(ua));
|
||||
const android =
|
||||
(mobile &&
|
||||
(uas.indexOf('android') > -1 || uas.indexOf('linux') > -1)) ||
|
||||
uas.indexOf('adr') > -1;
|
||||
const ios = mobile && !android && /Mac OS/i.test(ua);
|
||||
const iphone = ios && uas.indexOf('iphone') > -1;
|
||||
const ipad = ios && !iphone;
|
||||
const wx = /MicroMessenger/i.test(ua);
|
||||
const chrome = /CriOS/i.test(ua) || /Chrome/i.test(ua);
|
||||
const tiktok = mobile && /aweme/i.test(ua);
|
||||
const weibo = mobile && /Weibo/i.test(ua);
|
||||
const safari =
|
||||
ios &&
|
||||
!chrome &&
|
||||
!wx &&
|
||||
!weibo &&
|
||||
!tiktok &&
|
||||
/Safari|Macintosh/i.test(ua);
|
||||
const firefox = /Firefox/.test(ua);
|
||||
const win = /windows|win32|win64|wow32|wow64/.test(uas);
|
||||
const linux = /linux/.test(uas);
|
||||
return {
|
||||
ua,
|
||||
mobile,
|
||||
android,
|
||||
ios,
|
||||
wx,
|
||||
chrome,
|
||||
iphone,
|
||||
ipad,
|
||||
safari,
|
||||
tiktok,
|
||||
weibo,
|
||||
win,
|
||||
linux,
|
||||
firefox,
|
||||
};
|
||||
};
|
||||
|
||||
class UaHelper {
|
||||
private uaMap;
|
||||
public isLinux = false;
|
||||
public isMacOs = false;
|
||||
public isSafari = false;
|
||||
public isWindows = false;
|
||||
public isFireFox = false;
|
||||
|
||||
constructor() {
|
||||
this.uaMap = getUa();
|
||||
this.initUaFlags();
|
||||
}
|
||||
|
||||
public checkUseragent(isUseragent: keyof ReturnType<typeof getUa>) {
|
||||
return Boolean(this.uaMap[isUseragent]);
|
||||
}
|
||||
|
||||
private initUaFlags() {
|
||||
this.isLinux = this.checkUseragent('linux');
|
||||
this.isMacOs = this.checkUseragent('ios');
|
||||
this.isSafari = this.checkUseragent('safari');
|
||||
this.isWindows = this.checkUseragent('win');
|
||||
this.isFireFox = this.checkUseragent('firefox');
|
||||
}
|
||||
}
|
||||
uaHelper = new UaHelper();
|
||||
})(navigator);
|
||||
|
||||
return uaHelper;
|
||||
}
|
||||
|
||||
export { getUaHelper };
|
||||
Reference in New Issue
Block a user