@sunggang/ui-lib 0.4.47 → 0.4.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LiffProvider.cjs.js +54 -39
- package/LiffProvider.esm.js +54 -39
- package/package.json +1 -1
package/LiffProvider.cjs.js
CHANGED
|
@@ -728,15 +728,15 @@ var LiffProvider = function(param) {
|
|
|
728
728
|
// 初始化 LIFF
|
|
729
729
|
var initializeLiff = function() {
|
|
730
730
|
var _ref = _async_to_generator(function(isValid) {
|
|
731
|
-
var customFetch, liff, originalFetch, profile, lineToken,
|
|
731
|
+
var customFetch, liff, redirectUri, originalFetch, profile, lineToken, tempFriendship, friendship, friendFlag, error, err;
|
|
732
732
|
return _ts_generator(this, function(_state) {
|
|
733
733
|
switch(_state.label){
|
|
734
734
|
case 0:
|
|
735
735
|
_state.trys.push([
|
|
736
736
|
0,
|
|
737
|
-
|
|
737
|
+
12,
|
|
738
738
|
,
|
|
739
|
-
|
|
739
|
+
13
|
|
740
740
|
]);
|
|
741
741
|
customFetch = // 自訂 fetch 函數,避免每次請求都改變 URL
|
|
742
742
|
// eslint-disable-next-line no-inner-declarations
|
|
@@ -752,9 +752,34 @@ var LiffProvider = function(param) {
|
|
|
752
752
|
];
|
|
753
753
|
case 1:
|
|
754
754
|
liff = _state.sent().liff;
|
|
755
|
+
// 未登入先進行登入
|
|
756
|
+
if (!liff.isLoggedIn()) {
|
|
757
|
+
redirectUri = customerRedirectUrl || "".concat(window.location.href);
|
|
758
|
+
if (liffLogin) {
|
|
759
|
+
liff.login({
|
|
760
|
+
redirectUri: redirectUri
|
|
761
|
+
});
|
|
762
|
+
return [
|
|
763
|
+
2
|
|
764
|
+
];
|
|
765
|
+
}
|
|
766
|
+
if (loginByUser || ignoreRoute) return [
|
|
767
|
+
2
|
|
768
|
+
];
|
|
769
|
+
liff.login({
|
|
770
|
+
redirectUri: redirectUri
|
|
771
|
+
});
|
|
772
|
+
return [
|
|
773
|
+
2
|
|
774
|
+
];
|
|
775
|
+
}
|
|
755
776
|
originalFetch = window.fetch;
|
|
756
777
|
window.fetch = customFetch;
|
|
757
778
|
if (openInApp && !(liff === null || liff === void 0 ? void 0 : liff.isInClient()) && (liff === null || liff === void 0 ? void 0 : liff.getOS()) !== "web") window.location.href = "line://app/".concat(liffId);
|
|
779
|
+
if (!!liff.isLoggedIn()) return [
|
|
780
|
+
3,
|
|
781
|
+
4
|
|
782
|
+
];
|
|
758
783
|
return [
|
|
759
784
|
4,
|
|
760
785
|
liff.init({
|
|
@@ -774,60 +799,50 @@ var LiffProvider = function(param) {
|
|
|
774
799
|
profile = _state.sent();
|
|
775
800
|
setLiffProfile(profile);
|
|
776
801
|
saveLiffUserInfoToStorage(profile);
|
|
802
|
+
_state.label = 4;
|
|
803
|
+
case 4:
|
|
777
804
|
lineToken = liff === null || liff === void 0 ? void 0 : liff.getAccessToken();
|
|
778
|
-
// 未登入先進行登入
|
|
779
|
-
if (!liff.isLoggedIn()) {
|
|
780
|
-
redirectUri = customerRedirectUrl || "".concat(window.location.href);
|
|
781
|
-
if (liffLogin) {
|
|
782
|
-
liff.login({
|
|
783
|
-
redirectUri: redirectUri
|
|
784
|
-
});
|
|
785
|
-
return [
|
|
786
|
-
2
|
|
787
|
-
];
|
|
788
|
-
}
|
|
789
|
-
if (loginByUser || ignoreRoute) return [
|
|
790
|
-
2
|
|
791
|
-
];
|
|
792
|
-
liff.login({
|
|
793
|
-
redirectUri: redirectUri
|
|
794
|
-
});
|
|
795
|
-
}
|
|
796
805
|
tempFriendship = null;
|
|
797
806
|
if (!lineToken) return [
|
|
798
807
|
3,
|
|
799
|
-
|
|
808
|
+
11
|
|
800
809
|
];
|
|
801
|
-
_state.label =
|
|
802
|
-
case
|
|
810
|
+
_state.label = 5;
|
|
811
|
+
case 5:
|
|
803
812
|
_state.trys.push([
|
|
804
|
-
|
|
805
|
-
|
|
813
|
+
5,
|
|
814
|
+
8,
|
|
806
815
|
,
|
|
807
|
-
|
|
816
|
+
9
|
|
808
817
|
]);
|
|
818
|
+
if (!!liff.isLoggedIn()) return [
|
|
819
|
+
3,
|
|
820
|
+
7
|
|
821
|
+
];
|
|
809
822
|
return [
|
|
810
823
|
4,
|
|
811
824
|
liff.getFriendship()
|
|
812
825
|
];
|
|
813
|
-
case
|
|
826
|
+
case 6:
|
|
814
827
|
friendship = _state.sent();
|
|
815
828
|
friendFlag = friendship === null || friendship === void 0 ? void 0 : friendship.friendFlag;
|
|
816
829
|
setFriendship(friendFlag);
|
|
817
830
|
tempFriendship = friendFlag;
|
|
818
831
|
console.log("isFriendship", friendFlag);
|
|
832
|
+
_state.label = 7;
|
|
833
|
+
case 7:
|
|
819
834
|
return [
|
|
820
835
|
3,
|
|
821
|
-
|
|
836
|
+
9
|
|
822
837
|
];
|
|
823
|
-
case
|
|
838
|
+
case 8:
|
|
824
839
|
error = _state.sent();
|
|
825
840
|
console.error("Error in liff.getFriendship():", error);
|
|
826
841
|
return [
|
|
827
842
|
3,
|
|
828
|
-
|
|
843
|
+
9
|
|
829
844
|
];
|
|
830
|
-
case
|
|
845
|
+
case 9:
|
|
831
846
|
console.log("isValid", isValid);
|
|
832
847
|
if (tempFriendship && isValid) return [
|
|
833
848
|
2
|
|
@@ -836,23 +851,23 @@ var LiffProvider = function(param) {
|
|
|
836
851
|
4,
|
|
837
852
|
loginInit(lineToken)
|
|
838
853
|
];
|
|
839
|
-
case
|
|
854
|
+
case 10:
|
|
840
855
|
_state.sent();
|
|
841
|
-
_state.label =
|
|
842
|
-
case
|
|
856
|
+
_state.label = 11;
|
|
857
|
+
case 11:
|
|
843
858
|
return [
|
|
844
859
|
3,
|
|
845
|
-
|
|
860
|
+
13
|
|
846
861
|
];
|
|
847
|
-
case
|
|
862
|
+
case 12:
|
|
848
863
|
err = _state.sent();
|
|
849
864
|
setLiffError(err.toString());
|
|
850
865
|
console.log("LIFF init failed.", err);
|
|
851
866
|
return [
|
|
852
867
|
3,
|
|
853
|
-
|
|
868
|
+
13
|
|
854
869
|
];
|
|
855
|
-
case
|
|
870
|
+
case 13:
|
|
856
871
|
return [
|
|
857
872
|
2
|
|
858
873
|
];
|
package/LiffProvider.esm.js
CHANGED
|
@@ -724,15 +724,15 @@ var LiffProvider = function(param) {
|
|
|
724
724
|
// 初始化 LIFF
|
|
725
725
|
var initializeLiff = function() {
|
|
726
726
|
var _ref = _async_to_generator(function(isValid) {
|
|
727
|
-
var customFetch, liff, originalFetch, profile, lineToken,
|
|
727
|
+
var customFetch, liff, redirectUri, originalFetch, profile, lineToken, tempFriendship, friendship, friendFlag, error, err;
|
|
728
728
|
return _ts_generator(this, function(_state) {
|
|
729
729
|
switch(_state.label){
|
|
730
730
|
case 0:
|
|
731
731
|
_state.trys.push([
|
|
732
732
|
0,
|
|
733
|
-
|
|
733
|
+
12,
|
|
734
734
|
,
|
|
735
|
-
|
|
735
|
+
13
|
|
736
736
|
]);
|
|
737
737
|
customFetch = // 自訂 fetch 函數,避免每次請求都改變 URL
|
|
738
738
|
// eslint-disable-next-line no-inner-declarations
|
|
@@ -748,9 +748,34 @@ var LiffProvider = function(param) {
|
|
|
748
748
|
];
|
|
749
749
|
case 1:
|
|
750
750
|
liff = _state.sent().liff;
|
|
751
|
+
// 未登入先進行登入
|
|
752
|
+
if (!liff.isLoggedIn()) {
|
|
753
|
+
redirectUri = customerRedirectUrl || "".concat(window.location.href);
|
|
754
|
+
if (liffLogin) {
|
|
755
|
+
liff.login({
|
|
756
|
+
redirectUri: redirectUri
|
|
757
|
+
});
|
|
758
|
+
return [
|
|
759
|
+
2
|
|
760
|
+
];
|
|
761
|
+
}
|
|
762
|
+
if (loginByUser || ignoreRoute) return [
|
|
763
|
+
2
|
|
764
|
+
];
|
|
765
|
+
liff.login({
|
|
766
|
+
redirectUri: redirectUri
|
|
767
|
+
});
|
|
768
|
+
return [
|
|
769
|
+
2
|
|
770
|
+
];
|
|
771
|
+
}
|
|
751
772
|
originalFetch = window.fetch;
|
|
752
773
|
window.fetch = customFetch;
|
|
753
774
|
if (openInApp && !(liff === null || liff === void 0 ? void 0 : liff.isInClient()) && (liff === null || liff === void 0 ? void 0 : liff.getOS()) !== "web") window.location.href = "line://app/".concat(liffId);
|
|
775
|
+
if (!!liff.isLoggedIn()) return [
|
|
776
|
+
3,
|
|
777
|
+
4
|
|
778
|
+
];
|
|
754
779
|
return [
|
|
755
780
|
4,
|
|
756
781
|
liff.init({
|
|
@@ -770,60 +795,50 @@ var LiffProvider = function(param) {
|
|
|
770
795
|
profile = _state.sent();
|
|
771
796
|
setLiffProfile(profile);
|
|
772
797
|
saveLiffUserInfoToStorage(profile);
|
|
798
|
+
_state.label = 4;
|
|
799
|
+
case 4:
|
|
773
800
|
lineToken = liff === null || liff === void 0 ? void 0 : liff.getAccessToken();
|
|
774
|
-
// 未登入先進行登入
|
|
775
|
-
if (!liff.isLoggedIn()) {
|
|
776
|
-
redirectUri = customerRedirectUrl || "".concat(window.location.href);
|
|
777
|
-
if (liffLogin) {
|
|
778
|
-
liff.login({
|
|
779
|
-
redirectUri: redirectUri
|
|
780
|
-
});
|
|
781
|
-
return [
|
|
782
|
-
2
|
|
783
|
-
];
|
|
784
|
-
}
|
|
785
|
-
if (loginByUser || ignoreRoute) return [
|
|
786
|
-
2
|
|
787
|
-
];
|
|
788
|
-
liff.login({
|
|
789
|
-
redirectUri: redirectUri
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
801
|
tempFriendship = null;
|
|
793
802
|
if (!lineToken) return [
|
|
794
803
|
3,
|
|
795
|
-
|
|
804
|
+
11
|
|
796
805
|
];
|
|
797
|
-
_state.label =
|
|
798
|
-
case
|
|
806
|
+
_state.label = 5;
|
|
807
|
+
case 5:
|
|
799
808
|
_state.trys.push([
|
|
800
|
-
|
|
801
|
-
|
|
809
|
+
5,
|
|
810
|
+
8,
|
|
802
811
|
,
|
|
803
|
-
|
|
812
|
+
9
|
|
804
813
|
]);
|
|
814
|
+
if (!!liff.isLoggedIn()) return [
|
|
815
|
+
3,
|
|
816
|
+
7
|
|
817
|
+
];
|
|
805
818
|
return [
|
|
806
819
|
4,
|
|
807
820
|
liff.getFriendship()
|
|
808
821
|
];
|
|
809
|
-
case
|
|
822
|
+
case 6:
|
|
810
823
|
friendship = _state.sent();
|
|
811
824
|
friendFlag = friendship === null || friendship === void 0 ? void 0 : friendship.friendFlag;
|
|
812
825
|
setFriendship(friendFlag);
|
|
813
826
|
tempFriendship = friendFlag;
|
|
814
827
|
console.log("isFriendship", friendFlag);
|
|
828
|
+
_state.label = 7;
|
|
829
|
+
case 7:
|
|
815
830
|
return [
|
|
816
831
|
3,
|
|
817
|
-
|
|
832
|
+
9
|
|
818
833
|
];
|
|
819
|
-
case
|
|
834
|
+
case 8:
|
|
820
835
|
error = _state.sent();
|
|
821
836
|
console.error("Error in liff.getFriendship():", error);
|
|
822
837
|
return [
|
|
823
838
|
3,
|
|
824
|
-
|
|
839
|
+
9
|
|
825
840
|
];
|
|
826
|
-
case
|
|
841
|
+
case 9:
|
|
827
842
|
console.log("isValid", isValid);
|
|
828
843
|
if (tempFriendship && isValid) return [
|
|
829
844
|
2
|
|
@@ -832,23 +847,23 @@ var LiffProvider = function(param) {
|
|
|
832
847
|
4,
|
|
833
848
|
loginInit(lineToken)
|
|
834
849
|
];
|
|
835
|
-
case
|
|
850
|
+
case 10:
|
|
836
851
|
_state.sent();
|
|
837
|
-
_state.label =
|
|
838
|
-
case
|
|
852
|
+
_state.label = 11;
|
|
853
|
+
case 11:
|
|
839
854
|
return [
|
|
840
855
|
3,
|
|
841
|
-
|
|
856
|
+
13
|
|
842
857
|
];
|
|
843
|
-
case
|
|
858
|
+
case 12:
|
|
844
859
|
err = _state.sent();
|
|
845
860
|
setLiffError(err.toString());
|
|
846
861
|
console.log("LIFF init failed.", err);
|
|
847
862
|
return [
|
|
848
863
|
3,
|
|
849
|
-
|
|
864
|
+
13
|
|
850
865
|
];
|
|
851
|
-
case
|
|
866
|
+
case 13:
|
|
852
867
|
return [
|
|
853
868
|
2
|
|
854
869
|
];
|