261 lines
7.3 KiB
JavaScript
261 lines
7.3 KiB
JavaScript
import {
|
|
n as z,
|
|
aE as j,
|
|
af as F,
|
|
ap as M,
|
|
aw as A,
|
|
q as w,
|
|
s as N,
|
|
ag as S,
|
|
ah as I,
|
|
al as s,
|
|
au as l,
|
|
ax as o,
|
|
ai as t,
|
|
O as U,
|
|
aA as i,
|
|
aM as d,
|
|
aN as p,
|
|
at as J,
|
|
av as _,
|
|
a_ as H,
|
|
ak as q,
|
|
aH as K,
|
|
a$ as P,
|
|
aq as x,
|
|
aj as W,
|
|
b0 as G,
|
|
aO as Y,
|
|
} from './index-9c042f98.js';
|
|
function Q() {
|
|
const m = new Date(),
|
|
c = m.getDate(),
|
|
r = m.getMonth() + 1;
|
|
return `${m.getFullYear()}-${r}-${c}`;
|
|
}
|
|
const X = { class: 'p-4 space-y-5 min-h-[200px]' },
|
|
Z = { class: 'space-y-6' },
|
|
ee = { class: 'flex items-center space-x-4' },
|
|
te = { class: 'flex-shrink-0 w-[100px]' },
|
|
se = { class: 'w-[200px]' },
|
|
ae = { class: 'flex items-center space-x-4' },
|
|
ne = { class: 'flex-shrink-0 w-[100px]' },
|
|
oe = { class: 'flex-1' },
|
|
le = { class: 'flex-shrink-0 w-[100px]' },
|
|
ie = { class: 'flex flex-wrap gap-4 items-center' },
|
|
ce = { class: 'flex items-center space-x-4' },
|
|
re = { class: 'flex-shrink-0 w-[100px]' },
|
|
ue = { class: 'flex flex-wrap gap-4 items-center' },
|
|
de = { class: 'flex items-center space-x-4' },
|
|
pe = { class: 'flex-shrink-0 w-[100px]' },
|
|
me = { class: 'flex flex-wrap gap-4 items-center' },
|
|
fe = { class: 'flex items-center space-x-4' },
|
|
ge = { class: 'flex-shrink-0 w-[100px]' },
|
|
ve = z({
|
|
__name: 'General',
|
|
setup(m) {
|
|
const c = j(),
|
|
r = F(),
|
|
{ isMobile: f } = M(),
|
|
u = A(),
|
|
h = w(() => c.theme),
|
|
y = w(() => r.userInfo),
|
|
b = N(y.value.name ?? ''),
|
|
$ = N(y.value.description ?? ''),
|
|
B = w({
|
|
get() {
|
|
return c.language;
|
|
},
|
|
set(e) {
|
|
c.setLanguage(e);
|
|
},
|
|
}),
|
|
O = [
|
|
{ label: 'Auto', key: 'auto', icon: 'ri:contrast-line' },
|
|
{ label: 'Light', key: 'light', icon: 'ri:sun-foggy-line' },
|
|
{ label: 'Dark', key: 'dark', icon: 'ri:moon-foggy-line' },
|
|
],
|
|
R = [
|
|
{ label: 'English', key: 'en-US', value: 'en-US' },
|
|
{ label: 'Español', key: 'es-ES', value: 'es-ES' },
|
|
{ label: '한국어', key: 'ko-KR', value: 'ko-KR' },
|
|
{ label: 'Русский язык', key: 'ru-RU', value: 'ru-RU' },
|
|
{ label: 'Tiếng Việt', key: 'vi-VN', value: 'vi-VN' },
|
|
{ label: '简体中文', key: 'zh-CN', value: 'zh-CN' },
|
|
{ label: '繁體中文', key: 'zh-TW', value: 'zh-TW' },
|
|
];
|
|
function C(e) {
|
|
r.updateUserInfo(e), u.success(x('common.success'));
|
|
}
|
|
function D() {
|
|
r.resetUserInfo(), u.success(x('common.success')), window.location.reload();
|
|
}
|
|
function E() {
|
|
const e = Q(),
|
|
n = localStorage.getItem('chatStorage') || '{}',
|
|
a = JSON.stringify(JSON.parse(n), null, 2),
|
|
g = new Blob([a], { type: 'application/json' }),
|
|
k = URL.createObjectURL(g),
|
|
v = document.createElement('a');
|
|
(v.href = k), (v.download = `chat-store_${e}.json`), document.body.appendChild(v), v.click(), document.body.removeChild(v);
|
|
}
|
|
function L(e) {
|
|
const n = e.target;
|
|
if (!n || !n.files) return;
|
|
const a = n.files[0];
|
|
if (!a) return;
|
|
const g = new FileReader();
|
|
(g.onload = () => {
|
|
try {
|
|
const k = JSON.parse(g.result);
|
|
localStorage.setItem('chatStorage', JSON.stringify(k)), u.success(x('common.success')), location.reload();
|
|
} catch {
|
|
u.error(x('common.invalidFileFormat'));
|
|
}
|
|
}),
|
|
g.readAsText(a);
|
|
}
|
|
function V() {
|
|
localStorage.removeItem('chatStorage'), location.reload();
|
|
}
|
|
function T() {
|
|
const e = document.getElementById('fileInput');
|
|
e && e.click();
|
|
}
|
|
return (e, n) => (
|
|
S(),
|
|
I('div', X, [
|
|
s('div', Z, [
|
|
s('div', ee, [
|
|
s('span', te, l(e.$t('setting.name')), 1),
|
|
s('div', se, [
|
|
o(t(U), { value: b.value, 'onUpdate:value': n[0] || (n[0] = (a) => (b.value = a)), placeholder: '' }, null, 8, ['value']),
|
|
]),
|
|
o(
|
|
t(p),
|
|
{ size: 'tiny', text: '', type: 'primary', onClick: n[1] || (n[1] = (a) => C({ name: b.value })) },
|
|
{ default: i(() => [d(l(e.$t('common.save')), 1)]), _: 1 }
|
|
),
|
|
]),
|
|
s('div', ae, [
|
|
s('span', ne, l(e.$t('setting.description')), 1),
|
|
s('div', oe, [
|
|
o(t(U), { value: $.value, 'onUpdate:value': n[2] || (n[2] = (a) => ($.value = a)), placeholder: '' }, null, 8, ['value']),
|
|
]),
|
|
o(
|
|
t(p),
|
|
{ size: 'tiny', text: '', type: 'primary', onClick: n[3] || (n[3] = (a) => C({ description: $.value })) },
|
|
{ default: i(() => [d(l(e.$t('common.save')), 1)]), _: 1 }
|
|
),
|
|
]),
|
|
s(
|
|
'div',
|
|
{ class: J(['flex items-center space-x-4', t(f) && 'items-start']) },
|
|
[
|
|
s('span', le, l(e.$t('setting.chatHistory')), 1),
|
|
s('div', ie, [
|
|
o(
|
|
t(p),
|
|
{ size: 'small', onClick: E },
|
|
{ icon: i(() => [o(t(_), { icon: 'ri:download-2-fill' })]), default: i(() => [d(' ' + l(e.$t('common.export')), 1)]), _: 1 }
|
|
),
|
|
s('input', { id: 'fileInput', type: 'file', style: { display: 'none' }, onChange: L }, null, 32),
|
|
o(
|
|
t(p),
|
|
{ size: 'small', onClick: T },
|
|
{ icon: i(() => [o(t(_), { icon: 'ri:upload-2-fill' })]), default: i(() => [d(' ' + l(e.$t('common.import')), 1)]), _: 1 }
|
|
),
|
|
o(
|
|
t(H),
|
|
{ placement: 'bottom', onPositiveClick: V },
|
|
{
|
|
trigger: i(() => [
|
|
o(
|
|
t(p),
|
|
{ size: 'small' },
|
|
{
|
|
icon: i(() => [o(t(_), { icon: 'ri:close-circle-line' })]),
|
|
default: i(() => [d(' ' + l(e.$t('common.clear')), 1)]),
|
|
_: 1,
|
|
}
|
|
),
|
|
]),
|
|
default: i(() => [d(' ' + l(e.$t('chat.clearHistoryConfirm')), 1)]),
|
|
_: 1,
|
|
}
|
|
),
|
|
]),
|
|
],
|
|
2
|
|
),
|
|
s('div', ce, [
|
|
s('span', re, l(e.$t('setting.theme')), 1),
|
|
s('div', ue, [
|
|
(S(),
|
|
I(
|
|
q,
|
|
null,
|
|
K(O, (a) =>
|
|
o(
|
|
t(p),
|
|
{ key: a.key, size: 'small', type: a.key === t(h) ? 'primary' : void 0, onClick: (g) => t(c).setTheme(a.key) },
|
|
{ icon: i(() => [o(t(_), { icon: a.icon }, null, 8, ['icon'])]), _: 2 },
|
|
1032,
|
|
['type', 'onClick']
|
|
)
|
|
),
|
|
64
|
|
)),
|
|
]),
|
|
]),
|
|
s('div', de, [
|
|
s('span', pe, l(e.$t('setting.language')), 1),
|
|
s('div', me, [
|
|
o(t(P), { style: { width: '140px' }, value: t(B), options: R, onUpdateValue: n[4] || (n[4] = (a) => t(c).setLanguage(a)) }, null, 8, [
|
|
'value',
|
|
]),
|
|
]),
|
|
]),
|
|
s('div', fe, [
|
|
s('span', ge, l(e.$t('setting.resetUserInfo')), 1),
|
|
o(t(p), { size: 'small', onClick: D }, { default: i(() => [d(l(e.$t('common.reset')), 1)]), _: 1 }),
|
|
]),
|
|
]),
|
|
])
|
|
);
|
|
},
|
|
}),
|
|
ye = z({
|
|
__name: 'index',
|
|
props: { visible: { type: Boolean } },
|
|
emits: ['update:visible'],
|
|
setup(m, { emit: c }) {
|
|
const r = m,
|
|
f = w({
|
|
get() {
|
|
return r.visible;
|
|
},
|
|
set(u) {
|
|
c('update:visible', u);
|
|
},
|
|
});
|
|
return (u, h) => (
|
|
S(),
|
|
W(
|
|
t(Y),
|
|
{
|
|
show: t(f),
|
|
'onUpdate:show': h[0] || (h[0] = (y) => (G(f) ? (f.value = y) : null)),
|
|
'auto-focus': !1,
|
|
preset: 'card',
|
|
style: { width: '95%', 'max-width': '640px' },
|
|
},
|
|
{ default: i(() => [s('div', null, [o(ve)])]), _: 1 },
|
|
8,
|
|
['show']
|
|
)
|
|
);
|
|
},
|
|
});
|
|
export { ye as default };
|