It's such a difficult situation, because everyone has different needs and deals with things differently. Don't try and 'fix' her; most importantly, like Dez said, let her know you're there for her. Knowing that you're there for her no matter what should hopefully make her feel a bit safer, as she has you to fall back on.
Try and talk to her about the hard times you mentioned she's been going through, and help her to see that whatever it is can be fixed or dealt with in some way.. Maybe help her try to sort some of these issues so that she doesn't get to the point where harming becomes the only way she can deal with it?
To be honest, Dez pretty much hit the nail on the head with ways to try and help her and ways to help you deal with it. Some people find it a big burden to be holding the knowledge that somebody is considering harming themselves.. An ex boyfriend of mine often got very angry with me for harming myself, usually because he didn't understand, or because it was too much for him to deal with. So I think that's something to take on board; try not to get angry with her when she slips up, or goes against a promise not to hurt herself.
This is a really unorganised answer, sorry, but I hope it is somewhat helpful