export function getToken() {
    console.log('尝试获取token');
    return new Promise((s, j) => {
        if (window.location.port == '8080') {
            s('dev-token');
        } else {
            if (window['getPxToken']) {
                window['getPxToken'](function (e, token) {
                    switch (e) {
                        case 'net error':
                            // showToast(`getToken: ${e}`);
                            s(null);
                            break;
                        case 'need login':
                            // showToast(`getToken: ${e}`);
                            s(null);
                            break;
                        case 'state invalid':
                            // showToast(`getToken: ${e}`);
                            s(null);
                            break;
                        default:
                            if (token) {
                                s(token);
                            } else {
                                // showToast(`getToken: invalid key`);
                                s(null);
                            }
                            break;
                    }
                });
            } else {
                // showToast(`getToken: no ready`);
                s(null);
            }
        }
    })
}