init
This commit is contained in:
@@ -19,11 +19,11 @@ export function AuthProvider({ children }) {
|
|||||||
let res;
|
let res;
|
||||||
try {
|
try {
|
||||||
res = await fetch(`${API_BASE_URL}/auth/login`, {
|
res = await fetch(`${API_BASE_URL}/auth/login`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
body: JSON.stringify({ email, password }),
|
body: JSON.stringify({ email, password }),
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('네트워크 오류로 로그인에 실패했습니다. (서버 접속 불가)');
|
throw new Error('네트워크 오류로 로그인에 실패했습니다. (서버 접속 불가)');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ function normalizeExternalUrl(raw) {
|
|||||||
return s; // leave as-is (could be relative path on same origin)
|
return s; // leave as-is (could be relative path on same origin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractFirstHttpUrl(text) {
|
||||||
|
if (!text) return '';
|
||||||
|
const s = String(text);
|
||||||
|
// Capture first http/https URL until whitespace or common terminators.
|
||||||
|
const m = s.match(/https?:\/\/[^\s"'<>]+/i);
|
||||||
|
return m ? m[0] : '';
|
||||||
|
}
|
||||||
|
|
||||||
export default function AiNewsPage({ onNavigate }) {
|
export default function AiNewsPage({ onNavigate }) {
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const [news, setNews] = useState([]);
|
const [news, setNews] = useState([]);
|
||||||
@@ -109,7 +117,7 @@ export default function AiNewsPage({ onNavigate }) {
|
|||||||
if (nextOffset === null || nextOffset === offset) {
|
if (nextOffset === null || nextOffset === offset) {
|
||||||
setNewsHasMore(false);
|
setNewsHasMore(false);
|
||||||
} else {
|
} else {
|
||||||
setNewsOffset(nextOffset);
|
setNewsOffset(nextOffset);
|
||||||
}
|
}
|
||||||
return nextOffset;
|
return nextOffset;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -233,6 +241,14 @@ export default function AiNewsPage({ onNavigate }) {
|
|||||||
onChange={(e) => setNewsUrl(e.target.value)}
|
onChange={(e) => setNewsUrl(e.target.value)}
|
||||||
placeholder="뉴스 URL을 입력하세요"
|
placeholder="뉴스 URL을 입력하세요"
|
||||||
style={{ width: 'calc(100% - 25px)', marginBottom: 8, padding: '10px 12px', borderRadius: 8, border: '1px solid #ffd6c2' }}
|
style={{ width: 'calc(100% - 25px)', marginBottom: 8, padding: '10px 12px', borderRadius: 8, border: '1px solid #ffd6c2' }}
|
||||||
|
onPaste={(e) => {
|
||||||
|
const pasted = e.clipboardData?.getData('text') || '';
|
||||||
|
const url = extractFirstHttpUrl(pasted);
|
||||||
|
if (url) {
|
||||||
|
e.preventDefault();
|
||||||
|
setNewsUrl(url);
|
||||||
|
}
|
||||||
|
}}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user